Box3D.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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 : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/Box3D.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 3/26/01 2:05p $*
  29. * *
  30. * $Revision:: 5 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __BOX3D_H
  39. #define __BOX3D_H
  40. #include "Dynamesh.H"
  41. #include "EditorPhys.H"
  42. #include "Utils.H"
  43. /////////////////////////////////////////////////////////////////////////
  44. // Forward declarations
  45. /////////////////////////////////////////////////////////////////////////
  46. class RayCollisionTestClass;
  47. /////////////////////////////////////////////////////////////////////////
  48. //
  49. // Box3DClass
  50. //
  51. /////////////////////////////////////////////////////////////////////////
  52. class Box3DClass : public DynamicMeshClass
  53. {
  54. public:
  55. //////////////////////////////////////////////////////////
  56. // Public constructors/destructors
  57. //////////////////////////////////////////////////////////
  58. Box3DClass (void)
  59. : m_Dimensions (1, 1, 1),
  60. m_bDirty (false),
  61. DynamicMeshClass (12, 24) { Create_Model (); }
  62. Box3DClass (float width, float height, float depth)
  63. : m_Dimensions (depth, width, height),
  64. m_bDirty (false),
  65. DynamicMeshClass (12, 24) { Create_Model (); }
  66. Box3DClass (const Vector3 &dimensions)
  67. : m_Dimensions (dimensions),
  68. m_bDirty (false),
  69. DynamicMeshClass (12, 24) { Create_Model (); }
  70. virtual ~Box3DClass (void) {}
  71. //////////////////////////////////////////////////////////
  72. // Public methods
  73. ////////////////////////////////////////////////////////////
  74. //
  75. // Base class overrides
  76. //
  77. bool Cast_Ray (RayCollisionTestClass &raytest);
  78. void Get_Obj_Space_Bounding_Box(AABoxClass & box) const;
  79. void Render (RenderInfoClass &rinfo);
  80. //
  81. // Dimension methods
  82. //
  83. void Set_Dimensions (const Vector3 &dimensions);
  84. void Set_Width (float width);
  85. void Set_Height (float height);
  86. void Set_Depth (float depth);
  87. void Get_Dimensions (Vector3 &dimensions) const { dimensions = m_Dimensions; }
  88. const Vector3 & Get_Dimensions (void) const { return m_Dimensions; }
  89. float Get_Width (void) const { return m_Dimensions.Y; }
  90. float Get_Height (void) const { return m_Dimensions.Z; }
  91. float Get_Depth (void) const { return m_Dimensions.X; }
  92. //
  93. // Vertex methods
  94. //
  95. void Position_Vertex (int vertex, const Vector3 &new_position);
  96. void Translate_Vertex (int vertex, const Vector3 &translation);
  97. Vector3 Get_Vertex_Position (int vertex);
  98. void Get_Vertex_Position (int vertex, Vector3 &position);
  99. Vector3 Get_Vertex_Lock_Position (int vertex);
  100. //
  101. // Creation routines
  102. //
  103. void Make_Box (const Vector3 &point1, const Vector3 &point2);
  104. void Set_Color (const Vector3 &color);
  105. //
  106. // Dynamic modification
  107. //
  108. void Drag_VertexXY (int vertex, POINT new_point, const Vector3 &locked_vertex);
  109. void Drag_VertexZ (int vertex, POINT new_point, const Vector3 &locked_vertex);
  110. protected:
  111. //////////////////////////////////////////////////////////
  112. // Protected methods
  113. //////////////////////////////////////////////////////////
  114. void Create_Model (void);
  115. void Easy_Vertex (const Vector3 &vertex) { DynamicMeshClass::Vertex (vertex.X, vertex.Y, vertex.Z, 0, 0); }
  116. void Easy_Move_Vertex (int vertex_index, const Vector3 &vertex) { DynamicMeshClass::Move_Vertex (vertex_index, vertex.X, vertex.Y, vertex.Z); }
  117. void Update_Verticies (void);
  118. private:
  119. //////////////////////////////////////////////////////////
  120. // Private member data
  121. //////////////////////////////////////////////////////////
  122. Vector3 m_Dimensions;
  123. Vector3 m_Verticies[8];
  124. bool m_bDirty;
  125. };
  126. /////////////////////////////////////////////////////////////////////////
  127. //
  128. // Box3DPhysClass
  129. //
  130. /////////////////////////////////////////////////////////////////////////
  131. class Box3DPhysClass : public EditorPhysClass
  132. {
  133. public:
  134. //////////////////////////////////////////////////////////
  135. // Public constructors/destructors
  136. //////////////////////////////////////////////////////////
  137. Box3DPhysClass (void)
  138. : m_pBox (NULL) { Initialize (1, 1, 1); }
  139. Box3DPhysClass (const Vector3 &dimensions)
  140. : m_pBox (NULL) { Initialize (dimensions.X, dimensions.Y, dimensions.Z); }
  141. virtual ~Box3DPhysClass (void) { MEMBER_RELEASE (m_pBox); }
  142. //////////////////////////////////////////////////////////
  143. // Public operators/methods
  144. //////////////////////////////////////////////////////////
  145. operator Box3DClass * (void) const { return m_pBox; }
  146. Box3DClass * Get_Box (void) const { return m_pBox; }
  147. protected:
  148. //////////////////////////////////////////////////////////
  149. // Protected member data
  150. //////////////////////////////////////////////////////////
  151. void Initialize (float x, float y, float z) { m_pBox = new Box3DClass (x, y, z); Set_Model (m_pBox); }
  152. private:
  153. //////////////////////////////////////////////////////////
  154. // Private member data
  155. //////////////////////////////////////////////////////////
  156. Box3DClass * m_pBox;
  157. };
  158. #endif //__BOX3D_H