changeset 548:8ff86ba6e1aa

modify applications not using SGid but SGname.
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Thu, 22 Oct 2009 16:47:49 +0900
parents c878c27678f4
children 6df27ea54d7b
files TaskManager/Test/test_render/Application/Chain.cc TaskManager/Test/test_render/Application/ball_bound.cc TaskManager/Test/test_render/Application/gaplant.cc TaskManager/Test/test_render/Application/gaplant_action.cc TaskManager/Test/test_render/Application/universe.cc TaskManager/Test/test_render/Application/untitled.cc TaskManager/Test/test_render/Application/vacuum.cc TaskManager/Test/test_render/Application/vacuum.h TaskManager/Test/test_render/SceneGraphRoot.cc
diffstat 9 files changed, 125 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Application/Chain.cc	Thu Oct 22 13:53:29 2009 +0900
+++ b/TaskManager/Test/test_render/Application/Chain.cc	Thu Oct 22 16:47:49 2009 +0900
@@ -213,8 +213,7 @@
     // 未実装
     char *data = {"1"};
     int len = 0;
-    sgroot->createFromXMLmemory(manager, data, len);
-    //sgroot->createFromXMLmemory(manager, "xml_file/chain.xml");
+    sgroot->createFromXMLfile(manager, "xml_file/chain.xml");
 
     /* SPE に送る property の配列の領域確保 */
     properties[0] = (ChainPropertyPtr)manager->allocate(sizeof(ChainProperty)*CHAIN_LEN);
--- a/TaskManager/Test/test_render/Application/ball_bound.cc	Thu Oct 22 13:53:29 2009 +0900
+++ b/TaskManager/Test/test_render/Application/ball_bound.cc	Thu Oct 22 16:47:49 2009 +0900
@@ -111,12 +111,10 @@
     // random な値が欲しいなら、man random に方法が書いてあります。
     srandom(100);
 
-    // 未実装
     char *data = {"1"};
     int len = 0;
-    sgroot->createFromXMLmemory(manager, data, len);
 
-    //sgroot->createFromXMLmemory(manager, "xml_file/Ball.xml");
+    sgroot->createFromXMLfile(manager, "xml_file/Ball.xml");
     ball = sgroot->createSceneGraph("Ball");
     ball->set_move_collision(ball_move, ball_collision);
 
--- a/TaskManager/Test/test_render/Application/gaplant.cc	Thu Oct 22 13:53:29 2009 +0900
+++ b/TaskManager/Test/test_render/Application/gaplant.cc	Thu Oct 22 16:47:49 2009 +0900
@@ -2,32 +2,116 @@
 #include "gaplant_action.h"
 #include "back_action.h"
 
