particle.h
Engine/source/T3D/fx/particle.h
Classes:
class
class
Public Defines
define
MaxParticleSize() 50.0
Detailed Description
Public Defines
MaxParticleSize() 50.0
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 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 _PARTICLE_H_ 25#define _PARTICLE_H_ 26 27#ifndef _GAMEBASE_H_ 28#include "T3D/gameBase/gameBase.h" 29#endif 30#ifndef _GFXTEXTUREHANDLE_H_ 31#include "gfx/gfxTextureHandle.h" 32#endif 33 34#define MaxParticleSize 50.0 35 36struct Particle; 37 38//***************************************************************************** 39// Particle Data 40//***************************************************************************** 41class ParticleData : public SimDataBlock 42{ 43 typedef SimDataBlock Parent; 44 45 public: 46 enum PDConst 47 { 48 PDC_NUM_KEYS = 4, 49 }; 50 51 F32 dragCoefficient; 52 F32 windCoefficient; 53 F32 gravityCoefficient; 54 55 F32 inheritedVelFactor; 56 F32 constantAcceleration; 57 58 S32 lifetimeMS; 59 S32 lifetimeVarianceMS; 60 61 F32 spinSpeed; // degrees per second 62 F32 spinRandomMin; 63 F32 spinRandomMax; 64 65 bool useInvAlpha; 66 67 bool animateTexture; 68 U32 numFrames; 69 U32 framesPerSec; 70 71 ColorF colors[ PDC_NUM_KEYS ]; 72 F32 sizes[ PDC_NUM_KEYS ]; 73 F32 times[ PDC_NUM_KEYS ]; 74 75 Point2F* animTexUVs; 76 Point2F texCoords[4]; // default: {{"{"}}0.0,0.0}, {0.0,1.0}, {1.0,1.0}, {1.0,0.0}} 77 Point2I animTexTiling; 78 StringTableEntry animTexFramesString; 79 Vector<U8> animTexFrames; 80 StringTableEntry textureName; 81 GFXTexHandle textureHandle; 82 83 static bool protectedSetSizes( void *object, const char *index, const char *data ); 84 static bool protectedSetTimes( void *object, const char *index, const char *data ); 85 86 public: 87 ParticleData(); 88 ~ParticleData(); 89 90 // move this procedure to Particle 91 void initializeParticle(Particle*, const Point3F&); 92 93 void packData(BitStream* stream); 94 void unpackData(BitStream* stream); 95 bool onAdd(); 96 bool preload(bool server, String &errorStr); 97 DECLARE_CONOBJECT(ParticleData); 98 static void initPersistFields(); 99 100 bool reload(char errorBuffer[256]); 101}; 102 103//***************************************************************************** 104// Particle 105// 106// This structure should be as small as possible. 107//***************************************************************************** 108struct Particle 109{ 110 Point3F pos; // current instantaneous position 111 Point3F vel; // " " velocity 112 Point3F acc; // Constant acceleration 113 Point3F orientDir; // direction particle should go if using oriented particles 114 115 U32 totalLifetime; // Total ms that this instance should be "live" 116 ParticleData* dataBlock; // datablock that contains global parameters for 117 // this instance 118 U32 currentAge; 119 120 121 // are these necessary to store here? - they are interpolated in real time 122 ColorF color; 123 F32 size; 124 125 F32 spinSpeed; 126 Particle * next; 127}; 128 129 130#endif // _PARTICLE_H_ 131
