afxModel.h

Engine/source/afx/ce/afxModel.h

More...

Classes:

Detailed Description

  1
  2
  3//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  4// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  5// Copyright (C) 2015 Faust Logic, Inc.
  6//
  7// Permission is hereby granted, free of charge, to any person obtaining a copy
  8// of this software and associated documentation files (the "Software"), to
  9// deal in the Software without restriction, including without limitation the
 10// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 11// sell copies of the Software, and to permit persons to whom the Software is
 12// furnished to do so, subject to the following conditions:
 13//
 14// The above copyright notice and this permission notice shall be included in
 15// all copies or substantial portions of the Software.
 16//
 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 23// IN THE SOFTWARE.
 24//
 25//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 26
 27#ifndef _AFX_MODEL_H_
 28#define _AFX_MODEL_H_
 29
 30#include "renderInstance/renderPassManager.h"
 31
 32class ParticleEmitterData;
 33class ParticleEmitter;
 34class ExplosionData;
 35class TSPartInstance;
 36class TSShapeInstance;
 37class TSShape;
 38
 39//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 40// afxModel Data
 41
 42struct afxModelData : public GameBaseData
 43{
 44  typedef GameBaseData Parent;
 45
 46  StringTableEntry      shapeName;
 47  StringTableEntry      sequence;
 48  F32                   seq_rate;
 49  F32                   seq_offset;
 50  F32                   alpha_mult;
 51  bool                  use_vertex_alpha;
 52  U32                   force_on_material_flags;
 53  U32                   force_off_material_flags;
 54  bool                  texture_filtering;
 55  F32                   fog_mult;
 56
 57  struct TextureTagRemapping
 58  {
 59     char* old_tag;
 60     char* new_tag;
 61  };
 62  char*                 remap_buffer;
 63  Vector<TextureTagRemapping> txr_tag_remappings;
 64
 65  StringTableEntry      remap_txr_tags;
 66
 67  Resource<TSShape>     shape;
 68
 69  bool                  overrideLightingOptions;
 70  bool                  receiveSunLight;
 71  bool                  receiveLMLighting;
 72  bool                  useAdaptiveSelfIllumination;
 73  bool                  useCustomAmbientLighting;
 74  bool                  customAmbientForSelfIllumination;
 75  LinearColorF                customAmbientLighting;
 76  bool                  shadowEnable;
 77
 78  U32                   shadowSize;
 79  F32                   shadowMaxVisibleDistance;
 80  F32                   shadowProjectionDistance;
 81  F32                   shadowSphereAdjust;
 82
 83public:
 84  /*C*/                 afxModelData();
 85  /*C*/                 afxModelData(const afxModelData&, bool = false);
 86  /*D*/                 ~afxModelData();
 87
 88  bool                  preload(bool server, String &errorStr);
 89  void                  packData(BitStream* stream);
 90  void                  unpackData(BitStream* stream);
 91
 92  virtual void          onPerformSubstitutions();
 93  virtual bool          allowSubstitutions() const { return true; }
 94
 95  static void           initPersistFields();
 96
 97  DECLARE_CONOBJECT(afxModelData);
 98  DECLARE_CATEGORY("AFX");
 99};
100
101//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
102// afxModel
103
104class afxModel : public GameBase
105{
106  typedef GameBase Parent;
107
108private:
109  afxModelData*         mDataBlock;
110  TSShapeInstance*      shape_inst;
111  TSThread*             main_seq_thread;
112  S32                   main_seq_id;
113  F32                   seq_rate_factor;
114  bool                  seq_animates_vis;
115  U32                   last_anim_tag;
116  F32                   fade_amt;
117  bool                  is_visible;
118  S8                    sort_priority;
119
120  struct BlendThread
121  {
122    TSThread* thread;
123    U32       tag;
124  };
125  Vector<BlendThread>   blend_clips;
126  static U32            unique_anim_tag_counter;
127
128protected:
129  Vector<S32>           mCollisionDetails;
130  Vector<S32>           mLOSDetails;
131  bool                  castRay(const Point3F &start, const Point3F &end, RayInfo* info);
132
133  virtual void          advanceTime(F32 dt);
134
135  virtual void          prepRenderImage(SceneRenderState*);
136
137  void                  renderObject(SceneRenderState*);
138
139  virtual bool          onAdd();
140  virtual void          onRemove();
141
142public:
143  /*C*/                 afxModel();
144  /*D*/                 ~afxModel();
145
146  virtual bool          onNewDataBlock(GameBaseData* dptr, bool reload);
147
148  void                  setFadeAmount(F32 amt) { fade_amt = amt; }
149  void                  setSequenceRateFactor(F32 factor);
150  void                  setSortPriority(S8 priority) { sort_priority = priority; }
151
152  const char*           getShapeFileName() const { return mDataBlock->shapeName; }
153  void                  setVisibility(bool flag) { is_visible = flag; }
154  TSShape*              getTSShape() { return mDataBlock->shape; }
155  TSShapeInstance*      getTSShapeInstance() { return shape_inst; }
156
157  U32                   setAnimClip(const char* clip, F32 pos, F32 rate, F32 trans);
158  void                  resetAnimation(U32 tag);
159  F32                   getAnimClipDuration(const char* clip);
160
161  DECLARE_CONOBJECT(afxModel);
162  DECLARE_CATEGORY("AFX");
163};
164
165//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
166
167#endif // _AFX_MODEL_H_
168