arcaneFX.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //
  23. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  24. #ifndef _ARCANE_FX_H_
  25. #define _ARCANE_FX_H_
  26. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  27. #ifndef _PLATFORM_H_
  28. #include "platform/platform.h"
  29. #endif
  30. #define AFX_VERSION_STRING "2.0"
  31. #define AFX_VERSION 2.0
  32. // #define AFX_CUSTOMIZED_BRANCH
  33. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
  34. #if defined(AFX_CUSTOMIZED_BRANCH)
  35. #elif (TORQUE_GAME_ENGINE == 1100 || TORQUE_GAME_ENGINE >= 3000)
  36. #define AFX_CAP_SCOPE_TRACKING
  37. #define AFX_CAP_ROLLOVER_RAYCASTS
  38. //#define AFX_CAP_AFXMODEL_TYPE
  39. //#define BROKEN_POINT_IN_WATER
  40. #define BROKEN_DAMAGEFLASH_WHITEOUT_BLACKOUT
  41. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
  42. #else
  43. // This version of AFX source only supports T3D 1.1
  44. #endif
  45. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
  46. #ifndef _CONSOLETYPES_H_
  47. #include "console/consoleTypes.h"
  48. #endif
  49. #ifndef _ENGINEAPI_H_
  50. #include "console/engineAPI.h"
  51. #endif
  52. #ifndef _SIMBASE_H_
  53. #include "console/simBase.h"
  54. #endif
  55. #ifndef _BITSTREAM_H_
  56. #include "core/stream/bitStream.h"
  57. #endif
  58. #ifndef _GAMEBASE_H_
  59. #include "T3D/gameBase/gameBase.h"
  60. #endif
  61. #if defined(DGL_GRAPHICS_LAYER)
  62. #ifndef _DGL_H_
  63. #include "dgl/dgl.h"
  64. #endif
  65. #endif
  66. class afxChoreographer;
  67. class afxSelectronData;
  68. class GameConnection;
  69. class SceneObject;
  70. class arcaneFX
  71. {
  72. public:
  73. enum {
  74. TARGETING_OFF,
  75. TARGETING_STANDARD,
  76. TARGETING_FREE
  77. };
  78. enum {
  79. TARGET_CHECK_POLL,
  80. TARGET_CHECK_ON_MOUSE_MOVE
  81. };
  82. private:
  83. static Vector<afxChoreographer*> active_choreographers;
  84. static Vector<afxChoreographer*> client_choreographers;
  85. static Vector<afxSelectronData*> selectrons;
  86. static Vector<SceneObject*> scoped_objs;
  87. static bool is_shutdown;
  88. public:
  89. static StringTableEntry NULLSTRING;
  90. static U32 sTargetSelectionMask;
  91. static U32 sFreeTargetSelectionMask;
  92. static bool sIsFreeTargeting;
  93. static Point3F sFreeTargetPos;
  94. static bool sFreeTargetPosValid;
  95. static F32 sTargetSelectionRange;
  96. static U32 sTargetSelectionTimeoutMS;
  97. static bool sClickToTargetSelf;
  98. static U32 sMissileCollisionMask;
  99. static StringTableEntry sParameterFieldPrefix;
  100. static F32 sTerrainZodiacZBias;
  101. static F32 sInteriorZodiacZBias;
  102. static F32 sPolysoupZodiacZBias;
  103. static U32 master_choreographer_id;
  104. static U16 master_scope_id;
  105. public:
  106. static void init();
  107. static void shutdown();
  108. static void advanceTime(U32 delta);
  109. static U32 registerChoreographer(afxChoreographer*);
  110. static void unregisterChoreographer(afxChoreographer*);
  111. static void registerClientChoreographer(afxChoreographer*);
  112. static void unregisterClientChoreographer(afxChoreographer*);
  113. static afxChoreographer* findClientChoreographer(U32 id);
  114. static void registerSelectronData(afxSelectronData*);
  115. static void unregisterSelectronData(afxSelectronData*);
  116. static afxSelectronData* findSelectronData(U32 obj_type_mask, U8 code);
  117. static U16 generateScopeId();
  118. static void registerScopedObject(SceneObject*);
  119. static SceneObject* findScopedObject(U16 scope_id);
  120. static void unregisterScopedObject(SceneObject*);
  121. static void syncToNewConnection(GameConnection* conn);
  122. static void endMissionNotify();
  123. static S32 rolloverRayCast(Point3F start, Point3F end, U32 mask);
  124. static bool freeTargetingRayCast(Point3F start, Point3F end, U32 mask);
  125. static bool isShutdown() { return is_shutdown; }
  126. static StringTableEntry convertLightingModelName(StringTableEntry lm_name);
  127. private:
  128. static bool sUsePlayerCentricListener;
  129. public:
  130. static bool usePlayerCentricListener() { return sUsePlayerCentricListener; }
  131. };
  132. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
  133. class ByteRange
  134. {
  135. public:
  136. U8 low;
  137. U8 high;
  138. public:
  139. /*C*/ ByteRange() { low = 0; high = 255; }
  140. /*C*/ ByteRange(U8 l, U8 h=255) { low = l; high = h; }
  141. void set(U8 l, U8 h=255) { low = l; high = h; }
  142. bool outOfRange(U8 v) { return (v < low || v > high); }
  143. bool inRange(U8 v) { return !outOfRange(v); }
  144. S32 getSpan() const { return high - low; }
  145. };
  146. DefineConsoleType(TypeByteRange, ByteRange)
  147. DefineConsoleType(TypeByteRange2, ByteRange)
  148. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
  149. inline void writeDatablockID(BitStream* s, SimObject* simobj, bool packed=false)
  150. {
  151. if (s->writeFlag(simobj))
  152. s->writeRangedU32(packed ? SimObjectId((uintptr_t)simobj) : simobj->getId(),
  153. DataBlockObjectIdFirst, DataBlockObjectIdLast);
  154. }
  155. inline S32 readDatablockID(BitStream* s)
  156. {
  157. return (!s->readFlag()) ? 0 : ((S32)s->readRangedU32(DataBlockObjectIdFirst,
  158. DataBlockObjectIdLast));
  159. }
  160. inline void registerForCleanup(SimObject* obj)
  161. {
  162. SimGroup* cleanup_grp = dynamic_cast<SimGroup*>(Sim::findObject("MissionCleanup"));
  163. if (cleanup_grp)
  164. cleanup_grp->addObject(obj);
  165. }
  166. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
  167. #define ST_NULLSTRING (arcaneFX::NULLSTRING)
  168. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  169. #endif // _ARCANE_FX_H_