summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@JOEL-UBUNTU.(none)>2007-12-11 21:27:25 +0900
committerJoel Bosveld <joel@JOEL-UBUNTU.(none)>2007-12-11 21:27:25 +0900
commit6f388b608e0026f703026880eb2f3c3e159f061e (patch)
treec86d662f43fc0fc69add2bc6da9323a9a81cd003
parentff96006ff009e4d814ce9a482a7877431d7c47e6 (diff)
downloadcubedbus-6f388b608e0026f703026880eb2f3c3e159f061e.tar.gz
cubedbus-6f388b608e0026f703026880eb2f3c3e159f061e.tar.bz2
Use dbus argument to specify texture "string:'texture'
string:'/path/to/texture' Added support for normals
-rw-r--r--cubedbusModel.c.in82
1 files changed, 63 insertions, 19 deletions
diff --git a/cubedbusModel.c.in b/cubedbusModel.c.in
index b002c97..1b9f936 100644
--- a/cubedbusModel.c.in
+++ b/cubedbusModel.c.in
@@ -205,6 +205,39 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
nVertex++;
}
+ if(!strcmp(tmpType[0], "vn"))
+ {
+ tmpType[1]=strsep(&strline," ");
+ if(tmpType[1] == NULL)
+ {
+ compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "Error reading file...");
+ //free(strline);
+ return FALSE;
+ }
+
+ tmpType[2]=strsep(&strline," ");
+ if(tmpType[2] == NULL)
+ {
+ compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "Error reading file...");
+ //free(strline);
+ return FALSE;
+ }
+
+ tmpType[3]=strsep(&strline," ");
+ if(tmpType[3] == NULL)
+ {
+ compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "Error reading file...");
+ //free(strline);
+ return FALSE;
+ }
+
+ normal[nNormal].x=atof(tmpType[1]);
+ normal[nNormal].y=atof(tmpType[2]);
+ normal[nNormal].z=atof(tmpType[3]);
+
+ nNormal++;
+ }
+
if(!strcmp(tmpType[0], "vt"))
{
texture[nTexture].x=0;
@@ -252,7 +285,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
compLogMessage (obj->s->display, "cubedbus", CompLogLevelWarn, "CompTexture is not malloced properly");
}
else if(!readImageToTexture (obj->s, modelData->tex, /*texture pointer*/
- "/home/joel/hand/hand.png", /*XXX*/ /*file*/
+ getStringOptionNamed (option, nOption, "texture", ""), /*XXX*/ /*file*/
&(modelData->width), /*pointer for width*/
&(modelData->height)) ) /*pointer for height*/
{
@@ -341,32 +374,39 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
vertNum=atoi(tempPtr);
- tempPtr=strsep(&tmpType[polyCount],"/");
- if(tempPtr == NULL)
- {
- //free(tmpType);
- break;
- }
+ if(nTexture)
+ {
+ tempPtr=strsep(&tmpType[polyCount],"/");
+ if(tempPtr == NULL)
+ {
+ //free(tmpType);
+ break;
+ }
- textNum=atoi(tempPtr);
-
- tempPtr=strsep(&tmpType[polyCount],"/");
- if(tempPtr == NULL)
- {
- //free(tmpType);
- break;
- }
+ textNum=atoi(tempPtr);
+ }
+
+ if(nNormal)
+ {
+ tempPtr=strsep(&tmpType[polyCount],"/");
+ if(tempPtr == NULL)
+ {
+ //free(tmpType);
+ break;
+ }
- normNum=atoi(tempPtr);
+ normNum=atoi(tempPtr);
+ }
/* XXX also need to do normal and tex coord */
if(modelData->tex != NULL)
{
glTexCoord2f (COMP_TEX_COORD_X (&(modelData->tex->matrix), (modelData->width-1) * (texture[textNum-1].x)),
COMP_TEX_COORD_Y (&(modelData->tex->matrix), (modelData->height-1) * (1-texture[textNum-1].y) ));
- }
+ }
+ if(nNormal) glNormal3f (normal[normNum-1].x,normal[normNum-1].y,normal[normNum-1].z);
glVertex3f (vertex[vertNum-1].x,vertex[vertNum-1].y,vertex[vertNum-1].z);
-
+
polyCount++ ;
}
@@ -427,8 +467,12 @@ cubedbusDrawModelObject (CubedbusObject *obj)
}
- glCallList(data->dList);
+ glDisable (GL_LIGHTING);
+ glCallList(data->dList);
+
+ glDisable (GL_LIGHTING);
+
if(data->tex != NULL) disableTexture (obj->s, data->tex);
data->rotate[0]+=data->rotateSpeed;