afxZodiacMgr.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //
  23. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  24. #ifndef _AFX_ZODIAC_MGR_H_
  25. #define _AFX_ZODIAC_MGR_H_
  26. #ifndef _ARCANE_FX_H_
  27. #include "afx/arcaneFX.h"
  28. #endif
  29. #ifndef _AFX_ZODIAC_DEFS_H_
  30. #include "afx/ce/afxZodiacDefs.h"
  31. #endif
  32. #ifndef _AFX_ZODIAC_H_
  33. #include "afx/ce/afxZodiac.h"
  34. #endif
  35. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  36. struct GridSquare;
  37. class ShaderData;
  38. class TSStatic;
  39. class GroundPlane;
  40. class MeshRoad;
  41. class TerrainBlock;
  42. class TerrCell;
  43. class afxZodiacMgr : public afxZodiacDefs
  44. {
  45. friend class afxZodiacTerrainRenderer;
  46. friend class afxZodiacPolysoupRenderer;
  47. friend class afxZodiacGroundPlaneRenderer;
  48. friend class afxZodiacMeshRoadRenderer;
  49. friend struct TerrainRender;
  50. private:
  51. struct ZodiacSpec
  52. {
  53. Point3F pos; //12// world position
  54. F32 radius_xy; // 4// radius of zodiac
  55. Point2F vert_range; // 8// vertical range
  56. Point2F grade_range; // 8// plane gradient range
  57. ColorI color; // 4// color of zodiac
  58. F32 angle; // 4// angle in radians
  59. U32 zflags; // 4// 0=normal,1=additive,2=subtractive
  60. GFXTexHandle txr; // 4// zodiac texture
  61. F32 distance_max;
  62. F32 distance_falloff;
  63. F32 distance_delta;
  64. Point3F loc_pos; //12// transformed to local position
  65. F32 loc_cos_ang; // 4// cosine of local rotation angle
  66. F32 loc_sin_ang; // 4// sine of local rotation angle
  67. F32 calcDistanceFadeBias(F32 camDist) const
  68. {
  69. if (camDist < distance_falloff)
  70. return 1.0f;
  71. if (camDist < distance_max)
  72. return (1.0f - (camDist - distance_falloff)/distance_delta);
  73. return 0.0f;
  74. }
  75. };
  76. struct ZodiacTriangle
  77. {
  78. ColorI color;
  79. Point2F texco1;
  80. Point3F point1;
  81. Point2F texco2;
  82. Point3F point2;
  83. Point2F texco3;
  84. Point3F point3;
  85. U32 zflags; // 0=normal,1=additive,2=subtractive
  86. GFXTexHandle* txr;
  87. ZodiacTriangle* next;
  88. };
  89. static Vector<ZodiacSpec> terr_zodes;
  90. static Vector<ZodiacSpec> inter_zodes;
  91. static ZodiacTriangle* zode_tris_head;
  92. static ZodiacTriangle* zode_tris_tail;
  93. static ZodiacTriangle* zode_tris;
  94. static U32 zode_tris_idx;
  95. static U32 n_zode_tris;
  96. public:
  97. static ZodiacSpec* live_zodiac;
  98. private:
  99. static ShaderData* terrain_zode_shader;
  100. static ShaderData* atlas_zode_shader;
  101. static ShaderData* interior_zode_shader;
  102. static ShaderData* polysoup_zode_shader;
  103. public:
  104. static void addTerrainZodiac(Point3F& pos, F32 rad, LinearColorF&, F32 ang, afxZodiacData*);
  105. static void addInteriorZodiac(Point3F& pos, F32 rad, Point2F& vrange, LinearColorF&, F32 ang, afxZodiacData*);
  106. static void frameReset();
  107. static void missionCleanup();
  108. static S32 numTerrainZodiacs() { return terr_zodes.size(); }
  109. static S32 numInteriorZodiacs() { return inter_zodes.size(); }
  110. static void transformTerrainZodiacs(const MatrixF& world_xfm);
  111. static void testTerrainOverlap(GridSquare*, S32 level, Point2I sq_pos, afxZodiacBitmask&);
  112. static bool doesBoxOverlapZodiac(const Box3F& box, const ZodiacSpec& zode);
  113. static bool doesBlockContainZodiacs(SceneRenderState*, TerrainBlock* block_);
  114. static bool renderTerrainZodiacs(SceneRenderState*, TerrainBlock*, TerrCell*);
  115. static ShaderData* getTerrainZodiacShader();
  116. static void renderPolysoupZodiacs(SceneRenderState*, TSStatic*);
  117. static ShaderData* getPolysoupZodiacShader();
  118. static void renderGroundPlaneZodiacs(SceneRenderState*, GroundPlane*);
  119. static ShaderData* getGroundPlaneZodiacShader();
  120. static void renderMeshRoadZodiacs(SceneRenderState*, MeshRoad*);
  121. static ShaderData* getMeshRoadZodiacShader();
  122. };
  123. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  124. #endif // _AFX_ZODIAC_MGR_H_