MLR_I_PMesh.hpp 3.8 KB

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