MLRLightMap.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. #pragma once
  5. #define MLR_MLRLIGHTMAP_HPP
  6. #include "MLR.hpp"
  7. namespace MidLevelRenderer {
  8. //##########################################################################
  9. //######################### MLRLightMap ##############################
  10. //##########################################################################
  11. class MLRLightMap:
  12. public Stuff::RegisteredClass
  13. {
  14. public:
  15. static void
  16. InitializeClass();
  17. static void
  18. TerminateClass();
  19. MLRLightMap(MLRTexture*);
  20. ~MLRLightMap();
  21. enum MemoryStreamData {
  22. Matrix4D=0,
  23. ClippingState,
  24. MasterRenderState,
  25. LightMapRenderState,
  26. Polygon,
  27. PolygonWithColor
  28. };
  29. static void
  30. DrawLightMaps(MLRSorter*);
  31. static void
  32. SetDrawData
  33. (
  34. GOSVertexPool*,
  35. Stuff::Matrix4D*,
  36. MLRClippingState&,
  37. MLRState&
  38. );
  39. static MLRShape*
  40. CreateLightMapShape();
  41. void
  42. SetState(MLRState new_state)
  43. { Check_Object(this); state = new_state; }
  44. MLRState
  45. GetState()
  46. { Check_Object(this); return state; }
  47. inline void
  48. SetPolygonMarker (int type)
  49. { Check_Object(this); Check_Object(stream); *stream << (type ? ((int)((MemoryStreamData)PolygonWithColor)) : ((int)((MemoryStreamData)Polygon)) ); }
  50. inline void
  51. AddColor(Stuff::RGBAColor color)
  52. { Check_Object(this); Check_Object(stream); *stream << color; }
  53. inline void
  54. AddColor(Stuff::Scalar red, Stuff::Scalar green, Stuff::Scalar blue, Stuff::Scalar alpha)
  55. { Check_Object(this); Check_Object(stream); *stream << red << green << blue << alpha; }
  56. inline void
  57. AddCoord(Stuff::Point3D coord)
  58. { Check_Object(this); Check_Object(stream); *stream << coord; }
  59. inline void
  60. AddUVs(Stuff::Scalar u, Stuff::Scalar v)
  61. { Check_Object(this); Check_Object(stream); *stream << u << v; }
  62. inline void
  63. AddInt(int i)
  64. { Check_Object(this); Check_Object(stream); *stream << i; }
  65. inline void
  66. AddUShort(unsigned short i)
  67. { Check_Object(this); Check_Object(stream); *stream << i; }
  68. inline void
  69. AddState(int priority)
  70. {
  71. Check_Object(this);
  72. Check_Object(stream);
  73. *stream << (int)LightMapRenderState;
  74. state.SetPriority(priority);
  75. state.Save(stream);
  76. }
  77. const Vector2DScalar*
  78. GetCurrentUVPointer()
  79. { Check_Object(this); Check_Object(stream); return Cast_Pointer(Vector2DScalar*, stream->GetPointer()); }
  80. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  81. // Class Data Support
  82. //
  83. public:
  84. static ClassData
  85. *DefaultData;
  86. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  87. // Testing
  88. //
  89. public:
  90. void
  91. TestInstance();
  92. protected:
  93. static ClipPolygon2
  94. *clipBuffer;
  95. MLRState
  96. state;
  97. static Stuff::MemoryStream
  98. *stream;
  99. static GOSVertexPool*
  100. vertexPool;
  101. };
  102. }