MLRLight.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. #pragma once
  5. #define MLR_MLRLIGHT_HPP
  6. #include "MLR.hpp"
  7. namespace MidLevelRenderer {
  8. class GOSVertexPool;
  9. class MLRLightMap;
  10. struct MLRVertexData {
  11. Stuff::Point3D *point;
  12. #if COLOR_AS_DWORD
  13. DWORD *color;
  14. #else
  15. Stuff::RGBAColor *color;
  16. #endif
  17. Stuff::Vector3D *normal;
  18. int index;
  19. };
  20. //##########################################################################
  21. //######################### MLRLight #################################
  22. //##########################################################################
  23. class MLRLight:
  24. public Stuff::RegisteredClass
  25. {
  26. public:
  27. static void
  28. InitializeClass();
  29. static void
  30. TerminateClass();
  31. MLRLight(ClassData *class_data);
  32. MLRLight(
  33. ClassData *class_data,
  34. Stuff::MemoryStream *stream,
  35. int version
  36. );
  37. MLRLight(
  38. ClassData *class_data,
  39. Stuff::Page* page
  40. );
  41. ~MLRLight();
  42. static MLRLight*
  43. Make(
  44. Stuff::MemoryStream *stream,
  45. int version
  46. );
  47. static MLRLight*
  48. Make(Stuff::Page *page);
  49. virtual void
  50. Save(Stuff::MemoryStream *stream);
  51. virtual void
  52. Write(Stuff::Page *page);
  53. enum LightType {
  54. AmbientLight = 0,
  55. InfiniteLight,
  56. InfiniteLightWithFallOff,
  57. PointLight,
  58. SpotLight,
  59. LookUpLight
  60. };
  61. virtual LightType
  62. GetLightType() = 0;
  63. virtual void
  64. LightVertex(const MLRVertexData&) = 0;
  65. void SetIntensity (Stuff::Scalar _int)
  66. { Check_Object(this); intensity = _int; };
  67. Stuff::Scalar GetIntensity ()
  68. { Check_Object(this); return intensity; };
  69. void SetColor(Stuff::RGBColor col)
  70. { Check_Object(this); color = col; }
  71. void SetColor(Stuff::Scalar, Stuff::Scalar, Stuff::Scalar);
  72. void GetColor(Stuff::RGBColor& col)
  73. { Check_Object(this); col = color; };
  74. void GetColor(Stuff::Scalar&, Stuff::Scalar&, Stuff::Scalar&);
  75. void GetInWorldPosition(Stuff::Point3D& pos)
  76. { Check_Object(this); pos = lightToWorld; };
  77. void GetInWorldDirection(Stuff::UnitVector3D& dir)
  78. { Check_Object(this); lightToWorld.GetLocalForwardInWorld(&dir); };
  79. void GetInShapePosition(Stuff::Point3D& pos)
  80. { Check_Object(this); pos = lightToShape; };
  81. void GetInShapePosition(Stuff::LinearMatrix4D& pos)
  82. { Check_Object(this); pos = lightToShape; };
  83. void GetInShapeDirection(Stuff::UnitVector3D& dir)
  84. { Check_Object(this); lightToShape.GetLocalForwardInWorld(&dir); };
  85. void SetLightToWorldMatrix(const Stuff::LinearMatrix4D&);
  86. const Stuff::LinearMatrix4D&
  87. GetLightToWorldMatrix()
  88. { Check_Object(this); return lightToWorld; };
  89. virtual
  90. void SetLightToShapeMatrix(const Stuff::LinearMatrix4D&);
  91. const Stuff::LinearMatrix4D&
  92. GetLightToShapeMatrix()
  93. { Check_Object(this); return lightToShape; };
  94. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95. // Light Map Support
  96. //
  97. virtual MLRLightMap *
  98. GetLightMap()
  99. {Check_Object(this); return NULL; }
  100. int
  101. GetLightMask()
  102. {Check_Object(this); return lightMask;}
  103. void
  104. SetDynamicLight()
  105. {Check_Object(this); lightMask |= MLRState::TerrainLightingMode;}
  106. void
  107. SetStaticLight()
  108. {Check_Object(this); lightMask &= ~MLRState::TerrainLightingMode;}
  109. void
  110. SetName(const char *name)
  111. {Check_Object(this); lightName = name;}
  112. const char*
  113. GetName()
  114. {Check_Object(this); return lightName;}
  115. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  116. // Class Data Support
  117. //
  118. public:
  119. static ClassData
  120. *DefaultData;
  121. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  122. // Testing
  123. //
  124. public:
  125. void
  126. TestInstance();
  127. protected:
  128. Stuff::Scalar
  129. intensity;
  130. Stuff::RGBColor
  131. color;
  132. Stuff::LinearMatrix4D
  133. lightToWorld, lightToShape;
  134. int
  135. lightMask;
  136. Stuff::MString
  137. lightName;
  138. };
  139. }