dyntexproject.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.cpp $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 6/02/00 6:30p $*
  31. * *
  32. * $Revision:: 11 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #include "dyntexproject.h"
  38. #include "phys.h"
  39. DynTexProjectClass::DynTexProjectClass(PhysClass * shadow_generator) :
  40. ProjectionObject(shadow_generator),
  41. LightSourceID(0xFFFFFFFF),
  42. LightVector(0.0f,0.0f,-1.0f)
  43. {
  44. Set_Flag(VOLATILE,true);
  45. }
  46. DynTexProjectClass::~DynTexProjectClass(void)
  47. {
  48. }
  49. void DynTexProjectClass::Pre_Render_Update(const Matrix3D & camera)
  50. {
  51. TexProjectClass::Pre_Render_Update(camera);
  52. if (Get_Flag(TEXTURE_DIRTY)) {
  53. Compute_Texture(ProjectionObject);
  54. }
  55. }
  56. void DynTexProjectClass::Set_Projection_Object(PhysClass * obj)
  57. {
  58. ProjectionObject = obj;
  59. }
  60. PhysClass * DynTexProjectClass::Peek_Projection_Object(void) const
  61. {
  62. return ProjectionObject;
  63. }
  64. void DynTexProjectClass::Set_Light_Source_ID(uint32 id)
  65. {
  66. LightSourceID = id;
  67. }
  68. uint32 DynTexProjectClass::Get_Light_Source_ID(void)
  69. {
  70. return LightSourceID;
  71. }
  72. void DynTexProjectClass::Set_Light_Vector(const Vector3 & vector)
  73. {
  74. LightVector = vector;
  75. }
  76. void DynTexProjectClass::Get_Light_Vector(Vector3 * set_vector)
  77. {
  78. WWASSERT(set_vector != NULL);
  79. *set_vector = LightVector;
  80. }
  81. void DynTexProjectClass::Enable_Perspective(bool onoff)
  82. {
  83. Set_Flag(PERSPECTIVE,onoff);
  84. }
  85. bool DynTexProjectClass::Is_Perspective_Enabled(void)
  86. {
  87. return Get_Flag(PERSPECTIVE);
  88. }
  89. void DynTexProjectClass::Set_Texture_Dirty(bool onoff)
  90. {
  91. Set_Flag(TEXTURE_DIRTY,onoff);
  92. }
  93. bool DynTexProjectClass::Is_Texture_Dirty(void)
  94. {
  95. return Get_Flag(TEXTURE_DIRTY);
  96. }
  97. void DynTexProjectClass::Update_Projection(const AABoxClass & objbox,const Matrix3D & objtm,float znear,float zfar)
  98. {
  99. if (Get_Flag(PERSPECTIVE)) {
  100. TexProjectClass::Compute_Perspective_Projection(objbox,objtm,LightVector,znear,zfar);
  101. } else {
  102. TexProjectClass::Compute_Ortho_Projection(objbox,objtm,LightVector,znear,zfar);
  103. }
  104. }