Torque3D Documentation / _generateds / afxStaticShape.cpp

afxStaticShape.cpp

Engine/source/afx/ce/afxStaticShape.cpp

More...

Public Defines

define
myOffset(field) (field, )

Public Functions

ConsoleDocClass(afxStaticShape , "@brief A <a href="/coding/class/classstaticshape/">StaticShape</a> effect as defined by an <a href="/coding/class/classafxstaticshapedata/">afxStaticShapeData</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(afxStaticShapeData , "@brief A datablock that specifies <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/classstaticshape/">StaticShape</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">effect.\n\n</a>" "<a href="/coding/class/classafxstaticshapedata/">afxStaticShapeData</a> inherits from <a href="/coding/class/structstaticshapedata/">StaticShapeData</a> and adds some AFX specific fields. <a href="/coding/class/classstaticshape/">StaticShape</a> effects should be " "specified using <a href="/coding/class/classafxstaticshapedata/">afxStaticShapeData</a> rather than <a href="/coding/class/structstaticshapedata/">StaticShapeData</a> datablocks." "\<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>" )

Detailed Description

Public Defines

myOffset(field) (field, )

Public Functions

ConsoleDocClass(afxStaticShape , "@brief A <a href="/coding/class/classstaticshape/">StaticShape</a> effect as defined by an <a href="/coding/class/classafxstaticshapedata/">afxStaticShapeData</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(afxStaticShapeData , "@brief A datablock that specifies <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/classstaticshape/">StaticShape</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">effect.\n\n</a>" "<a href="/coding/class/classafxstaticshapedata/">afxStaticShapeData</a> inherits from <a href="/coding/class/structstaticshapedata/">StaticShapeData</a> and adds some AFX specific fields. <a href="/coding/class/classstaticshape/">StaticShape</a> effects should be " "specified using <a href="/coding/class/classafxstaticshapedata/">afxStaticShapeData</a> rather than <a href="/coding/class/structstaticshapedata/">StaticShapeData</a> datablocks." "\<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(afxStaticShapeData )

IMPLEMENT_CO_NETOBJECT_V1(afxStaticShape )

  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 "ts/tsShapeInstance.h"
 30
 31#include "afx/afxChoreographer.h"
 32#include "afx/ce/afxStaticShape.h"
 33
 34//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 35//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 36// afxStaticShapeData
 37
 38IMPLEMENT_CO_DATABLOCK_V1(afxStaticShapeData);
 39
 40ConsoleDocClass( afxStaticShapeData,
 41   "@brief A datablock that specifies a StaticShape effect.\n\n"
 42
 43   "afxStaticShapeData inherits from StaticShapeData and adds some AFX specific fields. StaticShape effects should be "
 44   "specified using afxStaticShapeData rather than StaticShapeData datablocks."
 45   "\n\n"
 46
 47   "@ingroup afxEffects\n"
 48   "@ingroup AFX\n"
 49   "@ingroup Datablocks\n"
 50);
 51
 52afxStaticShapeData::afxStaticShapeData()
 53{
 54  sequence = ST_NULLSTRING;
 55  ignore_scene_amb = false; 
 56  use_custom_scene_amb = false;
 57  custom_scene_amb.set(0.5f, 0.5f, 0.5f);
 58  do_spawn = false;
 59}
 60
 61afxStaticShapeData::afxStaticShapeData(const afxStaticShapeData& other, bool temp_clone) : StaticShapeData(other, temp_clone)
 62{
 63  sequence = other.sequence;
 64  ignore_scene_amb = other.ignore_scene_amb;
 65  use_custom_scene_amb = other.use_custom_scene_amb;
 66  custom_scene_amb = other.custom_scene_amb;
 67  do_spawn = other.do_spawn;
 68}
 69
 70#define myOffset(field) Offset(field, afxStaticShapeData)
 71
 72void afxStaticShapeData::initPersistFields()
 73{
 74  addField("sequence",              TypeFilename, myOffset(sequence),
 75    "An animation sequence in the StaticShape to play.");
 76  addField("ignoreSceneAmbient",    TypeBool,     myOffset(ignore_scene_amb),
 77    "...");
 78  addField("useCustomSceneAmbient", TypeBool,     myOffset(use_custom_scene_amb),
 79    "...");
 80  addField("customSceneAmbient",    TypeColorF,   myOffset(custom_scene_amb),
 81    "...");
 82  addField("doSpawn",               TypeBool,     myOffset(do_spawn),
 83    "When true, the StaticShape effect will leave behind the StaticShape object as a "
 84    "permanent part of the scene.");
 85
 86  Parent::initPersistFields();
 87}
 88
 89void afxStaticShapeData::packData(BitStream* stream)
 90{
 91  Parent::packData(stream);
 92
 93  stream->writeString(sequence);
 94  stream->writeFlag(ignore_scene_amb);
 95  if (stream->writeFlag(use_custom_scene_amb))
 96    stream->write(custom_scene_amb);
 97  stream->writeFlag(do_spawn);
 98}
 99
100void afxStaticShapeData::unpackData(BitStream* stream)
101{
102  Parent::unpackData(stream);
103
104  sequence = stream->readSTString();
105  ignore_scene_amb = stream->readFlag();
106  if ((use_custom_scene_amb = stream->readFlag()) == true)
107    stream->read(&custom_scene_amb);
108  do_spawn = stream->readFlag();
109}
110
111//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
112//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
113// afxStaticShape
114
115IMPLEMENT_CO_NETOBJECT_V1(afxStaticShape);
116
117ConsoleDocClass( afxStaticShape,
118   "@brief A StaticShape effect as defined by an afxStaticShapeData datablock.\n\n"
119
120   "@ingroup afxEffects\n"
121   "@ingroup AFX\n"
122);
123
124afxStaticShape::afxStaticShape()
125{
126  mDataBlock = NULL;
127  mAFX_data = 0;
128  mIs_visible = true;
129  mChor_id = 0;
130  mHookup_with_chor = false;
131  mGhost_cons_name = ST_NULLSTRING;
132}
133
134afxStaticShape::~afxStaticShape()
135{
136}
137
138void afxStaticShape::init(U32 chor_id, StringTableEntry cons_name)
139{
140  mChor_id = chor_id;
141  mGhost_cons_name = cons_name;
142}
143
144//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
145
146bool afxStaticShape::onNewDataBlock(GameBaseData* dptr, bool reload)
147{
148  mDataBlock = dynamic_cast<StaticShapeData*>(dptr);
149  if (!mDataBlock || !Parent::onNewDataBlock(dptr, reload))
150    return false;
151
152  mAFX_data = dynamic_cast<afxStaticShapeData*>(mDataBlock);
153
154  if (!mShapeInstance)
155    return true;
156
157  const char* seq_name = 0;
158
159  // if datablock is afxStaticShapeData we get the sequence setting 
160  // directly from the datablock on the client-side only
161  if (mAFX_data)
162  {
163    if (isClientObject())
164      seq_name = mAFX_data->sequence;
165  }
166  // otherwise datablock is stock StaticShapeData and we look for
167  // a sequence name on a dynamic field on the server.
168  else
169  {
170    if (isServerObject())
171      seq_name = mDataBlock->getDataField(StringTable->insert("sequence"),0);
172  } 
173
174  // if we have a sequence name, attempt to start a thread
175  if (seq_name)
176  {
177    TSShape* shape = mShapeInstance->getShape();
178    if (shape) 
179    {
180      S32 seq = shape->findSequence(seq_name);
181      if (seq != -1)
182        setThreadSequence(0,seq);
183    }
184  }
185
186  return true;
187}
188
189void afxStaticShape::advanceTime(F32 dt)
190{
191  Parent::advanceTime(dt);
192
193  if (mHookup_with_chor)
194  {
195    afxChoreographer* chor = arcaneFX::findClientChoreographer(mChor_id);
196    if (chor)
197    {
198      chor->setGhostConstraintObject(this, mGhost_cons_name);
199     mHookup_with_chor = false;
200    }
201  }
202}
203
204U32 afxStaticShape::packUpdate(NetConnection* conn, U32 mask, BitStream* stream)
205{
206  U32 retMask = Parent::packUpdate(conn, mask, stream);
207
208  // InitialUpdate
209  if (stream->writeFlag(mask & InitialUpdateMask)) 
210  {
211    stream->write(mChor_id);
212    stream->writeString(mGhost_cons_name);
213  }
214
215  return retMask;
216}
217
218//~~~~~~~~~~~~~~~~~~~~//
219
220void afxStaticShape::unpackUpdate(NetConnection * conn, BitStream * stream)
221{
222  Parent::unpackUpdate(conn, stream);
223  
224  // InitialUpdate
225  if (stream->readFlag())
226  {
227    stream->read(&mChor_id);
228   mGhost_cons_name = stream->readSTString();
229
230    if (mChor_id != 0 && mGhost_cons_name != ST_NULLSTRING)
231      mHookup_with_chor = true;
232  }
233}
234
235//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
236
237void afxStaticShape::prepRenderImage(SceneRenderState* state)
238{
239  if (mIs_visible) 
240     Parent::prepRenderImage(state);
241}
242
243//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
244