afxModel.h 5.8 KB

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