MLRClipper.hpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. #pragma once
  5. #define MLR_MLRCLIPPER_HPP
  6. #if !defined(MLR_MLR_HPP)
  7. #include <MLR\MLR.hpp>
  8. #endif
  9. #if !defined(MLR_MLRSORTER_HPP)
  10. #include <MLR\MLRSorter.hpp>
  11. #endif
  12. #if !defined(MLR_MLRLIGHT_HPP)
  13. #include <MLR\MLRLight.hpp>
  14. #endif
  15. #if !defined(MLR_MLRSHAPE_HPP)
  16. #include <MLR\MLRShape.hpp>
  17. #endif
  18. #if !defined(MLR_GOSVERTEXPOOL_HPP)
  19. #include <MLR\GOSVertexPool.hpp>
  20. #endif
  21. namespace MidLevelRenderer {
  22. typedef int AndyDisplay;
  23. class DrawShapeInformation
  24. #if defined(_ARMOR)
  25. : public Stuff::Signature
  26. #endif
  27. {
  28. public:
  29. DrawShapeInformation();
  30. MLRShape *shape;
  31. MLRState state;
  32. MLRClippingState clippingFlags;
  33. const Stuff::LinearMatrix4D *shapeToWorld;
  34. const Stuff::LinearMatrix4D *worldToShape;
  35. MLRLight *const *activeLights;
  36. int nrOfActiveLights;
  37. void
  38. TestInstance() const
  39. {}
  40. };
  41. class DrawScalableShapeInformation : public DrawShapeInformation
  42. {
  43. public:
  44. DrawScalableShapeInformation();
  45. const Stuff::Vector3D *scaling;
  46. const Stuff::RGBAColor *paintMe;
  47. void
  48. TestInstance() const
  49. {}
  50. };
  51. class MLREffect;
  52. class DrawEffectInformation
  53. #if defined(_ARMOR)
  54. : public Stuff::Signature
  55. #endif
  56. {
  57. public:
  58. DrawEffectInformation();
  59. MLREffect *effect;
  60. MLRState state;
  61. MLRClippingState clippingFlags;
  62. const Stuff::LinearMatrix4D *effectToWorld;
  63. #if 0 // for the time being no lights on the effects
  64. MLRLight *const *activeLights;
  65. int nrOfActiveLights;
  66. #endif
  67. void
  68. TestInstance() const
  69. {}
  70. };
  71. class DrawScreenQuadsInformation
  72. #if defined(_ARMOR)
  73. : public Stuff::Signature
  74. #endif
  75. {
  76. public:
  77. DrawScreenQuadsInformation();
  78. const Stuff::Vector4D *coords;
  79. const Stuff::RGBAColor *colors;
  80. const Vector2DScalar *texCoords;
  81. const bool *onOrOff;
  82. int
  83. nrOfQuads,
  84. currentNrOfQuads;
  85. MLRState state;
  86. void
  87. TestInstance() const
  88. {}
  89. };
  90. //##########################################################################
  91. //######################### MLRClipper #################################
  92. //##########################################################################
  93. class MLRClipper :
  94. public Stuff::RegisteredClass
  95. {
  96. public:
  97. static void
  98. InitializeClass();
  99. static void
  100. TerminateClass();
  101. // Camera gets attached to a film
  102. MLRClipper(AndyDisplay*, MLRSorter*);
  103. ~MLRClipper();
  104. // lets begin the dance
  105. void StartDraw(
  106. const Stuff::LinearMatrix4D& camera_to_world,
  107. const Stuff::Matrix4D& clip_matrix,
  108. const Stuff::RGBAColor &fog_color, // NOT USED ANYMORE
  109. const Stuff::RGBAColor *background_color,
  110. const MLRState &default_state,
  111. const Stuff::Scalar *z_value
  112. );
  113. // add another shape
  114. void DrawShape (DrawShapeInformation*);
  115. // add another shape
  116. void DrawScalableShape (DrawScalableShapeInformation*);
  117. // add screen quads
  118. void DrawScreenQuads (DrawScreenQuadsInformation*);
  119. // add another effect
  120. void DrawEffect (DrawEffectInformation*);
  121. // starts the action
  122. void RenderNow ()
  123. { Check_Object(this); sorter->RenderNow(); }
  124. // clear the film
  125. void Clear (unsigned int flags);
  126. AndyDisplay* GetDisplay () const
  127. { Check_Object(this); return display; };
  128. // statistics and time
  129. unsigned int GetFrameRate () const
  130. { Check_Object(this); return frameRate; }
  131. void SetTime (Stuff::Scalar t)
  132. { Check_Object(this); nowTime = t; }
  133. Stuff::Scalar GetTime () const
  134. { Check_Object(this); return nowTime; }
  135. const Stuff::LinearMatrix4D&
  136. GetCameraToWorldMatrix()
  137. {Check_Object(this); return cameraToWorldMatrix;}
  138. const Stuff::LinearMatrix4D&
  139. GetWorldToCameraMatrix()
  140. {Check_Object(this); return worldToCameraMatrix;}
  141. const Stuff::Matrix4D&
  142. GetCameraToClipMatrix()
  143. {Check_Object(this); return cameraToClipMatrix;}
  144. void
  145. ResetSorter()
  146. {Check_Object(this); sorter->Reset();}
  147. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  148. // Class Data Support
  149. //
  150. public:
  151. static ClassData
  152. *DefaultData;
  153. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  154. // Testing
  155. //
  156. public:
  157. void
  158. TestInstance() const
  159. {};
  160. protected:
  161. // statistics and time
  162. unsigned int frameRate;
  163. Stuff::Scalar usedTime;
  164. Stuff::Scalar nowTime;
  165. // world-to-camera matrix
  166. Stuff::LinearMatrix4D
  167. worldToCameraMatrix;
  168. Stuff::LinearMatrix4D
  169. cameraToWorldMatrix;
  170. Stuff::Matrix4D
  171. cameraToClipMatrix;
  172. Stuff::Matrix4D
  173. worldToClipMatrix;
  174. Stuff::Point3D
  175. cameraPosition;
  176. // this is the film
  177. AndyDisplay *display;
  178. // this defines the sort order of the draw
  179. MLRSorter *sorter;
  180. GOSVertexPool allVerticesToDraw;
  181. };
  182. }