summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@joel-desktop.(none)>2008-01-19 20:41:14 +0900
committerJoel Bosveld <joel@joel-desktop.(none)>2008-01-19 20:41:14 +0900
commitff0148b81e8bd975018e750f2502b63b2529126f (patch)
tree5c00b17cd6443828d25679210c044c8722010f47
parentb349b226a165e91b905d00f66f61e8151bd54075 (diff)
downloadcubedbus-ff0148b81e8bd975018e750f2502b63b2529126f.tar.gz
cubedbus-ff0148b81e8bd975018e750f2502b63b2529126f.tar.bz2
Fixed emitter to use new named data sets
Also added script, and added some error checking (won't crash if it can't find data set)
-rw-r--r--particleFx/death.c.in2
-rw-r--r--particleFx/draw.c.in4
-rw-r--r--particleFx/emitter.c.in64
-rw-r--r--particleFx/move.c.in2
-rw-r--r--particleFx/particleFxPrework11
-rwxr-xr-xscripts/particle.sh2
6 files changed, 59 insertions, 26 deletions
diff --git a/particleFx/death.c.in b/particleFx/death.c.in
index d105626..0b99977 100644
--- a/particleFx/death.c.in
+++ b/particleFx/death.c.in
@@ -32,6 +32,8 @@ compFxParticleDeathTimeout (CompFxParticle *particle)
CompFxParticleDataSet *timeout = compFxParticleFindDataSet ("timeout", particle, 0);
CompFxParticleDataSet *life = compFxParticleFindDataSet ("life", particle, 0);
+ if(timeout ==NULL || life==NULL) return;
+
life->data[0].l++;
if (life->data[0].l >= timeout->data[0].l)
diff --git a/particleFx/draw.c.in b/particleFx/draw.c.in
index d46ee71..407214f 100644
--- a/particleFx/draw.c.in
+++ b/particleFx/draw.c.in
@@ -7,9 +7,11 @@ compFxParticleDrawColour (CompFxParticle *particle)
CompFxParticleDataSet *position = compFxParticleFindDataSet ("position", particle, 0);
CompFxParticleDataSet *dList = compFxParticleFindDataSet ("dList", particle, 0);
+ if( colour==NULL || position == NULL || dList ==NULL) return;
+
glTranslatef (position->data[0].f, position->data[1].f, position->data[2].f); /* x, y, z */
glColor3f (colour->data[0].f, colour->data[1].f, colour->data[2].f); /* r, g, b */
- glCallList( (GLuint) dlist->data[0].u); /* dList */
+ glCallList( (GLuint) dList->data[0].u); /* dList */
}
diff --git a/particleFx/emitter.c.in b/particleFx/emitter.c.in
index 58e9966..3c10057 100644
--- a/particleFx/emitter.c.in
+++ b/particleFx/emitter.c.in
@@ -32,10 +32,10 @@ compFxParticleCreateEmitterColour (CompFxParticleEmitter *emitter)
{
CompFxParticle *particle = NULL;
- if(emitter->nParticles >= 1000)
+ if(emitter->nParticles >= 100) /* XXX should be a variable in emitter */
{
}
- else if( (particle = compFxParticleCreate (emitter)) == NULL) /* this function sets up the emitter, next, prev and baseData fields */
+ else if( (particle = compFxParticleCreate (emitter)) == NULL) /* this function sets up the emitter, next, and prev fields */
{
compLogMessage (NULL, "particleFX", CompLogLevelWarn, "Creating particle failed - memory error");
}
@@ -43,23 +43,37 @@ compFxParticleCreateEmitterColour (CompFxParticleEmitter *emitter)
{
emitter->nParticles++;
- particle->compFxParticleDrawProc = &compFxParticleDrawColour;
- particle->drawData = malloc (sizeof (CompFxParticleDrawColourData));
+ particle->nDataSets=6;
+ particle->dataSets = malloc (sizeof (CompFxParticleDataSet) * particle->nDataSets);
- particle->compFxParticleMoveProc = &compFxParticleMoveLinear;
- particle->moveData = malloc (sizeof (CompFxParticleMoveLinearData));
+ particle->dataSets[0].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[0].name, "position");
+ particle->dataSets[0].data = malloc (sizeof (CompFxParticleData) * 3);
- particle->compFxParticleDeathProc = &compFxParticleDeathTimeout;
- particle->deathData = malloc (sizeof (CompFxParticleDeathTimeoutData));
+ particle->dataSets[1].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[1].name, "velocity");
+ particle->dataSets[1].data = malloc (sizeof (CompFxParticleData) * 3);
- CompFxParticleDrawColourData *draw = particle->drawData;
- CompFxParticleMoveLinearData *move = particle->moveData;
- CompFxParticleDeathTimeoutData *death = particle->deathData;
+ particle->dataSets[2].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[2].name, "colour");
+ particle->dataSets[2].data = malloc (sizeof (CompFxParticleData) * 3); /* XXX should be RGBA not just RGB */
+ particle->dataSets[3].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[3].name, "timeout");
+ particle->dataSets[3].data = malloc (sizeof (CompFxParticleData) * 1);
+
+ particle->dataSets[4].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[4].name, "life");
+ particle->dataSets[4].data = malloc (sizeof (CompFxParticleData) * 1);
+
+ particle->dataSets[5].name= malloc (sizeof (char) * 10);
+ strcpy (particle->dataSets[5].name, "dList");
+ particle->dataSets[5].data = malloc (sizeof (CompFxParticleData) * 1);
+
/* XXX Generate dList XXX*/
- draw->dList=glGenLists (1);
- glNewList (draw->dList, GL_COMPILE);
+ particle->dataSets[5].data[0].u=glGenLists (1);
+ glNewList (particle->dataSets[5].data[0].u, GL_COMPILE);
glBegin(GL_TRIANGLES);
@@ -70,15 +84,25 @@ compFxParticleCreateEmitterColour (CompFxParticleEmitter *emitter)
glEnd();
glEndList();
- draw->r=(double) rand() / ((double) RAND_MAX+1);
- draw->g=(double) rand() / ((double) RAND_MAX+1);
- draw->b=(double) rand() / ((double) RAND_MAX+1);
+ particle->dataSets[2].data[0].f=(double) rand() / ((double) RAND_MAX+1);
+ particle->dataSets[2].data[1].f=(double) rand() / ((double) RAND_MAX+1);
+ particle->dataSets[2].data[2].f=(double) rand() / ((double) RAND_MAX+1);
+
+ particle->dataSets[1].data[0].f= .00125-(0.0025 * (double) rand() / ((double) RAND_MAX+1));
+ particle->dataSets[1].data[1].f= (0.0050 * (double) rand() / ((double) RAND_MAX+1));
+ particle->dataSets[1].data[2].f= .00125-(0.0025 * (double) rand() / ((double) RAND_MAX+1));
- move->vx= .00125-(0.0025 * (double) rand() / ((double) RAND_MAX+1));
- move->vy= (0.0050 * (double) rand() / ((double) RAND_MAX+1));
- move->vz= .00125-(0.0025 * (double) rand() / ((double) RAND_MAX+1));
+ particle->dataSets[3].data[0].l = 600;
+ particle->dataSets[4].data[0].l = 0;
+
+ particle->dataSets[0].data[0].f=0;
+ particle->dataSets[0].data[1].f=0;
+ particle->dataSets[0].data[2].f=0;
+
+ particle->compFxParticleDrawProc = &compFxParticleDrawColour;
+ particle->compFxParticleMoveProc = &compFxParticleMoveLinear;
+ particle->compFxParticleDeathProc = &compFxParticleDeathTimeout;
- death->timeout = 600;
}
}
diff --git a/particleFx/move.c.in b/particleFx/move.c.in
index 85bc2cc..819dbc3 100644
--- a/particleFx/move.c.in
+++ b/particleFx/move.c.in
@@ -6,6 +6,8 @@ compFxParticleMoveLinear (CompFxParticle *particle)
CompFxParticleDataSet *position = compFxParticleFindDataSet ("position", particle, 0);
CompFxParticleDataSet *velocity = compFxParticleFindDataSet ("velocity", particle, 0);
+ if(position==NULL || velocity==NULL) return;
+
position->data[0].f += velocity->data[0].f; /* x += vx */
position->data[1].f += velocity->data[0].f; /* y += vy */
position->data[2].f += velocity->data[0].f; /* z += vz */
diff --git a/particleFx/particleFxPrework b/particleFx/particleFxPrework
index b59a09f..6b23f98 100644
--- a/particleFx/particleFxPrework
+++ b/particleFx/particleFxPrework
@@ -1,11 +1,11 @@
/* Definitions */
-typedef struct _CompFxParticle CompFxParticle;
+typedef struct _CompFxParticle CompFxParticle;
typedef struct _CompFxParticleEmitter CompFxParticleEmitter;
typedef struct _CompFxParticleDataSet CompFxParticleDataSet;
-typedef union _CompFxParticleData CompFxParticleData;
+typedef union _CompFxParticleData CompFxParticleData;
-static CompFxParticleDataSet *compFxParticleFindDataSet (char *name, CompFxParticle *particle, int start)
+static CompFxParticleDataSet *compFxParticleFindDataSet (char *name, CompFxParticle *particle, int start);
/* Structs for particle system */
@@ -70,7 +70,8 @@ static CompFxParticleDataSet
{
return &(particle->dataSets[i]);
}
-
+ }
+
for(i=0; i< start; i++)
{
if(!strcmp(particle->dataSets[i].name, name))
@@ -78,7 +79,7 @@ static CompFxParticleDataSet
return &(particle->dataSets[i]);
}
}
-
+
return NULL;
}
diff --git a/scripts/particle.sh b/scripts/particle.sh
new file mode 100755
index 0000000..8f69164
--- /dev/null
+++ b/scripts/particle.sh
@@ -0,0 +1,2 @@
+dbus-send --type=method_call --dest=org.freedesktop.compiz /org/freedesktop/compiz/cubedbus/allscreens/add org.freedesktop.compiz.activate string:'root' int32:`xwininfo -root | grep id: | awk '{ print $4 }'` string:'type' int32:6 string:'name' string:'root.particle'
+