summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@joel-desktop.(none)>2008-01-19 21:22:12 +0900
committerJoel Bosveld <joel@joel-desktop.(none)>2008-01-19 21:22:12 +0900
commite027fbc8611de9b57983579012e484f4423f41cd (patch)
tree1c08f3a44b61d6a845f1ee6cdb0c7e346d11dda4
parent57920fefda378828eeffa8e84633ad108bb00e37 (diff)
downloadcubedbus-e027fbc8611de9b57983579012e484f4423f41cd.tar.gz
cubedbus-e027fbc8611de9b57983579012e484f4423f41cd.tar.bz2
Changed moveLinear function to moveConstantAcceleration
Just set acceleration to 0 to have same effect as before
-rw-r--r--particleFx/emitter.c.in16
-rw-r--r--particleFx/move.c.in12
2 files changed, 21 insertions, 7 deletions
diff --git a/particleFx/emitter.c.in b/particleFx/emitter.c.in
index 3c10057..444739e 100644
--- a/particleFx/emitter.c.in
+++ b/particleFx/emitter.c.in
@@ -32,7 +32,7 @@ compFxParticleCreateEmitterColour (CompFxParticleEmitter *emitter)
{
CompFxParticle *particle = NULL;
- if(emitter->nParticles >= 100) /* XXX should be a variable in emitter */
+ if(emitter->nParticles >= 1000) /* XXX should be a variable in emitter */
{
}
else if( (particle = compFxParticleCreate (emitter)) == NULL) /* this function sets up the emitter, next, and prev fields */
@@ -43,7 +43,7 @@ compFxParticleCreateEmitterColour (CompFxParticleEmitter *emitter)
{
emitter->nParticles++;
- particle->nDataSets=6;
+ particle->nDataSets=7;
particle->dataSets = malloc (sizeof (CompFxParticleDataSet) * particle->nDataSets);
particle->dataSets[0].name= malloc (sizeof (char) * 10);
@@ -68,7 +68,11 @@ compFxParticleCreateEmitterColour (CompFxParticleEmitter *emitter)
particle->dataSets[5].name= malloc (sizeof (char) * 10);
strcpy (particle->dataSets[5].name, "dList");
- particle->dataSets[5].data = malloc (sizeof (CompFxParticleData) * 1);
+ particle->dataSets[5].data = malloc (sizeof (CompFxParticleData) * 1);
+
+ particle->dataSets[6].name= malloc (sizeof (char) * 12);
+ strcpy (particle->dataSets[6].name, "acceleration");
+ particle->dataSets[6].data = malloc (sizeof (CompFxParticleData) * 3);
/* XXX Generate dList XXX*/
@@ -99,8 +103,12 @@ compFxParticleCreateEmitterColour (CompFxParticleEmitter *emitter)
particle->dataSets[0].data[1].f=0;
particle->dataSets[0].data[2].f=0;
+ particle->dataSets[6].data[0].f=0;
+ particle->dataSets[6].data[1].f=-0.000025;
+ particle->dataSets[6].data[2].f=0;
+
particle->compFxParticleDrawProc = &compFxParticleDrawColour;
- particle->compFxParticleMoveProc = &compFxParticleMoveLinear;
+ particle->compFxParticleMoveProc = &compFxParticleMoveConstantAcceleration;
particle->compFxParticleDeathProc = &compFxParticleDeathTimeout;
}
diff --git a/particleFx/move.c.in b/particleFx/move.c.in
index 733da4f..4470b3e 100644
--- a/particleFx/move.c.in
+++ b/particleFx/move.c.in
@@ -1,15 +1,21 @@
/* Some movement patterns */
static void
-compFxParticleMoveLinear (CompFxParticle *particle)
+compFxParticleMoveConstantAcceleration (CompFxParticle *particle)
{
- CompFxParticleDataSet *position = compFxParticleFindDataSet ("position", particle, 0);
- CompFxParticleDataSet *velocity = compFxParticleFindDataSet ("velocity", particle, 0);
+ CompFxParticleDataSet *position = compFxParticleFindDataSet ("position", particle, 0);
+ CompFxParticleDataSet *velocity = compFxParticleFindDataSet ("velocity", particle, 0);
+ CompFxParticleDataSet *acceleration = compFxParticleFindDataSet ("acceleration", particle, 0);
if(position==NULL || velocity==NULL) return;
position->data[0].f += velocity->data[0].f; /* x += vx */
position->data[1].f += velocity->data[1].f; /* y += vy */
position->data[2].f += velocity->data[2].f; /* z += vz */
+
+ velocity->data[0].f += acceleration->data[0].f; /* vx += ax */
+ velocity->data[1].f += acceleration->data[1].f; /* vy += ay */
+ velocity->data[2].f += acceleration->data[2].f; /* vz += az */
}
+