VTK  9.3.20240418
vtkLight.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
141 #ifndef vtkLight_h
142 #define vtkLight_h
143 
144 #include "vtkObject.h"
145 #include "vtkRenderingCoreModule.h" // For export macro
146 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
147 
148 /* need for virtual function */
149 VTK_ABI_NAMESPACE_BEGIN
150 class vtkInformation;
151 class vtkRenderer;
152 class vtkMatrix4x4;
153 
154 #define VTK_LIGHT_TYPE_HEADLIGHT 1
155 #define VTK_LIGHT_TYPE_CAMERA_LIGHT 2
156 #define VTK_LIGHT_TYPE_SCENE_LIGHT 3
157 
158 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkLight : public vtkObject
159 {
160 public:
161  vtkTypeMacro(vtkLight, vtkObject);
162  void PrintSelf(ostream& os, vtkIndent indent) override;
163 
172  static vtkLight* New();
173 
180  virtual vtkLight* ShallowClone();
181 
188  virtual void Render(vtkRenderer*, int) {}
189 
191 
197  vtkSetVector3Macro(AmbientColor, double);
198  vtkGetVectorMacro(AmbientColor, double, 3);
199  vtkSetVector3Macro(DiffuseColor, double);
200  vtkGetVectorMacro(DiffuseColor, double, 3);
201  vtkSetVector3Macro(SpecularColor, double);
202  vtkGetVectorMacro(SpecularColor, double, 3);
203  void SetColor(double, double, double);
204  void SetColor(const double a[3]) { this->SetColor(a[0], a[1], a[2]); }
206 
208 
215  vtkSetVector3Macro(Position, double);
216  vtkGetVectorMacro(Position, double, 3);
217  void SetPosition(const float* a) { this->SetPosition(a[0], a[1], a[2]); }
219 
221 
228  vtkSetVector3Macro(FocalPoint, double);
229  vtkGetVectorMacro(FocalPoint, double, 3);
230  void SetFocalPoint(const float* a) { this->SetFocalPoint(a[0], a[1], a[2]); }
232 
234 
237  vtkSetMacro(Intensity, double);
238  vtkGetMacro(Intensity, double);
240 
242 
245  vtkSetMacro(Switch, vtkTypeBool);
246  vtkGetMacro(Switch, vtkTypeBool);
247  vtkBooleanMacro(Switch, vtkTypeBool);
249 
251 
254  vtkSetMacro(Positional, vtkTypeBool);
255  vtkGetMacro(Positional, vtkTypeBool);
256  vtkBooleanMacro(Positional, vtkTypeBool);
258 
260 
263  vtkSetClampMacro(Exponent, double, 0.0, 128.0);
264  vtkGetMacro(Exponent, double);
266 
268 
275  vtkSetMacro(ConeAngle, double);
276  vtkGetMacro(ConeAngle, double);
278 
280 
284  vtkSetVector3Macro(AttenuationValues, double);
285  vtkGetVectorMacro(AttenuationValues, double, 3);
287 
289 
295  vtkGetObjectMacro(TransformMatrix, vtkMatrix4x4);
297 
299 
303  void GetTransformedPosition(double& x, double& y, double& z);
304  void GetTransformedPosition(double a[3]);
307 
309 
313  void GetTransformedFocalPoint(double& x, double& y, double& z);
314  void GetTransformedFocalPoint(double a[3]);
315  double* GetTransformedFocalPoint() VTK_SIZEHINT(3);
317 
321  void TransformPoint(double a[3], double b[3]);
322 
326  void TransformVector(double a[3], double b[3]);
327 
329 
335  void SetDirectionAngle(double elevation, double azimuth);
336  void SetDirectionAngle(const double ang[2]) { this->SetDirectionAngle(ang[0], ang[1]); }
338 
342  void DeepCopy(vtkLight* light);
343 
345 
363  virtual void SetLightType(int);
364  vtkGetMacro(LightType, int);
365 
366  void SetLightTypeToHeadlight() { this->SetLightType(VTK_LIGHT_TYPE_HEADLIGHT); }
367  void SetLightTypeToSceneLight() { this->SetLightType(VTK_LIGHT_TYPE_SCENE_LIGHT); }
370 
372 
379 
381 
387  vtkSetMacro(ShadowAttenuation, float);
388  vtkGetMacro(ShadowAttenuation, float);
390 
392 
396  vtkGetObjectMacro(Information, vtkInformation);
398  virtual void SetInformation(vtkInformation*);
400 
401 protected:
403  ~vtkLight() override;
404 
405  double FocalPoint[3];
406  double Position[3];
407  double Intensity;
408  double AmbientColor[3];
409  double DiffuseColor[3];
410  double SpecularColor[3];
412  vtkTypeBool Positional;
413  double Exponent;
414  double ConeAngle;
415  double AttenuationValues[3];
416  vtkMatrix4x4* TransformMatrix;
417  double TransformedFocalPointReturn[3];
418  double TransformedPositionReturn[3];
419  int LightType;
420  float ShadowAttenuation;
421 
422  // Arbitrary extra information associated with this light.
423  vtkInformation* Information;
424 
425 private:
426  vtkLight(const vtkLight&) = delete;
427  void operator=(const vtkLight&) = delete;
428 };
429 
430 VTK_ABI_NAMESPACE_END
431 #endif
a simple class to control print indentation
Definition: vtkIndent.h:108
Store vtkAlgorithm input/output information.
a virtual light for 3D rendering
Definition: vtkLight.h:159
void SetDirectionAngle(const double ang[2])
Set the position and focal point of a light based on elevation and azimuth.
Definition: vtkLight.h:336
int LightTypeIsHeadlight()
Query the type of the light.
static vtkLight * New()
Create a light with the focal point at the origin and its position set to (0,0,1).
double * GetTransformedPosition()
Get the position of the light, modified by the transformation matrix (if it exists).
void SetLightTypeToHeadlight()
Set/Get the type of the light.
Definition: vtkLight.h:366
virtual void SetLightType(int)
Set/Get the type of the light.
virtual void SetTransformMatrix(vtkMatrix4x4 *)
Set/Get the light's transformation matrix.
void SetFocalPoint(const float *a)
Set/Get the point at which the light is shining.
Definition: vtkLight.h:230
void SetColor(const double a[3])
Set/Get the color of the light.
Definition: vtkLight.h:204
void GetTransformedPosition(double &x, double &y, double &z)
Get the position of the light, modified by the transformation matrix (if it exists).
int LightTypeIsSceneLight()
Query the type of the light.
void SetPosition(const float *a)
Set/Get the position of the light.
Definition: vtkLight.h:217
void SetLightTypeToSceneLight()
Set/Get the type of the light.
Definition: vtkLight.h:367
void SetLightTypeToCameraLight()
Set/Get the type of the light.
Definition: vtkLight.h:368
virtual void Render(vtkRenderer *, int)
Abstract interface to renderer.
Definition: vtkLight.h:188
void DeepCopy(vtkLight *light)
Perform deep copy of this light.
virtual vtkLight * ShallowClone()
Create a new light object with the same light parameters than the current object (any ivar from the s...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetColor(double, double, double)
Set/Get the color of the light.
void GetTransformedPosition(double a[3])
Get the position of the light, modified by the transformation matrix (if it exists).
int LightTypeIsCameraLight()
Query the type of the light.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:141
abstract base class for most VTK objects
Definition: vtkObject.h:162
abstract specification for renderers
Definition: vtkRenderer.h:172
@ Switch
Definition: vtkX3D.h:53
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_LIGHT_TYPE_SCENE_LIGHT
Definition: vtkLight.h:156
#define VTK_LIGHT_TYPE_CAMERA_LIGHT
Definition: vtkLight.h:155
#define VTK_LIGHT_TYPE_HEADLIGHT
Definition: vtkLight.h:154
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_NOT_SUPPORTED
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)