1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkLightActor.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /**
16  * @class   vtkLightActor
17  * @brief   a cone and a frustum to represent a spotlight.
18  *
19  * vtkLightActor is a composite actor used to represent a spotlight. The cone
20  * angle is equal to the spotlight angle, the cone apex is at the position of
21  * the light, the direction of the light goes from the cone apex to the center
22  * of the base of the cone. The square frustum position is the light position,
23  * the frustum focal point is in the direction of the light direction. The
24  * frustum vertical view angle (aperture) (this is also the horizontal view
25  * angle as the frustum is square) is equal to twice the cone angle. The
26  * clipping range of the frustum is arbitrary set by the user
27  * (initially at 0.5,11.0).
28  *
29  * @warning
30  * Right now only spotlight are supported but directional light might be
31  * supported in the future.
32  *
33  * @sa
34  * vtkLight vtkConeSource vtkFrustumSource vtkCameraActor
35  */
36 
37 #ifndef vtkLightActor_h
38 #define vtkLightActor_h
39 
40 #include "vtkProp3D.h"
41 #include "vtkRenderingCoreModule.h" // For export macro
42 
43 class vtkLight;
44 class vtkConeSource;
45 class vtkPolyDataMapper;
46 class vtkActor;
47 class vtkCamera;
48 class vtkCameraActor;
49 class vtkBoundingBox;
50 class vtkProperty;
51 
52 class VTKRENDERINGCORE_EXPORT vtkLightActor : public vtkProp3D
53 {
54 public:
55   static vtkLightActor* New();
56   vtkTypeMacro(vtkLightActor, vtkProp3D);
57   void PrintSelf(ostream& os, vtkIndent indent) override;
58 
59   ///@{
60   /**
61    * The spotlight to represent. Initial value is NULL.
62    */
63   void SetLight(vtkLight* light);
64   vtkGetObjectMacro(Light, vtkLight);
65   ///@}
66 
67   ///@{
68   /**
69    * Set/Get the location of the near and far clipping planes along the
70    * direction of projection.  Both of these values must be positive.
71    * Initial values are  (0.5,11.0)
72    */
73   void SetClippingRange(double dNear, double dFar);
74   void SetClippingRange(const double a[2]);
75   vtkGetVector2Macro(ClippingRange, double);
76   ///@}
77 
78   ///@{
79   /**
80    * Set/Get properties of the different actors used to represent
81    * the camera
82    */
83   vtkProperty* GetConeProperty();
84   vtkProperty* GetFrustumProperty();
85   ///@}
86 
87   /**
88    * Support the standard render methods.
89    */
90   int RenderOpaqueGeometry(vtkViewport* viewport) override;
91 
92   /**
93    * Does this prop have some translucent polygonal geometry? No.
94    */
95   vtkTypeBool HasTranslucentPolygonalGeometry() override;
96 
97   /**
98    * Release any graphics resources that are being consumed by this actor.
99    * The parameter window could be used to determine which graphic
100    * resources to release.
101    */
102   void ReleaseGraphicsResources(vtkWindow*) override;
103 
104   /**
105    * Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
106    */
107   double* GetBounds() override;
108 
109   /**
110    * Get the actors mtime plus consider its properties and texture if set.
111    */
112   vtkMTimeType GetMTime() override;
113 
114 protected:
115   vtkLightActor();
116   ~vtkLightActor() override;
117 
118   void UpdateViewProps();
119 
120   vtkLight* Light;
121   double ClippingRange[2];
122 
123   vtkConeSource* ConeSource;
124   vtkPolyDataMapper* ConeMapper;
125   vtkActor* ConeActor;
126 
127   vtkCamera* CameraLight;
128   vtkCameraActor* FrustumActor;
129 
130   vtkBoundingBox* BoundingBox;
131 
132 private:
133   vtkLightActor(const vtkLightActor&) = delete;
134   void operator=(const vtkLightActor&) = delete;
135 };
136 
137 #endif
138