Mercurial > hg > Game > Cerium
changeset 1327:c2f9b2492a31 draft
minor change collada file reader.
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 20 Dec 2011 18:46:50 +0900 |
parents | 68373985b251 |
children | 0f41ff4ca2ab |
files | Renderer/Engine/SceneGraphRoot.cc |
diffstat | 1 files changed, 23 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.cc Tue Dec 20 13:08:51 2011 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Tue Dec 20 18:46:50 2011 +0900 @@ -338,7 +338,7 @@ int tmplength; int strlength; for (cur=list->first ;cur!=list->end ;cur=cur->next) { - for (strlength=0;id[strlength+1]==cur->id[strlength];strlength++); + for (strlength=0;id[strlength]==cur->id[strlength];strlength++); if (tmplength < strlength) { tmplength = strlength; src = cur; @@ -363,6 +363,10 @@ int normal_offset; int normal_count; + char *texcoord_src; + int texcoord_offset; + int texcoord_count; + float *vcount; float *pcount; @@ -409,15 +413,21 @@ s->vertex_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); s->vertex_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); - s->vertex_float = most_match(s->vertices_src, list); + s->vertex_float = most_match(s->vertices_src+1, list); } else if (!xmlStrcmp((xmlChar*)semantic, (xmlChar*)"NORMAL")) { s->normal_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); s->normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); - s->normal_float = most_match(s->normal_src, list); - } + s->normal_float = most_match(s->normal_src+1, list); + } else if (!xmlStrcmp((xmlChar*)semantic, (xmlChar*)"TEXCOORD")) { + + s->texcoord_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); + s->texcoord_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); + s->texcoord_float = most_match(s->normal_src+1, list); + } + } else if (!xmlStrcmp(cur->name, (xmlChar*)"vcount")) { char *vcont = (char*)xmlNodeGetContent(cur); @@ -446,9 +456,12 @@ float *normal_table = (float*)malloc(sizeof(float)*s->normal_float->count) ; /* p separate vertex position and nomal position. */ - for (int i = 0; i < s->polylist_count; i++) { - vertexp[i] = s->pcount[2*i]; - normal_table[i] = s->normal_float->u.array[(int)s->pcount[2*i+1]]; + for (int i = 0; i < s->polylist_count; i+=2) { + vertexp[i] = s->pcount[i]; + normal_table[i] = s->normal_float->u.array[(int)s->pcount[i+1]]; + if (texcoord_offset < 0) { + i++; + } } for (int i=0; vertexp[i];i++) { @@ -468,6 +481,9 @@ printf("vertex_table= %f\n", vertex_table[i]); } + free(vertex_table); + free(normal_table); + /* got out of polylist */ s->polylist = 0; in_polylist = 0;