dynamesh.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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 : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/ww3d2/dynamesh.h $*
  25. * *
  26. * $Author:: Greg_h $*
  27. * *
  28. * $Modtime:: 12/03/01 4:20p $*
  29. * *
  30. * $Revision:: 15 $*
  31. * *
  32. *-------------------------------------------------------------------------*/
  33. #if defined(_MSC_VER)
  34. #pragma once
  35. #endif
  36. #ifndef DYNAMESH_H
  37. #define DYNAMESH_H
  38. #include "meshgeometry.h"
  39. #include "meshmatdesc.h"
  40. #include "matinfo.h"
  41. #include "rendobj.h"
  42. #include "polyinfo.h"
  43. #include "dx8wrapper.h"
  44. class ShaderClass;
  45. class IntersectionClass;
  46. class IntersectionResultClass;
  47. /*
  48. ** DynamicMeshModel: used for low-level rendering of DynamicMeshClass.
  49. ** It is composed of the same two classes (one base, one embedded as
  50. ** MeshModelClass, so many of its features are similar (see meshmdl.h)
  51. */
  52. class DynamicMeshModel : public MeshGeometryClass
  53. {
  54. public:
  55. DynamicMeshModel(unsigned int max_polys, unsigned int max_verts);
  56. DynamicMeshModel(unsigned int max_polys, unsigned int max_verts, MaterialInfoClass *mat_info);
  57. DynamicMeshModel(const DynamicMeshModel &src);
  58. ~DynamicMeshModel(void);
  59. // Inherited from MeshGeometryClass
  60. virtual void Compute_Plane_Equations(void);
  61. virtual void Compute_Vertex_Normals(void);
  62. virtual void Compute_Bounds(Vector3 * verts);
  63. // Reset mesh (with existing max polygon and max vertex counts)
  64. void Reset(void);
  65. // Render mesh
  66. void Render(RenderInfoClass & rinfo);
  67. // Set current polygon and vertex counts
  68. void Set_Counts(int pnum, int vnum) { DynamicMeshPNum = pnum; DynamicMeshVNum = vnum; }
  69. // Access to material stuff:
  70. unsigned * Get_Color_Array(int color_array_index) { return MatDesc->Get_Color_Array(color_array_index); }
  71. Vector2 * Get_UV_Array(int uv_array_index) { return MatDesc->Get_UV_Array_By_Index(uv_array_index); }
  72. void Set_Single_Material(VertexMaterialClass * vmat, int pass=0) { MatDesc->Set_Single_Material(vmat, pass); }
  73. void Set_Single_Texture(TextureClass * tex, int pass=0, int stage=0) { MatDesc->Set_Single_Texture(tex, pass, stage); }
  74. void Set_Single_Shader(ShaderClass shader, int pass=0) { MatDesc->Set_Single_Shader(shader, pass); }
  75. void Set_Material(int vidx, VertexMaterialClass * vmat, int pass=0) { MatDesc->Set_Material(vidx, vmat, pass); }
  76. void Set_Shader(int pidx, ShaderClass shader, int pass=0) { MatDesc->Set_Shader(pidx, shader, pass); }
  77. void Set_Texture(int pidx, TextureClass * tex, int pass=0, int stage=0) { MatDesc->Set_Texture(pidx, tex, pass, stage); }
  78. void Set_Pass_Count(int passes) { MatDesc->Set_Pass_Count(passes); }
  79. int Get_Pass_Count(void) const { return MatDesc->Get_Pass_Count(); }
  80. // Create the array (if it doesn't exist), fill it with the supplied value.
  81. void Initialize_Texture_Array(int pass, int stage, TextureClass *texture = NULL);
  82. void Initialize_Material_Array(int pass, VertexMaterialClass *vmat = NULL);
  83. // Accessors to material info:
  84. MaterialInfoClass *Peek_Material_Info(void) { return MatInfo; }
  85. MaterialInfoClass *Get_Material_Info(void) { if (MatInfo) MatInfo->Add_Ref(); return MatInfo;}
  86. void Set_Material_Info(MaterialInfoClass *mat_info)
  87. {
  88. if (MatInfo)
  89. MatInfo->Release_Ref();
  90. WWASSERT(MatInfo != 0);
  91. MatInfo = mat_info;
  92. MatInfo->Add_Ref();
  93. }
  94. // New geometry accessors (non-const)
  95. TriIndex * Get_Non_Const_Polygon_Array(void);
  96. Vector3 * Get_Non_Const_Vertex_Normal_Array(void);
  97. private:
  98. // These are current counts, as opposed to those in the mesh geometry and
  99. // material description which are actually maximum counts.
  100. int DynamicMeshPNum;
  101. int DynamicMeshVNum;
  102. // All non-geometry properties (uvs, colors, textures, shaders, etc)
  103. MeshMatDescClass * MatDesc;
  104. // Lists of textures and vertex materials for ease of processing
  105. MaterialInfoClass * MatInfo;
  106. };
  107. /*
  108. ** Dynamic Meshes
  109. */
  110. class DynamicMeshClass : public RenderObjClass {
  111. public:
  112. // constructor and destructor
  113. DynamicMeshClass( int max_poly, int max_vert);
  114. DynamicMeshClass( int max_poly, int max_vert, MaterialInfoClass *mat_info);
  115. DynamicMeshClass( const DynamicMeshClass & src);
  116. virtual ~DynamicMeshClass( void);
  117. // Inherited from RenderObjClass:
  118. virtual RenderObjClass * Clone(void) const;
  119. virtual int Class_ID(void) const { return CLASSID_DYNAMESH; }
  120. virtual void Render(RenderInfoClass & rinfo);
  121. virtual MaterialInfoClass *Peek_Material_Info(void) { return Model->Peek_Material_Info(); }
  122. virtual MaterialInfoClass *Get_Material_Info(void) { return Model->Get_Material_Info(); }
  123. virtual void Set_Material_Info(MaterialInfoClass *mat_info) { Model->Set_Material_Info(mat_info); }
  124. // all render objects should be able to tell you how many polygons were
  125. // used in the making of the render object.
  126. virtual int Get_Num_Polys(void) const { return PolyCount; }
  127. // return the number of vertices used by this renderobject
  128. virtual int Get_Num_Vertices(void) const { return VertCount; }
  129. // Get and set static sort level
  130. virtual int Get_Sort_Level(void) const { return SortLevel; }
  131. virtual void Set_Sort_Level(int level) { SortLevel = level; if(level != SORT_LEVEL_NONE) Disable_Sort();}
  132. // object space bounding volumes
  133. virtual inline void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
  134. virtual inline void Get_Obj_Space_Bounding_Box(AABoxClass & box) const;
  135. // Set the vertex material for the current triangle
  136. int Set_Vertex_Material( int idx, int pass = 0);
  137. int Set_Vertex_Material( VertexMaterialClass *material, bool dont_search = false, int pass = 0);
  138. // Set the number of passes for the mesh
  139. void Set_Pass_Count(int passes) { assert(PolyCount == 0); Model->Set_Pass_Count(passes); }
  140. int Get_Pass_Count() { return Model->Get_Pass_Count(); }
  141. // Set the texture for the current triangle
  142. int Set_Texture( int idx, int pass = 0);
  143. int Set_Texture( TextureClass *texture, bool dont_search = false, int pass = 0);
  144. // Set the shader for the current triangle
  145. int Set_Shader( const ShaderClass & shader, int pass = 0) { Model->Set_Single_Shader(shader, pass); return 0; }
  146. // set the shader, texture, and vertex material as found in the polygon info object
  147. void Set_Polygon_Info(const PolygonInfoClass &polyInfo, bool dont_search_texture = false, bool dont_search_vertex_material = false, int pass = 0)
  148. {
  149. // there must be a shader..
  150. assert(polyInfo.Peek_Shader() != 0);
  151. Set_Shader(* (polyInfo.Peek_Shader()), pass);
  152. assert(polyInfo.Peek_Vertex_Material() != 0);
  153. Set_Vertex_Material(polyInfo.Peek_Vertex_Material(), dont_search_vertex_material, pass);
  154. if (polyInfo.Peek_Texture())
  155. Set_Texture(polyInfo.Peek_Texture(), dont_search_texture, pass);
  156. }
  157. // Set vertex Color
  158. inline int Set_Vertex_Color(const Vector4 & color, int color_array_index = 0);
  159. inline int Set_Vertex_Color(const Vector3 & color, int color_array_index = 0);
  160. // reset the mesh flags
  161. void Reset_Flags() { Set_Dirty(); }
  162. // Flush the mesh
  163. void Reset_Native_Mesh() { Model->Reset(); }
  164. // reset our poly and vertex counts
  165. void Reset_Mesh_Counters()
  166. {
  167. Model->Set_Counts(0, 0);
  168. Disable_Sort();
  169. PolyCount = 0;
  170. VertCount = 0;
  171. }
  172. // Reset all polys and verts. Call the other reset functions directly if you do not want all
  173. // characteristics to be reset.
  174. virtual void Reset( void )
  175. {
  176. // Note that the active poly count has changed since the last render call by setting the dirty flag
  177. Reset_Flags();
  178. Reset_Native_Mesh();
  179. Reset_Mesh_Counters();
  180. // reset all the texture & vertex material indices
  181. int pass = MAX_PASSES;
  182. while (pass--) {
  183. TextureIdx[pass] = -1;
  184. VertexMaterialIdx[pass] = -1;
  185. MultiVertexMaterial[pass] = false;
  186. }
  187. }
  188. // Deletes mesh and recreates it with new max_polys and verts.
  189. void Resize(int max_polys, int max_verts);
  190. // Triangle creation routines
  191. void Begin_Tri_Strip( void ) { TriVertexCount = 0; TriMode = TRI_MODE_STRIPS; }
  192. void Begin_Tri_Fan( void ) { TriVertexCount = 0; TriMode = TRI_MODE_FANS; FanVertex = VertCount; }
  193. // vertex creation routines
  194. void Begin_Vertex( void) {}
  195. virtual void Location( float x, float y, float z);
  196. // version for speedier use in certain cases
  197. void Location_Inline( float x, float y, float z )
  198. {
  199. Vector3 * loc = Model->Get_Vertex_Array();
  200. assert(loc);
  201. loc[VertCount].X = x;
  202. loc[VertCount].Y = y;
  203. loc[VertCount].Z = z;
  204. }
  205. void Location_Inline(Vector3 &v) { Location_Inline(v.X,v.Y,v.Z); }
  206. // retrieve a reference to the vertex in the object
  207. // WARNING: does not validate index
  208. Vector3 & Get_Location(int index) {
  209. return Model->Get_Vertex_Array()[index];
  210. }
  211. void Normal( float x, float y, float z)
  212. {
  213. Vector3 * norms = Model->Get_Non_Const_Vertex_Normal_Array();
  214. assert(norms);
  215. norms[VertCount].X = x;
  216. norms[VertCount].Y = y;
  217. norms[VertCount].Z = z;
  218. }
  219. void Normal(Vector3 &v) { Normal(v.X,v.Y,v.Z); }
  220. // retrieve a reference to the normal vector3 in the object
  221. // WARNING: does not validate index
  222. Vector3 & Get_Normal(int index) { return Model->Get_Non_Const_Vertex_Normal_Array()[index]; }
  223. void Color(float r, float g, float b, float a, int color_array_index = 0)
  224. {
  225. // Vector4 * color = Model->Get_Color_Array(color_array_index);
  226. unsigned * color = Model->Get_Color_Array(color_array_index);
  227. assert(color);
  228. color[VertCount]=DX8Wrapper::Convert_Color_Clamp(Vector4(r,g,b,a));
  229. // color[VertCount].X = r;
  230. // color[VertCount].Y = g;
  231. // color[VertCount].Z = b;
  232. // color[VertCount].W = a;
  233. }
  234. void Color(const Vector4 &v, int color_array_index = 0) { Color(v.X, v.Y, v.Z, v.W, color_array_index); }
  235. void Color(unsigned v, int color_array_index=0)
  236. {
  237. unsigned * color = Model->Get_Color_Array(color_array_index);
  238. assert(color);
  239. color[VertCount]=v;
  240. }
  241. // retrieve a reference to a color entry in the object
  242. // WARNING: does not validate index
  243. // Vector4 & Get_Color(int index, int color_array_index = 0) { return Model->Get_Color_Array(color_array_index)[index]; }
  244. unsigned Get_Color(int index, int color_array_index = 0) { return Model->Get_Color_Array(color_array_index)[index]; }
  245. void UV(float u, float v, int uv_array_index = 0)
  246. {
  247. Vector2 * uv = Model->Get_UV_Array(uv_array_index);
  248. assert(uv);
  249. uv[VertCount].U = u;
  250. uv[VertCount].V = v;
  251. }
  252. void UV( Vector2 &v, int uv_array_index = 0) { UV(v.U, v.V, uv_array_index); }
  253. // retrieve a reference to a UV entry in the object
  254. // WARNING: does not validate index
  255. Vector2 & Get_UV(int index, int uv_array_index = 0 )
  256. {
  257. return Model->Get_UV_Array(uv_array_index)[index];
  258. }
  259. bool End_Vertex( void);
  260. // vertex creation shortcut, performs a begin, projected, rotated, and end
  261. bool Vertex(float x, float y, float z, float u, float v)
  262. {
  263. Begin_Vertex();
  264. Location(x, y, z);
  265. UV(u, v);
  266. return End_Vertex();
  267. }
  268. bool Vertex(Vector2 v)
  269. {
  270. Begin_Vertex();
  271. Location(v.X, v.Y, 0);
  272. return End_Vertex();
  273. }
  274. void End_Tri_Strip( void )
  275. {
  276. TriVertexCount = 0;
  277. }
  278. void End_Tri_Fan( void )
  279. {
  280. TriVertexCount = 0;
  281. }
  282. // For moving a vertex after the DynaMesh has already been created.
  283. virtual void Move_Vertex(int index, float x, float y, float z);
  284. virtual void Get_Vertex(int index, float &x, float &y, float &z);
  285. // For moving all vertices in the mesh by a fixed amount
  286. void Translate_Vertices(const Vector3 & offset);
  287. // For changing the color of a vertex after DynaMesh has been created.
  288. virtual void Change_Vertex_Color(int index, const Vector4 &color, int color_array_index)
  289. {
  290. // check if switching to multivertexcolor
  291. if (!MultiVertexColor[color_array_index]) {
  292. Switch_To_Multi_Vertex_Color(color_array_index);
  293. }
  294. CurVertexColor[color_array_index].X = color.X;
  295. CurVertexColor[color_array_index].Y = color.Y;
  296. CurVertexColor[color_array_index].Z = color.Z;
  297. CurVertexColor[color_array_index].W = color.W;
  298. // Vector4 * color_list = Model->Get_Color_Array(color_array_index);
  299. unsigned * color_list = Model->Get_Color_Array(color_array_index);
  300. color_list[index] = DX8Wrapper::Convert_Color_Clamp(color);
  301. }
  302. /*
  303. ** The following are a bunch of inlined functions for setting & clearing the mesh model's various flags
  304. */
  305. // dirty flags
  306. void Set_Dirty_Bounds(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_BOUNDS, true); }
  307. void Clear_Dirty_Bounds(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_BOUNDS, false); }
  308. void Set_Dirty_Planes(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_PLANES, true); }
  309. void Clear_Dirty_Planes(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_PLANES, false); }
  310. void Set_Dirty_Vertex_Normals(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_VNORMALS, true); }
  311. void Clear_Dirty_Vertex_Normals(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_VNORMALS, false); }
  312. // control flags
  313. void Disable_Sort(void) { Model->Set_Flag(MeshGeometryClass::SORT, false); }
  314. void Enable_Sort(void) { Model->Set_Flag(MeshGeometryClass::SORT, true); }
  315. bool Sort_Enabled(void) { return (Model->Get_Flag(MeshGeometryClass::SORT) != 0); }
  316. void Disable_Bounding_Box(void) { Model->Set_Flag(MeshGeometryClass::DISABLE_BOUNDING_BOX, true); }
  317. void Enable_Bounding_Box(void) { Model->Set_Flag(MeshGeometryClass::DISABLE_BOUNDING_BOX, false); }
  318. bool Test_Bounding_Box(void) { return (Model->Get_Flag(MeshGeometryClass::DISABLE_BOUNDING_BOX) == 0); }
  319. void Disable_Bounding_Sphere(void) { Model->Set_Flag(MeshGeometryClass::DISABLE_BOUNDING_SPHERE, true); }
  320. void Enable_Bounding_Sphere(void) { Model->Set_Flag(MeshGeometryClass::DISABLE_BOUNDING_SPHERE, false); }
  321. bool Test_Bounding_Sphere(void) { return (Model->Get_Flag(MeshGeometryClass::DISABLE_BOUNDING_SPHERE) == 0); }
  322. // this is called by the Reset function
  323. void Set_Dirty( void) { Set_Dirty_Bounds(); Set_Dirty_Planes(); Set_Dirty_Vertex_Normals(); }
  324. enum {
  325. MAX_COLOR_ARRAYS = MeshMatDescClass::MAX_COLOR_ARRAYS,
  326. MAX_PASSES = MeshMatDescClass::MAX_PASSES
  327. };
  328. // USER BE WARNED: This hack is only here because DynamicMeshClass does not expose all of the
  329. // features that DynamicMeshModel provides. It may be dangerous to modify the model behind the
  330. // DynamicMeshClass's back so use at your own risk!
  331. DynamicMeshModel * Peek_Model(void) { return Model; }
  332. protected:
  333. inline void Switch_To_Multi_Vertex_Color(int color_array_index = 0);
  334. // tells when the triangle needs to be back flipped
  335. virtual bool Flip_Face( void) { return (!(TriVertexCount & 1)); }
  336. // Low-level mesh object
  337. DynamicMeshModel * Model;
  338. int VertexMaterialIdx[MAX_PASSES];
  339. bool MultiVertexMaterial[MAX_PASSES];
  340. int TextureIdx[MAX_PASSES];
  341. bool MultiTexture[MAX_PASSES];
  342. Vector4 CurVertexColor[MAX_COLOR_ARRAYS];
  343. bool MultiVertexColor[MAX_COLOR_ARRAYS];
  344. // number of polygons in the mesh
  345. int PolyCount;
  346. // number of vertices in the mesh
  347. int VertCount;
  348. // triangle vertex number
  349. int TriVertexCount;
  350. // base vertex when submitting fans
  351. int FanVertex;
  352. // is user currently submitting strips or fans
  353. enum { TRI_MODE_STRIPS = 0, TRI_MODE_FANS = 1 };
  354. int TriMode;
  355. // The static sort level
  356. char SortLevel;
  357. };
  358. inline Vector3 * DynamicMeshModel::Get_Non_Const_Vertex_Normal_Array(void)
  359. {
  360. if (Get_Flag(DIRTY_VNORMALS)) {
  361. Compute_Vertex_Normals();
  362. }
  363. return get_vert_normals();
  364. }
  365. inline TriIndex * DynamicMeshModel::Get_Non_Const_Polygon_Array(void)
  366. {
  367. return get_polys();
  368. }
  369. inline void DynamicMeshClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const
  370. {
  371. if (!Bounding_Volumes_Valid()) {
  372. Model->Compute_Bounds(NULL);
  373. }
  374. Model->Get_Bounding_Sphere(&sphere);
  375. }
  376. inline void DynamicMeshClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const
  377. {
  378. if (!Bounding_Volumes_Valid()) {
  379. Model->Compute_Bounds(NULL);
  380. }
  381. Model->Get_Bounding_Box(&box);
  382. }
  383. /*
  384. **
  385. */
  386. void DynamicMeshClass::Switch_To_Multi_Vertex_Color(int color_array_index)
  387. {
  388. /* Vector4 * color_list = Model->Get_Color_Array(color_array_index);
  389. // set the proper color for all the existing vertices
  390. for (int lp = 0; lp < VertCount; lp++) {
  391. color_list[lp].X = CurVertexColor[color_array_index].X;
  392. color_list[lp].Y = CurVertexColor[color_array_index].Y;
  393. color_list[lp].Z = CurVertexColor[color_array_index].Z;
  394. color_list[lp].W = CurVertexColor[color_array_index].W;
  395. }
  396. */
  397. unsigned * color_list = Model->Get_Color_Array(color_array_index);
  398. // set the proper color for all the existing vertices
  399. unsigned vertex_color=DX8Wrapper::Convert_Color_Clamp(CurVertexColor[color_array_index]);
  400. for (int lp = 0; lp < VertCount; lp++) {
  401. color_list[lp]=vertex_color;
  402. }
  403. MultiVertexColor[color_array_index] = true;
  404. }
  405. /*
  406. ** Set the color of all vertices in the mesh for one color_array_index
  407. */
  408. int DynamicMeshClass::Set_Vertex_Color(const Vector4 & color, int color_array_index)
  409. {
  410. // check if switching to multivertexcolor
  411. if (!MultiVertexColor[color_array_index]) {
  412. Switch_To_Multi_Vertex_Color(color_array_index);
  413. }
  414. CurVertexColor[color_array_index] = color;
  415. return 0;
  416. }
  417. int DynamicMeshClass::Set_Vertex_Color(const Vector3 & color, int color_array_index)
  418. {
  419. Set_Vertex_Color(Vector4(color.X,color.Y,color.Z,1),color_array_index);
  420. return 0;
  421. }
  422. /*
  423. ** Dynamic Screen Meshes
  424. **
  425. ** Same as DynamicMesh, but mapped in Screen Coordinates
  426. **
  427. ** Screen -> 0,0 1,0
  428. ** +---+
  429. ** | |
  430. ** +---+
  431. ** 0,1 1,1
  432. **
  433. **
  434. ** View -> -1,1 1,1
  435. ** +---+
  436. ** | |
  437. ** +---+
  438. ** -1,-1 1,-1
  439. **
  440. ** Note: since y is inverted, it switches from right handed to left handed
  441. ** (from counter-clockwise to clockwise), so Flip Face accounts for this
  442. */
  443. class DynamicScreenMeshClass : public DynamicMeshClass {
  444. public:
  445. // constructor and destructor
  446. DynamicScreenMeshClass( int max_poly, int max_vert, float aspect = 1.0f ) : DynamicMeshClass( max_poly, max_vert), Aspect( aspect ) {}
  447. DynamicScreenMeshClass( const DynamicScreenMeshClass & src) : DynamicMeshClass(src), Aspect(src.Aspect) {}
  448. virtual ~DynamicScreenMeshClass( void) {}
  449. // function to clone a dynamic screen mesh class
  450. virtual RenderObjClass * Clone(void) const { return NEW_REF( DynamicScreenMeshClass, (*this)); }
  451. // class id of this render object
  452. virtual int Class_ID(void) const { return CLASSID_DYNASCREENMESH; }
  453. // Remap locations to match a screen
  454. virtual void Location( float x, float y, float z = 0.0f);
  455. // For moving a vertex after the DynaMesh has already been created.
  456. virtual void Move_Vertex(int index, float x, float y, float z = 0.0f);
  457. // Set position
  458. virtual void Set_Position(const Vector3 &v);
  459. virtual void Reset( void);
  460. virtual void Set_Aspect(float aspect) { Aspect=aspect; };
  461. protected:
  462. // Aspect Ratio of the virtual screen.
  463. // 1.0 gives a -1,-1 to 1,1 display
  464. // 3/4 givs a -1,-3/4 to 1,3/4 display
  465. float Aspect;
  466. // tells when the triangle needs to be back flipped
  467. virtual bool Flip_Face( void) { return !DynamicMeshClass::Flip_Face(); }
  468. };
  469. #endif // DYNAMESH