Mercurial > hg > Game > Cerium
changeset 1305:b8248a728fc0 draft
improve collada file reader.
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Dec 2011 16:35:56 +0900 |
parents | b606adda63fe |
children | 6542098e127c |
files | Renderer/Engine/SceneGraphRoot.cc |
diffstat | 1 files changed, 73 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.cc Tue Dec 13 19:01:32 2011 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Wed Dec 14 16:35:56 2011 +0900 @@ -278,8 +278,11 @@ typedef struct source { char *id; + union { + float *array; + char *alias; + }u; int count; - float *array; struct source *next; } SOURCE; typedef SOURCE *SOURCE_P; @@ -300,12 +303,53 @@ list->end = src; } +static int +strcmp_a(const char *a, const char *b) +{ + while (*a && *a++ = *b++); + if (*a) return 0; + return a[-1] > b[-1] ? 1:-1; +} + +static float +get_point(char *id, int position, LIST_P list) +{ + SOURCE_P cur = list->first; + for (;cur ; cur=cur->next) { + if (!strcmp_a(id, cur->name)) { + if (list->count == 0) //alias + return get_point(list->.alias, position, list); + float *a = cur->u.array; + if (position <= list->count) { + return a[position]; + } + } + } +} + +static int polylist=0; +static const char *polylist_normal=0; +static const char *polylist_vertex=0; + + static void xml_walk( SceneGraphRoot* self, xmlNodePtr cur, LIST_P list) { + int in_polylist=0; /*get float array.*/ printf("name = %s, child:%s\n", (char *)cur->name, (char *)cur->children); + + if (!xmlStrcmp(cur->name, (xmlChar*)"polylist")) { + polylist=1; + in_polylist=1; + } + + if (polylist && !xmlStrcmp(cur->name, (xmlChar*)"input") { + char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic"); + if (xmlStrcmp(semantic, (xmlChar*)"VERTEX") + } + if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { SOURCE_P src = (SOURCE_P)malloc(sizeof(SOURCE)); @@ -322,9 +366,6 @@ //int count = atoi(get_property("count", cur)); for (int i = 0; cont != NULL; i++) { - - //cont = pickup_float(cont, src->array+1); - // ここ+1じゃなくて、+iじゃない? cont = pickup_float(cont, src->array+i); } @@ -338,7 +379,35 @@ printf("p:%s", p); } + } else if (!xmlStrcmp(cur->name, (xmlChar*)"vertices") { + + char *pid = (char*)xmlGetProp(cur, (xmlChar*)"id"); + + if (!xmlStrcmp(cur->name, (xmlChar*)"p")) { + char *pcont = (char*)xmlNodeGetContent(cur); + float *p = malloc(sizeof(float)*sum); + + for (int i=0; contp != NULL; i++) { + pcont = pickup_float(pcont, p+i); + } + } + } + + if (!xmlStrcmp(cur->name, (xmlChar*)"vcount")) { + int *vcount = malloc(sizeof(int)*count); + } + + for (SOURCE *iliner = list->first; list->end != iliner; iliner = iliner->next) { + if (!strcmp_a(pid, iliner->id)) { + if (vcount == 4) { + + } else if (vcount == 3) { + + } + } + } } + for (cur=cur->children; cur; cur=cur->next){ xml_walk(self, cur, list);