mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 11:42:31 +01:00
- included patch from willvarfar for animated attack particles (thanks will)
This commit is contained in:
parent
ba3071c15b
commit
7c43628643
@ -38,7 +38,7 @@ public:
|
||||
virtual void renderSystem(ParticleSystem *ps);
|
||||
virtual void renderSystemLine(ParticleSystem *ps);
|
||||
virtual void renderSystemLineAlpha(ParticleSystem *ps);
|
||||
virtual void renderSingleModel(AttackParticleSystem *ps, ModelRenderer *mr);
|
||||
virtual void renderModel(AttackParticleSystem *ps, ModelRenderer *mr);
|
||||
|
||||
protected:
|
||||
void renderBufferQuads(int quadCount);
|
||||
|
@ -351,6 +351,7 @@ protected:
|
||||
float sizeNoEnergy;
|
||||
float gravity;
|
||||
|
||||
float tween;
|
||||
Vec3f direction;
|
||||
|
||||
public:
|
||||
@ -369,6 +370,8 @@ public:
|
||||
void setGravity(float gravity) {this->gravity= gravity;}
|
||||
void setPrimitive(Primitive primitive) {this->primitive= primitive;}
|
||||
|
||||
float getTween() { return tween; } // 0.0 -> 1.0 for animation of model
|
||||
|
||||
static Primitive strToPrimitive(const string &str);
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
virtual void renderSystem(ParticleSystem *ps)=0;
|
||||
virtual void renderSystemLine(ParticleSystem *ps)=0;
|
||||
virtual void renderSystemLineAlpha(ParticleSystem *ps)=0;
|
||||
virtual void renderSingleModel(AttackParticleSystem *ps, ModelRenderer *mr)=0;
|
||||
virtual void renderModel(AttackParticleSystem *ps, ModelRenderer *mr)=0;
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
@ -223,9 +223,10 @@ void ParticleRendererGl::renderSystemLineAlpha(ParticleSystem *ps){
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void ParticleRendererGl::renderSingleModel(AttackParticleSystem *ps, ModelRenderer *mr){
|
||||
void ParticleRendererGl::renderModel(AttackParticleSystem *ps, ModelRenderer *mr){
|
||||
//render model
|
||||
if(ps->getModel()!=NULL){
|
||||
Model *model = ps->getModel();
|
||||
if(model != NULL) {
|
||||
|
||||
//init
|
||||
glEnable(GL_LIGHTING);
|
||||
@ -261,7 +262,8 @@ void ParticleRendererGl::renderSingleModel(AttackParticleSystem *ps, ModelRender
|
||||
|
||||
//render
|
||||
mr->begin(true, true, false);
|
||||
mr->render(ps->getModel());
|
||||
model->updateInterpolationData(ps->getTween(), false);
|
||||
mr->render(model);
|
||||
mr->end();
|
||||
|
||||
//end
|
||||
|
@ -684,13 +684,14 @@ AttackParticleSystem::AttackParticleSystem(int particleCount) :
|
||||
primitive= pQuad;
|
||||
offset= Vec3f(0.0f);
|
||||
gravity= 0.0f;
|
||||
tween= 0.0f;
|
||||
direction= Vec3f(1.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
void AttackParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr){
|
||||
if(active){
|
||||
if(model != NULL){
|
||||
pr->renderSingleModel(this, mr);
|
||||
pr->renderModel(this, mr);
|
||||
}
|
||||
switch(primitive){
|
||||
case pQuad:
|
||||
@ -760,7 +761,7 @@ void ProjectileParticleSystem::update(){
|
||||
Vec3f currentVector= flatPos - startPos;
|
||||
|
||||
// ratio
|
||||
float t= clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f);
|
||||
tween = clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f);
|
||||
|
||||
// trajectory
|
||||
switch(trajectory){
|
||||
@ -770,7 +771,7 @@ void ProjectileParticleSystem::update(){
|
||||
break;
|
||||
|
||||
case tParabolic: {
|
||||
float scaledT= 2.0f * (t - 0.5f);
|
||||
float scaledT= 2.0f * (tween - 0.5f);
|
||||
float paraboleY= (1.0f - scaledT * scaledT) * trajectoryScale;
|
||||
|
||||
pos= flatPos;
|
||||
@ -781,11 +782,11 @@ void ProjectileParticleSystem::update(){
|
||||
case tSpiral: {
|
||||
pos= flatPos;
|
||||
#ifdef USE_STREFLOP
|
||||
pos+= xVector * streflop::cos(t*trajectoryFrequency*targetVector.length())*trajectoryScale;
|
||||
pos+= yVector * streflop::sin(t*trajectoryFrequency*targetVector.length())*trajectoryScale;
|
||||
pos+= xVector * streflop::cos(tween * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
||||
pos+= yVector * streflop::sin(tween * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
||||
#else
|
||||
pos+= xVector * cos(t * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
||||
pos+= yVector * sin(t * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
||||
pos+= xVector * cos(tween * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
||||
pos+= yVector * sin(tween * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user