arcaneFX.h

Engine/source/afx/arcaneFX.h

More...

Classes:

Public Defines

define
define
define

Detailed Description

Public Defines

AFX_VERSION() 2.0
AFX_VERSION_STRING() "2.0"
ST_NULLSTRING() ()

Public Functions

DefineConsoleType(TypeByteRange , ByteRange )

DefineConsoleType(TypeByteRange2 , ByteRange )

readDatablockID(BitStream * s)

registerForCleanup(SimObject * obj)

writeDatablockID(BitStream * s, SimObject * simobj, bool packed)

  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 _ARCANE_FX_H_
 28#define _ARCANE_FX_H_
 29
 30//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 31
 32#ifndef _PLATFORM_H_
 33#include "platform/platform.h"
 34#endif
 35
 36#define AFX_VERSION_STRING "2.0"
 37#define AFX_VERSION         2.0
 38
 39// #define AFX_CUSTOMIZED_BRANCH
 40
 41//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
 42#if defined(AFX_CUSTOMIZED_BRANCH)
 43
 44#elif (TORQUE_GAME_ENGINE == 1100 || TORQUE_GAME_ENGINE >= 3000)
 45
 46#define AFX_CAP_SCOPE_TRACKING
 47#define AFX_CAP_ROLLOVER_RAYCASTS
 48//#define AFX_CAP_AFXMODEL_TYPE
 49//#define BROKEN_POINT_IN_WATER
 50#define BROKEN_DAMAGEFLASH_WHITEOUT_BLACKOUT
 51
 52//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
 53#else
 54
 55// This version of AFX source only supports T3D 1.1
 56
 57#endif
 58
 59//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
 60
 61#ifndef _CONSOLETYPES_H_
 62#include "console/consoleTypes.h"
 63#endif
 64
 65#ifndef _ENGINEAPI_H_
 66#include "console/engineAPI.h"
 67#endif
 68
 69#ifndef _SIMBASE_H_
 70#include "console/simBase.h"
 71#endif
 72
 73#ifndef _BITSTREAM_H_
 74#include "core/stream/bitStream.h"
 75#endif
 76
 77#ifndef _GAMEBASE_H_
 78#include "T3D/gameBase/gameBase.h"
 79#endif
 80
 81#if defined(DGL_GRAPHICS_LAYER)
 82#ifndef _DGL_H_
 83#include "dgl/dgl.h"
 84#endif
 85#endif
 86
 87class afxChoreographer;
 88class afxSelectronData;
 89class GameConnection;
 90class SceneObject;
 91
 92class arcaneFX
 93{
 94public:
 95  enum {
 96    TARGETING_OFF,
 97    TARGETING_STANDARD,
 98    TARGETING_FREE
 99  };
100  enum {
101    TARGET_CHECK_POLL,
102    TARGET_CHECK_ON_MOUSE_MOVE
103  };
104
105private:
106  static Vector<afxChoreographer*> active_choreographers;
107  static Vector<afxChoreographer*> client_choreographers;
108  static Vector<afxSelectronData*> selectrons;
109  static Vector<SceneObject*>      scoped_objs;
110  static bool                      is_shutdown;
111
112public:
113  static StringTableEntry   NULLSTRING;
114  static U32                sTargetSelectionMask;
115  static U32                sFreeTargetSelectionMask;
116  static bool               sIsFreeTargeting;
117  static Point3F            sFreeTargetPos;
118  static bool               sFreeTargetPosValid;
119  static F32                sTargetSelectionRange;
120  static U32                sTargetSelectionTimeoutMS;
121  static bool               sClickToTargetSelf;
122  static U32                sMissileCollisionMask;
123  static StringTableEntry   sParameterFieldPrefix;
124  static F32                sTerrainZodiacZBias;
125  static F32                sInteriorZodiacZBias;
126  static F32                sPolysoupZodiacZBias;
127  static U32                master_choreographer_id;
128  static U16                master_scope_id;
129
130public:
131  static void init();
132  static void shutdown();
133  static void advanceTime(U32 delta);
134
135  static U32  registerChoreographer(afxChoreographer*);
136  static void unregisterChoreographer(afxChoreographer*);
137  static void registerClientChoreographer(afxChoreographer*);
138  static void unregisterClientChoreographer(afxChoreographer*);
139  static afxChoreographer* findClientChoreographer(U32 id);
140
141  static void registerSelectronData(afxSelectronData*);
142  static void unregisterSelectronData(afxSelectronData*);
143  static afxSelectronData* findSelectronData(U32 obj_type_mask, U8 code);
144
145  static U16            generateScopeId();
146  static void           registerScopedObject(SceneObject*);
147  static SceneObject*   findScopedObject(U16 scope_id);
148  static void           unregisterScopedObject(SceneObject*);
149
150  static void syncToNewConnection(GameConnection* conn);
151  static void endMissionNotify();
152  static S32  rolloverRayCast(Point3F start, Point3F end, U32 mask);
153  static bool freeTargetingRayCast(Point3F start, Point3F end, U32 mask);
154
155  static bool isShutdown() { return is_shutdown; }
156  static StringTableEntry convertLightingModelName(StringTableEntry lm_name);
157
158private:
159  static bool sUsePlayerCentricListener;
160public:
161  static bool usePlayerCentricListener() { return sUsePlayerCentricListener; }
162};
163
164//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
165
166class ByteRange
167{
168public:
169  U8     low;
170  U8     high;
171
172public:
173  /*C*/  ByteRange() { low = 0; high = 255; }
174  /*C*/  ByteRange(U8 l, U8 h=255) { low = l; high = h; }
175
176  void   set(U8 l, U8 h=255) { low = l; high = h; }
177  bool   outOfRange(U8 v) { return (v < low || v > high); }
178  bool   inRange(U8 v) { return !outOfRange(v); }
179  S32    getSpan() const { return high - low; }
180};
181
182DefineConsoleType(TypeByteRange, ByteRange)
183DefineConsoleType(TypeByteRange2, ByteRange)
184
185//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
186
187inline void writeDatablockID(BitStream* s, SimObject* simobj, bool packed=false)
188{
189  if (s->writeFlag(simobj))
190    s->writeRangedU32(packed ? SimObjectId((uintptr_t)simobj) : simobj->getId(),
191                      DataBlockObjectIdFirst, DataBlockObjectIdLast);
192}
193
194inline S32 readDatablockID(BitStream* s)
195{
196  return (!s->readFlag()) ? 0 : ((S32)s->readRangedU32(DataBlockObjectIdFirst,
197          DataBlockObjectIdLast));
198}
199
200inline void registerForCleanup(SimObject* obj)
201{
202  SimGroup* cleanup_grp = dynamic_cast<SimGroup*>(Sim::findObject("MissionCleanup"));
203  if (cleanup_grp)
204    cleanup_grp->addObject(obj);
205}
206
207//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
208
209#define ST_NULLSTRING (arcaneFX::NULLSTRING)
210
211
212//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
213
214#endif // _ARCANE_FX_H_
215
216