changeset 1384:207e0ed76cf1 draft

minor changes.
author e095732 <e095732@ie.u-ryukyu.ac.jp>
date Fri, 27 Jan 2012 02:10:52 +0900
parents fa3d77953998
children 2247b81dd68f 20a09f7522a7
files Renderer/Engine/Collada.cc Renderer/Test/collada.cc
diffstat 2 files changed, 42 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Collada.cc	Fri Jan 27 02:03:57 2012 +0900
+++ b/Renderer/Engine/Collada.cc	Fri Jan 27 02:10:52 2012 +0900
@@ -239,9 +239,7 @@
     src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count"));
     src->u.array = new float[src->count];
     char *cont =(char*)xmlNodeGetContent(cur);
-    //const char *id = get_property("id", cur);
-    //int count = atoi(get_property("count", cur));
-    
+
     /* store float inpoint list */
     for (int i = 0; cont != NULL; i++) {
         cont = pickup_float(cont, src->u.array+i);
@@ -338,7 +336,7 @@
      * pickup_normal,pickup_coordinate,pickup_textureの処理
      * vcsumは頂点の数,countは面の数
      */
-    //int count = s->vcsum / 3; 
+   
     int count = size / 3;
     //polygonの作成
     sg->pp_num = (count + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE;
@@ -354,7 +352,8 @@
 	pp[i].info.size = tri_size;
     /* default texture peste */
     if (s->images_flag==0) {
-        get_texture_image("../Test/xml_file/blend/images/ball.jpg", sg, (xmlNodePtr)NULL, manager);
+        char *default_image = "../Test/xml_file/blend/images/ball.jpg"; 
+        get_texture_image(default_image, sg, (xmlNodePtr)NULL, manager);
     }
 	int k = 0;
 	int m = 0;
@@ -397,10 +396,7 @@
 	
     }
     sg->c_xyz[0] = sg->c_xyz[1] = sg->c_xyz[2] = 0;
-    
-    //int tex_id = 0;
-    //sgid_hash.sg_hash_regist(s->name, tex_id);
- 
+
     delete []vertexp;
     delete []vertex_table;
     delete []normal_table;
@@ -415,8 +411,6 @@
 xml_walk(xmlNodePtr cur, struct collada_state *s, LIST_P list,SceneGraphPtr sg, SceneGraphRoot *root)
 {
     int in_polylist=0;
-    //printf("name = %s, child:%s\n", (char *)cur->name, (char *)cur->children);
-    //printf("s->polylist = %d\n",s->polylist);
     if (!xmlStrcmp(cur->name, (xmlChar*)"polylist")) {
         s->polylist_count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count"));
         s->polylist=1;
@@ -429,7 +423,6 @@
     } else if (s->library_images && !xmlStrcmp(cur->name, (xmlChar*)"init_from")) { 
         s->tex_picname = (char*)xmlGetProp(cur, (xmlChar*)"init_from");
         get_texture_image(s->tex_picname, sg, cur , root->tmanager);
-        printf("------------------%s",s->tex_picname);
         s->library_images=0;
         s->images_flag=1;
     } else if (!s->polylist && !xmlStrcmp(cur->name, (xmlChar*)"input")) {
@@ -483,8 +476,6 @@
     /*make parse dom*/
     xmlDocPtr doc;
     xmlNodePtr cur;
-    //,cur_images,cur_effects,cur_geometries,cur_visual_scenes;
-    //SceneGraphPtr tmp;
     
     doc = xmlParseFile(xmlColladafile);
     cur = xmlDocGetRootElement(doc);
--- a/Renderer/Test/collada.cc	Fri Jan 27 02:03:57 2012 +0900
+++ b/Renderer/Test/collada.cc	Fri Jan 27 02:10:52 2012 +0900
@@ -30,25 +30,25 @@
     Pad *pad = sgroot->getController();
 
     if (pad->circle.isHold()) {
-		if (pad->left.isHold()) {
-			node->xyz[0] -= speed;
-			if(node->xyz[0] < ball_radius)
-				node->xyz[0] = ball_radius;
-		} else if (pad->right.isHold()) {
-			node->xyz[0] += speed;
-			if(node->xyz[0] > screen_w  - ball_radius)
-				node->xyz[0] = screen_w - ball_radius;
-		}
-
-		if (pad->up.isHold()) {
-			node->xyz[1] -= speed;
-		} else if (pad->down.isHold()) {
-			node->xyz[1] += speed;
+        if (pad->left.isHold()) {
+	    node->xyz[0] -= speed;
+	    if(node->xyz[0] < ball_radius)
+	        node->xyz[0] = ball_radius;
+	} else if (pad->right.isHold()) {
+	    node->xyz[0] += speed;
+	    if(node->xyz[0] > screen_w  - ball_radius)
+	        node->xyz[0] = screen_w - ball_radius;
+	}
+	
+	if (pad->up.isHold()) {
+	    node->xyz[1] -= speed;
+	} else if (pad->down.isHold()) {
+	    node->xyz[1] += speed;
             if(node->xyz[1] > screen_h - ball_radius)
-				node->xyz[1] = screen_h - ball_radius;
-		}
+	        node->xyz[1] = screen_h - ball_radius;
+	}
     } else {
-		node->set_move_collision(ball_move, ball_collision);
+        node->set_move_collision(ball_move, ball_collision);
     }
 }
 
@@ -61,28 +61,28 @@
     Pad *pad = sgroot->getController();
 
     if (pad->circle.isPush()) {
-		node->set_move_collision(ball_move_idle2, ball_collision_idle);
-		time_val = 0;
+        node->set_move_collision(ball_move_idle2, ball_collision_idle);
+	time_val = 0;
     }
 
     time_val++;
 
     if (time_val > 90) {
-		float w = (float)random();
-      
-		w = fmodf(w, screen_w - ball_radius*2);
-		node->xyz[0] = w + ball_radius;
-		node->xyz[1] = h0;
-		node->set_move_collision(ball_move, ball_collision);
-		time_val = 0;
+        float w = (float)random();
+	
+	w = fmodf(w, screen_w - ball_radius*2);
+	node->xyz[0] = w + ball_radius;
+	node->xyz[1] = h0;
+	node->set_move_collision(ball_move, ball_collision);
+	time_val = 0;
     }
 }
 
 static void
 ball_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
-  vy += g * dt;
-   node->xyz[1] += vy * dt;
+    vy += g * dt;
+    node->xyz[1] += vy * dt;
     //    node->xyz[0] += 10.0f;
 }
 
@@ -95,15 +95,15 @@
 ball_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 			   SceneGraphPtr tree)
 {
-  if (node->xyz[1] > screen_h - ball_radius) {
-  		node->xyz[1] = screen_h - ball_radius;
-  
-  		vy *= e;
-  		if (vy > -g && vy < 0) {
-  			vy = 0.0;
-  			node->set_move_collision(ball_move_idle, ball_collision_idle);
-  		}
-  }
+    if (node->xyz[1] > screen_h - ball_radius) {
+        node->xyz[1] = screen_h - ball_radius;
+	
+	vy *= e;
+	if (vy > -g && vy < 0) {
+	    vy = 0.0;
+	    node->set_move_collision(ball_move_idle, ball_collision_idle);
+	}
+    }
 }
 
 static const char *collada_file="collada_file/ball.dae";
@@ -127,7 +127,6 @@
     light->xyz[0] = screen_w / 2;
     light->xyz[1] = screen_h / 2;
     light->xyz[2] = -100;
-    printf("createSceneGraph\n");
     ball = sgroot->createSceneGraph(name);
     ball->set_move_collision(ball_move, ball_collision);