- included patch from willvarfar for animated attack particles (thanks will)

This commit is contained in:
Mark Vejvoda
2011-06-10 17:33:09 +00:00
parent ba3071c15b
commit 7c43628643
5 changed files with 18 additions and 12 deletions

View File

@@ -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

View File

@@ -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;