dyntexproject.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WWPhys *
  23. * *
  24. * $Archive:: /Commando/Code/wwphys/dyntexproject.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 6/02/00 6:30p $*
  31. * *
  32. * $Revision:: 7 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #ifndef DYNTEXPROJECT_H
  38. #define DYNTEXPROJECT_H
  39. #include "always.h"
  40. #include "phystexproject.h"
  41. /**
  42. ** DynTexProjectClass
  43. ** Dynamic projected textures. This class is simply a projected texture that
  44. ** can keep track of the object it is supposed to be projecting and refresh
  45. ** its texture only when needed. In addition, it stores the 'ID' of the
  46. ** light source which generated it so that we can re-use the same DynTexProjectClass's
  47. ** when the same object is being projected by the same light source (see the
  48. ** Update_Texture call in MovePhysClass...)
  49. ** NOTE: the pointer back to the projected object is not ref-counted because
  50. ** that would create a circular reference.
  51. */
  52. class DynTexProjectClass : public PhysTexProjectClass
  53. {
  54. public:
  55. DynTexProjectClass(PhysClass * shadow_generator);
  56. virtual ~DynTexProjectClass(void);
  57. /*
  58. ** TexProjectClass interface
  59. */
  60. virtual void Pre_Render_Update(const Matrix3D & camera);
  61. /*
  62. ** DynTexProjectClass interface
  63. ** - stores the object and light source parameters which generate this projector
  64. ** - regenerates the texture in the Pre_Render_Update call
  65. ** In order to properly set up a dynamic projector, be sure you set all of
  66. ** the following: the projection object, the light source ID (pointer cast to an int),
  67. ** the light vector, the perspective flag (indicates whether the vector is a direction
  68. ** or a light position)
  69. */
  70. void Set_Projection_Object(PhysClass * obj);
  71. PhysClass * Peek_Projection_Object(void) const;
  72. virtual void * Get_Projection_Object_ID(void) const { return ProjectionObject; }
  73. void Set_Light_Source_ID(uint32 id);
  74. uint32 Get_Light_Source_ID(void);
  75. void Set_Light_Vector(const Vector3 & vector);
  76. void Get_Light_Vector(Vector3 * set_vector);
  77. void Enable_Perspective(bool onoff);
  78. bool Is_Perspective_Enabled(void);
  79. void Set_Texture_Dirty(bool onoff = true);
  80. bool Is_Texture_Dirty(void);
  81. void Update_Projection(const AABoxClass & objbox,const Matrix3D & objtm,float znear = -1.0f,float zfar = -1.0f);
  82. protected:
  83. PhysClass * ProjectionObject; // Object to be projected, not ref-counted!
  84. uint32 LightSourceID; // ID of the light source (just its pointer,used for matching)
  85. Vector3 LightVector; // copy of the light vector (postion or direction)
  86. };
  87. #endif