00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00036 #ifndef __vtkProperty_h
00037 #define __vtkProperty_h
00038
00039 #include "vtkObject.h"
00040
00041
00042 #define VTK_FLAT 0
00043 #define VTK_GOURAUD 1
00044 #define VTK_PHONG 2
00045
00046
00047 #define VTK_POINTS 0
00048 #define VTK_WIREFRAME 1
00049 #define VTK_SURFACE 2
00050
00051 class vtkActor;
00052 class vtkRenderer;
00053 class vtkShaderProgram;
00054 class vtkTexture;
00055 class vtkWindow;
00056 class vtkXMLDataElement;
00057 class vtkXMLMaterial;
00058
00059 class vtkPropertyInternals;
00060
00061 class VTK_RENDERING_EXPORT vtkProperty : public vtkObject
00062 {
00063 public:
00064 vtkTypeRevisionMacro(vtkProperty,vtkObject);
00065 void PrintSelf(ostream& os, vtkIndent indent);
00066
00072 static vtkProperty *New();
00073
00075 void DeepCopy(vtkProperty *p);
00076
00082 virtual void Render(vtkActor *,vtkRenderer *);
00083
00089 virtual void BackfaceRender(vtkActor *,vtkRenderer *) {};
00090
00091
00093
00095 virtual void PostRender(vtkActor*, vtkRenderer*);
00096
00098
00100
00101 vtkSetClampMacro(Interpolation,int,VTK_FLAT,VTK_PHONG);
00102 vtkGetMacro(Interpolation,int);
00103 void SetInterpolationToFlat() {this->SetInterpolation(VTK_FLAT);};
00104 void SetInterpolationToGouraud() {this->SetInterpolation(VTK_GOURAUD);};
00105 void SetInterpolationToPhong() {this->SetInterpolation(VTK_PHONG);};
00106 const char *GetInterpolationAsString();
00108
00110
00111 vtkSetClampMacro(Representation,int,VTK_POINTS,VTK_SURFACE);
00112 vtkGetMacro(Representation,int);
00113 void SetRepresentationToPoints() {this->SetRepresentation(VTK_POINTS);};
00114 void SetRepresentationToWireframe() {
00115 this->SetRepresentation(VTK_WIREFRAME);};
00116 void SetRepresentationToSurface() {this->SetRepresentation(VTK_SURFACE);};
00117 const char *GetRepresentationAsString();
00119
00121
00124 void SetColor(double r, double g, double b);
00125 void SetColor(double a[3]) { this->SetColor(a[0], a[1], a[2]); };
00126 double *GetColor();
00127 void GetColor(double rgb[3]);
00128 void GetColor(double &r, double &g, double &b);
00130
00132
00133 vtkSetClampMacro(Ambient,double,0.0,1.0);
00134 vtkGetMacro(Ambient,double);
00136
00138
00139 vtkSetClampMacro(Diffuse,double,0.0,1.0);
00140 vtkGetMacro(Diffuse,double);
00142
00144
00145 vtkSetClampMacro(Specular,double,0.0,1.0);
00146 vtkGetMacro(Specular,double);
00148
00150
00151 vtkSetClampMacro(SpecularPower,double,0.0,100.0);
00152 vtkGetMacro(SpecularPower,double);
00154
00156
00158 vtkSetClampMacro(Opacity,double,0.0,1.0);
00159 vtkGetMacro(Opacity,double);
00161
00163
00167 vtkSetVector3Macro(AmbientColor,double);
00168 vtkGetVector3Macro(AmbientColor,double);
00170
00172
00173 vtkSetVector3Macro(DiffuseColor,double);
00174 vtkGetVector3Macro(DiffuseColor,double);
00176
00178
00179 vtkSetVector3Macro(SpecularColor,double);
00180 vtkGetVector3Macro(SpecularColor,double);
00182
00184
00187 vtkGetMacro(EdgeVisibility,int);
00188 vtkSetMacro(EdgeVisibility,int);
00189 vtkBooleanMacro(EdgeVisibility,int);
00191
00193
00194 vtkSetVector3Macro(EdgeColor,double);
00195 vtkGetVector3Macro(EdgeColor,double);
00197
00199
00201 vtkSetClampMacro(LineWidth,float,0,VTK_LARGE_FLOAT);
00202 vtkGetMacro(LineWidth,float);
00204
00206
00209 vtkSetMacro(LineStipplePattern,int);
00210 vtkGetMacro(LineStipplePattern,int);
00212
00214
00217 vtkSetClampMacro(LineStippleRepeatFactor,int,1,VTK_LARGE_INTEGER);
00218 vtkGetMacro(LineStippleRepeatFactor,int);
00220
00222
00224 vtkSetClampMacro(PointSize,float,0,VTK_LARGE_FLOAT);
00225 vtkGetMacro(PointSize,float);
00227
00229
00232 vtkGetMacro(BackfaceCulling,int);
00233 vtkSetMacro(BackfaceCulling,int);
00234 vtkBooleanMacro(BackfaceCulling,int);
00236
00238
00241 vtkGetMacro(FrontfaceCulling,int);
00242 vtkSetMacro(FrontfaceCulling,int);
00243 vtkBooleanMacro(FrontfaceCulling,int);
00245
00247
00249 vtkGetObjectMacro(Material, vtkXMLMaterial);
00251
00253
00254 vtkGetStringMacro(MaterialName);
00256
00259 void LoadMaterial(const char* name);
00260
00262 void LoadMaterialFromString(const char* materialxml);
00263
00265 void LoadMaterial(vtkXMLMaterial*);
00266
00268
00270 vtkSetMacro(Shading, int);
00271 vtkGetMacro(Shading, int);
00272 vtkBooleanMacro(Shading, int);
00274
00276
00278 vtkGetObjectMacro(ShaderProgram, vtkShaderProgram);
00280
00282
00286 virtual void AddShaderVariable(const char* name, int numVars, int* x);
00287 virtual void AddShaderVariable(const char* name, int numVars, float* x);
00288 virtual void AddShaderVariable(const char* name, int numVars, double* x);
00290
00292
00293 void AddShaderVariable(const char* name, int v)
00294 {
00295 this->AddShaderVariable(name, 1, &v);
00296 }
00297 void AddShaderVariable(const char* name, float v)
00298 {
00299 this->AddShaderVariable(name, 1, &v);
00300 }
00301 void AddShaderVariable(const char* name, double v)
00302 {
00303 this->AddShaderVariable(name, 1, &v);
00304 }
00305 void AddShaderVariable(const char* name, int v1, int v2)
00306 {
00307 int v[2];
00308 v[0] = v1;
00309 v[1] = v2;
00310 this->AddShaderVariable(name, 2, v);
00311 }
00312 void AddShaderVariable(const char* name, float v1, float v2)
00313 {
00314 float v[2];
00315 v[0] = v1;
00316 v[1] = v2;
00317 this->AddShaderVariable(name, 2, v);
00318 }
00319 void AddShaderVariable(const char* name, double v1, double v2)
00320 {
00321 double v[2];
00322 v[0] = v1;
00323 v[1] = v2;
00324 this->AddShaderVariable(name, 2, v);
00325 }
00326 void AddShaderVariable(const char* name, int v1, int v2, int v3)
00327 {
00328 int v[3];
00329 v[0] = v1;
00330 v[1] = v2;
00331 v[2] = v3;
00332 this->AddShaderVariable(name, 3, v);
00333 }
00334 void AddShaderVariable(const char* name, float v1, float v2, float v3)
00335 {
00336 float v[3];
00337 v[0] = v1;
00338 v[1] = v2;
00339 v[2] = v3;
00340 this->AddShaderVariable(name, 3, v);
00341 }
00342 void AddShaderVariable(const char* name, double v1, double v2, double v3)
00343 {
00344 double v[3];
00345 v[0] = v1;
00346 v[1] = v2;
00347 v[2] = v3;
00348 this->AddShaderVariable(name, 3, v);
00349 }
00351
00353
00357 void SetTexture(const char* name, vtkTexture* texture);
00358 vtkTexture* GetTexture(const char* name);
00360
00363 void RemoveTexture(const char* name);
00364
00366 void RemoveAllTextures();
00367
00369 int GetNumberOfTextures();
00370
00374 virtual void ReleaseGraphicsResources(vtkWindow *win);
00375
00376 protected:
00377 vtkProperty();
00378 ~vtkProperty();
00379
00381
00382 void LoadProperty();
00383 void LoadTextures();
00384 void LoadTexture(vtkXMLDataElement* elem);
00385 void LoadPerlineNoise(vtkXMLDataElement* );
00386 void LoadMember(vtkXMLDataElement* elem);
00388
00389 double Color[3];
00390 double AmbientColor[3];
00391 double DiffuseColor[3];
00392 double SpecularColor[3];
00393 double EdgeColor[3];
00394 double Ambient;
00395 double Diffuse;
00396 double Specular;
00397 double SpecularPower;
00398 double Opacity;
00399 float PointSize;
00400 float LineWidth;
00401 int LineStipplePattern;
00402 int LineStippleRepeatFactor;
00403 int Interpolation;
00404 int Representation;
00405 int EdgeVisibility;
00406 int BackfaceCulling;
00407 int FrontfaceCulling;
00408
00409 int Shading;
00410
00411 char* MaterialName;
00412 vtkSetStringMacro(MaterialName);
00413
00414 vtkShaderProgram* ShaderProgram;
00415 void SetShaderProgram(vtkShaderProgram*);
00416
00417 vtkXMLMaterial* Material;
00418
00419
00420 private:
00421
00422
00423 friend class vtkGLSLShaderProgram;
00424 friend class vtkShader;
00425
00426
00427
00428 vtkTexture* GetTextureAtIndex(int index);
00429 int GetTextureIndex(const char* name);
00430
00431 private:
00432 vtkProperty(const vtkProperty&);
00433 void operator=(const vtkProperty&);
00434
00435 vtkPropertyInternals* Internals;
00436 };
00437
00439 inline const char *vtkProperty::GetInterpolationAsString(void)
00440 {
00441 if ( this->Interpolation == VTK_FLAT )
00442 {
00443 return "Flat";
00444 }
00445 else if ( this->Interpolation == VTK_GOURAUD )
00446 {
00447 return "Gouraud";
00448 }
00449 else
00450 {
00451 return "Phong";
00452 }
00453 }
00454
00455
00457 inline const char *vtkProperty::GetRepresentationAsString(void)
00458 {
00459 if ( this->Representation == VTK_POINTS )
00460 {
00461 return "Points";
00462 }
00463 else if ( this->Representation == VTK_WIREFRAME )
00464 {
00465 return "Wireframe";
00466 }
00467 else
00468 {
00469 return "Surface";
00470 }
00471 }
00472
00473
00474
00475 #endif