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