+SceneGraphPtr
+create_gaplant() {
+    SceneGraphPtr base;
+    SceneGraphPtr p;
+
+    base = sgroot->createSceneGraph();
+
+p = sgroot->createSceneGraph("arm_L_D"          ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_L_B"         ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_L_E"         ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_L_C"         ), base->addChild(p);
+p = sgroot->createSceneGraph("shield_L_C"       ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_L_G"          ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_L_E"          ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_R_F"          ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_R_A"          ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_R_E"          ), base->addChild(p);
+p = sgroot->createSceneGraph("shoulder_R_C"     ), base->addChild(p);
+p = sgroot->createSceneGraph("shoulder_R_B"     ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_L_A"        ), base->addChild(p);
+p = sgroot->createSceneGraph("shoulder_R_A"     ), base->addChild(p);
+p = sgroot->createSceneGraph("head_E"           ), base->addChild(p);
+p = sgroot->createSceneGraph("shield_L_E"       ), base->addChild(p);
+p = sgroot->createSceneGraph("shield_L_D"       ), base->addChild(p);
+p = sgroot->createSceneGraph("shield_R_D"       ), base->addChild(p);
+p = sgroot->createSceneGraph("shield_L_A"       ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_R_C"          ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_R_B"          ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_L_C"          ), base->addChild(p);
+p = sgroot->createSceneGraph("eye"              ), base->addChild(p);
+p = sgroot->createSceneGraph("booster_B"        ), base->addChild(p);
+p = sgroot->createSceneGraph("booster_A"        ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_R_A"        ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_center_A"   ), base->addChild(p);
+p = sgroot->createSceneGraph("shoulder_L_A"     ), base->addChild(p);
+p = sgroot->createSceneGraph("body_A"           ), base->addChild(p);
+p = sgroot->createSceneGraph("body_B"           ), base->addChild(p);
+p = sgroot->createSceneGraph("body_C"           ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_center_B"   ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_R_C"        ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_L_C"        ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_L_B"        ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_R_B"        ), base->addChild(p);
+p = sgroot->createSceneGraph("west_D"           ), base->addChild(p);
+p = sgroot->createSceneGraph("west_A"           ), base->addChild(p);
+p = sgroot->createSceneGraph("west_B"           ), base->addChild(p);
+p = sgroot->createSceneGraph("body_L_A"         ), base->addChild(p);
+p = sgroot->createSceneGraph("body_R_A"         ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_center_C"   ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_B"          ), base->addChild(p);
+p = sgroot->createSceneGraph("head_C"           ), base->addChild(p);
+p = sgroot->createSceneGraph("head_F"           ), base->addChild(p);
+p = sgroot->createSceneGraph("head_D"           ), base->addChild(p);
+p = sgroot->createSceneGraph("head_R_B"         ), base->addChild(p);
+p = sgroot->createSceneGraph("head_L_B"         ), base->addChild(p);
+p = sgroot->createSceneGraph("head_L_A"         ), base->addChild(p);
+p = sgroot->createSceneGraph("head_R_A"         ), base->addChild(p);
+p = sgroot->createSceneGraph("head_B"           ), base->addChild(p);
+p = sgroot->createSceneGraph("head_A"           ), base->addChild(p);
+p = sgroot->createSceneGraph("shoulder_L_B"     ), base->addChild(p);
+p = sgroot->createSceneGraph("shoulder_L_C"     ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_L_A"          ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_L_B"          ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_R_D"          ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_L_F"          ), base->addChild(p);
+p = sgroot->createSceneGraph("arm_R_G"          ), base->addChild(p);
+p = sgroot->createSceneGraph("shield_R_C"       ), base->addChild(p);
+p = sgroot->createSceneGraph("shield_R_E"       ), base->addChild(p);
+p = sgroot->createSceneGraph("shield_L_B"       ), base->addChild(p);
+p = sgroot->createSceneGraph("shield_R_B"       ), base->addChild(p);
+p = sgroot->createSceneGraph("shield_R_A"       ), base->addChild(p);
+p = sgroot->createSceneGraph("west_C"           ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_L_D"         ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_R_D"         ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_L_F"         ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_R_F"         ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_R_C"         ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_R_E"         ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_R_A"         ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_R_B"         ), base->addChild(p);
+p = sgroot->createSceneGraph("chest_A"          ), base->addChild(p);
+p = sgroot->createSceneGraph("foot_L_A"         ), base->addChild(p);
+
+    return base;
+}
+
 void
 init_gaplant(TaskManager *manager, int w, int h)
 {
     SceneGraphPtr back;
     SceneGraphPtr gaplant;
-    //sgroot->createFromXMLmemory(manager, "xml_file/gap_plane_test.xml");
-    //sgroot->createFromXMLmemory(manager, "xml_file/Ball.xml");
-    // 未実装
-    char *data = {"1"};
+    sgroot->createFromXMLfile(manager, "xml_file/gap_plane_test.xml");
+    sgroot->createFromXMLfile(manager, "xml_file/Ball.xml");
     int len = 0;
-    sgroot->createFromXMLmemory(manager, data, len);
 
     back = sgroot->createSceneGraph();
     back->set_move_collision(back_move, back_coll);
-    gaplant = sgroot->createSceneGraph();
+    gaplant = create_gaplant();
+    /*
+    for (int i = arm_L_D; i <= foot_L_A; i++) {
+	SceneGraphPtr p = sgroot->createSceneGraph(i);
+	gaplant->addChild(p);
+    }
+    */
     gaplant->xyz[0] = 200;
     gaplant->angle[0] = -60;
     gaplant->angle[1] = 0;
     gaplant->angle[2] = 0;
     gaplant->set_move_collision(gaplant_move, gaplant_coll);
-#if 0 
-    for (int i = arm_L_D; i <= foot_L_A; i++) {
-	SceneGraphPtr p = sgroot->createSceneGraph(i);
-	gaplant->addChild(p);
-    }
-#endif
     back->addChild(gaplant);
     sgroot->setSceneData(back);        
 }
+
--- a/TaskManager/Test/test_render/Application/gaplant_action.cc	Thu Oct 22 13:53:29 2009 +0900
+++ b/TaskManager/Test/test_render/Application/gaplant_action.cc	Thu Oct 22 16:47:49 2009 +0900
@@ -77,22 +77,20 @@
 void
 gaplant_coll(SceneGraphPtr node, int w, int h, SceneGraphPtr tree)
 {
-  //SceneGraphIteratorPtr it = sgroot->getIterator(tree);
-    //static int damage = 0;
-#if 0    
-    for (; it->hasNext(Ball);) {
-	it->next(Ball);
+    SceneGraphIteratorPtr it = sgroot->getIterator(tree);
+    static int damage = 0;
+    for (; it->hasNext(sgroot->sglist->get("Ball")->id);) {
+	it->next(sgroot->sglist->get("Ball")->id);
 	SceneGraphPtr ball = it->get();
 
 	double dis_x = node->xyz[0] - ball->xyz[0];
 	double dis_y = node->xyz[1] - ball->xyz[1];
 	double dis_z = node->xyz[2] - ball->xyz[2];	    
 	double distance = sqrt(dis_x*dis_x + dis_y*dis_y + dis_z*dis_z);
-	
+
 	if (distance < CHECK_HIT_RAD + BALL_RAD) {
 	    cout << "今からもっと細かく判定するよ ^q^\n";	    
 	    ball->remove();
 	}
     }
-#endif
 }
--- a/TaskManager/Test/test_render/Application/universe.cc	Thu Oct 22 13:53:29 2009 +0900
+++ b/TaskManager/Test/test_render/Application/universe.cc	Thu Oct 22 16:47:49 2009 +0900
@@ -46,11 +46,10 @@
     SceneGraphPtr earth;
     SceneGraphPtr moon;
 
-    //sgroot->createFromXMLmemory(manager, "xml_file/universe.xml");
+    sgroot->createFromXMLfile(manager, "xml_file/universe.xml");
     // 未実装
     char *data = {"1"};
     int len = 0;
-    sgroot->createFromXMLmemory(manager, data, len);
 
     // SGList.h にある SceneGraph ID から SceneGraph を生成する
     earth = sgroot->createSceneGraph("Earth");
--- a/TaskManager/Test/test_render/Application/untitled.cc	Thu Oct 22 13:53:29 2009 +0900
+++ b/TaskManager/Test/test_render/Application/untitled.cc	Thu Oct 22 16:47:49 2009 +0900
@@ -86,11 +86,9 @@
     SceneGraphPtr test08;
     SceneGraphPtr test09;
 
-    //sgroot->createFromXMLmemory(manager, "xml_file/Venus.xml");
-    // 未実装
+    sgroot->createFromXMLfile(manager, "xml_file/Venus.xml");
     char *data = {"1"};
     int len = 0;
-    sgroot->createFromXMLmemory(manager, data, len);
 
     // SGList.h にある SceneGraph ID から SceneGraph を生成する
     /*
--- a/TaskManager/Test/test_render/Application/vacuum.cc	Thu Oct 22 13:53:29 2009 +0900
+++ b/TaskManager/Test/test_render/Application/vacuum.cc	Thu Oct 22 16:47:49 2009 +0900
@@ -30,15 +30,14 @@
 vacuum_coll(SceneGraphPtr node, int screen_w, int screen_h,
             SceneGraphPtr tree)
 {
-#if 0
     Pad *pad = sgroot->getController();
 
     if(node->frame%ENCOUNT == ENCOUNT-1) {
       if(random()%2) {
-      add_cubecollision_object(REDCUBE,node,screen_w,screen_h);
+      add_cubecollision_object("REDCUBE",node,screen_w,screen_h);
       }
       else {
-      add_cubecollision_object(ENEMY,node,screen_w,screen_h);
+      add_cubecollision_object("ENEMY",node,screen_w,screen_h);
       }
     }
 
@@ -53,21 +52,19 @@
       SceneGraphIteratorPtr it = sgroot->getIterator(tree);
       lock_attack(node,it);
     }
-#endif
 }
 
 void
 lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it)
 {
-#if 0
   SceneGraphPtr enemy;
   SceneGraphPtr near_enemy = NULL;
   float dx,dy,r,range = 100;
   // Pad *pad = sgroot->getController();
 
-  for(;it->hasNext(ENEMY);) {
+  for(;it->hasNext(sgroot->sglist->get("ENEMY")->id);) {
 
-      it->next(ENEMY);
+      it->next(sgroot->sglist->get("ENEMY")->id);
       enemy = it->get();
       dx = enemy->xyz[0] - node->xyz[0];
       dy = enemy->xyz[1] - node->xyz[1];
@@ -90,7 +87,6 @@
     //near_enemy_common_move->addChild(lockon);
     near_enemy->addChild(lockon);
     }
-#endif
 }
 
 void
@@ -141,7 +137,7 @@
 
 /*cubeをランダムな場所に生成*/
 void
-add_cubecollision_object(int id,SceneGraphPtr root,int w,int h)
+add_cubecollision_object(const char *id,SceneGraphPtr root,int w,int h)
 {
     SceneGraphPtr object;
     SceneGraphPtr common_move;
@@ -160,15 +156,13 @@
 vacuum_init2(TaskManager *manager, int w, int h)
 {
     SceneGraphPtr title;
-    /*
-    sgroot->createFromXMLmemory(manager, "xml_file/gamecube.xml");
-    sgroot->createFromXMLmemory(manager, "xml_file/title.xml");
-    sgroot->createFromXMLmemory(manager, "xml_file/gameover.xml");
-    */
+    sgroot->createFromXMLfile(manager, "xml_file/gamecube.xml");
+    sgroot->createFromXMLfile(manager, "xml_file/title.xml");
+    sgroot->createFromXMLfile(manager, "xml_file/gameover.xml");
+
     // 未実装
     char *data = {"1"};
     int len = 0;
-    sgroot->createFromXMLmemory(manager, data, len);
 
     title = sgroot->createSceneGraph("TITLE");
     title->xyz[0] = w/2;
--- a/TaskManager/Test/test_render/Application/vacuum.h	Thu Oct 22 13:53:29 2009 +0900
+++ b/TaskManager/Test/test_render/Application/vacuum.h	Thu Oct 22 16:47:49 2009 +0900
@@ -19,7 +19,7 @@
 void collision_red(SceneGraphIteratorPtr it,SceneGraphPtr node);
 void collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h);
 void gameover_scene(int w,int h, SceneGraphPtr node);
-void add_cubecollision_object(int id,SceneGraphPtr root,int w,int h);
+void add_cubecollision_object(const char *id,SceneGraphPtr root,int w,int h);
 void lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it);
 void lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree);
 void cube_rotate(SceneGraphPtr node,int w,int h);
--- a/TaskManager/Test/test_render/SceneGraphRoot.cc	Thu Oct 22 13:53:29 2009 +0900
+++ b/TaskManager/Test/test_render/SceneGraphRoot.cc	Thu Oct 22 16:47:49 2009 +0900
@@ -106,7 +106,7 @@
     xmlDocPtr doc;
     xmlNodePtr cur;
     SceneGraphPtr tmp;
-    
+
     /* パース DOM生成 */
     doc = xmlParseFile(xmlfile);
     cur = xmlDocGetRootElement(doc);
@@ -116,18 +116,20 @@
 
     /* XMLのノードを一つずつ解析  */
     for (cur=cur->children; cur; cur=cur->next) {
-		/* 扱うのはsurfaceオンリー  */
-		if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
-			continue;
-		}
+	/* 扱うのはsurfaceオンリー  */
+	if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
+	    continue;
+	}
 
-		/* ポリゴン(SceneGraph)生成  */
-		tmp = new SceneGraph(manager, cur);
+	/* ポリゴン(SceneGraph)生成  */
+	tmp = new SceneGraph(manager, cur);	
 
-		registSceneGraph(tmp);
+	addSceneGraphList(manager, tmp);
+	registSceneGraphList(tmp);
     }
 
     xmlFreeDoc(doc);
+
 }
 
 SceneGraphPtr