OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I686LINUX / util / I686LINUX / include / vtk / vtkEncodedGradientShader.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkEncodedGradientShader.h,v $
5   Language:  C++
6   Date:      $Date: 2002/08/22 18:39:30 $
7   Version:   $Revision: 1.24 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
13      This software is distributed WITHOUT ANY WARRANTY; without even 
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15      PURPOSE.  See the above copyright notice for more information.
16
17 =========================================================================*/
18
19 // .NAME vtkEncodedGradientShader - Compute shading tables for encoded normals.
20 //
21 // .SECTION Description
22 // vtkEncodedGradientShader computes shading tables for encoded normals 
23 // that indicates the amount of diffuse and specular illumination that is 
24 // received from all light sources at a surface location with that normal.
25 // For diffuse illumination this is accurate, but for specular illumination
26 // it is approximate for perspective projections since the center view
27 // direction is always used as the view direction. Since the shading table is
28 // dependent on the volume (for the transformation that must be applied to
29 // the normals to put them into world coordinates) there is a shading table
30 // per volume. This is necessary because multiple volumes can share a 
31 // volume mapper.
32
33 #ifndef __vtkEncodedGradientShader_h
34 #define __vtkEncodedGradientShader_h
35
36 #include "vtkObject.h"
37
38 class vtkVolume;
39 class vtkRenderer;
40 class vtkEncodedGradientEstimator;
41
42 #define VTK_MAX_SHADING_TABLES   100
43
44 class VTK_RENDERING_EXPORT vtkEncodedGradientShader : public vtkObject
45 {
46 public:
47   static vtkEncodedGradientShader *New();
48   vtkTypeRevisionMacro(vtkEncodedGradientShader,vtkObject);
49
50   // Description:
51   // Print the vtkEncodedGradientShader
52   void PrintSelf( ostream& os, vtkIndent indent );
53
54   // Description:
55   // Set / Get the intensity diffuse / specular light used for the
56   // zero normals. 
57   vtkSetClampMacro( ZeroNormalDiffuseIntensity,  float, 0.0, 1.0);
58   vtkGetMacro( ZeroNormalDiffuseIntensity, float );
59   vtkSetClampMacro( ZeroNormalSpecularIntensity, float, 0.0, 1.0);
60   vtkGetMacro( ZeroNormalSpecularIntensity, float );
61
62   // Description:
63   // Cause the shading table to be updated
64   void UpdateShadingTable( vtkRenderer *ren, vtkVolume *vol,
65                            vtkEncodedGradientEstimator *gradest);
66
67   // Description:
68   // Get the red/green/blue shading table.
69   float *GetRedDiffuseShadingTable(    vtkVolume *vol );
70   float *GetGreenDiffuseShadingTable(  vtkVolume *vol );
71   float *GetBlueDiffuseShadingTable(   vtkVolume *vol );
72   float *GetRedSpecularShadingTable(   vtkVolume *vol );
73   float *GetGreenSpecularShadingTable( vtkVolume *vol );
74   float *GetBlueSpecularShadingTable(  vtkVolume *vol );
75
76 protected:
77   vtkEncodedGradientShader();
78   ~vtkEncodedGradientShader();
79
80   // Description:
81   // Build a shading table for a light with the specified direction,
82   // and color for an object of the specified material properties.
83   // material[0] = ambient, material[1] = diffuse, material[2] = specular
84   // and material[3] = specular exponent.  If the ambient flag is 1, 
85   // then ambient illumination is added. If not, then this means we 
86   // are calculating the "other side" of two sided lighting, so no 
87   // ambient intensity is added in. If the update flag is 0,
88   // the shading table is overwritten with these new shading values.
89   // If the updateFlag is 1, then the computed light contribution is
90   // added to the current shading table values. There is one shading
91   // table per volume, and the index value indicated which index table
92   // should be used. It is computed in the UpdateShadingTable method.
93   void  BuildShadingTable( int index,
94                            float lightDirection[3],
95                            float lightColor[3],
96                            float lightIntensity,
97                            float viewDirection[3],
98                            float material[4],
99                            int twoSided,
100                            vtkEncodedGradientEstimator *gradest,
101                            int updateFlag );
102   
103   // The six shading tables (r diffuse ,g diffuse ,b diffuse, 
104   // r specular, g specular, b specular ) - with an entry for each
105   // encoded normal plus one entry at the end for the zero normal
106   // There is one shading table per volume listed in the ShadingTableVolume
107   // array. A null entry indicates an available slot.
108   float                        *ShadingTable[VTK_MAX_SHADING_TABLES][6];
109   vtkVolume                    *ShadingTableVolume[VTK_MAX_SHADING_TABLES];
110   int                          ShadingTableSize[VTK_MAX_SHADING_TABLES];
111
112   // The intensity of light used for the zero normals, since it
113   // can not be computed from the normal angles. Defaults to 0.0.
114   float    ZeroNormalDiffuseIntensity;
115   float    ZeroNormalSpecularIntensity;
116 private:
117   vtkEncodedGradientShader(const vtkEncodedGradientShader&);  // Not implemented.
118   void operator=(const vtkEncodedGradientShader&);  // Not implemented.
119 }; 
120
121
122 #endif