Torque3D Documentation / _generateds / afxXM_BoxConform.cpp

afxXM_BoxConform.cpp

Engine/source/afx/xm/afxXM_BoxConform.cpp

More...

Classes:

Public Enumerations

enum
afxXM_BoxConformType {
  X_POS 
  X_NEG 
  Y_POS 
  Y_NEG 
  Z_POS 
  Z_NEG 
}

Public Variables

Public Functions

ConsoleDocClass(afxXM_BoxConformData , "@brief An xmod <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">datablock.\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxXMods\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(afxXM_BoxConformType , "Possible box conform alignment <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">types.\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxXM_BoxConform\n\n</a>" )

Detailed Description

Public Enumerations

afxXM_BoxConformType

Enumerator

X_POS
X_NEG
Y_POS
Y_NEG
Z_POS
Z_NEG

Public Variables

 EndImplementEnumType 

Public Functions

ConsoleDocClass(afxXM_BoxConformData , "@brief An xmod <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">datablock.\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxXMods\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>" )

DefineEnumType(afxXM_BoxConformType )

IMPLEMENT_CO_DATABLOCK_V1(afxXM_BoxConformData )

ImplementEnumType(afxXM_BoxConformType , "Possible box conform alignment <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">types.\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxXM_BoxConform\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 "afx/afxEffectWrapper.h"
 30#include "afx/xm/afxXfmMod.h"
 31
 32//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 33enum afxXM_BoxConformType
 34{
 35  X_POS, X_NEG, Y_POS, Y_NEG, Z_POS, Z_NEG
 36};
 37DefineEnumType( afxXM_BoxConformType );
 38
 39class afxXM_BoxConformData : public afxXM_BaseData
 40{
 41  typedef afxXM_BaseData Parent;
 42
 43public:
 44  S32           aabb_alignment;
 45
 46public:
 47  /*C*/         afxXM_BoxConformData();
 48  /*C*/         afxXM_BoxConformData(const afxXM_BoxConformData&, bool = false);
 49
 50  void          packData(BitStream* stream);
 51  void          unpackData(BitStream* stream);
 52  static void   initPersistFields();
 53
 54  afxXM_Base*   create(afxEffectWrapper* fx, bool on_server);
 55
 56  DECLARE_CONOBJECT(afxXM_BoxConformData);
 57  DECLARE_CATEGORY("AFX");
 58};
 59
 60class afxXM_BoxConform : public afxXM_Base
 61{
 62  typedef afxXM_Base Parent;
 63
 64  afxXM_BoxConformData*  db;
 65
 66public:
 67  /*C*/         afxXM_BoxConform(afxXM_BoxConformData*, afxEffectWrapper*, bool on_server);
 68
 69  virtual void  updateParams(F32 dt, F32 elapsed, afxXM_Params& params);
 70};
 71
 72//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 73
 74IMPLEMENT_CO_DATABLOCK_V1(afxXM_BoxConformData);
 75
 76ConsoleDocClass( afxXM_BoxConformData,
 77   "@brief An xmod datablock.\n\n"
 78
 79   "@ingroup afxXMods\n"
 80   "@ingroup AFX\n"
 81   "@ingroup Datablocks\n"
 82);
 83
 84afxXM_BoxConformData::afxXM_BoxConformData()
 85{
 86  aabb_alignment = Z_NEG;
 87}
 88
 89afxXM_BoxConformData::afxXM_BoxConformData(const afxXM_BoxConformData& other, bool temp_clone) 
 90  : afxXM_BaseData(other, temp_clone)
 91{
 92  aabb_alignment = other.aabb_alignment;
 93}
 94
 95ImplementEnumType( afxXM_BoxConformType, "Possible box conform alignment types.\n" "@ingroup afxXM_BoxConform\n\n" )
 96   { X_POS, "+x", "..." },
 97   { X_NEG, "-x", "..." },
 98   { Y_POS, "+y", "..." },
 99   { Y_NEG, "-y", "..." },
100   { Z_POS, "+z", "..." },
101   { Z_NEG, "-z", "..." },
102   { X_POS, "x",  "..." },
103   { Y_POS, "y",  "..." },
104   { Z_POS, "z",  "..." },
105EndImplementEnumType;
106
107void afxXM_BoxConformData::initPersistFields()
108{
109  addField("boxAlignment",    TYPEID< afxXM_BoxConformType >(),    Offset(aabb_alignment, afxXM_BoxConformData),
110    "...");
111
112  Parent::initPersistFields();
113}
114
115void afxXM_BoxConformData::packData(BitStream* stream)
116{
117  Parent::packData(stream);
118  stream->write(aabb_alignment);
119}
120
121void afxXM_BoxConformData::unpackData(BitStream* stream)
122{
123  Parent::unpackData(stream);
124  stream->read(&aabb_alignment);
125}
126
127afxXM_Base* afxXM_BoxConformData::create(afxEffectWrapper* fx, bool on_server)
128{
129  return new afxXM_BoxConform(this, fx, on_server);
130}
131
132//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
133
134afxXM_BoxConform::afxXM_BoxConform(afxXM_BoxConformData* db, afxEffectWrapper* fxw, bool on_server) 
135: afxXM_Base(db, fxw) 
136{ 
137  this->db = db;
138}
139
140void afxXM_BoxConform::updateParams(F32 dt, F32 elapsed, afxXM_Params& params)
141{
142  afxConstraint* pos_cons = fx_wrapper->getPosConstraint();
143  if (!pos_cons)
144    return;
145
146  SceneObject* obj = pos_cons->getSceneObject();
147  if (!obj)
148    return;
149
150  const Box3F& box = obj->getWorldBox();
151
152  switch (db->aabb_alignment)
153  {
154  case X_POS:
155    params.pos.x = box.maxExtents.x;
156    break;
157  case X_NEG:
158    params.pos.x = box.minExtents.x;
159    break;
160  case Y_POS:
161    params.pos.y = box.maxExtents.y;
162    break;
163  case Y_NEG:
164    params.pos.y = box.minExtents.y;
165    break;
166  case Z_POS:
167    params.pos.z = box.maxExtents.z;
168    break;
169  case Z_NEG:
170    params.pos.z = box.minExtents.z;
171    break;
172  }
173}
174
175//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
176
177