mirror of
https://github.com/ENSL/NS.git
synced 2024-11-26 06:20:57 +00:00
4f13237895
Change CRLF to LF in repo.
590 lines
14 KiB
C++
590 lines
14 KiB
C++
#include <string.h>
|
|
#include "../util/nowarnings.h"
|
|
#include "AvHParticleTemplate.h"
|
|
#include "../common/renderingconst.h"
|
|
|
|
AvHParticleTemplate::AvHParticleTemplate()
|
|
{
|
|
// Populate with reasonable defaults
|
|
this->mMaxParticles = 10;
|
|
this->mParticleSize = 1.0f;
|
|
this->mBaseColor[0] = this->mBaseColor[1] = this->mBaseColor[2] = 1.0f;
|
|
this->mGravity[0] = this->mGravity[1] = this->mGravity[2] = 0.0f;
|
|
|
|
this->mGenerationShape = PS_Point;
|
|
memset(&this->mGenerationParams, 0, sizeof(this->mGenerationParams));
|
|
|
|
this->mDeathShape = PS_None;
|
|
memset(&this->mDeathParams, 0, sizeof(this->mDeathParams));
|
|
|
|
this->mCollisionShape = PS_None;
|
|
memset(&this->mCollisionParams, 0, sizeof(this->mCollisionParams));
|
|
|
|
this->mStartingVelocityShape = PS_None;
|
|
memset(&this->mStartingVelocityParams, 0, sizeof(this->mStartingVelocityParams));
|
|
|
|
this->mMinSpeed = 0.0f;
|
|
this->mMaxSpeed = 100.0f;
|
|
this->mParticleSystemLifetime = -1;
|
|
this->mParticleLifetime = -1;
|
|
this->mNumSpriteFrames = 1;
|
|
this->mAnimationSpeed = 1.0f;
|
|
this->mParticleScaling = 1.0f;
|
|
this->mRenderMode = (int)kRenderNormal;
|
|
//this->mInitialParticles = 0;
|
|
this->mMaxAlpha = 1.0f;
|
|
this->mFadeIn = false;
|
|
this->mGenerationEntityParameter = 0.0f;
|
|
this->mGenerationEntityIndex = -1;
|
|
this->mFlags = 0;
|
|
this->mParticleSystemIndexToGenerate = -1;
|
|
}
|
|
|
|
//AvHParticleTemplate::AvHParticleTemplate(const AvHParticleTemplate& inTemplate)
|
|
//{
|
|
// this->mMaxParticles = inTemplate.mMaxParticles;
|
|
// this->mName = inTemplate.mName;
|
|
// memcpy(&this->mBaseColor, &inTemplate.mBaseColor, sizeof(this->mBaseColor));
|
|
// memcpy(&this->mGravity, &inTemplate.mGravity, sizeof(this->mGravity));
|
|
//
|
|
// this->mGenerationRate = inTemplate.mGenerationRate;
|
|
// this->mParticleSize = inTemplate.mParticleSize;
|
|
// this->mSprite = inTemplate.mSprite;
|
|
//
|
|
// this->mGenerationShape = inTemplate.mGenerationShape;
|
|
// memcpy(&this->mGenerationParams, &inTemplate.mGenerationParams, sizeof(this->mGenerationParams));
|
|
//
|
|
// this->mDeathShape = inTemplate.mDeathShape;
|
|
// memcpy(&this->mDeathParams, &inTemplate.mDeathParams, sizeof(this->mDeathParams));
|
|
//
|
|
// this->mCollisionShape = inTemplate.mCollisionShape;
|
|
// memcpy(&this->mCollisionParams, &inTemplate.mCollisionParams, sizeof(this->mCollisionParams));
|
|
//
|
|
// this->mMinSpeed = inTemplate.mMinSpeed;
|
|
// this->mMaxParticles = inTemplate.mMaxSpeed;
|
|
//}
|
|
|
|
|
|
bool
|
|
AvHParticleTemplate::GetFadeIn() const
|
|
{
|
|
return this->mFlags & 4;
|
|
}
|
|
|
|
bool
|
|
AvHParticleTemplate::GetFadeOut() const
|
|
{
|
|
return this->mFlags & 8;
|
|
}
|
|
|
|
bool
|
|
AvHParticleTemplate::GetUseDensity() const
|
|
{
|
|
return this->mFlags & 2;
|
|
}
|
|
|
|
bool
|
|
AvHParticleTemplate::GetUseWorldGravity() const
|
|
{
|
|
return this->mFlags & 16;
|
|
}
|
|
|
|
bool
|
|
AvHParticleTemplate::GetUseTrisNotQuads() const
|
|
{
|
|
return this->mFlags & 32;
|
|
}
|
|
|
|
bool
|
|
AvHParticleTemplate::GetMinimizeEdges() const
|
|
{
|
|
return this->mFlags & 64;
|
|
}
|
|
|
|
bool
|
|
AvHParticleTemplate::GetConstrainPitch() const
|
|
{
|
|
return this->mFlags & 128;
|
|
}
|
|
|
|
bool
|
|
AvHParticleTemplate::GetCollide() const
|
|
{
|
|
return this->mFlags & 256;
|
|
}
|
|
|
|
bool
|
|
AvHParticleTemplate::GetHighDetailOnly() const
|
|
{
|
|
return this->mFlags & 512;
|
|
}
|
|
|
|
bool
|
|
AvHParticleTemplate::GetFaceUp() const
|
|
{
|
|
return this->mFlags & 1024;
|
|
}
|
|
|
|
int
|
|
AvHParticleTemplate::GetFlags() const
|
|
{
|
|
return this->mFlags;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetFlags(int inFlags)
|
|
{
|
|
this->mFlags = inFlags;
|
|
}
|
|
|
|
const string&
|
|
AvHParticleTemplate::GetName() const
|
|
{
|
|
return this->mName;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetName(const string& inName)
|
|
{
|
|
this->mName = inName;
|
|
}
|
|
|
|
//int
|
|
//AvHParticleTemplate::GetInitialParticles() const
|
|
//{
|
|
// //return this->mInitialParticles;
|
|
// return this->mMaxParticles;
|
|
//}
|
|
|
|
//void
|
|
//AvHParticleTemplate::SetInitialParticles(int inInitialParticles)
|
|
//{
|
|
// if(inInitialParticles < 0)
|
|
// inInitialParticles = 0;
|
|
//
|
|
// this->mInitialParticles = inInitialParticles;
|
|
//}
|
|
|
|
uint32
|
|
AvHParticleTemplate::GetMaxParticles() const
|
|
{
|
|
return this->mMaxParticles;
|
|
}
|
|
|
|
float
|
|
AvHParticleTemplate::GetParticleSize() const
|
|
{
|
|
return this->mParticleSize;
|
|
}
|
|
|
|
float
|
|
AvHParticleTemplate::GetParticleSystemLifetime() const
|
|
{
|
|
return this->mParticleSystemLifetime;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetParticleSystemLifetime(float inNewLifetime)
|
|
{
|
|
this->mParticleSystemLifetime = inNewLifetime;
|
|
}
|
|
|
|
float
|
|
AvHParticleTemplate::GetParticleLifetime() const
|
|
{
|
|
return this->mParticleLifetime;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetParticleLifetime(float inNewLifetime)
|
|
{
|
|
this->mParticleLifetime = inNewLifetime;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetMaxParticles(uint32 inMaxParticles)
|
|
{
|
|
this->mMaxParticles = inMaxParticles;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetParticleSize(float inSize)
|
|
{
|
|
this->mParticleSize = inSize;
|
|
}
|
|
|
|
string
|
|
AvHParticleTemplate::GetSprite() const
|
|
{
|
|
return this->mSprite;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetSprite(string inSpriteName)
|
|
{
|
|
this->mSprite = inSpriteName;
|
|
}
|
|
|
|
ShapeType
|
|
AvHParticleTemplate::GetGenerationShape() const
|
|
{
|
|
return this->mGenerationShape;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetGenerationShape(ShapeType inShape)
|
|
{
|
|
this->mGenerationShape = inShape;
|
|
}
|
|
|
|
string
|
|
AvHParticleTemplate::GetGenerationEntityName() const
|
|
{
|
|
return this->mGenerationEntityName;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetGenerationEntityName(const string& inName)
|
|
{
|
|
this->mGenerationEntityName = inName;
|
|
}
|
|
|
|
string
|
|
AvHParticleTemplate::GetParticleSystemToGenerate() const
|
|
{
|
|
return this->mParticleSystemToGenerate;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetParticleSystemToGenerate(const string& inName)
|
|
{
|
|
this->mParticleSystemToGenerate = inName;
|
|
}
|
|
|
|
int
|
|
AvHParticleTemplate::GetParticleSystemIndexToGenerate() const
|
|
{
|
|
return this->mParticleSystemIndexToGenerate;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetParticleSystemIndexToGenerate(int inIndex)
|
|
{
|
|
this->mParticleSystemIndexToGenerate = inIndex;
|
|
}
|
|
|
|
int
|
|
AvHParticleTemplate::GetGenerationEntityIndex() const
|
|
{
|
|
return this->mGenerationEntityIndex;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetGenerationEntityIndex(int inIndex)
|
|
{
|
|
this->mGenerationEntityIndex = inIndex;
|
|
}
|
|
|
|
const float
|
|
AvHParticleTemplate::GetGenerationEntityParameter() const
|
|
{
|
|
return this->mGenerationEntityParameter;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetGenerationEntityParameter(float inEntityParameter)
|
|
{
|
|
this->mGenerationEntityParameter = inEntityParameter;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::GetGenerationParams(ParticleParams& outParams) const
|
|
{
|
|
memcpy(outParams, this->mGenerationParams, sizeof(ParticleParams));
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetGenerationParams(const ParticleParams& inParms)
|
|
{
|
|
memcpy(this->mGenerationParams, inParms, sizeof(inParms));
|
|
}
|
|
|
|
uint32
|
|
AvHParticleTemplate::GetGenerationRate() const
|
|
{
|
|
return this->mGenerationRate;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetGenerationRate(uint32 inGenRate)
|
|
{
|
|
this->mGenerationRate = inGenRate;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::GetGravity(PSVector& outGravity) const
|
|
{
|
|
memcpy(&outGravity, &this->mGravity, sizeof(PSVector));
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetGravity(const PSVector& inGravity)
|
|
{
|
|
memcpy(&this->mGravity, &inGravity, sizeof(inGravity));
|
|
}
|
|
|
|
|
|
float
|
|
AvHParticleTemplate::GetAnimationSpeed() const
|
|
{
|
|
return this->mAnimationSpeed;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetAnimationSpeed(float inSpeed)
|
|
{
|
|
this->mAnimationSpeed = inSpeed;
|
|
}
|
|
|
|
int
|
|
AvHParticleTemplate::GetNumSpriteFrames(void) const
|
|
{
|
|
return this->mNumSpriteFrames;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetNumSpriteFrames(int inFrames)
|
|
{
|
|
this->mNumSpriteFrames = inFrames;
|
|
}
|
|
|
|
float
|
|
AvHParticleTemplate::GetMaxAlpha() const
|
|
{
|
|
return this->mMaxAlpha;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetMaxAlpha(float inMaxAlpha)
|
|
{
|
|
if(inMaxAlpha > 1.0f)
|
|
inMaxAlpha = 1.0f;
|
|
if(inMaxAlpha < 0.0f)
|
|
inMaxAlpha = 0.0f;
|
|
|
|
this->mMaxAlpha = inMaxAlpha;
|
|
}
|
|
|
|
|
|
|
|
float
|
|
AvHParticleTemplate::GetParticleScaling() const
|
|
{
|
|
return this->mParticleScaling;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetParticleScaling(float inScaling)
|
|
{
|
|
this->mParticleScaling = inScaling;
|
|
}
|
|
|
|
int
|
|
AvHParticleTemplate::GetRenderMode(void) const
|
|
{
|
|
return this->mRenderMode;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetRenderMode(int inRenderMode)
|
|
{
|
|
this->mRenderMode = inRenderMode;
|
|
}
|
|
|
|
|
|
ShapeType
|
|
AvHParticleTemplate::GetStartingVelocityShape() const
|
|
{
|
|
return this->mStartingVelocityShape;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetStartingVelocityShape(ShapeType inShape)
|
|
{
|
|
this->mStartingVelocityShape = inShape;
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::GetStartingVelocityParams(ParticleParams& outParams) const
|
|
{
|
|
memcpy(outParams, this->mStartingVelocityParams, sizeof(ParticleParams));
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplate::SetStartingVelocityParams(const ParticleParams& inParms)
|
|
{
|
|
memcpy(this->mStartingVelocityParams, inParms, sizeof(inParms));
|
|
}
|
|
|
|
|
|
void AvHParticleTemplate::operator=(const AvHParticleTemplate& other)
|
|
{
|
|
this->mName = other.mName;
|
|
this->mMaxParticles = other.mMaxParticles;
|
|
memcpy(this->mBaseColor, other.mBaseColor, sizeof(PSVector));
|
|
this->mSprite = other.mSprite;
|
|
this->mParticleSize = other.mParticleSize;
|
|
this->mParticleSystemLifetime = other.mParticleSystemLifetime;
|
|
this->mParticleLifetime = other.mParticleLifetime;
|
|
memcpy(this->mGravity, other.mGravity, sizeof(PSVector));
|
|
this->mGenerationRate = other.mGenerationRate;
|
|
this->mGenerationShape = other.mGenerationShape;
|
|
memcpy(this->mGenerationParams, other.mGenerationParams, sizeof(ParticleParams));
|
|
this->mGenerationEntityIndex = other.mGenerationEntityIndex;
|
|
this->mGenerationEntityParameter = other.mGenerationEntityParameter;
|
|
this->mGenerationEntityName = other.mGenerationEntityName;
|
|
this->mStartingVelocityShape = other.mStartingVelocityShape;
|
|
memcpy(this->mStartingVelocityParams, other.mStartingVelocityParams, sizeof(ParticleParams));
|
|
this->mDeathShape = other.mDeathShape;
|
|
memcpy(this->mDeathParams, other.mDeathParams, sizeof(ParticleParams));
|
|
this->mCollisionShape = other.mCollisionShape;
|
|
memcpy(this->mCollisionParams, other.mCollisionParams, sizeof(ParticleParams));
|
|
this->mMinSpeed = other.mMinSpeed;
|
|
this->mMaxSpeed = other.mMaxSpeed;
|
|
this->mNumSpriteFrames = other.mNumSpriteFrames;
|
|
this->mAnimationSpeed = other.mAnimationSpeed;
|
|
this->mParticleScaling = other.mParticleScaling;
|
|
this->mRenderMode = other.mRenderMode;
|
|
this->mMaxAlpha = other.mMaxAlpha;
|
|
this->mFadeIn = other.mFadeIn;
|
|
this->mFlags = other.mFlags;
|
|
this->mParticleSystemToGenerate = other.mParticleSystemToGenerate;
|
|
this->mParticleSystemIndexToGenerate = other.mParticleSystemIndexToGenerate;
|
|
}
|
|
|
|
bool AvHParticleTemplate::operator==(const AvHParticleTemplate& other) const
|
|
{
|
|
bool result=false;
|
|
if ( this->mName == other.mName &&
|
|
this->mMaxParticles == other.mMaxParticles &&
|
|
this->mBaseColor == other.mBaseColor &&
|
|
this->mSprite == other.mSprite &&
|
|
this->mParticleSize == other.mParticleSize &&
|
|
this->mParticleSystemLifetime == other.mParticleSystemLifetime &&
|
|
this->mParticleLifetime == other.mParticleLifetime &&
|
|
this->mGravity == other.mGravity &&
|
|
this->mGenerationRate == other.mGenerationRate &&
|
|
this->mGenerationShape == other.mGenerationShape &&
|
|
this->mGenerationParams == other.mGenerationParams &&
|
|
this->mGenerationEntityIndex == other.mGenerationEntityIndex &&
|
|
this->mGenerationEntityParameter == other.mGenerationEntityParameter &&
|
|
this->mGenerationEntityName == other.mGenerationEntityName &&
|
|
this->mStartingVelocityShape == other.mStartingVelocityShape &&
|
|
this->mStartingVelocityParams == other.mStartingVelocityParams &&
|
|
this->mDeathShape == other.mDeathShape &&
|
|
this->mDeathParams == other.mDeathParams &&
|
|
this->mCollisionShape == other.mCollisionShape &&
|
|
this->mCollisionParams == other.mCollisionParams &&
|
|
this->mMinSpeed == other.mMinSpeed &&
|
|
this->mMaxSpeed == other.mMaxSpeed &&
|
|
this->mNumSpriteFrames == other.mNumSpriteFrames &&
|
|
this->mAnimationSpeed == other.mAnimationSpeed &&
|
|
this->mParticleScaling == other.mParticleScaling &&
|
|
this->mRenderMode == other.mRenderMode &&
|
|
this->mMaxAlpha == other.mMaxAlpha &&
|
|
this->mFadeIn == other.mFadeIn &&
|
|
this->mFlags == other.mFlags &&
|
|
this->mParticleSystemToGenerate == other.mParticleSystemToGenerate &&
|
|
this->mParticleSystemIndexToGenerate == other.mParticleSystemIndexToGenerate )
|
|
result=true;
|
|
return result;
|
|
}
|
|
|
|
AvHParticleTemplateList::AvHParticleTemplateList()
|
|
{
|
|
}
|
|
|
|
void
|
|
AvHParticleTemplateList::Clear()
|
|
{
|
|
//for(ParticleTemplateListType::iterator theIter = this->mTemplateList.begin(); theIter != this->mTemplateList.end(); theIter++)
|
|
if ( this->mTemplateList.size() > 0 )
|
|
this->mTemplateList.erase(this->mTemplateList.begin(), this->mTemplateList.end());
|
|
}
|
|
|
|
int
|
|
AvHParticleTemplateList::CreateTemplateFromIndex(int inBaseIndex)
|
|
{
|
|
AvHParticleTemplate theNewTemplate;
|
|
|
|
if(inBaseIndex != -1)
|
|
{
|
|
ASSERT(inBaseIndex >= 0);
|
|
ASSERT(inBaseIndex < (signed)this->mTemplateList.size());
|
|
theNewTemplate = this->mTemplateList[inBaseIndex];
|
|
}
|
|
|
|
int theNewIndex = (int)this->mTemplateList.size();
|
|
this->mTemplateList[theNewIndex]=theNewTemplate;
|
|
|
|
return theNewIndex;
|
|
}
|
|
|
|
AvHParticleTemplate*
|
|
AvHParticleTemplateList::GetTemplateAtIndex(uint32 inIndex)
|
|
{
|
|
AvHParticleTemplate* theTemplate = NULL;
|
|
|
|
if(inIndex < this->mTemplateList.size())
|
|
{
|
|
theTemplate = &(this->mTemplateList[inIndex]);
|
|
}
|
|
|
|
return theTemplate;
|
|
}
|
|
|
|
const AvHParticleTemplate*
|
|
AvHParticleTemplateList::GetTemplateAtIndex(uint32 inIndex) const
|
|
{
|
|
const AvHParticleTemplate* theTemplate = NULL;
|
|
|
|
ParticleTemplateListType::const_iterator theIter=this->mTemplateList.find(inIndex);
|
|
|
|
|
|
if(theIter != this->mTemplateList.end() )
|
|
{
|
|
theTemplate = &(theIter->second);
|
|
}
|
|
|
|
return theTemplate;
|
|
}
|
|
|
|
bool
|
|
AvHParticleTemplateList::GetTemplateIndexWithName(const string& inName, uint32& outIndex) const
|
|
{
|
|
bool theSuccess = false;
|
|
uint32 theIndex = 0;
|
|
|
|
ParticleTemplateListType::const_iterator theIter;
|
|
|
|
for(theIter = this->mTemplateList.begin(); theIter != this->mTemplateList.end(); theIter++, theIndex++)
|
|
{
|
|
if(theIter->second.GetName() == inName)
|
|
{
|
|
outIndex = theIndex;
|
|
theSuccess = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return theSuccess;
|
|
}
|
|
|
|
uint32
|
|
AvHParticleTemplateList::GetNumberTemplates() const
|
|
{
|
|
return (uint32)this->mTemplateList.size();
|
|
}
|
|
|
|
|
|
|