changeset 1307:5b1589ce972e draft

improve collada file reader.
author Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
date Wed, 14 Dec 2011 19:39:43 +0900
parents 6542098e127c
children 78248082c56d
files Renderer/Engine/SceneGraphRoot.cc
diffstat 1 files changed, 35 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.cc	Wed Dec 14 16:41:07 2011 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Wed Dec 14 19:39:43 2011 +0900
@@ -293,6 +293,7 @@
 } LIST;
 typedef LIST *LIST_P;
 
+/* add source list */
 static void
 addSource(LIST_P list, SOURCE_P src) {
     if (list->first == NULL && list->end == NULL) {
@@ -303,6 +304,7 @@
     list->end = src;
 }
 
+/* compare a with b. Using to compare id */
 static int
 strcmp_a(const char *a, const char *b)
 {
@@ -318,7 +320,7 @@
     for (;cur ; cur=cur->next) {
         if (!strcmp_a(id, cur->name)) {
             if (list->count == 0) //alias
-                return get_point(list->.alias, position, list);
+                return get_point(list->u.alias, position, list);
             float *a = cur->u.array;
             if (position <= list->count) {
                 return a[position];
@@ -333,7 +335,7 @@
 
 
 static void 
-xml_walk( SceneGraphRoot* self, xmlNodePtr cur, LIST_P list)
+xml_walk(SceneGraphRoot* self, xmlNodePtr cur, LIST_P list)
 {
 
     int in_polylist=0;
@@ -347,7 +349,24 @@
 
     if (polylist && !xmlStrcmp(cur->name, (xmlChar*)"input") {
             char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic");
-            if (xmlStrcmp(semantic, (xmlChar*)"VERTEX")
+            if (!xmlStrcmp(semantic, (xmlChar*)"VERTEX") {
+                char *vertex_id = (char*)xmlGetProp(cur, (xmlChar*)"source");
+                int *vertex_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset"));
+            }
+
+            if (!xmlStrcmp(semantic, (xmlChar*)"NORMAL") {
+                char *normal_id = (char*)xmlGetProp(cur, (xmlChar*)"id");
+                int *normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset"));
+            }
+            /*
+            if (!xmlStrcmp(semantic, (xmlChar*)"TEXTURE") {
+                char *normal_id = (char*)xmlGetProp(cur, (xmlChar*)"id");
+                int *normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset"));
+            }
+            */
+
+            get_point( , , );
+
     }
 
     if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) {
@@ -369,7 +388,6 @@
             cont = pickup_float(cont, src->array+i);
         }
 
-
         src->next = NULL;
         addSource(list, src);
         printf("id:%s count:%d cont:%s\n", id, count, cont);
@@ -382,25 +400,29 @@
     } else if (!xmlStrcmp(cur->name, (xmlChar*)"vertices") {
 
             char *pid = (char*)xmlGetProp(cur, (xmlChar*)"id");
+            float *vcount = malloc(sizeof(int)*count);
+            float *pcount = malloc(sizeof(float)*sum); 
+
+            if (!xmlStrcmp(cur->name, (xmlChar*)"vcount")) {
+                char *vcount_cont = (char*)xmlNodeGetContent(cur);
+                    for (int i=0; vcount!=NULL; i++) {
+                        vcount = pickup_float(vcount, p+i);
+                    }
+            }
 
             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);
+                for (int i=0; pcont != NULL; i++) {
+                    pcount = 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) {
 
                 }
@@ -435,7 +457,7 @@
 	/*エラー処理……だけど何書けばいいのか謎。とりあえず-1返してみる*/
 	if(xmlStrcmp(cur->name, (xmlChar*)"COLLADA")){
 		return ;
-       }
+     }
 
 	/* node analyze */
 	for(cur=cur->children; cur; cur=cur->next){