Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkLightKit.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkLightKit.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00105 #ifndef __vtkLightKit_h
00106 #define __vtkLightKit_h
00107 
00108 #include "vtkObject.h"
00109 class vtkLight;
00110 class vtkPiecewiseFunction;
00111 class vtkRenderer;
00112 
00113 class VTK_RENDERING_EXPORT vtkLightKit : public vtkObject
00114 {
00115 public:
00116   static vtkLightKit *New();
00117   vtkTypeRevisionMacro(vtkLightKit, vtkObject);
00118   void PrintSelf(ostream& os, vtkIndent indent);
00119 
00121 
00124   vtkSetMacro(KeyLightIntensity, double);  
00125   vtkGetMacro(KeyLightIntensity, double);
00127 
00129 
00137   vtkSetClampMacro(KeyToFillRatio, double, 0.5, VTK_FLOAT_MAX);
00138   vtkGetMacro(KeyToFillRatio, double);
00140 
00142 
00151   vtkSetClampMacro(KeyToHeadRatio, double, 0.5, VTK_FLOAT_MAX);
00152   vtkGetMacro(KeyToHeadRatio, double);
00154 
00156 
00161   vtkSetClampMacro(KeyToBackRatio, double, 0.5, VTK_FLOAT_MAX);
00162   vtkGetMacro(KeyToBackRatio, double);
00164 
00166 
00175   vtkSetMacro(KeyLightWarmth, double);
00176   vtkGetMacro(KeyLightWarmth, double);
00178 
00179   vtkSetMacro(FillLightWarmth, double);
00180   vtkGetMacro(FillLightWarmth, double);
00181 
00182   vtkSetMacro(HeadlightWarmth, double);
00183   vtkGetMacro(HeadlightWarmth, double);
00184 
00185   vtkSetMacro(BackLightWarmth, double);
00186   vtkGetMacro(BackLightWarmth, double);
00187 
00189 
00190   vtkGetVectorMacro(KeyLightColor,  double, 3);
00191   vtkGetVectorMacro(FillLightColor, double, 3);
00192   vtkGetVectorMacro(HeadlightColor, double, 3);
00193   vtkGetVectorMacro(BackLightColor, double, 3);
00195 
00197 
00200   vtkBooleanMacro(MaintainLuminance, int);
00201   vtkGetMacro(MaintainLuminance, int);
00202   vtkSetMacro(MaintainLuminance, int);
00204 
00206 
00217   void SetKeyLightAngle(double elevation, double azimuth);
00218   void SetKeyLightAngle(double angle[2]) { 
00219     this->SetKeyLightAngle(angle[0], angle[1]); };
00221 
00222   void SetKeyLightElevation(double x) {
00223     this->SetKeyLightAngle(x, this->KeyLightAngle[1]); };
00224 
00225   void SetKeyLightAzimuth(double x) {
00226     this->SetKeyLightAngle(this->KeyLightAngle[0], x); };
00227 
00228   vtkGetVectorMacro(KeyLightAngle, double, 2);
00229   double GetKeyLightElevation() {
00230     double ang[2]; this->GetKeyLightAngle(ang); return ang[0]; };
00231 
00232   double GetKeyLightAzimuth() {
00233     double ang[2]; this->GetKeyLightAngle(ang); return ang[1]; };
00234 
00235   void SetFillLightAngle(double elevation, double azimuth);
00236   void SetFillLightAngle(double angle[2]) { 
00237     this->SetFillLightAngle(angle[0], angle[1]); };
00238 
00239   void SetFillLightElevation(double x) {
00240     this->SetFillLightAngle(x, this->FillLightAngle[1]); };
00241 
00242   void SetFillLightAzimuth(double x) {
00243     this->SetFillLightAngle(this->FillLightAngle[0], x); };
00244 
00245   vtkGetVectorMacro(FillLightAngle, double, 2);
00246   double GetFillLightElevation() {
00247     double ang[2]; this->GetFillLightAngle(ang); return ang[0]; };
00248 
00249   double GetFillLightAzimuth() {
00250     double ang[2]; this->GetFillLightAngle(ang); return ang[1]; };
00251 
00252   void SetBackLightAngle(double elevation, double azimuth);
00253   void SetBackLightAngle(double angle[2]) { 
00254     this->SetBackLightAngle(angle[0], angle[1]); };
00255 
00256   void SetBackLightElevation(double x) {
00257     this->SetBackLightAngle(x, this->BackLightAngle[1]); };
00258 
00259   void SetBackLightAzimuth(double x) {
00260     this->SetBackLightAngle(this->BackLightAngle[0], x); };
00261 
00262   vtkGetVectorMacro(BackLightAngle, double, 2);
00263   double GetBackLightElevation() {
00264     double ang[2]; this->GetBackLightAngle(ang); return ang[0]; };
00265 
00266   double GetBackLightAzimuth() {
00267     double ang[2]; this->GetBackLightAngle(ang); return ang[1]; };
00268 
00270 
00272   void AddLightsToRenderer(vtkRenderer *renderer);
00273   void RemoveLightsFromRenderer(vtkRenderer *renderer);
00275 
00276   void DeepCopy(vtkLightKit *kit);
00277 
00278   void Modified();
00279   void Update();
00280 
00281 protected:
00282   vtkLightKit();
00283   ~vtkLightKit();
00284 
00285   void WarmthToRGBI(double w, double rgb[3], double& i);
00286   void WarmthToRGB(double w, double rgb[3]);
00287   void InitializeWarmthFunctions();
00288   double WarmthToIntensity(double w);
00289 
00290 
00291   double KeyLightIntensity;
00292   double KeyToFillRatio;
00293   double KeyToHeadRatio;
00294   double KeyToBackRatio;
00295   
00296   vtkLight *KeyLight;
00297   double KeyLightWarmth;
00298   double KeyLightAngle[2];
00299   double KeyLightColor[3];
00300 
00301   vtkLight *FillLight;
00302   double FillLightWarmth;
00303   double FillLightAngle[2];
00304   double FillLightColor[3];
00305 
00306   double BackLightWarmth;
00307   double BackLightColor[3];
00308 
00309   vtkLight *BackLight0;
00310   vtkLight *BackLight1;
00311 
00312   double BackLightAngle[2];
00313 
00314   vtkLight *Headlight;
00315   double HeadlightWarmth;
00316   double HeadlightColor[3];
00317 
00318   int MaintainLuminance;
00319 
00320   vtkPiecewiseFunction *WarmthFunction[4]; // r, g, b, perceptual length
00321 private:
00322   vtkLightKit(const vtkLightKit&);  // Not implemented.
00323   void operator=(const vtkLightKit&);  // Not implemented.
00324 };
00325 
00326 #endif