afxModel.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. U32 shadowSize;
  66. F32 shadowMaxVisibleDistance;
  67. F32 shadowProjectionDistance;
  68. F32 shadowSphereAdjust;
  69. public:
  70. /*C*/ afxModelData();
  71. /*C*/ afxModelData(const afxModelData&, bool = false);
  72. /*D*/ ~afxModelData();
  73. bool preload(bool server, String &errorStr);
  74. void packData(BitStream* stream);
  75. void unpackData(BitStream* stream);
  76. virtual void onPerformSubstitutions();
  77. virtual bool allowSubstitutions() const { return true; }
  78. static void initPersistFields();
  79. void onShapeChanged() {}
  80. void onSequenceChanged() {}
  81. DECLARE_CONOBJECT(afxModelData);
  82. DECLARE_CATEGORY("AFX");
  83. };
  84. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  85. // afxModel
  86. class afxModel : public GameBase
  87. {
  88. typedef GameBase Parent;
  89. private:
  90. afxModelData* mDataBlock;
  91. TSShapeInstance* shape_inst;
  92. TSThread* main_seq_thread;
  93. S32 main_seq_id;
  94. F32 seq_rate_factor;
  95. bool seq_animates_vis;
  96. U32 last_anim_tag;
  97. F32 fade_amt;
  98. bool is_visible;
  99. S8 sort_priority;
  100. struct BlendThread
  101. {
  102. TSThread* thread;
  103. U32 tag;
  104. };
  105. Vector<BlendThread> blend_clips;
  106. static U32 unique_anim_tag_counter;
  107. protected:
  108. Vector<S32> mCollisionDetails;
  109. Vector<S32> mLOSDetails;
  110. bool castRay(const Point3F &start, const Point3F &end, RayInfo* info);
  111. virtual void advanceTime(F32 dt);
  112. virtual void prepRenderImage(SceneRenderState*);
  113. void renderObject(SceneRenderState*);
  114. virtual bool onAdd();
  115. virtual void onRemove();
  116. public:
  117. /*C*/ afxModel();
  118. /*D*/ ~afxModel();
  119. virtual bool onNewDataBlock(GameBaseData* dptr, bool reload);
  120. void setFadeAmount(F32 amt) { fade_amt = amt; }
  121. void setSequenceRateFactor(F32 factor);
  122. void setSortPriority(S8 priority) { sort_priority = priority; }
  123. const char* getShapeFileName() const { return mDataBlock->getShape(); }
  124. void setVisibility(bool flag) { is_visible = flag; }
  125. TSShape* getTSShape() { return mDataBlock->getShapeResource(); }
  126. TSShapeInstance* getTSShapeInstance() { return shape_inst; }
  127. U32 setAnimClip(const char* clip, F32 pos, F32 rate, F32 trans);
  128. void resetAnimation(U32 tag);
  129. F32 getAnimClipDuration(const char* clip);
  130. DECLARE_CONOBJECT(afxModel);
  131. DECLARE_CATEGORY("AFX");
  132. };
  133. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  134. #endif // _AFX_MODEL_H_