summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@JOEL-UBUNTU.(none)>2007-12-17 18:14:42 +0900
committerJoel Bosveld <joel@JOEL-UBUNTU.(none)>2007-12-17 18:14:42 +0900
commit0329214a30fc05819af3b9cdb12f3a1444cca153 (patch)
tree9be7fb22070a41840fe919f6f9f3ac4a611ce7c5
parentedab27b4c1725d8cf558eba873129e4e700918dc (diff)
downloadcubedbus-0329214a30fc05819af3b9cdb12f3a1444cca153.tar.gz
cubedbus-0329214a30fc05819af3b9cdb12f3a1444cca153.tar.bz2
Seperate string (for mtllib, v, etc) at tabs as well as spaces
-rw-r--r--cubedbusModel.c.in72
1 files changed, 40 insertions, 32 deletions
diff --git a/cubedbusModel.c.in b/cubedbusModel.c.in
index 78c9633..c95b744 100644
--- a/cubedbusModel.c.in
+++ b/cubedbusModel.c.in
@@ -86,6 +86,8 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
int nTexture=0;
int nMtllib=0;
+ char delim[]={' ','\t','\0'};
+
/* First pass - count how much data we need to store */
@@ -99,7 +101,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
while((strline=getLine(fp))!=NULL)
{
tmpType = malloc ( sizeof (char *) * 2);
- tmpType[0]=strsep(&strline," ");
+ tmpType[0]=strsep(&strline,delim);
if(tmpType[0] == NULL)
{
@@ -116,7 +118,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
{
while(1)
{
- tmpType[1]=strsep(&strline," ");
+ tmpType[1]=strsep(&strline,delim);
if(tmpType[1]==NULL) break;
if(!strcmp(tmpType[1],"")) continue;
nMtllib++;
@@ -152,7 +154,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
while((strline=getLine(fp))!=NULL)
{
tmpType = malloc ( sizeof (char *));
- tmpType[0]=strsep(&strline," ");
+ tmpType[0]=strsep(&strline,delim);
if(tmpType[0] == NULL)
{
compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "Error reading file...");
@@ -162,26 +164,26 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
if(!strcmp(tmpType[0], "v"))
{
- vertex[nVertex].x=atof(strsep(&strline," "));
- vertex[nVertex].y=atof(strsep(&strline," "));
- vertex[nVertex].z=atof(strsep(&strline," "));
+ vertex[nVertex].x=atof(strsep(&strline,delim));
+ vertex[nVertex].y=atof(strsep(&strline,delim));
+ vertex[nVertex].z=atof(strsep(&strline,delim));
nVertex++;
}
if(!strcmp(tmpType[0], "vn"))
{
- normal[nNormal].x=atof(strsep(&strline," "));
- normal[nNormal].y=atof(strsep(&strline," "));
- normal[nNormal].z=atof(strsep(&strline," "));
+ normal[nNormal].x=atof(strsep(&strline,delim));
+ normal[nNormal].y=atof(strsep(&strline,delim));
+ normal[nNormal].z=atof(strsep(&strline,delim));
nNormal++;
}
if(!strcmp(tmpType[0], "vt"))
{
- texture[nTexture].x=atof(strsep(&strline," "));
- texture[nTexture].y=atof(strsep(&strline," "));
+ texture[nTexture].x=atof(strsep(&strline,delim));
+ texture[nTexture].y=atof(strsep(&strline,delim));
nTexture++;
}
@@ -190,7 +192,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
{
while(1)
{
- mtllib[nMtllib]=strsep(&strline," ");
+ mtllib[nMtllib]=strsep(&strline,delim);
if(mtllib[nMtllib] == NULL) break;
if(!strcmp(mtllib[nMtllib],"")) continue; /* if blank override next time */
nMtllib++;
@@ -238,7 +240,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
{
/* code to move stuff to array */
tmpType = malloc ( sizeof (char *) * 4);
- tmpType[0]=strsep(&strline," ");
+ tmpType[0]=strsep(&strline,delim);
if(tmpType[0] == NULL)
{
@@ -248,7 +250,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
}
if(!strcmp(tmpType[0], "newmtl"))
{
- tmpType[1]=strsep(&strline," ");
+ tmpType[1]=strsep(&strline,delim);
if(tmpType[1] == NULL)
{
compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "Error reading file...");
@@ -272,39 +274,39 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
}
if(!strcmp(tmpType[0], "Ka"))
{
- mtlPtr->Ka[0]=atof(strsep(&strline," "));
- mtlPtr->Ka[1]=atof(strsep(&strline," "));
- mtlPtr->Ka[2]=atof(strsep(&strline," "));
+ mtlPtr->Ka[0]=atof(strsep(&strline,delim));
+ mtlPtr->Ka[1]=atof(strsep(&strline,delim));
+ mtlPtr->Ka[2]=atof(strsep(&strline,delim));
}
if(!strcmp(tmpType[0], "Kd"))
{
- mtlPtr->Kd[0]=atof(strsep(&strline," "));
- mtlPtr->Kd[1]=atof(strsep(&strline," "));
- mtlPtr->Kd[2]=atof(strsep(&strline," "));
+ mtlPtr->Kd[0]=atof(strsep(&strline,delim));
+ mtlPtr->Kd[1]=atof(strsep(&strline,delim));
+ mtlPtr->Kd[2]=atof(strsep(&strline,delim));
}
if(!strcmp(tmpType[0], "Ks"))
{
- mtlPtr->Ks[0]=atof(strsep(&strline," "));
- mtlPtr->Ks[1]=atof(strsep(&strline," "));
- mtlPtr->Ks[2]=atof(strsep(&strline," "));
+ mtlPtr->Ks[0]=atof(strsep(&strline,delim));
+ mtlPtr->Ks[1]=atof(strsep(&strline,delim));
+ mtlPtr->Ks[2]=atof(strsep(&strline,delim));
}
if(!strcmp(tmpType[0], "illum"))
{
- mtlPtr->illum=atoi(strsep(&strline," "));
+ mtlPtr->illum=atoi(strsep(&strline,delim));
}
if(!strcmp(tmpType[0], "Tr") || !strcmp(tmpType[0], "d"))
{
- mtlPtr->Ka[4]=mtlPtr->Kd[4]=mtlPtr->Ks[4]=atof(strsep(&strline," "));
+ mtlPtr->Ka[4]=mtlPtr->Kd[4]=mtlPtr->Ks[4]=atof(strsep(&strline,delim));
}
if(!strcmp(tmpType[0], "Ns"))
{
- mtlPtr->Ns[0]=atof(strsep(&strline," "));
+ mtlPtr->Ns[0]=atof(strsep(&strline,delim));
}
if(!strcmp(tmpType[0], "map_Ka")) /* XXX map_Kd and map_Ks */
{
mtlPtr->tex=malloc(sizeof(CompTexture));
- tmpType[1]=strsep(&strline," ");
+ tmpType[1]=strsep(&strline,delim);
if(mtlPtr->tex == NULL)
{
@@ -363,7 +365,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
return FALSE;
}
- tmpType[0]=strsep(&strline," ");
+ tmpType[0]=strsep(&strline,delim);
if(tmpType[0] == NULL)
{
compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "Error reading file...");
@@ -388,7 +390,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
}
tmpType=tempInfo;
- tmpType[polyCount]=strsep(&strline," ");
+ tmpType[polyCount]=strsep(&strline,delim);
if(tmpType[polyCount] == NULL)
{
//free(strline);
@@ -436,7 +438,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
return FALSE;
}
tmpType=tempInfo;
- tmpType[1]=strsep(&strline," ");
+ tmpType[1]=strsep(&strline,delim);
if(tmpType[1]== NULL)
{
//free(strline);
@@ -450,7 +452,7 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
{
if(mtlPtr==NULL)
{
- compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "couldn't find material");
+ compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "couldn't find material: %s", tmpType[1]);
mtlPtr=modelData->head;
break;
}
@@ -493,7 +495,13 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
fclose (fp);
-
+
+ if(mtlPtr->tex != NULL)
+ {
+ disableTexture (obj->s, mtlPtr->tex);
+ compLogMessage(obj->s->display, "cubedbus", CompLogLevelWarn, "disable last texture");
+ }
+
glEndList();
return TRUE;