MLREffect.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. #pragma once
  5. #define MLR_MLREFFECT_HPP
  6. #if !defined(MLR_MLR_HPP)
  7. #include <MLR\MLR.hpp>
  8. #endif
  9. namespace MidLevelRenderer {
  10. struct EffectClipPolygon
  11. {
  12. void Init();
  13. void Destroy();
  14. Stuff::DynamicArrayOf<Stuff::Vector4D> coords; //[Max_Number_Vertices_Per_Polygon];
  15. Stuff::DynamicArrayOf<Stuff::RGBAColor> colors; //[Max_Number_Vertices_Per_Polygon];
  16. Stuff::DynamicArrayOf<Vector2DScalar> texCoords; //[Max_Number_Vertices_Per_Polygon];
  17. Stuff::DynamicArrayOf<MLRClippingState> clipPerVertex; //[Max_Number_Vertices_Per_Polygon];
  18. };
  19. class DrawEffectInformation;
  20. //##########################################################################
  21. //######################### MLREffect #################################
  22. //##########################################################################
  23. class MLREffect :
  24. public Stuff::RegisteredClass
  25. {
  26. public:
  27. static void
  28. InitializeClass();
  29. static void
  30. TerminateClass();
  31. MLREffect(int, ClassData *class_data);
  32. ~MLREffect();
  33. virtual void
  34. SetData(
  35. const int *count,
  36. const Stuff::Point3D *point_data,
  37. const Stuff::RGBAColor *color_data
  38. ) = 0;
  39. virtual int
  40. GetType(int) { return 0; }
  41. // add another effect
  42. virtual void Draw (DrawEffectInformation*, GOSVertexPool*, MLRSorter*) = 0;
  43. virtual void Transform(int, int);
  44. // switches single/all effects on or off
  45. void
  46. TurnAllOn();
  47. void
  48. TurnAllOff();
  49. void
  50. TurnOn(int nr)
  51. { Check_Object(this); Verify(nr<maxNrOf); testList[nr] |= 2; }
  52. void
  53. TurnOff(int nr)
  54. { Check_Object(this); Verify(nr<maxNrOf); testList[nr] &= ~2; }
  55. bool IsOn(int nr)
  56. { Check_Object(this); Verify(nr<maxNrOf); return (testList[nr] & 2)? true : false; }
  57. virtual int Clip(MLRClippingState, GOSVertexPool*) = 0;
  58. void
  59. SetEffectToClipMatrix(
  60. const Stuff::LinearMatrix4D *effectToWorld,
  61. const Stuff::Matrix4D *worldToClipMatrix
  62. )
  63. {
  64. Check_Object(this);
  65. effectToClipMatrix.Multiply(*effectToWorld, *worldToClipMatrix);
  66. }
  67. GOSVertex*
  68. GetGOSVertices()
  69. { Check_Object(this); return gos_vertices; }
  70. int
  71. GetNumGOSVertices()
  72. { Check_Object(this); return numGOSVertices; }
  73. int
  74. GetSortDataMode()
  75. { Check_Object(this); return drawMode; }
  76. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. // Class Data Support
  78. //
  79. public:
  80. static ClassData
  81. *DefaultData;
  82. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  83. // Testing
  84. //
  85. public:
  86. void
  87. TestInstance() const
  88. {};
  89. protected:
  90. static EffectClipPolygon *clipBuffer;
  91. void
  92. TurnAllVisible();
  93. void
  94. TurnAllInVisible();
  95. void
  96. TurnVisible(int nr)
  97. { Check_Object(this); Verify(nr<maxNrOf); testList[nr] |= 1; }
  98. void
  99. TurnInVisible(int nr)
  100. { Check_Object(this); Verify(nr<maxNrOf); testList[nr] &= ~1; }
  101. int visible;
  102. int maxNrOf;
  103. const Stuff::Point3D *points;
  104. const Stuff::RGBAColor *colors;
  105. static Stuff::DynamicArrayOf<Stuff::Vector4D> *transformedCoords;
  106. Stuff::DynamicArrayOf<int> testList;
  107. int drawMode;
  108. Stuff::LinearMatrix4D
  109. worldToEffect;
  110. Stuff::Matrix4D
  111. effectToClipMatrix;
  112. GOSVertex *gos_vertices;
  113. int numGOSVertices;
  114. };
  115. struct EffectClipData
  116. {
  117. Stuff::Vector4D *coords;
  118. Stuff::RGBAColor *colors;
  119. Vector2DScalar *texCoords;
  120. MLRClippingState *clipPerVertex;
  121. int flags;
  122. int length;
  123. };
  124. }