Torque3D Documentation / _generateds / afxZodiacPlane.cpp

afxZodiacPlane.cpp

Engine/source/afx/ce/afxZodiacPlane.cpp

More...

Public Defines

define
myOffset(field) (field, )

Public Variables

Public Functions

ConsoleDocClass(afxZodiacPlane , "@brief A ZodiacPlane effect as defined by an <a href="/coding/class/classafxzodiacplanedata/">afxZodiacPlaneData</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">datablock.\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxEffects\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">AFX\n</a>" )
ConsoleDocClass(afxZodiacPlaneData , "@brief A datablock that specifies <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Zodiac Plane <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">effect.\n\n</a>" "<a href="/coding/class/classafxzodiacdata/">afxZodiacData</a> describes <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> zodiac-like effect called <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> zodiac plane. It reproduces most of the behavior of normal zodiacs " "but unlike zodiac decals, it is represented as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> flat plane of geometry that can be more flexibly positioned and oriented." "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxEffects\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">AFX\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Datablocks\n</a>" )
ImplementEnumType(afxZodiacPlane_BlendType , "Possible zodiac blend <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">types.\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxZodiacPlane\n\n</a>" )
ImplementEnumType(afxZodiacPlane_FacingType , "Possible zodiac plane facing <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">types.\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxZodiacPlane\n\n</a>" )

Detailed Description

Public Defines

myOffset(field) (field, )

Public Variables

 EndImplementEnumType 

Public Functions

ConsoleDocClass(afxZodiacPlane , "@brief A ZodiacPlane effect as defined by an <a href="/coding/class/classafxzodiacplanedata/">afxZodiacPlaneData</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">datablock.\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxEffects\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">AFX\n</a>" )

ConsoleDocClass(afxZodiacPlaneData , "@brief A datablock that specifies <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Zodiac Plane <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">effect.\n\n</a>" "<a href="/coding/class/classafxzodiacdata/">afxZodiacData</a> describes <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> zodiac-like effect called <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> zodiac plane. It reproduces most of the behavior of normal zodiacs " "but unlike zodiac decals, it is represented as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> flat plane of geometry that can be more flexibly positioned and oriented." "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxEffects\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">AFX\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Datablocks\n</a>" )

IMPLEMENT_CO_DATABLOCK_V1(afxZodiacPlaneData )

IMPLEMENT_CO_NETOBJECT_V1(afxZodiacPlane )

ImplementEnumType(afxZodiacPlane_BlendType , "Possible zodiac blend <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">types.\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxZodiacPlane\n\n</a>" )

ImplementEnumType(afxZodiacPlane_FacingType , "Possible zodiac plane facing <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">types.\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxZodiacPlane\n\n</a>" )

  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 "math/mathIO.h"
 30#include "renderInstance/renderPassManager.h"
 31
 32#include "afx/afxChoreographer.h"
 33#include "afx/ce/afxZodiac.h"
 34#include "afx/ce/afxZodiacPlane.h"
 35
 36//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 37// afxZodiacPlaneData
 38
 39IMPLEMENT_CO_DATABLOCK_V1(afxZodiacPlaneData);
 40
 41ConsoleDocClass( afxZodiacPlaneData,
 42   "@brief A datablock that specifies a Zodiac Plane effect.\n\n"
 43
 44   "afxZodiacData describes a zodiac-like effect called a zodiac plane. It reproduces most of the behavior of normal zodiacs "
 45   "but unlike zodiac decals, it is represented as a flat plane of geometry that can be more flexibly positioned and oriented."
 46   "\n\n"
 47
 48   "@ingroup afxEffects\n"
 49   "@ingroup AFX\n"
 50   "@ingroup Datablocks\n"
 51);
 52
 53afxZodiacPlaneData::afxZodiacPlaneData()
 54{
 55  txr_name = ST_NULLSTRING;
 56  radius_xy = 1;
 57  start_ang = 0;
 58  ang_per_sec = 0;
 59  grow_in_time = 0.0f; 
 60  shrink_out_time = 0.0f;
 61  growth_rate = 0.0f;
 62  color.set(1,1,1,1);
 63  blend_flags = BLEND_NORMAL;
 64  respect_ori_cons = false;
 65  zflags = 0;
 66  double_sided = true;
 67  face_dir = FACES_UP;
 68  use_full_xfm = false;
 69}
 70
 71afxZodiacPlaneData::afxZodiacPlaneData(const afxZodiacPlaneData& other, bool temp_clone)
 72  : GameBaseData(other, temp_clone)
 73{
 74  txr_name = other.txr_name;
 75  txr = other.txr;
 76  radius_xy = other.radius_xy;
 77  start_ang = other.start_ang;
 78  ang_per_sec = other.ang_per_sec;
 79  grow_in_time = other.grow_in_time;
 80  shrink_out_time = other.shrink_out_time;
 81  growth_rate = other.growth_rate;
 82  color = other.color;
 83
 84  double_sided = other.double_sided;
 85  face_dir = other.face_dir;
 86  use_full_xfm = other.use_full_xfm;
 87
 88  zflags = other.zflags;
 89  expand_zflags();
 90}
 91
 92ImplementEnumType( afxZodiacPlane_BlendType, "Possible zodiac blend types.\n" "@ingroup afxZodiacPlane\n\n" )
 93   { afxZodiacData::BLEND_NORMAL,      "normal",         "..." },
 94   { afxZodiacData::BLEND_ADDITIVE,    "additive",       "..." },
 95   { afxZodiacData::BLEND_SUBTRACTIVE, "subtractive",    "..." },
 96EndImplementEnumType;
 97
 98ImplementEnumType( afxZodiacPlane_FacingType, "Possible zodiac plane facing types.\n" "@ingroup afxZodiacPlane\n\n" )
 99  { afxZodiacPlaneData::FACES_UP,        "up",        "..." },
100  { afxZodiacPlaneData::FACES_DOWN,      "down",      "..." },
101  { afxZodiacPlaneData::FACES_FORWARD,   "forward",   "..." },
102  { afxZodiacPlaneData::FACES_BACK,      "backward",  "..." },
103  { afxZodiacPlaneData::FACES_RIGHT,     "right",     "..." },
104  { afxZodiacPlaneData::FACES_LEFT,      "left",      "..." },
105
106  { afxZodiacPlaneData::FACES_FORWARD,   "front",     "..." },
107  { afxZodiacPlaneData::FACES_BACK,      "back",      "..." },
108EndImplementEnumType;
109
110#define myOffset(field) Offset(field, afxZodiacPlaneData)
111
112void afxZodiacPlaneData::initPersistFields()
113{
114  addField("texture",         TypeFilename,   myOffset(txr_name),
115    "An image to use as the zodiac's texture.");
116  addField("radius",          TypeF32,        myOffset(radius_xy),
117    "The zodiac's radius in scene units.");
118  addField("startAngle",      TypeF32,        myOffset(start_ang),
119    "The starting angle in degrees of the zodiac's rotation.");
120  addField("rotationRate",    TypeF32,        myOffset(ang_per_sec),
121    "The rate of rotation in degrees-per-second. Zodiacs with a positive rotationRate "
122    "rotate clockwise, while those with negative values turn counter-clockwise.");
123  addField("growInTime",      TypeF32,        myOffset(grow_in_time),
124    "A duration of time in seconds over which the zodiac grows from a zero size to its "
125    "full size as specified by the radius.");
126  addField("shrinkOutTime",   TypeF32,        myOffset(shrink_out_time),
127    "A duration of time in seconds over which the zodiac shrinks from full size to "
128    "invisible.");
129  addField("growthRate",      TypeF32,        myOffset(growth_rate),
130    "A rate in meters-per-second at which the zodiac grows in size. A negative value will "
131    "shrink the zodiac.");
132  addField("color",           TypeColorF,     myOffset(color),
133    "A color value for the zodiac.");
134
135  addField("blend", TYPEID<BlendType>(), myOffset(blend_flags),
136    "A blending style for the zodiac. Possible values: normal, additive, or subtractive.");
137
138  addField("trackOrientConstraint", TypeBool,  myOffset(respect_ori_cons),
139    "Specifies if the zodiac's rotation should be defined by its constrained "
140    "transformation.");
141
142  addField("doubleSided",     TypeBool,       myOffset(double_sided),
143    "Controls whether the zodiac-plane's polygons are rendered when viewed from either "
144    "side. If set to false, the zodiac-plane will only be seen when viewed from the "
145    "direction it is facing (according to faceDir).");
146
147  addField("faceDir", TYPEID<afxZodiacPlaneData::FacingType>(), myOffset(face_dir),
148    "Specifies which direction the zodiac-plane's polygons face. Possible values: "
149    "up, down, front, back, right, or left.");
150
151  addField("useFullTransform",      TypeBool,  myOffset(use_full_xfm),
152    "Normal zodiacs have only one degree of freedom, a rotation around the z-axis. "
153    "Depending on the setting for trackOrientConstraint, this means that the effect's "
154    "orientation is either ignored or is limited to influencing the zodiac's angle of "
155    "rotation. By default, zodiac-plane reproduces this limited behavior in order to "
156    "match normal zodiacs. When useFullTransform is set to true, the zodiac can be "
157    "arbitrarily oriented.");
158
159  Parent::initPersistFields();
160}
161
162void afxZodiacPlaneData::packData(BitStream* stream)
163{
164   Parent::packData(stream);
165
166  merge_zflags();
167
168  stream->writeString(txr_name);
169  stream->write(radius_xy);
170  stream->write(start_ang);
171  stream->write(ang_per_sec);
172  stream->write(grow_in_time);
173  stream->write(shrink_out_time);
174  stream->write(growth_rate);
175  stream->write(color);
176  stream->write(zflags);
177  stream->write(double_sided);
178  stream->writeFlag(use_full_xfm);
179  stream->writeInt(face_dir, FACES_BITS);
180}
181
182void afxZodiacPlaneData::unpackData(BitStream* stream)
183{
184  Parent::unpackData(stream);
185
186  txr_name = stream->readSTString();
187  txr = GFXTexHandle();
188  stream->read(&radius_xy);
189  stream->read(&start_ang);
190  stream->read(&ang_per_sec);
191  stream->read(&grow_in_time);
192  stream->read(&shrink_out_time);
193  stream->read(&growth_rate);
194  stream->read(&color);
195  stream->read(&zflags);
196  stream->read(&double_sided);
197  use_full_xfm = stream->readFlag();
198  face_dir = stream->readInt(FACES_BITS);
199
200  expand_zflags();
201}
202
203bool afxZodiacPlaneData::preload(bool server, String &errorStr)
204{
205  if (!Parent::preload(server, errorStr))
206    return false;
207
208  if (!server)
209  {
210    if (txr_name && txr_name[0] != '\0')
211    {
212      txr.set(txr_name, &AFX_GFXZodiacTextureProfile, "Zodiac Texture");
213    }
214  }
215
216  return true;
217}
218
219F32 afxZodiacPlaneData::calcRotationAngle(F32 elapsed, F32 rate_factor)
220{
221  F32 angle = start_ang + elapsed*ang_per_sec*rate_factor;
222  angle = mFmod(angle, 360.0f);
223
224  return angle;
225}
226
227void afxZodiacPlaneData::expand_zflags()
228{
229  blend_flags = (zflags & BLEND_MASK);
230  respect_ori_cons = ((zflags & RESPECT_ORIENTATION) != 0);
231}
232
233void afxZodiacPlaneData::merge_zflags()
234{
235  zflags = (blend_flags & BLEND_MASK);
236  if (respect_ori_cons)
237    zflags |= RESPECT_ORIENTATION;
238}
239
240//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
241//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
242// afxZodiacPlane
243
244IMPLEMENT_CO_NETOBJECT_V1(afxZodiacPlane);
245
246ConsoleDocClass( afxZodiacPlane,
247   "@brief A ZodiacPlane effect as defined by an afxZodiacPlaneData datablock.\n\n"
248
249   "@ingroup afxEffects\n"
250   "@ingroup AFX\n"
251);
252
253afxZodiacPlane::afxZodiacPlane()
254{
255  mNetFlags.clear();
256  mNetFlags.set(IsGhost);
257
258  mDataBlock = 0;
259  color.set(1,1,1,1);
260  radius = 1;
261  is_visible = true;
262}
263
264afxZodiacPlane::~afxZodiacPlane()
265{
266}
267
268//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
269
270bool afxZodiacPlane::onNewDataBlock(GameBaseData* dptr, bool reload)
271{
272  mDataBlock = dynamic_cast<afxZodiacPlaneData*>(dptr);
273  if (!mDataBlock || !Parent::onNewDataBlock(dptr, reload))
274    return false;
275
276  return true;
277}
278
279bool afxZodiacPlane::onAdd()
280{
281  if(!Parent::onAdd())
282    return false;
283  
284  F32 len = mDataBlock->radius_xy;
285
286  switch (mDataBlock->face_dir)
287  {
288  case afxZodiacPlaneData::FACES_UP:
289  case afxZodiacPlaneData::FACES_DOWN:
290    mObjBox = Box3F(Point3F(-len, -len, -0.01f), Point3F(len, len, 0.01f));
291    break;  
292  case afxZodiacPlaneData::FACES_FORWARD:
293  case afxZodiacPlaneData::FACES_BACK:
294    mObjBox = Box3F(Point3F(-len, -0.01f, -len), Point3F(len, 0.01f, len));
295    break;  
296  case afxZodiacPlaneData::FACES_RIGHT:
297  case afxZodiacPlaneData::FACES_LEFT:
298    mObjBox = Box3F(Point3F(-0.01f, -len, -len), Point3F(0.01f, len, len));
299    break;  
300  }
301
302  addToScene();
303  
304  return true;
305}
306
307void afxZodiacPlane::onRemove()
308{
309  removeFromScene();
310  
311  Parent::onRemove();
312}
313
314//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
315