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