summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@JOEL-UBUNTU.(none)>2007-12-15 23:25:44 +0900
committerJoel Bosveld <joel@JOEL-UBUNTU.(none)>2007-12-15 23:25:44 +0900
commitbe4a354fd29c15ce3a6239bf350a239bbb87df3c (patch)
treede1697b174f61b7a185986c8b48c0a99774917fa
parent97b7ad3bb10884b5878ca9e4dcb10f011a02ee3b (diff)
downloadcubedbus-be4a354fd29c15ce3a6239bf350a239bbb87df3c.tar.gz
cubedbus-be4a354fd29c15ce3a6239bf350a239bbb87df3c.tar.bz2
Fixed problem, should now load texture files
Note, in the .obj and .mtl file all filenames must be specified with full path - this will be changed soon (as I will calculate path from given obj file). Also ppm images will not work, you will need to convert these to png images (I plan on porting imagemagick plugin to master, in order to load ppm images)
-rw-r--r--cubedbusModel.c.in24
1 files changed, 9 insertions, 15 deletions
diff --git a/cubedbusModel.c.in b/cubedbusModel.c.in
index 1a9af15..bfed1b6 100644
--- a/cubedbusModel.c.in
+++ b/cubedbusModel.c.in
@@ -219,8 +219,6 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
mtlPtr->name=malloc(sizeof(char) * 5);
strcpy (mtlPtr->name, "fake");
-
-
/* XXX Parse MTL file and load textures XXX */
int mtlCount;
@@ -235,8 +233,6 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
mtllib[mtlCount], strerror(errno));
return FALSE;
}
-
- compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "Parsing file: %s",mtllib[mtlCount] );
while((strline=getLine(fp))!=NULL)
{
@@ -265,7 +261,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
mtlPtr->name=tmpType[1];
mtlPtr->next=NULL;
-
+
mtlPtr->Ka[0]=mtlPtr->Ka[1]=mtlPtr->Ka[2]=0.2; /* Set defaults */
mtlPtr->Kd[0]=mtlPtr->Kd[1]=mtlPtr->Kd[2]=0.8;
mtlPtr->Ks[0]=mtlPtr->Ks[1]=mtlPtr->Ks[2]=1.0;
@@ -310,8 +306,6 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
tmpType[1]=strsep(&strline," ");
- compLogMessage (obj->s->display, "cubedbus", CompLogLevelWarn, "%s", tmpType[1]);
-
if(mtlPtr->tex == NULL)
{
compLogMessage (obj->s->display, "cubedbus", CompLogLevelWarn, "CompTexture is not malloced properly");
@@ -449,26 +443,26 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "no mtl specified");
return FALSE;
}
-
+
if(mtlPtr->tex != NULL) disableTexture (obj->s, mtlPtr->tex);
- for(mtlPtr=modelData->head;; mtlPtr=mtlPtr->next)
+ for(mtlPtr=modelData->head; ; mtlPtr=mtlPtr->next)
{
if(mtlPtr==NULL)
{
- //compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "couldn't find material"); XXX
+ compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "couldn't find material");
mtlPtr=modelData->head;
break;
- }
+ }
+
if(!strcmp(tmpType[1], mtlPtr->name))
- {
+ {
if(mtlPtr->tex != NULL)
- {
+ {
glEnable(mtlPtr->tex->target);
enableTexture(obj->s, mtlPtr->tex,
COMP_TEXTURE_FILTER_GOOD);
}
-
if(mtlPtr->illum==0) glDisable(GL_LIGHTING);
else
{
@@ -573,7 +567,7 @@ getLine (FILE *fp)
strline=tmp; /* The strline array should now be big enough to hold all characters read so far, plus the one being read */
strline[n]=c;
- if(c=='\n' || c=='\0') /* the line is ended - return */
+ if(c=='\n' || c=='\0' || c=='\r' || c=='\t') /* the line is ended - return */
{
strline[n]='\0';
return strline;