1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkProp3DFollower.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 vtkProp3DFollower 17 * @brief a vtkProp3D that always faces the camera 18 * 19 * vtkProp3DFollower is a type of vtkProp3D that always faces the camera. 20 * More specifically it will not change its position or scale, 21 * but it will continually update its orientation so that it is right side 22 * up and facing the camera. This is typically used for complex billboards 23 * or props that need to face the viewer at all times. 24 * 25 * Note: All of the transformations that can be made to a vtkProp3D will take 26 * effect with the follower. Thus, if you change the orientation of the 27 * follower by 90 degrees, then it will follow the camera, but be off by 90 28 * degrees. 29 * 30 * @sa 31 * vtkFollower vtkProp3D vtkCamera vtkProp3DAxisFollower 32 */ 33 34 #ifndef vtkProp3DFollower_h 35 #define vtkProp3DFollower_h 36 37 #include "vtkRenderingCoreModule.h" // For export macro 38 #include "vtkProp3D.h" 39 40 class vtkCamera; 41 class vtkMapper; 42 43 44 class VTKRENDERINGCORE_EXPORT vtkProp3DFollower : public vtkProp3D 45 { 46 public: 47 /** 48 * Creates a follower with no camera set. 49 */ 50 static vtkProp3DFollower *New(); 51 52 //@{ 53 /** 54 * Standard VTK methods for type and printing. 55 */ 56 vtkTypeMacro(vtkProp3DFollower,vtkProp3D); 57 void PrintSelf(ostream& os, vtkIndent indent) override; 58 //@} 59 60 //@{ 61 /** 62 * Set/Get the vtkProp3D to control (i.e., face the camera). 63 */ 64 virtual void SetProp3D(vtkProp3D *prop); 65 virtual vtkProp3D *GetProp3D(); 66 //@} 67 68 //@{ 69 /** 70 * Set/Get the camera to follow. If this is not set, then the follower 71 * won't know what to follow and will act like a normal vtkProp3D. 72 */ 73 virtual void SetCamera(vtkCamera*); 74 vtkGetObjectMacro(Camera, vtkCamera); 75 //@} 76 77 //@{ 78 /** 79 * This causes the actor to be rendered. It in turn will render the actor's 80 * property, texture map and then mapper. If a property hasn't been 81 * assigned, then the actor will create one automatically. 82 */ 83 int RenderOpaqueGeometry(vtkViewport *viewport) override; 84 int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override; 85 int RenderVolumetricGeometry(vtkViewport *viewport) override; 86 //@} 87 88 /** 89 * Does this prop have some translucent polygonal geometry? 90 */ 91 vtkTypeBool HasTranslucentPolygonalGeometry() override; 92 93 /** 94 * Release any graphics resources associated with this vtkProp3DFollower. 95 */ 96 void ReleaseGraphicsResources(vtkWindow*) override; 97 98 /** 99 * Generate the matrix based on ivars. This method overloads its superclasses 100 * ComputeMatrix() method due to the special vtkProp3DFollower matrix operations. 101 */ 102 void ComputeMatrix() override; 103 104 /** 105 * Shallow copy of a follower. Overloads the virtual vtkProp method. 106 */ 107 void ShallowCopy(vtkProp *prop) override; 108 109 /** 110 * Return the bounds of this vtkProp3D. 111 */ 112 double *GetBounds() override; 113 114 //@{ 115 /** 116 * Overload vtkProp's method for setting up assembly paths. See 117 * the documentation for vtkProp. 118 */ 119 void InitPathTraversal() override; 120 vtkAssemblyPath *GetNextPath() override; 121 //@} 122 123 protected: 124 vtkProp3DFollower(); 125 ~vtkProp3DFollower() override; 126 127 vtkCamera *Camera; 128 vtkProp3D *Device; 129 130 //Internal matrices to avoid New/Delete for performance reasons 131 vtkMatrix4x4 *InternalMatrix; 132 133 private: 134 vtkProp3DFollower(const vtkProp3DFollower&) = delete; 135 void operator=(const vtkProp3DFollower&) = delete; 136 }; 137 138 #endif 139