- updated patch from willvarfar for animated models in particles
This commit is contained in:
parent
90fcb0abe7
commit
4aca4af404
|
@ -244,6 +244,8 @@ ProjectileParticleSystem *ParticleSystemTypeProjectile::create() {
|
|||
ps->setTrajectoryScale(trajectoryScale);
|
||||
ps->setTrajectoryFrequency(trajectoryFrequency);
|
||||
|
||||
ps->initParticleSystem();
|
||||
|
||||
return ps;
|
||||
}
|
||||
|
||||
|
@ -297,6 +299,8 @@ SplashParticleSystem *ParticleSystemTypeSplash::create(){
|
|||
ps->setHorizontalSpreadA(horizontalSpreadA);
|
||||
ps->setHorizontalSpreadB(horizontalSpreadB);
|
||||
|
||||
ps->initParticleSystem();
|
||||
|
||||
return ps;
|
||||
}
|
||||
|
||||
|
|
|
@ -370,7 +370,7 @@ public:
|
|||
void setPrimitive(Primitive primitive) {this->primitive= primitive;}
|
||||
|
||||
float getTween() { return tween; } // 0.0 -> 1.0 for animation of model
|
||||
virtual void initParticleSystem() {} // opportunity to do any initialisation when the system has been created and all settings set
|
||||
virtual void initParticleSystem() {} // opportunity to do any initialization when the system has been created and all settings set
|
||||
|
||||
static Primitive strToPrimitive(const string &str);
|
||||
};
|
||||
|
@ -401,6 +401,8 @@ private:
|
|||
Vec3f yVector;
|
||||
Vec3f zVector;
|
||||
|
||||
float modelCycle;
|
||||
|
||||
Trajectory trajectory;
|
||||
float trajectorySpeed;
|
||||
|
||||
|
@ -424,6 +426,8 @@ public:
|
|||
void setTrajectorySpeed(float trajectorySpeed) {this->trajectorySpeed= trajectorySpeed;}
|
||||
void setTrajectoryScale(float trajectoryScale) {this->trajectoryScale= trajectoryScale;}
|
||||
void setTrajectoryFrequency(float trajectoryFrequency) {this->trajectoryFrequency= trajectoryFrequency;}
|
||||
|
||||
void setModelCycle(float modelCycle) {this->modelCycle= modelCycle;}
|
||||
void setPath(Vec3f startPos, Vec3f endPos);
|
||||
|
||||
static Trajectory strToTrajectory(const string &str);
|
||||
|
|
|
@ -73,6 +73,9 @@ void InterpolationData::update(float t, bool cycle){
|
|||
}
|
||||
|
||||
void InterpolationData::updateVertices(float t, bool cycle) {
|
||||
if(t <0.0f || t>1.0f) {
|
||||
printf("ERROR t = [%f] for cycle [%d] f [%d] v [%d]\n",t,cycle,mesh->getFrameCount(),mesh->getVertexCount());
|
||||
}
|
||||
assert(t>=0.0f && t<=1.0f);
|
||||
|
||||
uint32 frameCount= mesh->getFrameCount();
|
||||
|
|
|
@ -747,6 +747,7 @@ ProjectileParticleSystem::~ProjectileParticleSystem(){
|
|||
|
||||
void ProjectileParticleSystem::link(SplashParticleSystem *particleSystem){
|
||||
nextParticleSystem= particleSystem;
|
||||
nextParticleSystem->setVisible(false);
|
||||
nextParticleSystem->setState(sPause);
|
||||
nextParticleSystem->prevParticleSystem= this;
|
||||
}
|
||||
|
@ -761,7 +762,20 @@ void ProjectileParticleSystem::update(){
|
|||
Vec3f currentVector= flatPos - startPos;
|
||||
|
||||
// ratio
|
||||
tween = clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f);
|
||||
float t= clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f);
|
||||
|
||||
// animation?
|
||||
if(modelCycle == 0.0f) {
|
||||
tween= t;
|
||||
}
|
||||
else {
|
||||
#ifdef USE_STREFLOP
|
||||
tween= streflop::fmod(currentVector.length(), modelCycle);
|
||||
#else
|
||||
tween= fmod(currentVector.length(), modelCycle);
|
||||
#endif
|
||||
tween= clamp(tween / currentVector.length(), 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
// trajectory
|
||||
switch(trajectory) {
|
||||
|
@ -771,7 +785,7 @@ void ProjectileParticleSystem::update(){
|
|||
break;
|
||||
|
||||
case tParabolic: {
|
||||
float scaledT= 2.0f * (tween - 0.5f);
|
||||
float scaledT= 2.0f * (t - 0.5f);
|
||||
float paraboleY= (1.0f - scaledT * scaledT) * trajectoryScale;
|
||||
|
||||
pos= flatPos;
|
||||
|
@ -808,6 +822,7 @@ void ProjectileParticleSystem::update(){
|
|||
}
|
||||
|
||||
if(nextParticleSystem != NULL){
|
||||
nextParticleSystem->setVisible(true);
|
||||
nextParticleSystem->setState(sPlay);
|
||||
nextParticleSystem->setPos(endPos);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user