projectormanager.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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/projectormanager.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 9/15/00 9:57a $*
  31. * *
  32. * $Revision:: 5 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #if defined(_MSC_VER)
  38. #pragma once
  39. #endif
  40. #ifndef PROJECTORMANAGER_H
  41. #define PROJECTORMANAGER_H
  42. #include "always.h"
  43. #include "bittype.h"
  44. #include "wwstring.h"
  45. class RenderObjClass;
  46. class TexProjectClass;
  47. class ChunkLoadClass;
  48. class ChunkSaveClass;
  49. class ProjectorManagerDefClass;
  50. /**
  51. ** ProjectorManagerClass
  52. ** This class is meant to be embedded in a phyisics object and simply manages the
  53. ** chore of updating the transforms for texture projectors which are attached
  54. ** to bones in a model
  55. */
  56. class ProjectorManagerClass
  57. {
  58. public:
  59. ProjectorManagerClass(void);
  60. ~ProjectorManagerClass(void);
  61. enum
  62. {
  63. IS_ANIMATED = 0x00000001,
  64. };
  65. void Init(const ProjectorManagerDefClass & def,RenderObjClass * model);
  66. void Update_From_Model(RenderObjClass * model);
  67. void Set_Flag(int flag,bool onoff) { (onoff ? Flags |= flag : Flags &= ~flag); }
  68. bool Get_Flag(int flag) { return ((Flags & flag) == flag); }
  69. protected:
  70. void Free(void);
  71. uint16 Flags;
  72. uint16 ProjectorBoneIndex;
  73. TexProjectClass * Projector;
  74. };
  75. /**
  76. ** ProjectorManagerDefClass
  77. ** This class is meant to be a component of a definition class for a physics object
  78. ** which has a ProjectorManager. The member variables of this class are public since
  79. ** various physics def classes make them directly editable.
  80. */
  81. class ProjectorManagerDefClass
  82. {
  83. public:
  84. ProjectorManagerDefClass(void);
  85. ~ProjectorManagerDefClass(void);
  86. void Validate_Parameters(void);
  87. bool Save(ChunkSaveClass &csave);
  88. bool Load(ChunkLoadClass &cload);
  89. public:
  90. bool IsEnabled; // should this object create a projector
  91. bool IsPerspective; // is this a perspective projection
  92. bool IsAdditive; // is this an additive projection
  93. bool IsAnimated; // is this projector animated (attached to a bone that animates?)
  94. float OrthoWidth; // width of the orthographic projection
  95. float OrthoHeight; // height of the orthographic projection
  96. float HorizontalFOV; // horizontal field of view
  97. float VerticalFOV; // vertical field of view
  98. float NearZ; // near clip plane
  99. float FarZ; // far clip plane
  100. float Intensity; // intensity of the projector
  101. StringClass TextureName; // name of texture to project
  102. StringClass BoneName; // name of the bone which should control the projector
  103. };
  104. /*
  105. ** Use this macro to make all of the member variables in a ProjectorManagerDefClass editable.
  106. ** The first parameter to the macro is the type-name of your class (e.g. StaticAnimPhysDefClass) and
  107. ** the second parameter is the name of the member variable which is a ProjectorManagerDefClass.
  108. */
  109. #define PROJECTORMANAGERDEF_EDITABLE_PARAMS( class_name , member_name ) \
  110. PARAM_SEPARATOR( class_name, "Texture Projector Settings"); \
  111. NAMED_EDITABLE_PARAM( class_name , ParameterClass::TYPE_BOOL, member_name ## .IsEnabled, "EnableProjector"); \
  112. NAMED_EDITABLE_PARAM( class_name , ParameterClass::TYPE_BOOL, member_name ## .IsPerspective, "Perspective Projection" ); \
  113. NAMED_EDITABLE_PARAM( class_name , ParameterClass::TYPE_BOOL, member_name ## .IsAdditive, "Projector Is Additive" ); \
  114. NAMED_EDITABLE_PARAM( class_name , ParameterClass::TYPE_BOOL, member_name ## .IsAnimated, "Projector Is Animated" ); \
  115. NAMED_FLOAT_UNITS_PARAM( class_name , member_name ## .OrthoWidth , 0.01f , 1000.0f, "meters","Ortho Width" ); \
  116. NAMED_FLOAT_UNITS_PARAM( class_name , member_name ## .OrthoHeight , 0.01f , 1000.0f, "meters","Ortho Height" ); \
  117. NAMED_ANGLE_EDITABLE_PARAM( class_name , member_name ## .HorizontalFOV, DEG_TO_RADF(0.01f), DEG_TO_RADF(89.99f), "Horizontal FOV" ); \
  118. NAMED_ANGLE_EDITABLE_PARAM( class_name , member_name ## .VerticalFOV, DEG_TO_RADF(0.01f), DEG_TO_RADF(89.99f), "Vertical FOV" ); \
  119. NAMED_FLOAT_UNITS_PARAM( class_name , member_name ## .NearZ , 0.01f , 1000.0f, "meters","NearZ" ); \
  120. NAMED_FLOAT_UNITS_PARAM( class_name , member_name ## .FarZ , 0.01f , 1000.0f, "meters","FarZ" ); \
  121. NAMED_FLOAT_UNITS_PARAM( class_name , member_name ## .Intensity , 0.01f , 1.0f, "","Intensity" ); \
  122. FILENAME_PARAM ( class_name , member_name ## .TextureName, "Texture files", ".tga"); \
  123. NAMED_EDITABLE_PARAM( class_name , ParameterClass::TYPE_STRING, member_name ## .BoneName, "BoneName" );
  124. #endif