changeset 563:b21a013051a2

all exmple on Mac OS X
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 22 Oct 2009 23:05:16 +0900
parents a5fda4e51498
children f7ec374fc093
files Renderer/Test/Makefile.macosx Renderer/Test/cube.cc Renderer/Test/game_over.cc Renderer/Test/ieshoot.cc Renderer/Test/node.cc Renderer/Test/panel.cc Renderer/Test/panel.h Renderer/Test/title.cc Renderer/Test/universe.cc Renderer/Test/untitled.cc Renderer/Test/untitled.h Renderer/Test/vacuum.cc Renderer/Test/vacuum.h
diffstat 13 files changed, 122 insertions(+), 91 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Test/Makefile.macosx	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/Makefile.macosx	Thu Oct 22 23:05:16 2009 +0900
@@ -10,7 +10,7 @@
 .cc.o:
 	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
 
-all: ball_bound boss1_action direction gaplant
+all: ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum
 
 
 BALL_BOUND_OBJ = ball_bound.o
@@ -29,6 +29,29 @@
 gaplant : $(GAPLAN_OBJ) 
 	$(CC) -o $@ $?    $(LIBS)
 
+IESHOOT_OBJ = ieshoot.o
+ieshoot : $(IESHOOT_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+NODE_OBJ = node.o
+node : $(NODE_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+PANEL_OBJ = panel.o
+panel : $(PANEL_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+UNIV_OBJ = universe.o
+universe : $(UNIV_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+UNTITLED_OBJ = untitled.o
+untitled : $(UNTITLED_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
+
+VACUUM_OBJ = vacuum.o cube.o game_over.o title.o
+vacuum : $(VACUUM_OBJ) 
+	$(CC) -o $@ $?    $(LIBS)
 
 run: $(TARGET)
 	sudo ./$(TARGET) -width 576 -height 384 -bpp 32
--- a/Renderer/Test/cube.cc	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/cube.cc	Thu Oct 22 23:05:16 2009 +0900
@@ -1,7 +1,6 @@
 #include <math.h>
 #include "SceneGraphRoot.h"
 #include "vacuum.h"
-#include "SGList.h"
 #define SELECT 2
 
 void
@@ -52,6 +51,8 @@
 
 }
 
+extern int redcube ;
+extern int enemy ;
 
 void
 cube_split(SceneGraphPtr root,SceneGraphPtr tree)
@@ -62,10 +63,10 @@
   //  SceneGraphPtr root_common_move = root->parent;
 
   if(random()%SELECT) {
-    p = sgroot->createSceneGraph(REDCUBE);
+    p = sgroot->createSceneGraph(redcube);
   }
   else {
-    p = sgroot->createSceneGraph(ENEMY);
+    p = sgroot->createSceneGraph(enemy);
   }
 
     root->set_move_collision(cube_move_right, cube_collision);
@@ -98,9 +99,9 @@
   float dx, dy,ddx,ddy, r;
   float q = 0;
 
-  for (; it->hasNext(REDCUBE);) {
+  for (; it->hasNext(redcube);) {
 
-    it->next(REDCUBE);
+    it->next(redcube);
     SceneGraphPtr mcube = it->get();
     dx = node->xyz[0] - mcube->xyz[0];
     dy = node->xyz[1] - mcube->xyz[1];
@@ -138,8 +139,8 @@
   float dx, dy,ddx,ddy, r;
   float q = 0;
 
-  for (; it->hasNext(ENEMY);) {
-    it->next(ENEMY);
+  for (; it->hasNext(enemy);) {
+    it->next(enemy);
     SceneGraphPtr mcube = it->get();
 
     dx = node->xyz[0] - mcube->xyz[0];
--- a/Renderer/Test/game_over.cc	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/game_over.cc	Thu Oct 22 23:05:16 2009 +0900
@@ -1,6 +1,5 @@
 #include "SceneGraphRoot.h"
 #include "vacuum.h"
-#include "SGList.h"
 
 
 void
@@ -9,7 +8,7 @@
 
   SceneGraphPtr over;
 
-  over = sgroot->createSceneGraph(GAMEOVER);
+  over = sgroot->createSceneGraph("GAMEOVER");
   over->xyz[0] = w/2;
   over->xyz[1] = h/2;
   over->set_move_collision(gameover_idle,gameover_collision);
@@ -31,7 +30,7 @@
 
     SceneGraphPtr title;
 
-    title = sgroot->createSceneGraph(TITLE);
+    title = sgroot->createSceneGraph("TITLE");
     title->xyz[0] = screen_w/2;
     title->xyz[1] = screen_h/2;
     title->set_move_collision(no_move_idle, title_collision);
--- a/Renderer/Test/ieshoot.cc	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/ieshoot.cc	Thu Oct 22 23:05:16 2009 +0900
@@ -1,5 +1,5 @@
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+#include "ieshoot.h"
 
 static const float jiki_speed = 6.0f;
 static const float jiki_radius = 32.0f;
@@ -40,9 +40,9 @@
 {
     SceneGraphIteratorPtr it = sgroot->getIterator(tree);
     static int damage = 0;
-
-    for (; it->hasNext(IETAMA);) {
-	it->next(IETAMA);
+    int ietama = sgroot->getSgid("IETAMA");
+    for (; it->hasNext(ietama);) {
+	it->next(ietama);
 	SceneGraphPtr tama = it->get();
 
 	if (node->xyz[0] - boss_radius_x < tama->xyz[0] + tama_radius
@@ -52,7 +52,7 @@
 
 	    node->set_move_collision(ieboss_move, ieboss_collision_invincibil);
 
-	    SceneGraphPtr iebosstama = sgroot->createSceneGraph(Earth);
+	    SceneGraphPtr iebosstama = sgroot->createSceneGraph("Earth");
 	    iebosstama->set_move_collision(iebosstama_move, ietama_collision);
 	    iebosstama->xyz[0] = node->xyz[0];
 	    iebosstama->xyz[1] = node->xyz[1] + boss_radius_y;
@@ -179,7 +179,7 @@
     }
 
     if (pad->circle.isPush()) {
-	SceneGraphPtr ietama = sgroot->createSceneGraph(IETAMA);
+	SceneGraphPtr ietama = sgroot->createSceneGraph("IETAMA");
 	ietama->set_move_collision(ietama_move, ietama_collision);
 	ietama->xyz[0] = node->xyz[0];
 	ietama->xyz[1] = node->xyz[1];
@@ -195,19 +195,19 @@
     SceneGraphPtr enemy;
     SceneGraphPtr back;
 
-    sgroot->createFromXMLfile(manager, "xml_file/ietama.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/ieboss.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/iejiki.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/universe.xml");
+    sgroot->createFromXMLfile( "xml_file/ietama.xml");
+    sgroot->createFromXMLfile( "xml_file/ieboss.xml");
+    sgroot->createFromXMLfile( "xml_file/iejiki.xml");
+    sgroot->createFromXMLfile( "xml_file/universe.xml");
 
     back = sgroot->createSceneGraph();
 
-    iejiki = sgroot->createSceneGraph(IEJIKI);
+    iejiki = sgroot->createSceneGraph("IEJIKI");
     iejiki->set_move_collision(iejiki_move, iejiki_collision);
     iejiki->xyz[2] = 20;
     back->addChild(iejiki);
 
-    enemy = sgroot->createSceneGraph(IEBOSS);
+    enemy = sgroot->createSceneGraph("IEBOSS");
     enemy->set_move_collision(ieboss_move, ieboss_collision);
     enemy->xyz[1] = boss_radius_y;
     back->addChild(enemy);
--- a/Renderer/Test/node.cc	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/node.cc	Thu Oct 22 23:05:16 2009 +0900
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "SceneGraphRoot.h"
 #include "SceneGraph.h"
-#include "xml_file/cube.h"
+#include "node.h"
 
 static void
 cube_collision(SceneGraphPtr node, int screen_w, int screen_h,
@@ -65,7 +65,8 @@
 MainLoopPtr
 node::init(Viewer *sgroot, int screen_w, int screen_h)
 {
-    sgroot->createFromXMLfile(manager, "xml_file/cube.xml");
+    sgroot->createFromXMLfile( "xml_file/cube.xml");
+    SceneGraphPtr Cube = sgroot->createSceneGraph("Cube");
     Cube->set_move_collision(cube_move, cube_collision);
     Cube->stack_xyz[0] = 2.0f;
     Cube->stack_xyz[1] = 2.0f;
@@ -74,7 +75,7 @@
 
 extern Application *
 application() {
-    return new ball_bound();
+    return new node();
 }
 
 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
--- a/Renderer/Test/panel.cc	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/panel.cc	Thu Oct 22 23:05:16 2009 +0900
@@ -24,14 +24,14 @@
     SceneGraphPtr panel;
 
     if (bg == 2) {
-		sgroot->createFromXMLfile(manager, "xml_file/panel_512.xml");
-		panel = sgroot->createSceneGraph(PANEL_512);
+		sgroot->createFromXMLfile( "xml_file/panel_512.xml");
+		panel = sgroot->createSceneGraph("PANEL_512");
     } else if (bg == 3) {
-		sgroot->createFromXMLfile(manager, "xml_file/panel_1024.xml");
-		panel = sgroot->createSceneGraph(PANEL_1024);
+		sgroot->createFromXMLfile( "xml_file/panel_1024.xml");
+		panel = sgroot->createSceneGraph("PANEL_1024");
     } else {
-		sgroot->createFromXMLfile(manager, "xml_file/panel_2048.xml");
-		panel = sgroot->createSceneGraph(PANEL_2048);
+		sgroot->createFromXMLfile( "xml_file/panel_2048.xml");
+		panel = sgroot->createSceneGraph("PANEL_2048");
     }
 
     panel->set_move_collision(panel_move, panel_collision);
@@ -57,7 +57,7 @@
     task_initialize();
     manager->set_TMend(TMend);
     for(int i=0;i<argc;i++) {
-         if (strcmp(argv[i],"-sg")) {
+         if (strcmp(argv[i],"-sg")==0) {
              bg = atoi(argv[i+1]);
          }
     }
--- a/Renderer/Test/panel.h	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/panel.h	Thu Oct 22 23:05:16 2009 +0900
@@ -3,7 +3,7 @@
 #include "Application.h"
 #include "MainLoop.h"
 
-class ball_bound : public Application {
+class panel : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
 
--- a/Renderer/Test/title.cc	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/title.cc	Thu Oct 22 23:05:16 2009 +0900
@@ -1,6 +1,7 @@
 #include "SceneGraphRoot.h"
 #include "vacuum.h"
-#include "SGList.h"
+
+extern int redcube;
 
 void
 title_collision(SceneGraphPtr node, int w, int h,SceneGraphPtr tree)
@@ -13,14 +14,14 @@
     SceneGraphPtr vacuum;
     SceneGraphPtr back = sgroot->createSceneGraph(); 
 
-    vacuum = sgroot->createSceneGraph(BIGCUBE);
+    vacuum = sgroot->createSceneGraph("BIGCUBE");
     vacuum->xyz[0] = w/2;
     vacuum->xyz[1] = h*0.8;
     vacuum->set_move_collision(vacuum_move, vacuum_coll);
     
     back->addChild(vacuum);
     
-    add_cubecollision_object(REDCUBE,vacuum,w,h);
+    add_cubecollision_object(redcube,vacuum,w,h);
     
     sgroot->setSceneData(back);
       
--- a/Renderer/Test/universe.cc	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/universe.cc	Thu Oct 22 23:05:16 2009 +0900
@@ -46,17 +46,17 @@
     SceneGraphPtr earth;
     SceneGraphPtr moon;
 
-    sgroot->createFromXMLfile(manager, "xml_file/universe.xml");
+    sgroot->createFromXMLfile( "xml_file/universe.xml");
 
     // SGList.h にある SceneGraph ID から SceneGraph を生成する
-    earth = sgroot->createSceneGraph(Earth);
+    earth = sgroot->createSceneGraph("Earth");
 
     // SceneGraph の move と collision を設定
     earth->set_move_collision(earth_move, earth_collision);
     earth->stack_xyz[0] = 3.0f;
     earth->stack_xyz[1] = 3.0f;
     
-    moon = sgroot->createSceneGraph(Moon);
+    moon = sgroot->createSceneGraph("Moon");
     moon->set_move_collision(moon_move, moon_collision);
     
     // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon)
@@ -71,7 +71,7 @@
 
 extern Application *
 application() {
-    return new ball_bound();
+    return new universe();
 }
 
 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
--- a/Renderer/Test/untitled.cc	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/untitled.cc	Thu Oct 22 23:05:16 2009 +0900
@@ -1,6 +1,6 @@
 #include <stdlib.h>
 #include "SceneGraphRoot.h"
-#include "SGList.h"
+#include "untitled.h"
 #include <math.h>
 
 static void
@@ -87,7 +87,7 @@
     SceneGraphPtr test08;
     SceneGraphPtr test09;
 
-    sgroot->createFromXMLfile(manager, "xml_file/Venus.xml");
+    sgroot->createFromXMLfile( "xml_file/Venus.xml");
 
     // SGList.h にある SceneGraph ID から SceneGraph を生成する
     /*
@@ -102,16 +102,16 @@
     test08 = sgroot->createSceneGraph(cubetest002);
     test09 = sgroot->createSceneGraph(cubetest001);
     */
-    test00 = sgroot->createSceneGraph(Venus000);
-    test01 = sgroot->createSceneGraph(Venus009);
-    test02 = sgroot->createSceneGraph(Venus008);
-    test03 = sgroot->createSceneGraph(Venus007);
-    test04 = sgroot->createSceneGraph(Venus006);
-    test05 = sgroot->createSceneGraph(Venus005);
-    test06 = sgroot->createSceneGraph(Venus004);
-    test07 = sgroot->createSceneGraph(Venus003);
-    test08 = sgroot->createSceneGraph(Venus002);
-    test09 = sgroot->createSceneGraph(Venus001);
+    test00 = sgroot->createSceneGraph("Venus000");
+    test01 = sgroot->createSceneGraph("Venus009");
+    test02 = sgroot->createSceneGraph("Venus008");
+    test03 = sgroot->createSceneGraph("Venus007");
+    test04 = sgroot->createSceneGraph("Venus006");
+    test05 = sgroot->createSceneGraph("Venus005");
+    test06 = sgroot->createSceneGraph("Venus004");
+    test07 = sgroot->createSceneGraph("Venus003");
+    test08 = sgroot->createSceneGraph("Venus002");
+    test09 = sgroot->createSceneGraph("Venus001");
     
     // SceneGraph の move と collision を設定
     test00->set_move_collision(cubetest_move, cubetest_collision);
@@ -150,7 +150,7 @@
 
 extern Application *
 application() {
-    return new untitiled();
+    return new untitled();
 }
 
 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
--- a/Renderer/Test/untitled.h	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/untitled.h	Thu Oct 22 23:05:16 2009 +0900
@@ -4,7 +4,7 @@
 #include "Application.h"
 #include "MainLoop.h"
 
-class untitiled : public Application {
+class untitled : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
 
--- a/Renderer/Test/vacuum.cc	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/vacuum.cc	Thu Oct 22 23:05:16 2009 +0900
@@ -1,7 +1,6 @@
 #include <math.h>
 #include "vacuum.h"
 #include "SceneGraphRoot.h"
-#include "SGList.h"
 #define ENCOUNT 55
 using namespace std;
 
@@ -27,6 +26,9 @@
 
 }
 
+int redcube;
+int enemy;
+
 void
 vacuum_coll(SceneGraphPtr node, int screen_w, int screen_h,
             SceneGraphPtr tree)
@@ -35,10 +37,10 @@
 
     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);
       }
     }
 
@@ -60,22 +62,22 @@
 lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it)
 {
 
-  SceneGraphPtr enemy;
+  SceneGraphPtr e;
   SceneGraphPtr near_enemy = NULL;
   float dx,dy,r,range = 100;
   // Pad *pad = sgroot->getController();
 
-  for(;it->hasNext(ENEMY);) {
+  for(;it->hasNext(enemy);) {
 
-      it->next(ENEMY);
-      enemy = it->get();
-      dx = enemy->xyz[0] - node->xyz[0];
-      dy = enemy->xyz[1] - node->xyz[1];
+      it->next(enemy);
+      e = it->get();
+      dx = e->xyz[0] - node->xyz[0];
+      dy = e->xyz[1] - node->xyz[1];
       r = sqrt(dx*dx+dy*dy);
 
-      if(range > r && enemy->stack_xyz[2] == 0) {
+      if(range > r && e->stack_xyz[2] == 0) {
         range = r;
-        near_enemy = enemy;
+        near_enemy = e;
       }
   }
 
@@ -85,7 +87,7 @@
     SceneGraphPtr lockon;
     //    SceneGraphPtr near_enemy_common_move = near_enemy->parent;
     near_enemy->stack_xyz[2] = 1;
-    lockon = sgroot->createSceneGraph(LOCK);
+    lockon = sgroot->createSceneGraph("LOCK");
     lockon->set_move_collision(no_move_idle,lockon_collision);
     //near_enemy_common_move->addChild(lockon);
     near_enemy->addChild(lockon);
@@ -161,16 +163,20 @@
 {
     SceneGraphPtr title;
 
-    sgroot->createFromXMLfile(manager, "xml_file/gamecube.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/title.xml");
-    sgroot->createFromXMLfile(manager, "xml_file/gameover.xml");
+    sgroot->createFromXMLfile( "xml_file/gamecube.xml");
+    sgroot->createFromXMLfile( "xml_file/title.xml");
+    sgroot->createFromXMLfile( "xml_file/gameover.xml");
 
-    title = sgroot->createSceneGraph(TITLE);
+    title = sgroot->createSceneGraph("TITLE");
     title->xyz[0] = w/2;
     title->xyz[1] = h/2;
     title->set_move_collision(no_move_idle, title_collision);
 
     sgroot->setSceneData(title);
+
+    redcube = sgroot->getSgid("REDCUBE");
+    enemy = sgroot->getSgid("ENEMY");
+
     return sgroot;
 }
 
--- a/Renderer/Test/vacuum.h	Thu Oct 22 22:22:31 2009 +0900
+++ b/Renderer/Test/vacuum.h	Thu Oct 22 23:05:16 2009 +0900
@@ -14,25 +14,25 @@
 };
 
 
-static void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h);
-static void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h);
-static void no_move_idle(SceneGraphPtr node, int screen_w, int screen_h);
-static void cube_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
-static void cube_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
-static void cube_split(SceneGraphPtr root,SceneGraphPtr tree);
-static void vacuum_move(SceneGraphPtr node, int w, int h);
-static void vacuum_coll(SceneGraphPtr node, int w, int h,SceneGraphPtr tree);
-static void title_idle(SceneGraphPtr node, int screen_w, int screen_h);
-static void title_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
-static void scene_change(int w,int h,SceneGraphPtr node);
-static void gameover_idle(SceneGraphPtr node, int screen_w, int screen_h);
-static void gameover_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
-static void collision_red(SceneGraphIteratorPtr it,SceneGraphPtr node);
-static void collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h);
-static void gameover_scene(int w,int h, SceneGraphPtr node);
-static void add_cubecollision_object(int id,SceneGraphPtr root,int w,int h);
-static void lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it);
-static void lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree);
-static void cube_rotate(SceneGraphPtr node,int w,int h);
+extern void cube_move_left(SceneGraphPtr node, int screen_w, int screen_h);
+extern void cube_move_right(SceneGraphPtr node, int screen_w, int screen_h);
+extern void no_move_idle(SceneGraphPtr node, int screen_w, int screen_h);
+extern void cube_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
+extern void cube_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
+extern void cube_split(SceneGraphPtr root,SceneGraphPtr tree);
+extern void vacuum_move(SceneGraphPtr node, int w, int h);
+extern void vacuum_coll(SceneGraphPtr node, int w, int h,SceneGraphPtr tree);
+extern void title_idle(SceneGraphPtr node, int screen_w, int screen_h);
+extern void title_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
+extern void scene_change(int w,int h,SceneGraphPtr node);
+extern void gameover_idle(SceneGraphPtr node, int screen_w, int screen_h);
+extern void gameover_collision(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree);
+extern void collision_red(SceneGraphIteratorPtr it,SceneGraphPtr node);
+extern void collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h);
+extern void gameover_scene(int w,int h, SceneGraphPtr node);
+extern void add_cubecollision_object(int id,SceneGraphPtr root,int w,int h);
+extern void lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it);
+extern void lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree);
+extern void cube_rotate(SceneGraphPtr node,int w,int h);
 
 #endif