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 // .NAME vtkLightActor - a cone and a frustum to represent a spotlight.
16 // .SECTION Description
17 // vtkLightActor is a composite actor used to represent a spotlight. The cone
18 // angle is equal to the spotlight angle, the cone apex is at the position of
19 // the light, the direction of the light goes from the cone apex to the center
20 // of the base of the cone. The square frustum position is the light position,
21 // the frustum focal point is in the direction of the light direction. The
22 // frustum vertical view angle (aperture) (this is also the horizontal view
23 // angle as the frustum is square) is equal to twice the cone angle. The
24 // clipping range of the frustum is arbitrary set by the user
25 // (initially at 0.5,11.0).
26 
27 // .SECTION Caveats
28 // Right now only spotlight are supported but directional light might be
29 // supported in the future.
30 
31 // .SECTION See Also
32 // vtkLight vtkConeSource vtkFrustumSource vtkCameraActor
33 
34 #ifndef vtkLightActor_h
35 #define vtkLightActor_h
36 
37 #include "vtkRenderingCoreModule.h" // For export macro
38 #include "vtkProp3D.h"
39 
40 class vtkLight;
41 class vtkConeSource;
42 class vtkPolyDataMapper;
43 class vtkActor;
44 class vtkCamera;
45 class vtkCameraActor;
46 class vtkBoundingBox;
47 
48 class VTKRENDERINGCORE_EXPORT vtkLightActor : public vtkProp3D
49 {
50 public:
51   static vtkLightActor *New();
52   vtkTypeMacro(vtkLightActor, vtkProp3D);
53   void PrintSelf(ostream& os, vtkIndent indent);
54 
55   // Description:
56   // The spotlight to represent. Initial value is NULL.
57   void SetLight(vtkLight *light);
58   vtkGetObjectMacro(Light, vtkLight);
59 
60   // Description:
61   // Set/Get the location of the near and far clipping planes along the
62   // direction of projection.  Both of these values must be positive.
63   // Initial values are  (0.5,11.0)
64   void SetClippingRange(double dNear, double dFar);
65   void SetClippingRange(const double a[2]);
66   vtkGetVector2Macro(ClippingRange, double);
67 
68   // Description:
69   // Support the standard render methods.
70   virtual int RenderOpaqueGeometry(vtkViewport *viewport);
71 
72   // Description:
73   // Does this prop have some translucent polygonal geometry? No.
74   virtual int HasTranslucentPolygonalGeometry();
75 
76   // Description:
77   // Release any graphics resources that are being consumed by this actor.
78   // The parameter window could be used to determine which graphic
79   // resources to release.
80   void ReleaseGraphicsResources(vtkWindow *);
81 
82   // Description:
83   // Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
84   double *GetBounds();
85 
86   // Description:
87   // Get the actors mtime plus consider its properties and texture if set.
88   unsigned long int GetMTime();
89 
90 protected:
91   vtkLightActor();
92   ~vtkLightActor();
93 
94   void UpdateViewProps();
95 
96   vtkLight *Light;
97   double ClippingRange[2];
98 
99   vtkConeSource *ConeSource;
100   vtkPolyDataMapper *ConeMapper;
101   vtkActor *ConeActor;
102 
103   vtkCamera *CameraLight;
104   vtkCameraActor *FrustumActor;
105 
106   vtkBoundingBox *BoundingBox;
107 
108 private:
109   vtkLightActor(const vtkLightActor&);  // Not implemented.
110   void operator=(const vtkLightActor&);  // Not implemented.
111 };
112 
113 #endif
114