summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mikos <david@FAMILYCOMPUTER.(none)>2008-02-17 11:46:59 +1030
committerDavid Mikos <david@FAMILYCOMPUTER.(none)>2008-02-17 11:46:59 +1030
commit4f26d204f464f9977bd5ff636ff764ee964b646b (patch)
treedab38f4c5efefc21a598bbd640ec353da5f7eac0
parent57816c4ddc1c993db786d2cadb492c327d4e9b5c (diff)
downloadcubedbus-4f26d204f464f9977bd5ff636ff764ee964b646b.tar.gz
cubedbus-4f26d204f464f9977bd5ff636ff764ee964b646b.tar.bz2
Make animatedModel.sh executable. Add pre/post strings to animation filename.
-rw-r--r--cubedbusModel.c.in60
-rwxr-xr-x[-rw-r--r--]scripts/animatedModel.sh2
2 files changed, 28 insertions, 34 deletions
diff --git a/cubedbusModel.c.in b/cubedbusModel.c.in
index 3e5ab06..472e4f3 100644
--- a/cubedbusModel.c.in
+++ b/cubedbusModel.c.in
@@ -16,7 +16,7 @@ static bool cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int
static bool cubedbusDrawVBOModel (CubedbusObject *obj, float *vertex, float *normal);
static int
-addNumToString (char *, unsigned int, int, unsigned int, unsigned int);
+addNumToString (char *, unsigned int, int, char *, char *, unsigned int, unsigned int);
static int
addVertex (unsigned int **indices, int nUniqueIndices, int iTexture, int iNormal);
@@ -82,9 +82,9 @@ int fileCounter;
Bool animation;
int fps;
-vect3d **reorderedVertex; //not used yet
-vect3d **reorderedNormal; //to be replaced
-vect3d **reorderedTexture; //not used yet
+vect3d **reorderedVertex;
+vect3d **reorderedNormal;
+vect3d **reorderedTexture;
unsigned int * indices;
groupIndices *group;
@@ -150,6 +150,9 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
int i, j;
+ char *pre = getStringOptionNamed(option, nOption, "pre", "");
+ char *post = getStringOptionNamed(option, nOption, "post", "");
+
char *strline = NULL;
char *oldStrline = NULL;
char *tmpType;
@@ -238,7 +241,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
do {
if (animation)
- size = addNumToString (filename, size, lenBaseFilename, startFileNum+fileCounter, maxNumZeros);
+ size = addNumToString (filename, size, lenBaseFilename, pre, post, startFileNum+fileCounter, maxNumZeros);
fp = fopen(filename, "r");
if (fp!=NULL) {
@@ -290,16 +293,13 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
/* First pass - count how much data we need to store */
if (animation)
- size = addNumToString (filename, size, lenBaseFilename, startFileNum+fc, maxNumZeros);
+ size = addNumToString (filename, size, lenBaseFilename, pre, post, startFileNum+fc, maxNumZeros);
fp = fopen(filename, "r");
if (fp == NULL)
{
compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn,
- "Failed to open model file");
- compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn,
- filename);
-
+ "Failed to open model file - %s", filename);
return FALSE;
}
@@ -775,7 +775,6 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
if (tmpPtr!=NULL) {
vertexIndex = atoi(tmpPtr);
- //printf ("v: %d, ", vertexIndex);
if (vertexIndex>0)
{
if (vertexIndex > modelData->nVertex) /* skip vertex index past last in obj file */
@@ -796,7 +795,6 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
tmpPtr=strsep(&tmpType, "/");
if (tmpPtr!=NULL && complexity!=0) { /* texture */
if (strcmp(tmpPtr, "")) {
- //printf ("t: %d, ", atoi(tmpPtr));
textureIndex = atoi(tmpPtr);
if (textureIndex>0)
@@ -898,8 +896,6 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
else
modelData->indices[nIndices] = tmpInd;
- //printf("Actually got here. %i, %i, %i\n", nIndices, nUniqueIndices, vertexIndex);
-
nIndices++;
polyCount++;
}
@@ -909,7 +905,6 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
if (updateGroup && fc==0)
{
- //printf ("\n");
if (polyCount!=0 && ( polyCount!=oldPolyCount
|| usingNormal!=oldUsingNormal || usingTexture!=oldUsingTexture
|| loadingMaterial ) )
@@ -920,8 +915,6 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
nGroups++;
- //printf ("polyCount = %d\n", polyCount);
- //printf ("usingNormal = %d\n", usingNormal);
modelData->group = (groupIndices *) realloc (modelData->group, (nGroups)*sizeof(groupIndices));
modelData->group[nGroups-1].polyCount = polyCount;
modelData->group[nGroups-1].complexity = complexity;
@@ -1024,7 +1017,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
}
static int
-addNumToString (char * s, unsigned int size, int offset, unsigned int x, unsigned int maxNumZeros)
+addNumToString (char * s, unsigned int size, int offset, char *pre, char *post, unsigned int x, unsigned int maxNumZeros)
{
int c = 0;
int numZeros = 0;
@@ -1038,25 +1031,30 @@ addNumToString (char * s, unsigned int size, int offset, unsigned int x, unsigne
if (maxNumZeros>c)
numZeros = maxNumZeros - c;
- if (offset+c+numZeros+1>size) {
- size = offset+1+c+numZeros+4+1;
+ int j = offset+strlen(pre)+c+numZeros+strlen(post)+4+1;
+ if (j>size) {
+ size = j;
s = (char *) realloc(s, size*sizeof(char));
}
- s[offset] = '_';
+ for (j=0; j<strlen(pre); j++)
+ s[offset+j] = pre[j];
while (i<numZeros) {
- s[offset+1+i] = '0';
+ s[offset+strlen(pre)+i] = '0';
i++;
}
- sprintf(s+offset+numZeros+1, "%d", x);
+ sprintf(s+offset+strlen(pre)+numZeros, "%d", x);
+
+ for (j=0; j<strlen(post); j++)
+ s[offset+strlen(pre)+c+numZeros+j] = post[j];
- s[offset+1+c+numZeros] = '.';
- s[offset+1+c+numZeros+1] = 'o';
- s[offset+1+c+numZeros+2] = 'b';
- s[offset+1+c+numZeros+3] = 'j';
- s[offset+1+c+numZeros+4] = '\0';
+ s[offset+strlen(pre)+c+numZeros+strlen(post)] = '.';
+ s[offset+strlen(pre)+c+numZeros+strlen(post)+1] = 'o';
+ s[offset+strlen(pre)+c+numZeros+strlen(post)+2] = 'b';
+ s[offset+strlen(pre)+c+numZeros+strlen(post)+3] = 'j';
+ s[offset+strlen(pre)+c+numZeros+strlen(post)+4] = '\0';
return size;
@@ -1073,8 +1071,6 @@ addVertex (unsigned int **indices, int nUniqueIndices, int iTexture, int iNormal
(*indices)[2] = iNormal;
(*indices)[3] = nUniqueIndices; /* ptr to the new unique vertex index */
- //printf ("indices == NULL\n");
-
return -1; /* new vertex/texture/normal */
}
int i;
@@ -1083,8 +1079,7 @@ addVertex (unsigned int **indices, int nUniqueIndices, int iTexture, int iNormal
{
if ((*indices)[1+3*i]==iTexture && (*indices)[2+3*i]==iNormal)
{
- //printf ("\n-- %i, %i --\n", (*indices)[1+3*i], (*indices)[2+3*i]);
- return (*indices)[3+3*i];
+ return (*indices)[3+3*i]; /* found same vertex/texture/normal before */
}
}
*indices = realloc ( *indices, ( 1+3*((*indices)[0]+1) )*sizeof(int) );
@@ -1168,7 +1163,6 @@ cubedbusDrawModelObject (CubedbusObject *obj)
if (data->fileCounter==0)
return TRUE;
- /*FIX - this is for when the mtl file is not found or overridden */
glEnable (GL_COLOR_MATERIAL);
glColor4fv (data->color);
diff --git a/scripts/animatedModel.sh b/scripts/animatedModel.sh
index d22b6c2..54fc9db 100644..100755
--- a/scripts/animatedModel.sh
+++ b/scripts/animatedModel.sh
@@ -1,3 +1,3 @@
-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:5 string:'name' string:'root.model' string:'file' string:$1 string:'rotateY' double:1.0 string:'rotateSpeed' double:1.0 string:'animation' boolean:true string:'r' double:1.0 string:'g' double:1.0 string:'b' double:1.0 string:'a' double:1.0 string:'scale' double:1 string:'numZeros' int32:2 string:'fps' int32:15 string:'start' int32:0
+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:5 string:'name' string:'root.model' string:'file' string:$1 string:'rotateY' double:1.0 string:'rotateSpeed' double:1.0 string:'animation' boolean:true string:'r' double:1.0 string:'g' double:1.0 string:'b' double:1.0 string:'a' double:1.0 string:'scale' double:1.0 string:'numZeros' int32:2 string:'fps' int32:15 string:'start' int32:0 string:'pre' string:'_' string:'post' string:''
#Run this in terminal - accepts as argument 1 .obj file