Torque3D Documentation / _generateds / afxZodiacMgr.cpp

afxZodiacMgr.cpp

Engine/source/afx/ce/afxZodiacMgr.cpp

More...

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#include "afx/arcaneFX.h"
 28
 29#include "terrain/terrRender.h"
 30
 31#include "afx/ce/afxZodiac.h"
 32#include "afx/ce/afxZodiacMgr.h"
 33
 34//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 35// afxZodiacMgr
 36
 37Vector<afxZodiacMgr::ZodiacSpec>  afxZodiacMgr::terr_zodes;
 38Vector<afxZodiacMgr::ZodiacSpec>  afxZodiacMgr::inter_zodes;
 39
 40afxZodiacMgr::ZodiacTriangle*   afxZodiacMgr::zode_tris_head = NULL;
 41afxZodiacMgr::ZodiacTriangle*   afxZodiacMgr::zode_tris_tail = NULL;
 42afxZodiacMgr::ZodiacTriangle*   afxZodiacMgr::zode_tris = NULL;
 43U32                             afxZodiacMgr::zode_tris_idx = 0;
 44U32                             afxZodiacMgr::n_zode_tris = 0;
 45
 46afxZodiacMgr::ZodiacSpec*       afxZodiacMgr::live_zodiac = 0;
 47ShaderData*                     afxZodiacMgr::terrain_zode_shader = 0;
 48ShaderData*                     afxZodiacMgr::atlas_zode_shader = 0;
 49ShaderData*                     afxZodiacMgr::interior_zode_shader = 0;
 50ShaderData*                     afxZodiacMgr::polysoup_zode_shader = 0;
 51
 52void afxZodiacMgr::addTerrainZodiac(Point3F& pos, F32 radius, LinearColorF& color, F32 angle, afxZodiacData* zode)
 53{
 54  if (radius < 0.001f)
 55    return;
 56
 57  ZodiacSpec z;
 58  z.pos = pos;
 59  z.radius_xy = radius;
 60  z.vert_range.set(0.0f, 0.0f);
 61  z.grade_range.set(0.0f, 1.0f);
 62  z.color = color.toColorI();
 63  z.angle = mDegToRad(angle);
 64  z.zflags = zode->zflags;
 65  z.txr = &zode->txr;
 66
 67  z.distance_max = zode->distance_max*zode->distance_max;
 68  z.distance_falloff = zode->distance_falloff*zode->distance_falloff;
 69  z.distance_delta = z.distance_max - z.distance_falloff;
 70
 71  if (terr_zodes.size() < MAX_ZODIACS)
 72    terr_zodes.push_back(z);
 73}
 74
 75void afxZodiacMgr::addInteriorZodiac(Point3F& pos, F32 radius, Point2F& vert_range, LinearColorF& color, F32 angle, afxZodiacData* zode)
 76{
 77  if (radius < 0.001f)
 78    return;
 79
 80  ZodiacSpec z;
 81  z.pos = pos;
 82  z.radius_xy = radius;
 83  z.vert_range = vert_range;
 84  z.grade_range = zode->grade_range;
 85  z.color = color.toColorI();
 86  z.angle = mDegToRad(angle);
 87  z.zflags = zode->zflags;
 88  z.txr = &zode->txr;
 89
 90  z.distance_max = zode->distance_max*zode->distance_max;
 91  z.distance_falloff = zode->distance_falloff*zode->distance_falloff;
 92  z.distance_delta = z.distance_max - z.distance_falloff;
 93
 94  if (inter_zodes.size() < MAX_ZODIACS)
 95    inter_zodes.push_back(z);
 96}
 97
 98void afxZodiacMgr::frameReset()
 99{
100  terr_zodes.clear();
101  inter_zodes.clear();
102}
103
104void afxZodiacMgr::missionCleanup()
105{
106  terrain_zode_shader = 0;
107  atlas_zode_shader = 0;
108  interior_zode_shader = 0;
109  polysoup_zode_shader = 0;
110}
111
112// REGULAR TERRAIN ZODIACS //
113
114void afxZodiacMgr::transformTerrainZodiacs(const MatrixF& world_xfm)
115{
116  VectorF facing_vec;
117  world_xfm.getColumn(1, &facing_vec);
118  F32 yaw = mAtan2(facing_vec.x, facing_vec.y);
119  while (yaw < 0.0) yaw += M_2PI_F;
120
121  for (S32 i = 0; i < terr_zodes.size(); i++)
122  {
123    world_xfm.mulP(terr_zodes[i].pos, &terr_zodes[i].loc_pos);
124    F32 ang = terr_zodes[i].angle + yaw;
125    terr_zodes[i].loc_cos_ang = mCos(ang);
126    terr_zodes[i].loc_sin_ang = mSin(ang);
127  }
128
129  zode_tris_head = zode_tris_tail = NULL;
130}
131
132//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
133