afxModel.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 _AFX_MODEL_H_
  25. #define _AFX_MODEL_H_
  26. #include "renderInstance/renderPassManager.h"
  27. #include "T3D/assets/ShapeAsset.h"
  28. class ParticleEmitterData;
  29. class ParticleEmitter;
  30. class ExplosionData;
  31. class TSPartInstance;
  32. class TSShapeInstance;
  33. class TSShape;
  34. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  35. // afxModel Data
  36. struct afxModelData : public GameBaseData
  37. {
  38. typedef GameBaseData Parent;
  39. DECLARE_SHAPEASSET(afxModelData, Shape, onShapeChanged);
  40. DECLARE_ASSET_SETGET(afxModelData, Shape);
  41. StringTableEntry sequence;
  42. F32 seq_rate;
  43. F32 seq_offset;
  44. F32 alpha_mult;
  45. bool use_vertex_alpha;
  46. U32 force_on_material_flags;
  47. U32 force_off_material_flags;
  48. bool texture_filtering;
  49. F32 fog_mult;
  50. struct TextureTagRemapping
  51. {
  52. char* old_tag;
  53. char* new_tag;
  54. };
  55. char* remap_buffer;
  56. Vector<TextureTagRemapping> txr_tag_remappings;
  57. StringTableEntry remap_txr_tags;
  58. bool overrideLightingOptions;
  59. bool receiveSunLight;
  60. bool receiveLMLighting;
  61. bool useAdaptiveSelfIllumination;
  62. bool useCustomAmbientLighting;
  63. bool customAmbientForSelfIllumination;
  64. LinearColorF customAmbientLighting;
  65. bool shadowEnable;
  66. U32 shadowSize;
  67. F32 shadowMaxVisibleDistance;
  68. F32 shadowProjectionDistance;
  69. F32 shadowSphereAdjust;
  70. public:
  71. /*C*/ afxModelData();
  72. /*C*/ afxModelData(const afxModelData&, bool = false);
  73. /*D*/ ~afxModelData();
  74. bool preload(bool server, String &errorStr);
  75. void packData(BitStream* stream);
  76. void unpackData(BitStream* stream);
  77. virtual void onPerformSubstitutions();
  78. virtual bool allowSubstitutions() const { return true; }
  79. static void initPersistFields();
  80. void onShapeChanged() {}
  81. void onSequenceChanged() {}
  82. DECLARE_CONOBJECT(afxModelData);
  83. DECLARE_CATEGORY("AFX");
  84. };
  85. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  86. // afxModel
  87. class afxModel : public GameBase
  88. {
  89. typedef GameBase Parent;
  90. private:
  91. afxModelData* mDataBlock;
  92. TSShapeInstance* shape_inst;
  93. TSThread* main_seq_thread;
  94. S32 main_seq_id;
  95. F32 seq_rate_factor;
  96. bool seq_animates_vis;
  97. U32 last_anim_tag;
  98. F32 fade_amt;
  99. bool is_visible;
  100. S8 sort_priority;
  101. struct BlendThread
  102. {
  103. TSThread* thread;
  104. U32 tag;
  105. };
  106. Vector<BlendThread> blend_clips;
  107. static U32 unique_anim_tag_counter;
  108. protected:
  109. Vector<S32> mCollisionDetails;
  110. Vector<S32> mLOSDetails;
  111. bool castRay(const Point3F &start, const Point3F &end, RayInfo* info);
  112. virtual void advanceTime(F32 dt);
  113. virtual void prepRenderImage(SceneRenderState*);
  114. void renderObject(SceneRenderState*);
  115. virtual bool onAdd();
  116. virtual void onRemove();
  117. public:
  118. /*C*/ afxModel();
  119. /*D*/ ~afxModel();
  120. virtual bool onNewDataBlock(GameBaseData* dptr, bool reload);
  121. void setFadeAmount(F32 amt) { fade_amt = amt; }
  122. void setSequenceRateFactor(F32 factor);
  123. void setSortPriority(S8 priority) { sort_priority = priority; }
  124. const char* getShapeFileName() const { return mDataBlock->getShape(); }
  125. void setVisibility(bool flag) { is_visible = flag; }
  126. TSShape* getTSShape() { return mDataBlock->getShapeResource(); }
  127. TSShapeInstance* getTSShapeInstance() { return shape_inst; }
  128. U32 setAnimClip(const char* clip, F32 pos, F32 rate, F32 trans);
  129. void resetAnimation(U32 tag);
  130. F32 getAnimClipDuration(const char* clip);
  131. DECLARE_CONOBJECT(afxModel);
  132. DECLARE_CATEGORY("AFX");
  133. };
  134. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  135. #endif // _AFX_MODEL_H_