changeset 1315:c0a5a9abff9c draft

improve collada file reader.
author Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
date Fri, 16 Dec 2011 15:39:42 +0900
parents a62cde2aaf7c
children 53f6855985f6
files Renderer/Engine/SceneGraphRoot.cc
diffstat 1 files changed, 86 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.cc	Thu Dec 15 22:53:33 2011 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Fri Dec 16 15:39:42 2011 +0900
@@ -318,17 +318,30 @@
 {
     SOURCE_P cur = list->first;
     for (;cur ; cur=cur->next) {
-        if (!strcmp_a(id, cur->name)) {
+        if (!strcmp_a(id, cur->id)) {
             if (list->count == 0) //alias 
                 return get_point(list->u.alias, position, list);
             float *a = cur->u.array;
             if (position <= list->count) {
                 return a[position];
             }
-        }
+       }
     }
 }
 
+static SOURCE
+must_mach_id(const char *id_1 ,const char *id_2)
+{
+    int tmplength;
+    char *tmpsrc;
+    for (int strlength=0;normal_id[i+1]==cur->id[i];str_length++); 
+    if (tmplength < strlength) {
+         tmplength = strlength;
+         tmpsrc = cur;
+    }
+    return cur;
+}
+
 static int polylist=0;
 static const char *polylist_normal=0;
 static const char *polylist_vertex=0;
@@ -339,34 +352,84 @@
 {
 
     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")) {
+        int polylist_count = atoi((char*)xmlGetProp(cur, (xmlChar*)"source"));
+
         polylist=1;
         in_polylist=1;
     }
 
+    if (!xmlStrcmp(cur->name, (xmlChar*)"vertices") {
+            char *vertices_src = (char*)xmlGetProp(cur, (xmlChar*)"source");
+
+            char *pid = (char*)xmlGetProp(cur, (xmlChar*)"id");
+            float *vcount = malloc(sizeof(int)*count);
+            float *pcount = malloc(sizeof(float)*sum); 
+
+
+    }
     if (polylist && !xmlStrcmp(cur->name, (xmlChar*)"input") {
-            char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic");
-            if (!xmlStrcmp(semantic, (xmlChar*)"VERTEX") {
-                char *vertex_id = (char*)xmlGetProp(cur, (xmlChar*)"source");
-                int vertex_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset"));
-            }
-            get_point(vertex_id, , cur);
+         char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic");
+         if (semantic == "VERTEX") {
+             char *vertex_src = (char*)xmlGetProp(cur, (xmlChar*)"source");
+             int vertex_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset"));
+             
+             if (vertex_src == pid) {
+                SOURCE *vertex_float = must_mach_id(vertices_src, pid) 
+             }
+
+        }
 
-            if (!xmlStrcmp(semantic, (xmlChar*)"NORMAL") {
-                char *normal_id = (char*)xmlGetProp(cur, (xmlChar*)"source");
-                int normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset"));
+        if (semantic == "NORMAL") {
+            char *normal_src = (char*)xmlGetProp(cur, (xmlChar*)"source");
+            int normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset"));
+            
+                SOURCE *normal_float = must_mach_id(normal_src, cur->id);
+        }
+    
+        /*
+        if (semantic == "TEXCOORD") {
+             char *normal_src = (char*)xmlGetProp(cur, (xmlChar*)"id");
+             int *normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset"));
+        }
+        */
+        
+        if (!xmlStrcmp(cur->name, (xmlChar*)"vcount")) {
+            char *vcont = (char*)xmlNodeGetContent(cur);
+            for (int i=0; vcount!=NULL; i++) {
+                 vcont = pickup_float(vcont, vcount+i);
             }
-            /*
-            if (!xmlStrcmp(semantic, (xmlChar*)"TEXTURE") {
-                char *normal_id = (char*)xmlGetProp(cur, (xmlChar*)"id");
-                int *normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset"));
+        }
+        
+        if (!xmlStrcmp(cur->name, (xmlChar*)"p")) {
+            char *pcont = (char*)xmlNodeGetContent(cur);
+            for (int i=0; pcont != NULL; i++) {
+                pcont = pickup_float(pcont, pcount+i);
             }
-            */
+        }
+
+        get_point(pid, , cur);
+
+        for (int i = 0; i<polylist_count; i++) {
+            vertex[i] = pcount[i];
+            normal[i] = pcount[i+1];
+        }
+        
+        if (vcount == 4) {
+
+        } else if (vcount == 3) {
+
+        }
+               
+
+    }       
             
-    } else if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) {
+            
+    if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) {
 
         SOURCE_P src = (SOURCE_P)malloc(sizeof(SOURCE));
         
@@ -389,12 +452,9 @@
         addSource(list, src);
         printf("id:%s count:%d cont:%s\n", id, count, cont);
         
-        if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) {
-            char *p = (char*)xmlNodeGetContent(cur);
-            printf("p:%s", p);
-        }
-        
-    } else if (!xmlStrcmp(cur->name, (xmlChar*)"vertices") {
+    }
+    /*
+    if (!xmlStrcmp(cur->name, (xmlChar*)"vertices") {
 
             char *pid = (char*)xmlGetProp(cur, (xmlChar*)"id");
             float *vcount = malloc(sizeof(int)*count);
@@ -414,6 +474,7 @@
                 }
             }
         }
+    
 
         get_point(pid, , cur);
 
@@ -429,6 +490,7 @@
             }
         }
     }
+    */
 
     
     for (cur=cur->children; cur; cur=cur->next){