MLR_I_DeT_TMesh.hpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. #pragma once
  5. #define MLR_MLR_I_DeT_TMESH_HPP
  6. #include <MLR\MLR.hpp>
  7. #include <MLR\MLR_I_TMesh.hpp>
  8. #include <MLR\MLR_I_DeT_PMesh.hpp>
  9. extern DWORD gEnableDetailTexture;
  10. namespace MidLevelRenderer {
  11. //##########################################################################
  12. //#### MLRIndexedPolyMesh with no color no lighting w/ detail texture #####
  13. //##########################################################################
  14. class MLR_I_DeT_TMesh:
  15. public MLR_I_TMesh
  16. {
  17. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. // Initialization
  19. //
  20. public:
  21. static void
  22. InitializeClass();
  23. static void
  24. TerminateClass();
  25. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  26. // Constructors/Destructors
  27. //
  28. protected:
  29. MLR_I_DeT_TMesh(
  30. ClassData *class_data,
  31. Stuff::MemoryStream *stream,
  32. int version
  33. );
  34. ~MLR_I_DeT_TMesh();
  35. public:
  36. MLR_I_DeT_TMesh(ClassData *class_data=MLR_I_DeT_TMesh::DefaultData);
  37. static MLR_I_DeT_TMesh*
  38. Make(
  39. Stuff::MemoryStream *stream,
  40. int version
  41. );
  42. void
  43. Save(Stuff::MemoryStream *stream);
  44. public:
  45. void
  46. Copy(
  47. MLR_I_TMesh*,
  48. MLRState detailState,
  49. Stuff::Scalar xOff,
  50. Stuff::Scalar yOff,
  51. Stuff::Scalar xFac,
  52. Stuff::Scalar yFac
  53. );
  54. bool
  55. Copy(MLR_I_DeT_PMesh *pmesh)
  56. { Check_Object(pmesh); STOP(("Not implemented yet !")); return false; }
  57. void
  58. SetDetailData(
  59. Stuff::Scalar xOff,
  60. Stuff::Scalar yOff,
  61. Stuff::Scalar xFac,
  62. Stuff::Scalar yFac,
  63. Stuff::Scalar detailStart,
  64. Stuff::Scalar detailEnd
  65. );
  66. void
  67. GetDetailData(
  68. Stuff::Scalar& xOff,
  69. Stuff::Scalar& yOff,
  70. Stuff::Scalar& xFac,
  71. Stuff::Scalar& yFac,
  72. Stuff::Scalar& dStart,
  73. Stuff::Scalar& dEnd
  74. )
  75. {
  76. Check_Object(this);
  77. xOff = xOffset;
  78. yOff = yOffset;
  79. xFac = xScale;
  80. yFac = yScale;
  81. dStart = fadeDetailStart;
  82. dEnd = fadeDetailEnd;
  83. }
  84. virtual int TransformAndClip(Stuff::Matrix4D *, MLRClippingState, GOSVertexPool*,bool=false);
  85. virtual void
  86. TransformNoClip(Stuff::Matrix4D*, GOSVertexPool*,bool=false);
  87. virtual void
  88. SetReferenceState(const MLRState& _state, int pass=0)
  89. {
  90. Check_Object(this);
  91. Verify(pass>=0 && pass<2);
  92. if(pass==0)
  93. {
  94. referenceState = _state;
  95. }
  96. else
  97. {
  98. passes = 2;
  99. referenceState2 = _state;
  100. }
  101. }
  102. virtual const MLRState&
  103. GetReferenceState(int pass=0) const
  104. {
  105. Check_Object(this);
  106. if(pass==0)
  107. return referenceState;
  108. else
  109. return referenceState2;
  110. }
  111. virtual const MLRState&
  112. GetCurrentState(int pass=0) const
  113. {
  114. Check_Object(this);
  115. if(pass==0)
  116. return state;
  117. else
  118. return state2;
  119. }
  120. virtual void
  121. CombineStates (const MLRState& master)
  122. {
  123. Check_Object(this);
  124. state.Combine(master, referenceState);
  125. if(gEnableDetailTexture==0)
  126. {
  127. state.SetMultiTextureMode(MLRState::MultiTextureOffMode);
  128. }
  129. state2.Combine(master, referenceState2);
  130. };
  131. virtual GOSVertex*
  132. GetGOSVertices(int pass=0)
  133. {
  134. Check_Object(this);
  135. if(pass==0)
  136. return gos_vertices;
  137. else
  138. return gos_vertices+numGOSVertices;
  139. }
  140. virtual int
  141. GetNumPasses();
  142. GOSVertex2UV*
  143. GetGOSVertices2UV(int=0)
  144. { Check_Object(this); return gos_vertices2uv; }
  145. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  146. // Class Data Support
  147. //
  148. public:
  149. static ClassData
  150. *DefaultData;
  151. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  152. // Testing
  153. //
  154. public:
  155. void
  156. TestInstance() const;
  157. virtual int
  158. GetSize()
  159. {
  160. Check_Object(this);
  161. int ret = MLR_I_TMesh::GetSize();
  162. return ret;
  163. }
  164. protected:
  165. bool detTextureVisible;
  166. MLRState state2, referenceState2;
  167. Stuff::Scalar fadeDetailStart, fadeDetailEnd, fadeMultiplicator;
  168. Stuff::Scalar xOffset, yOffset, xScale, yScale;
  169. GOSVertex2UV *gos_vertices2uv;
  170. };
  171. MLR_I_DeT_TMesh*
  172. CreateIndexedTriCube_NoColor_NoLit_DetTex(Stuff::Scalar, MLRState*, MLRState*);
  173. MLRShape*
  174. CreateIndexedTriIcosahedron_NoColor_NoLit_DetTex(
  175. IcoInfo&,
  176. MLRState*,
  177. MLRState*
  178. );
  179. }