Mercurial > hg > Game > Cerium
changeset 1358:db8bba42ad80 draft
minor changes.
author | e095732 <e095732@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 19 Jan 2012 21:18:11 +0900 |
parents | d532204d76c1 |
children | 842e04373d3a |
files | Renderer/Engine/SceneGraphRoot.cc |
diffstat | 1 files changed, 16 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.cc Thu Jan 19 20:10:29 2012 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Thu Jan 19 21:18:11 2012 +0900 @@ -232,9 +232,6 @@ doc = xmlParseFile(xmlfile); cur = xmlDocGetRootElement(doc); - /* ?? */ - xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); - /* XMLのノードを一つずつ解析 */ for (cur=cur->children; cur; cur=cur->next) { /*初期化:curをドキュメントルートの一個下に設定 @@ -456,7 +453,6 @@ int count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); - //src->u.array = (float*)malloc(sizeof(float)*src->count); src->u.array = new float[src->count]; char *cont =(char*)xmlNodeGetContent(cur); //const char *id = get_property("id", cur); @@ -496,7 +492,6 @@ decode_points(xmlNodePtr cur, collada_state *s, TaskManager *manager){ int *vertexp; vertexp = new int[s->vcsum]; - //int vertexp[s->vcsum]; for (int i=0;i<s->vcsum;i++){ vertexp[i]=0; } @@ -506,18 +501,27 @@ vertex_table = new float[s->vcsum]; normal_table = new float[s->vcsum]; texcoord_table = new float[s->vcsum]; + for (int i=0;i < s->vcsum;i++){ + vertex_table[i] = 0; + normal_table[i] = 0; + texcoord_table[i] = 0; + } /** * s->vcsum と s->vertex_float->countの値が違うので大きい方をとりあえず使っておく */ /* p separate vertex position and nomal position. */ - for (int i=0,j=0; i < s->limit; i+=2,j++) { - vertexp[j] = (int)s->pcount[i]; - normal_table[j] = s->normal_float->u.array[(int)s->pcount[i+1]]; - if (s->texcoord_offset == 2) { + if (s->texcoord_offset == 2){ + for (int i=0,j=0; i < s->limit; i+=3,j++) { + vertexp[j] = (int)s->pcount[i]; + normal_table[j] = s->normal_float->u.array[(int)s->pcount[i+1]]; texcoord_table[j] = s->texcoord_float->u.array[(int)s->pcount[i+2]]; - i++; + } + } else{ + for (int i=0,j=0; i < s->limit; i+=2,j++) { + vertexp[j] = (int)s->pcount[i]; + normal_table[j] = s->normal_float->u.array[(int)s->pcount[i+1]]; } } @@ -541,8 +545,7 @@ //polygonの作成 SceneGraphPtr sg = new SceneGraph(manager); sg->pp_num = (count + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE; - sg->pp = (PolygonPack*)malloc(sizeof(PolygonPack)*sg->pp_num); - //sg->pp = new PolygonPack[sg->pp_num]; + sg->pp = new PolygonPack[sg->pp_num]; for (int i = 0;i < sg->pp_num; i++ ){ PolygonPackPtr pp = sg->pp; @@ -646,7 +649,6 @@ } } else if (!xmlStrcmp(cur->name, (xmlChar*)"vcount")) { char *vcont = (char*)xmlNodeGetContent(cur); - //s->vcount = (float*)malloc(sizeof(float)*s->polylist_count); s->vcount = new float[s->polylist_count]; for (int i=0; vcont!=NULL; i++) { /* store vcount list */ @@ -695,7 +697,7 @@ xml_walk(cur,&s,&list,this); } registSceneGraph(decode_points(cur,&s,manager)); - //xmlFreeDoc(doc); + xmlFreeDoc(doc); } void @@ -709,9 +711,6 @@ doc = xmlParseMemory(data, len); cur = xmlDocGetRootElement(doc); - /* ?? */ - xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); - /* XMLのノードを一つずつ解析 */ for (cur=cur->children; cur; cur=cur->next) { /* 扱うのはsurfaceオンリー */ @@ -849,9 +848,6 @@ light_vector[i*4+3] = light_vector_tmp[i*4+3]; } - - - } }