changeset 1347:a6373ea9a669 draft

separate decode_points
author e095732 <e095732@ie.u-ryukyu.ac.jp>
date Tue, 17 Jan 2012 16:44:10 +0900
parents ef3864bb2776
children f8cabb739697
files Renderer/Engine/SceneGraphRoot.cc
diffstat 1 files changed, 24 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.cc	Mon Jan 16 17:24:23 2012 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Tue Jan 17 16:44:10 2012 +0900
@@ -368,11 +368,11 @@
 	texcoord_count = 0; 
 	
 	polylist_count = 0;
+	vcsum = 0;
 
     }
     int polylist;
     int library_images;
-
     xmlChar *pid;
 
     char *vertex_src;
@@ -399,7 +399,8 @@
  
     char *name;
     char *tex_picname;
-};
+    int vcsum;
+}; 
 
 static texture_list list[TABLE_SIZE];
 static texture_list *texture_info;
@@ -472,22 +473,23 @@
 
 
 void 
-decode_points(xmlNodePtr cur, collada_state *s, TaskManager *manager){
+get_points(xmlNodePtr cur, collada_state *s, TaskManager *manager){
     printf("start decode points\n");
     char *pcont = (char*)xmlNodeGetContent(cur);
-    int vcsum = 0;
     for (int i = 0;i < s->polylist_count;i++){
-       vcsum += s->vcount[i];
+       s->vcsum += s->vcount[i];
     }
 
     //s->pcount = (float*)malloc(sizeof(float)*vcsum);
-    s->pcount = new float[vcsum];
+    s->pcount = new float[s->vcsum];
     for (int i=0; pcont != NULL; i++) {
         pcont = pickup_float(pcont, s->pcount+i);
     }
-
-    int vertexp[vcsum];
-    for (int i=0;i<vcsum;i++){
+}
+void
+decode_points(xmlNodePtr cur, collada_state *s, TaskManager *manager){
+    int vertexp[s->vcsum];
+    for (int i=0;i<s->vcsum;i++){
        vertexp[i]=0;
     }
     //float *vertex_table;
@@ -506,9 +508,9 @@
     //texcoord_table = new float[s->texcoord_float->count];
     //float *texcoord_table = (float*)malloc(sizeof(float)*s->texcoord_float->count) ;
 
-    int limit = vcsum * 2;
+    int limit = s->vcsum * 2;
     if (s->texcoord_offset == 2){
-        limit = vcsum * 3;
+        limit = s->vcsum * 3;
     }
 
     /* p separate vertex position and nomal position. */
@@ -521,7 +523,7 @@
 	}
     }
 
-    for (int i=0;i<vcsum;i++) {
+    for (int i=0;i<s->vcsum;i++) {
         if (s->vcount[i] == 4) {
 	    for (int j=0; j < s->vcount[i]; j++) {
 	        vertex_table[i] = s->vertex_float->u.array[vertexp[i]];
@@ -534,12 +536,15 @@
     }
     /**
      * (SceneGraph.cc)
-     * pickup_normal,pickup_coordinate,pickup_textureの処理に当たる
+     * pickup_normal,pickup_coordinate,pickup_textureの処理
+     * vcsumは頂点の数,countは面の数
      */
-    int count = vcsum / 3; 
+    int count = s->vcsum / 3; 
+    //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];
     
     for (int i = 0;i < sg->pp_num; i++ ){
         PolygonPackPtr pp = sg->pp;
@@ -590,11 +595,11 @@
     sg->c_xyz[0] = sg->c_xyz[1] = sg->c_xyz[2] = 0;
     
     /*TEST*/
-    for (int i=0; i<vcsum; i++) {
+    for (int i=0; i<s->vcsum; i++) {
         printf("vertexp = %d\n", vertexp[i]);
-        //printf("vertex_table= %f\n", vertex_table[i]);
+        //printf("vertex_table= %f\n", s->vertex_table[i]);
     } 
-    int tex_id;
+    int tex_id = 0;
     sgid_hash.sg_hash_regist("Ball", tex_id);
     //get_texpic(s->tex_picname, sg, cur , manager);
     //free(vertexp);
@@ -657,12 +662,13 @@
 	    vcont = pickup_float(vcont, s->vcount+i);
         }
     } else if (!xmlStrcmp(cur->name, (xmlChar*)"p")) {
-        decode_points(cur,s,root->tmanager);
+        get_points(cur,s,root->tmanager);
 	in_polylist = 0;
     } else if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) {
         decode_float_array(cur,list);
     } else if (!xmlStrcmp(cur->name, (xmlChar*)"node" )) {
         s->name = (char*)xmlGetProp(cur, (xmlChar*)"id");
+	decode_points(cur,s,root->tmanager);
     }
     for (cur=cur->children; cur; cur=cur->next){
         xml_walk(cur,s,list,root);