summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@joel-desktop.(none)>2008-01-28 20:51:10 +0900
committerJoel Bosveld <joel@joel-desktop.(none)>2008-01-28 20:51:10 +0900
commita61cb3c0c1db4f459ff288e6eb42e4e7083a810a (patch)
tree978a4401255133fb09546ad4ebafa3c9bb43c9e9
parent3488db512ee238f131ad59f755288efd806fa338 (diff)
downloadcubedbus-a61cb3c0c1db4f459ff288e6eb42e4e7083a810a.tar.gz
cubedbus-a61cb3c0c1db4f459ff288e6eb42e4e7083a810a.tar.bz2
Add missing functionality
-rw-r--r--cubedbusParticle.c.in24
-rw-r--r--particleFx/emitter.c.in42
2 files changed, 57 insertions, 9 deletions
diff --git a/cubedbusParticle.c.in b/cubedbusParticle.c.in
index dd93975..d947132 100644
--- a/cubedbusParticle.c.in
+++ b/cubedbusParticle.c.in
@@ -142,12 +142,15 @@ cubedbusAddParticleObject (CubedbusObject *obj, CompOption *option, int nOption)
particle->dataSets[2].data = malloc (sizeof (CompFxParticleEmitterParticleData) * particle->dataSets[2].nData);
particle->dataSets[2].name= malloc (sizeof (char) * 10);
strcpy (particle->dataSets[2].name, "colour");
- particle->dataSets[2].data[0].compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
- particle->dataSets[2].data[1].compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
- particle->dataSets[2].data[2].compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataStandard;
- particle->dataSets[2].data[0].data = malloc (sizeof(CompFxParticleData));
- particle->dataSets[2].data[1].data = malloc (sizeof(CompFxParticleData));
- particle->dataSets[2].data[2].data = malloc (sizeof(CompFxParticleData));
+ particle->dataSets[2].data[0].compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataRandomComponent;
+ particle->dataSets[2].data[1].compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataRandomComponent;
+ particle->dataSets[2].data[2].compFxParticleEmitterAddDataProc = &compFxParticleEmitterAddDataRandomComponent;
+ particle->dataSets[2].data[0].data = malloc (sizeof(CompFxParticleData)*2);
+ particle->dataSets[2].data[0].type = CompFxParticleDataTypeFloat;
+ particle->dataSets[2].data[1].data = malloc (sizeof(CompFxParticleData)*2);
+ particle->dataSets[2].data[1].type = CompFxParticleDataTypeFloat;
+ particle->dataSets[2].data[2].data = malloc (sizeof(CompFxParticleData)*2);
+ particle->dataSets[2].data[2].type = CompFxParticleDataTypeFloat;
particle->dataSets[3].nData=1;
particle->dataSets[3].data = malloc (sizeof (CompFxParticleEmitterParticleData) * particle->dataSets[3].nData);
@@ -199,13 +202,16 @@ cubedbusAddParticleObject (CubedbusObject *obj, CompOption *option, int nOption)
particleDataUnion = &particle->dataSets[2].data[0];
dta = particleDataUnion->data;
- dta[0].f=0.75+0.25*((double) rand() / ((double) RAND_MAX+1));
+ dta[0].f=0.5;
+ dta[1].f=1;
particleDataUnion = &particle->dataSets[2].data[1];
dta = particleDataUnion->data;
- dta[0].f=0.25*((double) rand() / ((double) RAND_MAX+1));
+ dta[0].f=0.5;
+ dta[1].f=1;
particleDataUnion = &particle->dataSets[2].data[2];
dta = particleDataUnion->data;
- dta[0].f=0.25*((double) rand() / ((double) RAND_MAX+1));
+ dta[0].f=0.5;
+ dta[1].f=1;
particleDataUnion = &particle->dataSets[1].data[0];
diff --git a/particleFx/emitter.c.in b/particleFx/emitter.c.in
index 8f953ec..6607aa6 100644
--- a/particleFx/emitter.c.in
+++ b/particleFx/emitter.c.in
@@ -1,4 +1,46 @@
/* the data pointer under emitterData should point to a typedef'd union of type CompFxParticleData */
+/* will give a number between (a - b/2) and (a + b/2) */
+
+static void
+compFxParticleEmitterAddDataRandomComponent (CompFxParticleData *particleData, CompFxParticleEmitterParticleData *emitterData)
+{
+
+ switch(emitterData->type)
+ {
+ case CompFxParticleDataTypeFloat:
+ {
+ CompFxParticleData *data=emitterData->data;
+ particleData->f= data[0].f -(data[1].f)/2 + data[1].f * ((double) rand() / ((double) RAND_MAX+1));
+ break;
+ }
+ case CompFxParticleDataTypeInt:
+ {
+ CompFxParticleData *data=emitterData->data;
+ particleData->i= data[0].i -(data[1].i)/2 + data[1].i * ((double) rand() / ((double) RAND_MAX+1));
+ break;
+ }
+ case CompFxParticleDataTypeUnsigned:
+ {
+ CompFxParticleData *data=emitterData->data;
+ particleData->u= data[0].u -(data[1].u)/2 + data[1].u * ((double) rand() / ((double) RAND_MAX+1));
+ break;
+ }
+ case CompFxParticleDataTypeDouble:
+ {
+ CompFxParticleData *data=emitterData->data;
+ particleData->d= data[0].d -(data[1].d)/2 + data[1].d * ((double) rand() / ((double) RAND_MAX+1));
+ break;
+ }
+ case CompFxParticleDataTypeLong:
+ {
+ CompFxParticleData *data=emitterData->data;
+ particleData->l= data[0].l -(data[1].l)/2 + data[1].l * ((double) rand() / ((double) RAND_MAX+1));
+ break;
+ }
+ }
+}
+
+/* the data pointer under emitterData should be an array of CompFxParticleData */
static void
compFxParticleEmitterAddDataStandard (CompFxParticleData *particleData, CompFxParticleEmitterParticleData *emitterData)