PathDebugPlotter.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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/wwphys/PathDebugPlotter.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/13/00 3:03p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __PATH_DEBUG_PLOTTER_H
  39. #define __PATH_DEBUG_PLOTTER_H
  40. #include "pscene.h"
  41. #include "vector3.h"
  42. #include "vector.h"
  43. #include "rendobj.h"
  44. #include "decophys.h"
  45. #include "widgets.h"
  46. /////////////////////////////////////////////////////////////////////////
  47. //
  48. // PathDebugPlotterClass
  49. //
  50. /////////////////////////////////////////////////////////////////////////
  51. class PathDebugPlotterClass : public RenderObjClass
  52. {
  53. public:
  54. /////////////////////////////////////////////////////////////////////////
  55. // Public constructors/destructors
  56. /////////////////////////////////////////////////////////////////////////
  57. PathDebugPlotterClass (void)
  58. : m_ShouldDisplay (false),
  59. m_PhysObj (NULL) { _ThePathDebugPlotter = this; WidgetSystem::Init_Debug_Widgets (); m_BoundingBox.Center.Set (0, 0, 0); m_BoundingBox.Extent.Set (2000, 2000, 2000); }
  60. ~PathDebugPlotterClass (void) { Reset (); _ThePathDebugPlotter = NULL; }
  61. /////////////////////////////////////////////////////////////////////////
  62. // RenderObjClass required methods
  63. /////////////////////////////////////////////////////////////////////////
  64. RenderObjClass *Clone (void) const { return NULL; }
  65. int Class_ID (void) const { return CLASSID_LAST + 104L; }
  66. void Render (RenderInfoClass &rinfo);
  67. const AABoxClass &Get_Bounding_Box(void) const { return m_BoundingBox; }
  68. /////////////////////////////////////////////////////////////////////////
  69. // Public methods
  70. /////////////////////////////////////////////////////////////////////////
  71. void Add (const Vector3 &start, const Vector3 &end, const Vector3 &color);
  72. void Reset (void) { m_VectorList.Delete_All (); }
  73. void Display (bool display);
  74. bool Is_Displayed (void) const { return m_ShouldDisplay; }
  75. void Render_Vector (RenderInfoClass & rinfo, const Vector3 & pt, const Vector3 & vec, const Vector3 & color);
  76. /////////////////////////////////////////////////////////////////////////
  77. // Static methods
  78. /////////////////////////////////////////////////////////////////////////
  79. static PathDebugPlotterClass *Get_Instance (void) { return _ThePathDebugPlotter; }
  80. private:
  81. /////////////////////////////////////////////////////////////////////////
  82. // Static members
  83. /////////////////////////////////////////////////////////////////////////
  84. static PathDebugPlotterClass *_ThePathDebugPlotter;
  85. /////////////////////////////////////////////////////////////////////////
  86. // Private data types
  87. /////////////////////////////////////////////////////////////////////////
  88. typedef struct _VECTOR_INFO
  89. {
  90. Vector3 point;
  91. Vector3 vector;
  92. Vector3 color;
  93. _VECTOR_INFO(void)
  94. : point (0, 0, 0), vector (0, 0, 0), color (1, 0, 0) { }
  95. _VECTOR_INFO(const Vector3 &_point, const Vector3 &_vector, const Vector3 &_color)
  96. : point (_point), vector (_vector), color (_color) { }
  97. bool operator== (const _VECTOR_INFO &src) { return false; }
  98. bool operator!= (const _VECTOR_INFO &src) { return true; }
  99. } VECTOR_INFO;
  100. /////////////////////////////////////////////////////////////////////////
  101. // Private member data
  102. /////////////////////////////////////////////////////////////////////////
  103. DynamicVectorClass<VECTOR_INFO> m_VectorList;
  104. bool m_ShouldDisplay;
  105. AABoxClass m_BoundingBox;
  106. DecorationPhysClass * m_PhysObj;
  107. };
  108. /////////////////////////////////////////////////////////////////////////
  109. //
  110. // Inlines
  111. //
  112. /////////////////////////////////////////////////////////////////////////
  113. inline void
  114. PathDebugPlotterClass::Add (const Vector3 &start, const Vector3 &end, const Vector3 &color)
  115. {
  116. VECTOR_INFO info;
  117. info.point = start;
  118. info.vector = end - start;
  119. info.color = color;
  120. //
  121. // Add the vector to our list
  122. //
  123. m_VectorList.Add (info);
  124. return ;
  125. }
  126. inline void
  127. PathDebugPlotterClass::Render (RenderInfoClass &rinfo)
  128. {
  129. if (m_ShouldDisplay) {
  130. for (int index = 0; index < m_VectorList.Count (); index ++) {
  131. VECTOR_INFO &info = m_VectorList[index];
  132. //
  133. //Render the vector
  134. //
  135. Render_Vector (rinfo, info.point, info.vector, info.color);
  136. }
  137. }
  138. return ;
  139. }
  140. inline void
  141. PathDebugPlotterClass::Display (bool display)
  142. {
  143. PhysicsSceneClass *scene = PhysicsSceneClass::Get_Instance ();
  144. if (scene != NULL) {
  145. if ((m_ShouldDisplay == false) && display) {
  146. if (m_PhysObj == NULL) {
  147. m_PhysObj = new DecorationPhysClass;
  148. m_PhysObj->Set_Model (this);
  149. m_PhysObj->Set_Cull_Box (m_BoundingBox);
  150. }
  151. scene->Add_Dynamic_Object (m_PhysObj);
  152. m_ShouldDisplay = true;
  153. } else if (m_ShouldDisplay && (display == false)) {
  154. scene->Remove_Object (m_PhysObj);
  155. m_ShouldDisplay = false;
  156. }
  157. }
  158. return ;
  159. }
  160. #endif //__PATH_DEBUG_PLOTTER_H