afxModel.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. class ParticleEmitterData;
  28. class ParticleEmitter;
  29. class ExplosionData;
  30. class TSPartInstance;
  31. class TSShapeInstance;
  32. class TSShape;
  33. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  34. // afxModel Data
  35. struct afxModelData : public GameBaseData
  36. {
  37. typedef GameBaseData Parent;
  38. StringTableEntry shapeName;
  39. StringTableEntry sequence;
  40. F32 seq_rate;
  41. F32 seq_offset;
  42. F32 alpha_mult;
  43. bool use_vertex_alpha;
  44. U32 force_on_material_flags;
  45. U32 force_off_material_flags;
  46. bool texture_filtering;
  47. F32 fog_mult;
  48. struct TextureTagRemapping
  49. {
  50. char* old_tag;
  51. char* new_tag;
  52. };
  53. char* remap_buffer;
  54. Vector<TextureTagRemapping> txr_tag_remappings;
  55. StringTableEntry remap_txr_tags;
  56. Resource<TSShape> shape;
  57. bool overrideLightingOptions;
  58. bool receiveSunLight;
  59. bool receiveLMLighting;
  60. bool useAdaptiveSelfIllumination;
  61. bool useCustomAmbientLighting;
  62. bool customAmbientForSelfIllumination;
  63. LinearColorF customAmbientLighting;
  64. bool shadowEnable;
  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. DECLARE_CONOBJECT(afxModelData);
  80. DECLARE_CATEGORY("AFX");
  81. };
  82. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  83. // afxModel
  84. class afxModel : public GameBase
  85. {
  86. typedef GameBase Parent;
  87. private:
  88. afxModelData* mDataBlock;
  89. TSShapeInstance* shape_inst;
  90. TSThread* main_seq_thread;
  91. S32 main_seq_id;
  92. F32 seq_rate_factor;
  93. bool seq_animates_vis;
  94. U32 last_anim_tag;
  95. F32 fade_amt;
  96. bool is_visible;
  97. S8 sort_priority;
  98. struct BlendThread
  99. {
  100. TSThread* thread;
  101. U32 tag;
  102. };
  103. Vector<BlendThread> blend_clips;
  104. static U32 unique_anim_tag_counter;
  105. protected:
  106. Vector<S32> mCollisionDetails;
  107. Vector<S32> mLOSDetails;
  108. bool castRay(const Point3F &start, const Point3F &end, RayInfo* info);
  109. virtual void advanceTime(F32 dt);
  110. virtual void prepRenderImage(SceneRenderState*);
  111. void renderObject(SceneRenderState*);
  112. virtual bool onAdd();
  113. virtual void onRemove();
  114. public:
  115. /*C*/ afxModel();
  116. /*D*/ ~afxModel();
  117. virtual bool onNewDataBlock(GameBaseData* dptr, bool reload);
  118. void setFadeAmount(F32 amt) { fade_amt = amt; }
  119. void setSequenceRateFactor(F32 factor);
  120. void setSortPriority(S8 priority) { sort_priority = priority; }
  121. const char* getShapeFileName() const { return mDataBlock->shapeName; }
  122. void setVisibility(bool flag) { is_visible = flag; }
  123. TSShape* getTSShape() { return mDataBlock->shape; }
  124. TSShapeInstance* getTSShapeInstance() { return shape_inst; }
  125. U32 setAnimClip(const char* clip, F32 pos, F32 rate, F32 trans);
  126. void resetAnimation(U32 tag);
  127. F32 getAnimClipDuration(const char* clip);
  128. DECLARE_CONOBJECT(afxModel);
  129. DECLARE_CATEGORY("AFX");
  130. };
  131. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  132. #endif // _AFX_MODEL_H_