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 vtkTypeMacro(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 vtkGetMacro(Lighting,bool);
00102 vtkSetMacro(Lighting,bool);
00103 vtkBooleanMacro(Lighting,bool);
00105
00107
00108 vtkSetClampMacro(Interpolation,int,VTK_FLAT,VTK_PHONG);
00109 vtkGetMacro(Interpolation,int);
00110 void SetInterpolationToFlat() {this->SetInterpolation(VTK_FLAT);};
00111 void SetInterpolationToGouraud() {this->SetInterpolation(VTK_GOURAUD);};
00112 void SetInterpolationToPhong() {this->SetInterpolation(VTK_PHONG);};
00113 const char *GetInterpolationAsString();
00115
00117
00118 vtkSetClampMacro(Representation,int,VTK_POINTS,VTK_SURFACE);
00119 vtkGetMacro(Representation,int);
00120 void SetRepresentationToPoints() {this->SetRepresentation(VTK_POINTS);};
00121 void SetRepresentationToWireframe() {
00122 this->SetRepresentation(VTK_WIREFRAME);};
00123 void SetRepresentationToSurface() {this->SetRepresentation(VTK_SURFACE);};
00124 const char *GetRepresentationAsString();
00126
00128
00131 void SetColor(double r, double g, double b);
00132 void SetColor(double a[3]) { this->SetColor(a[0], a[1], a[2]); };
00133 double *GetColor();
00134 void GetColor(double rgb[3]);
00135 void GetColor(double &r, double &g, double &b);
00137
00139
00140 vtkSetClampMacro(Ambient,double,0.0,1.0);
00141 vtkGetMacro(Ambient,double);
00143
00145
00146 vtkSetClampMacro(Diffuse,double,0.0,1.0);
00147 vtkGetMacro(Diffuse,double);
00149
00151
00152 vtkSetClampMacro(Specular,double,0.0,1.0);
00153 vtkGetMacro(Specular,double);
00155
00157
00158 vtkSetClampMacro(SpecularPower,double,0.0,128.0);
00159 vtkGetMacro(SpecularPower,double);
00161
00163
00165 vtkSetClampMacro(Opacity,double,0.0,1.0);
00166 vtkGetMacro(Opacity,double);
00168
00170
00174 vtkSetVector3Macro(AmbientColor,double);
00175 vtkGetVector3Macro(AmbientColor,double);
00177
00179
00180 vtkSetVector3Macro(DiffuseColor,double);
00181 vtkGetVector3Macro(DiffuseColor,double);
00183
00185
00186 vtkSetVector3Macro(SpecularColor,double);
00187 vtkGetVector3Macro(SpecularColor,double);
00189
00191
00194 vtkGetMacro(EdgeVisibility,int);
00195 vtkSetMacro(EdgeVisibility,int);
00196 vtkBooleanMacro(EdgeVisibility,int);
00198
00200
00201 vtkSetVector3Macro(EdgeColor,double);
00202 vtkGetVector3Macro(EdgeColor,double);
00204
00206
00208 vtkSetClampMacro(LineWidth,float,0,VTK_LARGE_FLOAT);
00209 vtkGetMacro(LineWidth,float);
00211
00213
00216 vtkSetMacro(LineStipplePattern,int);
00217 vtkGetMacro(LineStipplePattern,int);
00219
00221
00224 vtkSetClampMacro(LineStippleRepeatFactor,int,1,VTK_LARGE_INTEGER);
00225 vtkGetMacro(LineStippleRepeatFactor,int);
00227
00229
00231 vtkSetClampMacro(PointSize,float,0,VTK_LARGE_FLOAT);
00232 vtkGetMacro(PointSize,float);
00234
00236
00239 vtkGetMacro(BackfaceCulling,int);
00240 vtkSetMacro(BackfaceCulling,int);
00241 vtkBooleanMacro(BackfaceCulling,int);
00243
00245
00248 vtkGetMacro(FrontfaceCulling,int);
00249 vtkSetMacro(FrontfaceCulling,int);
00250 vtkBooleanMacro(FrontfaceCulling,int);
00252
00254
00256 vtkGetObjectMacro(Material, vtkXMLMaterial);
00258
00260
00261 vtkGetStringMacro(MaterialName);
00263
00266 void LoadMaterial(const char* name);
00267
00269 void LoadMaterialFromString(const char* materialxml);
00270
00272 void LoadMaterial(vtkXMLMaterial*);
00273
00275
00277 vtkSetMacro(Shading, int);
00278 vtkGetMacro(Shading, int);
00279 vtkBooleanMacro(Shading, int);
00281
00283
00285 vtkGetObjectMacro(ShaderProgram, vtkShaderProgram);
00287
00289
00293 virtual void AddShaderVariable(const char *name, int numVars, int *x);
00294 virtual void AddShaderVariable(const char *name, int numVars, float *x);
00295 virtual void AddShaderVariable(const char *name, int numVars, double *x);
00297
00299
00300 void AddShaderVariable(const char* name, int v)
00301 {
00302 this->AddShaderVariable(name, 1, &v);
00303 }
00304 void AddShaderVariable(const char* name, float v)
00305 {
00306 this->AddShaderVariable(name, 1, &v);
00307 }
00308 void AddShaderVariable(const char* name, double v)
00309 {
00310 this->AddShaderVariable(name, 1, &v);
00311 }
00312 void AddShaderVariable(const char* name, int v1, int v2)
00313 {
00314 int v[2];
00315 v[0] = v1;
00316 v[1] = v2;
00317 this->AddShaderVariable(name, 2, v);
00318 }
00319 void AddShaderVariable(const char* name, float v1, float v2)
00320 {
00321 float v[2];
00322 v[0] = v1;
00323 v[1] = v2;
00324 this->AddShaderVariable(name, 2, v);
00325 }
00326 void AddShaderVariable(const char* name, double v1, double v2)
00327 {
00328 double v[2];
00329 v[0] = v1;
00330 v[1] = v2;
00331 this->AddShaderVariable(name, 2, v);
00332 }
00333 void AddShaderVariable(const char* name, int v1, int v2, int v3)
00334 {
00335 int v[3];
00336 v[0] = v1;
00337 v[1] = v2;
00338 v[2] = v3;
00339 this->AddShaderVariable(name, 3, v);
00340 }
00341 void AddShaderVariable(const char* name, float v1, float v2, float v3)
00342 {
00343 float v[3];
00344 v[0] = v1;
00345 v[1] = v2;
00346 v[2] = v3;
00347 this->AddShaderVariable(name, 3, v);
00348 }
00349 void AddShaderVariable(const char* name, double v1, double v2, double v3)
00350 {
00351 double v[3];
00352 v[0] = v1;
00353 v[1] = v2;
00354 v[2] = v3;
00355 this->AddShaderVariable(name, 3, v);
00356 }
00358
00360
00364 void SetTexture(const char* name, vtkTexture* texture);
00365 vtkTexture* GetTexture(const char* name);
00367
00369
00373 void SetTexture(int unit, vtkTexture* texture);
00374 vtkTexture* GetTexture(int unit);
00375 void RemoveTexture(int unit);
00377
00378
00381 void RemoveTexture(const char* name);
00382
00384 void RemoveAllTextures();
00385
00387 int GetNumberOfTextures();
00388
00392 virtual void ReleaseGraphicsResources(vtkWindow *win);
00393
00394
00396
00398 enum VTKTextureUnit
00399 {
00400 VTK_TEXTURE_UNIT_0 = 0,
00401 VTK_TEXTURE_UNIT_1,
00402 VTK_TEXTURE_UNIT_2,
00403 VTK_TEXTURE_UNIT_3,
00404 VTK_TEXTURE_UNIT_4,
00405 VTK_TEXTURE_UNIT_5,
00406 VTK_TEXTURE_UNIT_6,
00407 VTK_TEXTURE_UNIT_7
00408 };
00409
00411
00412 protected:
00413 vtkProperty();
00414 ~vtkProperty();
00415
00417
00418 void LoadProperty();
00419 void LoadTextures();
00420 void LoadTexture(vtkXMLDataElement* elem);
00421 void LoadPerlineNoise(vtkXMLDataElement* );
00422 void LoadMember(vtkXMLDataElement* elem);
00424
00425 double Color[3];
00426 double AmbientColor[3];
00427 double DiffuseColor[3];
00428 double SpecularColor[3];
00429 double EdgeColor[3];
00430 double Ambient;
00431 double Diffuse;
00432 double Specular;
00433 double SpecularPower;
00434 double Opacity;
00435 float PointSize;
00436 float LineWidth;
00437 int LineStipplePattern;
00438 int LineStippleRepeatFactor;
00439 int Interpolation;
00440 int Representation;
00441 int EdgeVisibility;
00442 int BackfaceCulling;
00443 int FrontfaceCulling;
00444 bool Lighting;
00445
00446 int Shading;
00447
00448 char* MaterialName;
00449 vtkSetStringMacro(MaterialName);
00450
00451 vtkShaderProgram* ShaderProgram;
00452 void SetShaderProgram(vtkShaderProgram*);
00453
00454 vtkXMLMaterial* Material;
00455
00458 virtual void ReadFrameworkMaterial();
00459
00460
00461
00462
00463 friend class vtkGLSLShaderProgram;
00464 friend class vtkShader;
00465
00466
00467
00468 vtkTexture* GetTextureAtIndex(int index);
00469 int GetTextureUnitAtIndex(int index);
00470 int GetTextureUnit(const char* name);
00471
00472
00473 private:
00474 vtkProperty(const vtkProperty&);
00475 void operator=(const vtkProperty&);
00476
00477 vtkPropertyInternals* Internals;
00478 };
00479
00481
00482 inline const char *vtkProperty::GetInterpolationAsString(void)
00483 {
00484 if ( this->Interpolation == VTK_FLAT )
00485 {
00486 return "Flat";
00487 }
00488 else if ( this->Interpolation == VTK_GOURAUD )
00489 {
00490 return "Gouraud";
00491 }
00492 else
00493 {
00494 return "Phong";
00495 }
00496 }
00498
00499
00501
00502 inline const char *vtkProperty::GetRepresentationAsString(void)
00503 {
00504 if ( this->Representation == VTK_POINTS )
00505 {
00506 return "Points";
00507 }
00508 else if ( this->Representation == VTK_WIREFRAME )
00509 {
00510 return "Wireframe";
00511 }
00512 else
00513 {
00514 return "Surface";
00515 }
00516 }
00518
00519
00520
00521 #endif