summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <joel@JOEL-UBUNTU.(none)>2007-12-11 20:08:20 +0900
committerJoel Bosveld <joel@JOEL-UBUNTU.(none)>2007-12-11 20:08:20 +0900
commitff96006ff009e4d814ce9a482a7877431d7c47e6 (patch)
treebaac8876cc19c54a705d03c099dd63e14f06ba8f
parent49d9308c827b3078ad0ae49f6fe8f2e0746e0f6f (diff)
downloadcubedbus-ff96006ff009e4d814ce9a482a7877431d7c47e6.tar.gz
cubedbus-ff96006ff009e4d814ce9a482a7877431d7c47e6.tar.bz2
Fixed textures (still no automatic loading of texture, the file is
hardcoded)
-rw-r--r--cubedbusModel.c.in24
1 files changed, 22 insertions, 2 deletions
diff --git a/cubedbusModel.c.in b/cubedbusModel.c.in
index f683a0a..b002c97 100644
--- a/cubedbusModel.c.in
+++ b/cubedbusModel.c.in
@@ -236,6 +236,8 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
fclose (fp);
int vertNum=0;
+ int textNum=0;
+ int normNum=0;
int polyCount;
char *tempPtr;
char **tempInfo;
@@ -339,11 +341,29 @@ cubedbusAddModelObject (CubedbusObject *obj, CompOption *option, int nOption)
vertNum=atoi(tempPtr);
+ tempPtr=strsep(&tmpType[polyCount],"/");
+ if(tempPtr == NULL)
+ {
+ //free(tmpType);
+ break;
+ }
+
+ textNum=atoi(tempPtr);
+
+ tempPtr=strsep(&tmpType[polyCount],"/");
+ if(tempPtr == NULL)
+ {
+ //free(tmpType);
+ break;
+ }
+
+ 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)*(texture[vertNum-1].x)),
- COMP_TEX_COORD_Y (&(modelData->tex->matrix), (modelData->height)*(1-texture[vertNum-1].y) ));
+ 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) ));
}
glVertex3f (vertex[vertNum-1].x,vertex[vertNum-1].y,vertex[vertNum-1].z);