MLR_I_TMesh.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. #pragma once
  5. #define MLR_MLR_I_TMESH_HPP
  6. #include <MLR\MLR.hpp>
  7. #include <MLR\MLR_I_PMesh.hpp>
  8. namespace MidLevelRenderer {
  9. //##########################################################################
  10. //#### MLRIndexedTriMesh with no color no lighting one texture layer #####
  11. //##########################################################################
  12. class MLR_I_TMesh:
  13. public MLRIndexedPrimitiveBase
  14. {
  15. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  16. // Initialization
  17. //
  18. public:
  19. static void
  20. InitializeClass();
  21. static void
  22. TerminateClass();
  23. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. // Constructors/Destructors
  25. //
  26. protected:
  27. MLR_I_TMesh(
  28. ClassData *class_data,
  29. Stuff::MemoryStream *stream,
  30. int version
  31. );
  32. ~MLR_I_TMesh();
  33. public:
  34. MLR_I_TMesh(ClassData *class_data=MLR_I_TMesh::DefaultData);
  35. static MLR_I_TMesh*
  36. Make(
  37. Stuff::MemoryStream *stream,
  38. int version
  39. );
  40. void
  41. Save(Stuff::MemoryStream *stream);
  42. public:
  43. virtual void InitializeDrawPrimitive(unsigned char, int=0);
  44. virtual int
  45. GetNumPrimitives()
  46. { Check_Object(this); return numOfTriangles; }
  47. virtual void
  48. SetSubprimitiveLengths(
  49. unsigned char *length_array,
  50. int subprimitive_count
  51. )
  52. {
  53. Check_Object(this);
  54. Verify(gos_GetCurrentHeap() == Heap);
  55. numOfTriangles = subprimitive_count;
  56. testList.SetLength(numOfTriangles);
  57. facePlanes.SetLength(numOfTriangles);
  58. }
  59. void FindFacePlanes();
  60. virtual int FindBackFace(const Stuff::Point3D&);
  61. const Stuff::Plane *GetTrianglePlane(int i)
  62. {
  63. Check_Object(this);
  64. Verify(i<facePlanes.GetLength());
  65. return &facePlanes[i];
  66. }
  67. virtual void Lighting(MLRLight* const*, int nrLights);
  68. virtual void LightMapLighting(MLRLight*);
  69. virtual void
  70. #if COLOR_AS_DWORD
  71. PaintMe(const DWORD *paintMe) {};
  72. #else
  73. PaintMe(const Stuff::RGBAColor *paintMe) {};
  74. #endif
  75. virtual int TransformAndClip(Stuff::Matrix4D *, MLRClippingState, GOSVertexPool*,bool=false);
  76. bool
  77. CastRay(
  78. Stuff::Line3D *line,
  79. Stuff::Normal3D *normal
  80. );
  81. // void
  82. // Transform(Stuff::Matrix4D*);
  83. virtual void
  84. TransformNoClip(Stuff::Matrix4D*, GOSVertexPool*,bool=false);
  85. // Initializes the visibility test list
  86. void
  87. ResetTestList();
  88. // find which vertices are visible which not - returns nr of visible vertices
  89. // the result is stored in the visibleIndexedVertices array
  90. int
  91. FindVisibleVertices();
  92. bool
  93. Copy(MLR_I_PMesh*);
  94. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95. // Class Data Support
  96. //
  97. public:
  98. static ClassData
  99. *DefaultData;
  100. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  101. // Testing
  102. //
  103. public:
  104. void
  105. TestInstance() const;
  106. virtual int
  107. GetSize()
  108. {
  109. Check_Object(this);
  110. int ret = MLRIndexedPrimitiveBase::GetSize();
  111. ret += testList.GetSize();
  112. ret += facePlanes.GetSize();
  113. return ret;
  114. }
  115. protected:
  116. int numOfTriangles;
  117. Stuff::DynamicArrayOf<unsigned char> testList;
  118. Stuff::DynamicArrayOf<Stuff::Plane> facePlanes;
  119. };
  120. #define ICO_X 0.525731112119133606f
  121. #define ICO_Z 0.850650808352039932f
  122. extern float vdata[12][3];
  123. extern unsigned int tindices [20][3];
  124. extern long triDrawn;
  125. MLR_I_TMesh*
  126. CreateIndexedTriCube_NoColor_NoLit(Stuff::Scalar, MLRState*);
  127. MLRShape*
  128. CreateIndexedTriIcosahedron_NoColor_NoLit(
  129. IcoInfo&,
  130. MLRState*
  131. );
  132. }