summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@joel-desktop.(none)>2008-01-25 12:46:55 +0900
committerJoel Bosveld <joel@joel-desktop.(none)>2008-01-25 12:46:55 +0900
commitab43e948af6282ea83edd0e0a949b108163093ee (patch)
tree038024aaf71864e78f1b9673fbb3ba96f87a7b25
parent13fb652485a8449d2881b37c5f15fcd524287c21 (diff)
downloadcubedbus-ab43e948af6282ea83edd0e0a949b108163093ee.tar.gz
cubedbus-ab43e948af6282ea83edd0e0a949b108163093ee.tar.bz2
Break some stuff with particle system to try get it to use the emitter
structs for dataSets, doesn't work yet (crash)
-rw-r--r--cubedbusParticle.c.in99
-rw-r--r--particleFx/death.c.in2
-rw-r--r--particleFx/emitter.c.in3
-rw-r--r--particleFx/particleFxPrework8
4 files changed, 109 insertions, 3 deletions
diff --git a/cubedbusParticle.c.in b/cubedbusParticle.c.in
index e5744ae..211af73 100644
--- a/cubedbusParticle.c.in
+++ b/cubedbusParticle.c.in
@@ -101,7 +101,104 @@ cubedbusAddParticleObject (CubedbusObject *obj, CompOption *option, int nOption)
particleData->emitter->prev = NULL;
particleData->emitter->head = particleData->emitter->tail = NULL;
particleData->emitter->nParticles=0;
- particleData->emitter->compFxParticleEmitterStepProc = &compFxParticleEmitterStepColour;
+
+ particleData->emitter->compFxParticleEmitterStepProc = &compFxParticleEmitterStepSoft;
+ particleData->emitter->particleInfo = malloc (sizeof(CompFxParticleEmitterParticleDataInfo));
+ particleData->emitter->nParticleInfo =1 ;
+
+
+ CompFxParticleEmitterParticleDataInfo *particle = particleData->emitter->particleInfo;
+
+ particle->compFxParticleDrawProc = &compFxParticleDrawColour;
+ particle->compFxParticleMoveProc = &compFxParticleMoveConstantAcceleration;
+ particle->compFxParticleDeathProc = &compFxParticleDeathTimeout;
+
+ particle->nDataSets=7;
+ particle->dataSets = malloc (sizeof (CompFxParticleEmitterParticleDataSet) * particle->nDataSets);
+
+ particle->dataSets[0].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[0].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[0].name, "position");
+ particle->dataSets[0].data->data = malloc (sizeof (CompFxParticleData) * 3);
+
+ particle->dataSets[1].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[1].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[1].name, "velocity");
+ particle->dataSets[1].data->data = malloc (sizeof (CompFxParticleData) * 3);
+ particle->dataSets[1].data->compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
+
+ particle->dataSets[2].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[2].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[2].name, "colour");
+ particle->dataSets[2].data->data = malloc (sizeof (CompFxParticleData) * 3); /* XXX should be RGBA not just RGB */
+
+ particle->dataSets[3].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[3].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[3].name, "timeout");
+ particle->dataSets[3].data->data = malloc (sizeof (CompFxParticleData) * 1);
+
+ particle->dataSets[4].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[4].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[4].name, "life");
+ particle->dataSets[4].data->data = malloc (sizeof (CompFxParticleData) * 1);
+
+ particle->dataSets[5].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[5].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[5].name, "dList");
+ particle->dataSets[5].data->data = malloc (sizeof (CompFxParticleData) * 1);
+
+ particle->dataSets[6].data = malloc (sizeof (CompFxParticleEmitterParticleData));
+ particle->dataSets[6].name= malloc (sizeof (char) * 12);
+ strcpy (particle->dataSets[6].name, "acceleration");
+ particle->dataSets[6].data->data = malloc (sizeof (CompFxParticleData) * 3);
+
+
+ CompFxParticleEmitterParticleData *particleDataUnion = particle->dataSets[5].data;
+ CompFxParticleData *dta = particleDataUnion->data;
+ dta[0].u=glGenLists (1);
+ glNewList (dta[0].u, GL_COMPILE);
+
+ glBegin(GL_TRIANGLES);
+
+ glVertex3f (0,0,0);
+ glVertex3f (0,0.01,0);
+ glVertex3f (0.01,0,0);
+
+ glEnd();
+ glEndList();
+
+ particleDataUnion = particle->dataSets[2].data;
+ dta = particleDataUnion->data;
+ dta[0].f=0.75+0.25*((double) rand() / ((double) RAND_MAX+1));
+ dta[1].f=0.25*((double) rand() / ((double) RAND_MAX+1));
+ dta[2].f=0.25*((double) rand() / ((double) RAND_MAX+1));
+
+ particleDataUnion = particle->dataSets[1].data;
+ dta = particleDataUnion->data;
+ dta[0].f= .00125-(0.0025 * (double) rand() / ((double) RAND_MAX+1));
+ dta[1].f= (0.0050 * (double) rand() / ((double) RAND_MAX+1));
+ dta[2].f= .00125-(0.0025 * (double) rand() / ((double) RAND_MAX+1));
+
+ particleDataUnion = particle->dataSets[3].data;
+ dta = particleDataUnion->data;
+ dta[0].l = 600;
+
+ particleDataUnion = particle->dataSets[4].data;
+ dta = particleDataUnion->data;
+ dta[0].l = 0;
+
+ particleDataUnion = particle->dataSets[0].data;
+ dta = particleDataUnion->data;
+ dta[0].f=0;
+ dta[1].f=0;
+ dta[2].f=0;
+
+ particleDataUnion = particle->dataSets[6].data;
+ dta = particleDataUnion->data;
+ dta[0].f=0;
+ dta[1].f=-0.000025;
+ dta[2].f=0;
+
return TRUE;
diff --git a/particleFx/death.c.in b/particleFx/death.c.in
index 0b99977..9dbdc85 100644
--- a/particleFx/death.c.in
+++ b/particleFx/death.c.in
@@ -9,7 +9,7 @@ compFxParticleDestroy (CompFxParticle *particle)
for(i=0; i<particle->nDataSets; i++)
{
- free(particle->dataSets[i].name);
+ //free(particle->dataSets[i].name); /* should be done by emitter as it should be a pointer to location in emitters memory */
free(particle->dataSets[i].data);
}
diff --git a/particleFx/emitter.c.in b/particleFx/emitter.c.in
index fb52560..5aaceaf 100644
--- a/particleFx/emitter.c.in
+++ b/particleFx/emitter.c.in
@@ -57,7 +57,8 @@ compFxParticleInitiate (CompFxParticle *particle, CompFxParticleEmitterParticleD
static void
compFxParticleEmitterAddDataStandard (CompFxParticleData *particleData, CompFxParticleEmitterParticleData *emitterData)
{
- memcpy(particleData, emitterData->data, sizeof( CompFxParticleData));
+ particleData=emitterData->data;
+ //memcpy(particleData, *emitterData->data, sizeof( CompFxParticleData));
}
diff --git a/particleFx/particleFxPrework b/particleFx/particleFxPrework
index 3392385..3929ab3 100644
--- a/particleFx/particleFxPrework
+++ b/particleFx/particleFxPrework
@@ -110,6 +110,14 @@ static CompFxParticleDataSet
*compFxParticleFindDataSet (char *name, CompFxParticle *particle, int start) //start is used for optimization
{
int i;
+
+ char *test,*test1,*test2,*test3;
+ test=particle->dataSets[0].name;
+
+ test1=particle->emitter->particleInfo[0].dataSets[0].name;
+ test2=particle->emitter->particleInfo[0].dataSets[1].name;
+ test3=particle->emitter->particleInfo[0].dataSets[2].name;
+
for(i=start; i< particle->nDataSets; i++)
{
if(!strcmp(particle->dataSets[i].name, name))