changeset 1344:fbe51e90993a draft

collada file reader try various test.but it is incorrect move.
author Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
date Fri, 13 Jan 2012 08:56:49 +0900
parents e4a65e0be060
children 95de5f81924d
files Renderer/Engine/SceneGraphRoot.cc
diffstat 1 files changed, 57 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.cc	Fri Jan 13 03:58:49 2012 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Fri Jan 13 08:56:49 2012 +0900
@@ -6,6 +6,7 @@
 #include "TextureHash.h"
 #include "texture.h"
 #include "Application.h"
+#include "polygon.h"
 
 static int cnt = 0;
 static const int SGLIST_LENGTH = 138;
@@ -15,6 +16,7 @@
 
 static TextureHash sgid_hash;
 
+
 SceneGraphRoot *sgroot;
 
 SceneGraphRoot::SceneGraphRoot(float w, float h, TaskManager *manager)
@@ -368,6 +370,7 @@
 
     }
     int polylist;
+    int library_images;
 
     xmlChar *pid;
 
@@ -394,10 +397,55 @@
     int polylist_count;
  
     char *name;
+    char *tex_picname;
 };
 
+static texture_list list[TABLE_SIZE];
+static texture_list *texture_info;
 
+void get_texpic(char *filename, SceneGraphPtr sg,  xmlNodePtr cur, TaskManager *manager)
+{
+    char image_name[20] = "/tmp/image_XXXXXX";
+    if (filename == NULL || filename[0] == 0) {
+        return;
+    }
 
+    /**
+     * image_name を既に Load していれば何もしない
+     */
+    int tex_id;
+    /* ball test */
+    if (sgid_hash.sg_hash_regist(/*filename*/"Ball", tex_id) == -1) {
+
+        SDL_Surface *texture_image = sg->load_decode_image(filename, image_name, cur);
+	    if (texture_image==0) {
+	    printf("Can't load image %s\n",filename);
+	    exit(0);
+	    }
+        texture_info->texture_id = sg->makeTapestries(manager, texture_image, tex_id);
+	    tex_id = texture_info->texture_id;
+
+        if (unlink(image_name)) {
+            printf("unlink error\n");
+        }
+    } else {
+        /**
+         * 以前に Load されている Texture を共用
+         */
+        texture_info->texture_id = tex_id;
+    }
+
+      // こんなことすると list[] のいみあるのかなーと
+      // 微妙に思う、自分で書き換えた感想 by gongo
+      texture_info->t_w = list[tex_id].t_w;
+      texture_info->t_h = list[tex_id].t_h;;
+      texture_info->pixels_orig = list[tex_id].pixels_orig;
+      texture_info->pixels = list[tex_id].pixels;
+      texture_info->scale_max = list[tex_id].scale_max;
+      texture_info->texture_image = list[tex_id].texture_image;
+
+}
+ 
 void decode_float_array(xmlNodePtr cur,LIST_P list ){ 
     SOURCE_P src = (SOURCE_P)malloc(sizeof(SOURCE));
     char *id = (char*)xmlGetProp(cur, (xmlChar*)"id");
@@ -545,6 +593,9 @@
         printf("vertexp = %d\n", vertexp[i]);
         //printf("vertex_table= %f\n", vertex_table[i]);
     } 
+    int tex_id;
+    sgid_hash.sg_hash_regist("Ball", tex_id);
+    //get_texpic(s->tex_picname, sg, cur , manager);
     //free(vertexp);
     //free(vertex_table);
     //free(normal_table);
@@ -570,6 +621,12 @@
         in_polylist=1;
     } else if (!xmlStrcmp(cur->name, (xmlChar*)"vertices")) {
         s->pid = xmlGetProp(cur, (xmlChar*)"id");
+    } else if (!xmlStrcmp(cur->name, (xmlChar*)"library_images")) {
+        s->library_images=1;// library_images is wrote at texture image name. only use one image file
+    } else if (s->library_images && !xmlStrcmp(cur->name, (xmlChar*)"init_from")) { 
+        s->tex_picname = (char*)xmlGetProp(cur, (xmlChar*)"init_from");
+        printf("------------------%s",s->tex_picname);
+        s->library_images=0;
     } else if (!s->polylist && !xmlStrcmp(cur->name, (xmlChar*)"input")) {
         char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic");
         if (!xmlStrcmp((xmlChar*)semantic, (xmlChar*)"POSITION")) {