changeset 659:00391feebc79

branch merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 27 Nov 2009 18:27:32 +0900
parents 30a72124c7fd (current diff) 63a0cf8d67bc (diff)
children e1856ef4fc74
files
diffstat 47 files changed, 739 insertions(+), 158 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Application.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Engine/Application.h	Fri Nov 27 18:27:32 2009 +0900
@@ -4,11 +4,13 @@
 #include "SceneGraph.h"
 #include "MainLoop.h"
 #include "viewer.h"
+#include "SgChange.h"
 
 typedef void (*Move_func)(SceneGraph* node, int screen_w, int screen_h);
 typedef void (*Coll_func)(SceneGraph* node, int screen_w, int screen_h, SceneGraphPtr tree);
 
 class Viewer;
+class SgChange;
 
 class Application {
 public:
@@ -16,7 +18,7 @@
     virtual ~Application();
     
     virtual MainLoopPtr init(Viewer *viewer, int w, int h)  = 0;
-
+    virtual MainLoopPtr init_only_sg(SgChange *sgchange, int w, int h) = 0;
 };
 
 #endif
--- a/Renderer/Engine/Camera.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Engine/Camera.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -6,9 +6,13 @@
 #include "show_time.h"
 #include "TaskManager.h"
 
+//static SceneGraphRoot *sgroot;
+
+#if 1
 static void
-camera_move(SceneGraphPtr _node, int screen_w, int screen_h)
+camera_move(SceneGraphPtr _node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
     CameraPtr node = (CameraPtr)_node;
 
@@ -62,9 +66,45 @@
     }
 
 }
+#endif
+
+#if 0
+static void
+Camera::camera_move(SceneGraphPtr _node, int screen_w, int screen_h)
+{
+    Pad *pad = sgroot->getController();
+    CameraPtr node = (CameraPtr)_node;
+
+    if (pad->r1.isPush() || pad->r1.isHold()) {
+	node->xyz[2] += 10.0f;
+    } else if (pad->l1.isPush() || pad->l1.isHold()) {
+	node->xyz[2] -= 10.0f;
+    }
+
+    if (pad->r2.isHold()) {
+	if (node->zd[0] <= 1.0f) {
+	    node->zd[0] += 0.02f;
+	}
+	if (node->zd[2] >= 0.0f) {
+	    node->zd[2] -= 0.02f;
+	}
+    } else if (pad->l2.isHold()) {
+	if (node->zd[0] > -1.0f) {
+	    node->zd[0] -= -0.02f;
+	}
+	if (node->zd[2] >= 0.0f) {
+	    node->zd[2] -= 0.02f;
+	}
+    } else {
+	node->zd[0] = 0.0f;
+	node->zd[2] = 1.0f;
+    }
+
+}
+#endif
 
 static void
-camera_collision(SceneGraphPtr node, int screen_w, int screen_h,
+camera_collision(SceneGraphPtr node, void *sgroot_,int screen_w, int screen_h,
 		 SceneGraphPtr tree)
 {
 }
@@ -73,10 +113,10 @@
  * @param w Width of screen
  * @param h Height of screen
  */
-Camera::Camera(float w, float h)
+Camera::Camera(float w, float h, SceneGraphRoot *sgroot_)
 {
     name = (char*)"Camera";
-
+    sgroot = sgroot_;
 
     fov  = 60.0f;
     near = 0.0f;
@@ -105,7 +145,7 @@
     m_pers = new float[16];
     m_screen = new float[16];
     
-    this->set_move_collision(camera_move, camera_collision);
+    this->set_move_collision(camera_move, camera_collision, (void *)sgroot);
 }
 
 Camera::~Camera(void)
--- a/Renderer/Engine/Camera.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Engine/Camera.h	Fri Nov 27 18:27:32 2009 +0900
@@ -3,10 +3,15 @@
 
 #include "SceneGraph.h"
 
+class SceneGraphRoot;
+
 class Camera : public SceneGraph {
 public:
-    Camera(float w = 640, float h = 480);
-    ~Camera(void);
+    //Camera(float w = 640, float h = 480, SceneGraphRoot *sgroot);
+    Camera(float w, float h, SceneGraphRoot *sgroot);
+    ~Camera(void);    
+
+    SceneGraphRoot *sgroot;
 
     float zd[4]; // direction z
     float yd[4]; // direction y
@@ -24,6 +29,8 @@
 
     void setCamera(float *pose);
     void update(float screen_w, float screen_h);
+
+    //void camera_move(SceneGraphPtr _node, int screen_w, int screen_h);
 };
 
 typedef Camera *CameraPtr;
--- a/Renderer/Engine/Light.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Engine/Light.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -7,13 +7,13 @@
 #include "TaskManager.h"
 
 static void
-light_move(SceneGraphPtr node, int screen_w, int screen_h)
+light_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
 
 }
 
 static void
-light_collision(SceneGraphPtr node, int screen_w, int screen_h,
+light_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 		 SceneGraphPtr tree)
 {
 }
--- a/Renderer/Engine/SceneGraph.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -21,10 +21,10 @@
 extern int decode(char *cont, FILE *outfile);
 
 static void
-no_move(SceneGraphPtr self, int screen_w, int screen_h) {}
+no_move(SceneGraphPtr self, void *sgroot_, int screen_w, int screen_h) {}
 
 static void
-no_collision(SceneGraphPtr self, int screen_w, int screen_h,
+no_collision(SceneGraphPtr self, void *sgroot_, int screen_w, int screen_h,
              SceneGraphPtr tree) {}
 
 /**
@@ -522,16 +522,17 @@
     }
 }
 
+/* move_func 実行 sgroot 渡す */
 void
 SceneGraph::move_execute(int w, int h)
 {
-    (*move)(this, w, h);
+    (*move)(this, this->sgroot, w, h);
 }
 
 void
 SceneGraph::collision_check(int w, int h, SceneGraphPtr tree)
 {
-    (*collision)(this, w, h, tree);
+    (*collision)(this, this->sgroot, w, h, tree);
 }
 
 void
@@ -590,6 +591,17 @@
     this->collision = new_collision;
 }
 
+
+void
+SceneGraph::set_move_collision(move_func new_move,
+                               collision_func new_collision, void *sgroot_)
+{
+    this->move = new_move;
+    this->collision = new_collision;
+    // add
+    this->sgroot = sgroot_;
+}
+
 void
 SceneGraph::add_next(SceneGraphPtr next)
 {
--- a/Renderer/Engine/SceneGraph.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Engine/SceneGraph.h	Fri Nov 27 18:27:32 2009 +0900
@@ -6,8 +6,11 @@
 #include "TaskManager.h"
 class SceneGraph;
 
-typedef void (*move_func)(SceneGraph* node, int screen_w, int screen_h);
-typedef void (*collision_func)(SceneGraph* node, int screen_w, int screen_h,
+//typedef void (*move_func)(SceneGraph* node, int screen_w, int screen_h);
+typedef void (*move_func)(SceneGraph* node, void *sgroot, int screen_w, int screen_h);
+//typedef void (*collision_func)(SceneGraph* node, int screen_w, int screen_h,
+//                               SceneGraph* tree);
+typedef void (*collision_func)(SceneGraph* node, void *sgroot, int screen_w, int screen_h,
                                SceneGraph* tree);
 typedef SceneGraph* SceneGraphPtr;
 
@@ -18,6 +21,9 @@
     SceneGraph(SceneGraphPtr orig);
     ~SceneGraph(void);
 
+    // add
+    void *sgroot;
+
     // Node がもつ状態変数(というべきか否か
     // xyz,angle ぐらいあればおk?
     float stack_xyz[3];
@@ -79,6 +85,7 @@
     void set_move_collision(SceneGraphPtr node,
                             move_func new_move, collision_func new_collision);
     void set_move_collision(move_func new_move, collision_func new_collision);
+    void set_move_collision(move_func new_move, collision_func new_collision, void *sgroot);
     void remove(void);
     SceneGraphPtr realRemoveFromTree(SceneGraphPtr tree);
     SceneGraphPtr realRemoveFromList(SceneGraphPtr list);
--- a/Renderer/Engine/SceneGraphRoot.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -24,7 +24,7 @@
     //
     sg_src = (SceneGraphPtr*) malloc(sizeof(SceneGraphPtr)*SGLIST_LENGTH);
 
-    camera = new Camera(w, h);
+    camera = new Camera(w, h, this);
     light = new Light(w, h);
     iterator = new SceneGraphIterator;
     controller = create_controller();
@@ -183,6 +183,9 @@
     /* ユーザーにはオリジナルの clone を返す */
     p = src->clone();
 
+    /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/
+    p->sgroot = (void *)this;
+
     addNext(p);
 
     return p;
@@ -207,6 +210,9 @@
 
     /* ユーザーにはオリジナルの clone を返す */
     p = src->clone();
+    
+    /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/
+    p->sgroot = (void *)this;
 
     addNext(p);
 
@@ -240,6 +246,9 @@
 {
     SceneGraphPtr p = new SceneGraph;
 
+    /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/
+    p->sgroot = (void *)this;
+
     addNext(p);
     p->flag_drawable = 0;
 
@@ -392,9 +401,8 @@
         list->move_execute(screen_w, screen_h);
         list->collision_check(screen_w, screen_h, list);	
         
-		list->frame++; 
+	list->frame++; 
         list = list->next;
-
     }
 
     if(sg_exec_tree != NULL) {
--- a/Renderer/Engine/SceneGraphRoot.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Engine/SceneGraphRoot.h	Fri Nov 27 18:27:32 2009 +0900
@@ -104,7 +104,9 @@
 
 
 // 大域変数は無くすこと
-extern SceneGraphRoot *sgroot;
+//extern SceneGraphRoot *sgroot;
+//extern SceneGraphRoot *sgroot_A;
+//extern SceneGraphRoot *sgroot_B;
 
 #endif
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/SgChange.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -0,0 +1,166 @@
+#include <SDL.h>
+#include "SgChange.h"
+#include "viewer_types.h"
+#include "SceneGraph.h"
+#include "SceneGraphRoot.h"
+#include "scene_graph_pack.h"
+#include "sys.h"
+#include "Func.h"
+#include "error.h"
+#include "TaskManager.h"
+#include <wchar.h>
+#include "Pad.h"
+#include "Application.h"
+#include "lindaapi.h"
+
+static void post2runLoop(SchedTask *s,void *viewer,void *s1);
+
+/* measure for FPS (Frame Per Second) */
+int start_time;
+int this_time;
+int frames;
+
+/* Data Pack sent to Other CPUs (ex. SPE) */
+SceneGraphPack *sgpack;
+PolygonPack *ppack;
+SpanPackPtr spackList;
+SpanPackPtr *spackList_ptr;
+
+int spackList_length;
+int spackList_length_align;
+
+/**
+ *
+ */
+
+SgChange::SgChange(int b, int w, int h, int _num)
+{
+    bpp = b;
+    width = w;
+    height = h;
+    spe_num = _num;
+}
+
+int
+SgChange::get_ticks(void)
+{
+    int time;
+    time = SDL_GetTicks();
+    return time;
+}
+
+bool
+SgChange::quit_check(void)
+{
+    SDL_Event event;
+
+    while(SDL_PollEvent(&event)) {
+        if (event.type==SDL_QUIT) {
+            return true;
+        }
+    }
+
+    Uint8 *keys=SDL_GetKeyState(NULL);
+
+    if (keys[SDLK_q] == SDL_PRESSED) {
+        return true;
+    }
+
+    return false;
+}
+
+void
+SgChange::quit(void)
+{
+    SDL_Quit();
+}
+
+void
+SgChange::swap_buffers(void)
+{
+    SDL_GL_SwapBuffers();
+}
+
+
+void
+SgChange::run_init(TaskManager *manager, Application *app)
+{
+    this->manager = manager;
+
+    start_time = get_ticks();
+    this_time  = 0;
+    frames     = 0;
+
+    // ココ!
+    sgroot_A = new SceneGraphRoot(this->width, this->height);
+    sgroot_A->tmanager = manager;
+    sgroot_B = new SceneGraphRoot(this->width, this->height);
+    sgroot_B->tmanager = manager;
+
+    MainLoop *mainloop = app->init_only_sg(this, this->width, this->height);
+
+    mainloop->mainLoop();
+}
+
+void
+SgChange::mainLoop()
+{
+    HTaskPtr task_next = manager->create_task(Dummy);
+
+    task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL)
+    task_next->spawn();
+}
+
+static void
+post2runLoop(SchedTask *s, void *viewer_, void *arg)
+{
+    SgChange *viewer = (SgChange*)viewer_;
+    HTaskPtr task_next = viewer->manager->create_task(Dummy);
+    viewer->run_loop(task_next);
+
+    psx_sync_n();
+}
+
+void
+SgChange::exchange_sgroot()
+{
+    SceneGraphRoot *tmp;
+    tmp = sgroot_A;
+    sgroot_A = sgroot_B;
+    sgroot_B = tmp;
+}
+
+void
+SgChange::run_loop(HTaskPtr task_next)
+{
+    bool quit_flg;
+    quit_flg = quit_check();
+    if (quit_flg == true) {
+        this_time = get_ticks();
+        run_finish();
+        return;
+    }
+
+    sgroot_A->allExecute(width, height);
+    exchange_sgroot();
+
+    //printf("Sgroot = %x\n", sgroot_A);
+
+    task_next->set_post(&post2runLoop, (void *)this, 0);
+    task_next->spawn();
+}
+
+
+void
+SgChange::run_finish(void)
+{
+    if (this_time != start_time) {
+        printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0);
+    }
+
+    delete sgroot_A;
+    delete sgroot_B;
+    quit();
+}
+
+/* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/SgChange.h	Fri Nov 27 18:27:32 2009 +0900
@@ -0,0 +1,106 @@
+#ifndef INCLUDED_SG_CHANGE
+#define INCLUDED_SG_CHANGE
+
+#include <SDL.h>
+
+#include "viewer_types.h"
+#include "TaskManager.h"
+#include "KeyStat.h"
+#include "MainLoop.h"
+#include "Application.h"
+#include "SceneGraphRoot.h"
+
+class SceneGraphRoot;
+
+class Application;
+
+class SgChange : public MainLoop {
+
+public:
+
+    SgChange(int bpp, int width, int height, int spenum);
+
+    virtual ~SgChange() {}
+
+    Application *app;
+
+    TaskManager *manager;
+    key_stat *keyPtr;
+    HTaskPtr draw_dummy;
+
+    SceneGraphRoot *sgroot_A;
+    SceneGraphRoot *sgroot_B;
+
+    /* screen info */
+    int width;
+    int height;
+    int bpp;
+
+    int spe_num;
+
+    int rgb_size[3];
+    Uint32 video_flags;
+    Uint32 *pixels;
+
+    void init();
+
+    int get_ticks();
+    bool quit_check();
+    void quit();
+
+    virtual void swap_buffers();
+    virtual void clean_pixels() {}
+
+    virtual void run_init(TaskManager *manager, Application *app);
+    virtual void run_loop(HTaskPtr task_next);
+    virtual void run_finish();
+    virtual void exchange_sgroot();
+    void mainLoop();
+
+    void createFromXMLfile(const char *file)
+    {
+	sgroot_A->createFromXMLfile(manager, file);
+    }
+
+    SceneGraph * createSceneGraph(int id)
+    {
+	return sgroot_A->createSceneGraph(id);
+    }
+
+    SceneGraph * createSceneGraph(const char *id)
+    {
+	return sgroot_A->createSceneGraph(id);
+    }
+
+    int getSgid(const char *id)
+    {
+	return sgroot_A->getSgid(id);
+    }
+
+    SceneGraph * createSceneGraph()
+    {
+	return sgroot_A->createSceneGraph();
+    }
+
+    void setSceneData(SceneGraph *g)
+    {
+	sgroot_A->setSceneData(g);
+    }
+
+    int getLast()
+    {
+	return sgroot_A->getLast();
+    }
+
+
+
+
+private:
+    HTaskPtr initLoop();
+};
+
+#define default_sdl_flag SDL_INIT_TIMER | SDL_INIT_JOYSTICK
+
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/SgMain.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -0,0 +1,61 @@
+#include "TaskManager.h"
+#include "SgChange.h"
+#include "Application.h"
+
+/* prototype */
+extern void task_initialize();
+extern Application *application();
+extern int sg_init(TaskManager *manager, int argc, char *argv[]);
+
+int
+sg_init(TaskManager *manager, int argc, char *argv[])
+{
+    int bpp    = 32;
+    int width  = 640;
+    int height = 480;
+    int spenum = 1;
+
+    for(int i = 1; argv[i]; ++i)
+    {
+	if (strcmp(argv[i], "-bpp") == 0) {
+	    bpp = atoi(argv[++i]);
+	}
+	if (strcmp(argv[i], "-width") == 0) {
+	    width = atoi(argv[++i]);
+	} 
+	if (strcmp(argv[i], "-height") == 0) {
+	    height = atoi(argv[++i]);
+	}
+	if (strcmp(argv[i], "-cpu") == 0) {
+	    spenum = atoi(argv[++i]);
+	}
+    }
+
+    SgChange *screen = new SgChange(bpp, width, height, spenum);
+    screen->run_init(manager, application());
+
+    return 0;
+}
+
+#if 0
+
+// These are defined in Application
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+#endif
+
+/* end */
--- a/Renderer/Test/Makefile.cell	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/Makefile.cell	Fri Nov 27 18:27:32 2009 +0900
@@ -11,7 +11,7 @@
 .cc.o:
 	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
 
-ALL =  ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum dynamic viewer
+ALL = ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum dynamic viewer SgRootChange
 all: $(ALL)
 
 speobject:
@@ -76,6 +76,10 @@
 viewer : $(VIEWER_OBJ) 
 	$(CC) -o $@ $?    $(LIBS)
 
+SG_CHANGE_OBJ = SgRootChange.o
+SgRootChange : $(SG_CHANGE_OBJ) 
+	   $(CC) -o $@ $?   $(LIBS)
+	
 debug: $(TARGET)
 	sudo ppu-gdb ./$(TARGET) 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/SgRootChange.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -0,0 +1,63 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "MainLoop.h"
+#include "SgRootChange.h"
+
+
+
+
+// prototype
+MainLoopPtr 
+SgRootChange::init(Viewer *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
+MainLoopPtr 
+SgRootChange::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    SceneGraphPtr ball;
+    SceneGraphPtr cube;
+    SceneGraphRoot *sg_buff_A = sgroot->sgroot_A;
+    SceneGraphRoot *sg_buff_B = sgroot->sgroot_B;
+
+    sg_buff_A->createFromXMLfile(sgroot->manager, "xml_file/Ball.xml");
+    sg_buff_B->createFromXMLfile(sgroot->manager, "xml_file/cube.xml");
+
+    ball = sgroot->sgroot_A->createSceneGraph("Ball");
+    cube = sgroot->sgroot_B->createSceneGraph("Cube");
+
+    sgroot->sgroot_A->setSceneData(ball);
+    sgroot->sgroot_B->setSceneData(cube);
+
+    return sgroot;
+}
+
+extern Application *
+application() {
+    return new SgRootChange();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int sg_init(TaskManager *manager, int argc, char *argv[]);
+extern void task_initialize();
+static void TMend(TaskManager *manager);
+
+int
+TMmain(TaskManager *manager, int argc, char *argv[])
+{
+    task_initialize();
+    manager->set_TMend(TMend);
+    return sg_init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/SgRootChange.h	Fri Nov 27 18:27:32 2009 +0900
@@ -0,0 +1,12 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "Application.h"
+#include "MainLoop.h"
+
+class SgRootChange : public Application {
+
+    MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
+
+};
--- a/Renderer/Test/back_action.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/back_action.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -4,8 +4,9 @@
 using namespace std;
 
 void
-back_move(SceneGraphPtr node, int w, int h)
+back_move(SceneGraphPtr node, void *sgroot_, int w, int h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
 
     if (pad->triangle.isPush()) {
@@ -17,7 +18,7 @@
 }
 
 void
-back_coll(SceneGraphPtr node, int w, int h, SceneGraphPtr tree)
+back_coll(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree)
 {
     
 }
--- a/Renderer/Test/back_action.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/back_action.h	Fri Nov 27 18:27:32 2009 +0900
@@ -1,2 +1,2 @@
-void back_move(SceneGraphPtr, int, int);
-void back_coll(SceneGraphPtr, int, int, SceneGraphPtr);
+void back_move(SceneGraphPtr node, void *sgroot_, int w, int h);
+void back_coll(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree);
--- a/Renderer/Test/ball_action.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/ball_action.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -4,13 +4,13 @@
 using namespace std;
 
 void
-ball_move(SceneGraphPtr node, int w, int h)
+ball_move(SceneGraphPtr node, void *sgroot_, int w, int h)
 {
     node->xyz[0] += 4;
 }
 
 void
-ball_coll(SceneGraphPtr node, int w, int h, SceneGraphPtr tree)
+ball_coll(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree)
 {
     if (node->xyz[0] > 600) node->remove();
 }
--- a/Renderer/Test/ball_action.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/ball_action.h	Fri Nov 27 18:27:32 2009 +0900
@@ -1,2 +1,2 @@
-void ball_move(SceneGraphPtr, int, int);
-void ball_coll(SceneGraphPtr, int, int, SceneGraphPtr);
+void ball_move(SceneGraphPtr node, void *sgroot_, int w, int h);
+void ball_coll(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree);
--- a/Renderer/Test/ball_bound.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/ball_bound.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -6,9 +6,9 @@
 
 
 // prototype
-static void ball_move(SceneGraphPtr node, int screen_w, int screen_h);
-static void ball_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree);
-static void ball_collision_idle(SceneGraphPtr, int w, int h, SceneGraphPtr tree);
+static void ball_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
+static void ball_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree);
+static void ball_collision_idle(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree);
 
 
 static float vy = 0.0f; // y 方向速度
@@ -24,8 +24,9 @@
 static float speed = 10.0f;
 
 static void
-ball_move_idle2(SceneGraphPtr node, int screen_w, int screen_h)
+ball_move_idle2(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
 
     if (pad->circle.isHold()) {
@@ -54,8 +55,9 @@
 static int time = 0;
 
 static void
-ball_move_idle(SceneGraphPtr node, int screen_w, int screen_h)
+ball_move_idle(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
 
     if (pad->circle.isPush()) {
@@ -77,7 +79,7 @@
 }
 
 static void
-ball_move(SceneGraphPtr node, int screen_w, int screen_h)
+ball_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     vy += g * dt;
     node->xyz[1] += vy * dt;
@@ -85,12 +87,12 @@
 }
 
 static void
-ball_collision_idle(SceneGraphPtr, int w, int h, SceneGraphPtr tree)
+ball_collision_idle(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree)
 {
 }
 
 static void
-ball_collision(SceneGraphPtr node, int screen_w, int screen_h,
+ball_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 			   SceneGraphPtr tree)
 {
     if (node->xyz[1] > screen_h - ball_radius) {
@@ -131,6 +133,12 @@
     return sgroot;
 }
 
+MainLoopPtr 
+ball_bound::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new ball_bound();
--- a/Renderer/Test/ball_bound.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/ball_bound.h	Fri Nov 27 18:27:32 2009 +0900
@@ -7,5 +7,5 @@
 class ball_bound : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };
--- a/Renderer/Test/boss1_action.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/boss1_action.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -10,14 +10,14 @@
 */
 
 static void
-null_collision(SceneGraphPtr node, int screen_w, int screen_h,
+null_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 	       SceneGraphPtr tree)
 {
 }
 
 
 static void
-boss1_move_right(SceneGraphPtr node, int screen_w, int screen_h) {
+boss1_move_right(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) {
   node->xyz[0] += node->stack_xyz[0];
   if(node->xyz[0] > (screen_w - boss_radius_x)) {
     node->set_move_collision(boss1_move_left, null_collision);
@@ -26,7 +26,7 @@
 
 //ボスが左に移動する動作
 static void
-boss1_move_left(SceneGraphPtr node, int screen_w, int screen_h) {
+boss1_move_left(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) {
   node->xyz[0] -= node->stack_xyz[0];
   if(node->xyz[0] < boss_radius_x) {
     node->set_move_collision(boss1_move_right, null_collision);
@@ -64,8 +64,9 @@
 */
 
 static void
-player_move(SceneGraphPtr node, int screen_w, int screen_h)
+player_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
   Pad *pad = sgroot->getController();
   
   if (pad->left.isPush()
@@ -126,9 +127,11 @@
 static int boss1sgid;
 
 static void
-player_collision(SceneGraphPtr node, int screen_w, int screen_h,
+player_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 		 SceneGraphPtr tree)
 {
+    
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
   //自機とボスのx,y座標での距離と2点間の距離
   static float x_distant, y_distant, distance;
   //ボスの四角形の四隅の座標
@@ -160,7 +163,7 @@
 }
 
 static void
-shot_move(SceneGraphPtr node, int screen_w, int screen_h)
+shot_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
   node->xyz[1] -= shot_speed;
   
@@ -171,9 +174,10 @@
 }
 
 static void
-shot_collision(SceneGraphPtr node, int screen_2, int screen_h,
+shot_collision(SceneGraphPtr node, void *sgroot_, int screen_2, int screen_h,
 	       SceneGraphPtr tree)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
   //自機とボスのx,y座標での距離と2点間の距離
   static float x_distant, y_distant, distance;
   //ボスの四角形の四隅の座標
@@ -205,6 +209,12 @@
   }
 }
 
+MainLoopPtr 
+boss1_action::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new boss1_action();
@@ -215,8 +225,10 @@
 static int blast8;
 
 static void
-blast_move(SceneGraphPtr node, int screen_w, int screen_h)
+blast_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
+
   if(node->sgid > blast8) {
     SceneGraphPtr blast = sgroot->createSceneGraph(node->sgid - 1);
     blast->set_move_collision(blast_move, null_collision);
--- a/Renderer/Test/boss1_action.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/boss1_action.h	Fri Nov 27 18:27:32 2009 +0900
@@ -10,7 +10,7 @@
 class boss1_action : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };
 
 static const float player_speed = 10.0f;
@@ -32,14 +32,14 @@
 */
 
 static void
-null_collision(SceneGraphPtr node, int screen_w, int screen_h,
+null_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 		SceneGraphPtr tree);
 
 static void
-boss1_move_right(SceneGraphPtr node, int screen_w, int screen_h);
+boss1_move_right(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
 
 static void
-boss1_move_left(SceneGraphPtr node, int screen_w, int screen_h);
+boss1_move_left(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
 
 /*
 static void
@@ -52,7 +52,7 @@
 */
 
 static void
-player_move(SceneGraphPtr node,int screen_2, int screen_h);
+player_move(SceneGraphPtr node, void *sgroot_, int screen_2, int screen_h);
 
 /*
 static void
@@ -60,15 +60,15 @@
 */
 
 static void
-player_collision(SceneGraphPtr node, int screen_w, int screen_h,
+player_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 		SceneGraphPtr tree);
 static void
-shot_move(SceneGraphPtr node, int screen_w, int screen_h);
+shot_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
 
 static void
-shot_collision(SceneGraphPtr node, int screen_2, int screen_h,
+shot_collision(SceneGraphPtr node, void *sgroot_, int screen_2, int screen_h,
 	       SceneGraphPtr tree);
 static void
-blast_move(SceneGraphPtr node, int screen_w, int screen_h);
+blast_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
 
 #endif
--- a/Renderer/Test/cube.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/cube.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -4,16 +4,17 @@
 #define SELECT 2
 
 void
-cube_collision(SceneGraphPtr node, int screen_w, int screen_h,
+cube_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
                SceneGraphPtr tree)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     if (node->frame > 120) {
-      cube_split(node,tree);
+	cube_split(node,tree, sgroot);
     }
 }
 
 void
-cube_move_left(SceneGraphPtr node, int screen_w, int screen_h)
+cube_move_left(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     node->xyz[0] -= node->stack_xyz[0];
     node->xyz[1] += node->stack_xyz[1];
@@ -36,7 +37,7 @@
 }
 
 void
-cube_move_right(SceneGraphPtr node, int screen_w, int screen_h)
+cube_move_right(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     node->xyz[0] += node->stack_xyz[0];
     node->xyz[1] += node->stack_xyz[1];
@@ -55,7 +56,8 @@
 extern int enemy ;
 
 void
-cube_split(SceneGraphPtr root,SceneGraphPtr tree)
+cube_split(SceneGraphPtr root,SceneGraphPtr tree, SceneGraphRoot *sgroot
+)
 {
 
   SceneGraphPtr p;
@@ -134,7 +136,7 @@
 }
 
 void
-collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h)
+collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h, SceneGraphRoot *sgroot)
 {
   float dx, dy,ddx,ddy, r;
   float q = 0;
@@ -149,7 +151,7 @@
     ddy = dy*dy;
 
     if(sqrt(ddx) < 10 && sqrt(ddy) < 10) {
-      gameover_scene(w,h,mcube);
+	gameover_scene(w,h,mcube, sgroot);
       node->remove();
       break;
     }
--- a/Renderer/Test/direction.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/direction.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -2,8 +2,9 @@
 #include "direction.h"
 
 static void
-x_move(SceneGraphPtr node, int w, int h)
+x_move(SceneGraphPtr node, void *sgroot_, int w, int h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
 
     node->xyz[0] = w/2;
@@ -27,8 +28,9 @@
 }
 
 static void
-y_move(SceneGraphPtr node, int w, int h)
+y_move(SceneGraphPtr node, void *sgroot_, int w, int h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
 
     node->xyz[0] = w/2;
@@ -50,14 +52,14 @@
 }
 
 static void
-z_move(SceneGraphPtr node, int w, int h)
+z_move(SceneGraphPtr node, void *sgroot_, int w, int h)
 {
     node->xyz[0] = w/2;
     node->xyz[1] = h/2;
 }
 
 static void
-dir_collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree)
+dir_collision(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree)
 {
 }
 
@@ -93,6 +95,12 @@
     return sgroot;
 }
 
+MainLoopPtr 
+direction::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new direction();
--- a/Renderer/Test/direction.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/direction.h	Fri Nov 27 18:27:32 2009 +0900
@@ -6,6 +6,6 @@
 class direction : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };
 
--- a/Renderer/Test/dynamic_create.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/dynamic_create.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -73,20 +73,21 @@
 
 
 static void
-earth_collision(SceneGraphPtr node, int screen_w, int screen_h,
+earth_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 		SceneGraphPtr tree)
 {    
 }
 
 static void
-moon_collision(SceneGraphPtr node, int screen_w, int screen_h,
+moon_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 	       SceneGraphPtr tree)
 {
 }
 
 static void
-moon_move(SceneGraphPtr node, int screen_w, int screen_h)
+moon_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
 	// LindaServerから座標データを取得してオブジェクトに反映させる。
     unsigned char *reply = psx_reply(node->seq);
 	if (reply != NULL) {
@@ -110,7 +111,8 @@
 }
 
 SceneGraphPtr
-create_sg(TaskManager *manager, SceneGraphPtr parent, unsigned char *data, int len, int serial_id)
+create_sg(TaskManager *manager, SceneGraphPtr parent, unsigned char *data,
+	  int len, int serial_id)
 {
     SceneGraphPtr child = sgroot->createSceneGraph();
     parent->addChild(child);
@@ -207,6 +209,12 @@
     return sgroot;
 }
 
+MainLoopPtr 
+dynamic_create::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new dynamic_create();
--- a/Renderer/Test/dynamic_create.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/dynamic_create.h	Fri Nov 27 18:27:32 2009 +0900
@@ -7,5 +7,5 @@
 class dynamic_create : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };
--- a/Renderer/Test/game_over.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/game_over.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -3,9 +3,8 @@
 
 
 void
-gameover_scene(int w,int h,SceneGraphPtr node)
+gameover_scene(int w,int h,SceneGraphPtr node, SceneGraphRoot *sgroot)
 {
-
   SceneGraphPtr over;
 
   over = sgroot->createSceneGraph("GAMEOVER");
@@ -16,14 +15,14 @@
 }
 
 void
-gameover_idle(SceneGraphPtr node,int screen_w,int screen_h)
+gameover_idle(SceneGraphPtr node, void *sgroot_, int screen_w,int screen_h)
 {
 }
 
 void
-gameover_collision(SceneGraphPtr node,int screen_w,int screen_h,SceneGraphPtr tree)
+gameover_collision(SceneGraphPtr node, void *sgroot_, int screen_w,int screen_h,SceneGraphPtr tree)
 {
-
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
   Pad *pad = sgroot->getController();
 
   if(pad->start.isPush()) {
--- a/Renderer/Test/gaplant.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/gaplant.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -33,7 +33,11 @@
     return sgroot;
 }
 
-
+MainLoopPtr 
+gaplant::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
 
 extern Application *
 application() {
--- a/Renderer/Test/gaplant.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/gaplant.h	Fri Nov 27 18:27:32 2009 +0900
@@ -10,6 +10,6 @@
 class gaplant : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };
 
--- a/Renderer/Test/gaplant_action.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/gaplant_action.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -49,8 +49,9 @@
 }
 
 void
-gaplant_move(SceneGraphPtr node, int w, int h)
+gaplant_move(SceneGraphPtr node, void *sgroot_, int w, int h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
     
     if (pad->right.isHold() || pad->left.isHold() || pad->down.isHold() || pad->up.isHold()) {
@@ -75,8 +76,9 @@
 }
 
 void
-gaplant_coll(SceneGraphPtr node, int w, int h, SceneGraphPtr tree)
+gaplant_coll(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     SceneGraphIteratorPtr it = sgroot->getIterator(tree);
     //static int damage = 0;
     
--- a/Renderer/Test/gaplant_action.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/gaplant_action.h	Fri Nov 27 18:27:32 2009 +0900
@@ -1,2 +1,2 @@
-void gaplant_move(SceneGraphPtr, int, int);
-void gaplant_coll(SceneGraphPtr, int, int, SceneGraphPtr);
+void gaplant_move(SceneGraphPtr node, void *sgroot_, int w, int h);
+void gaplant_coll(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree);
--- a/Renderer/Test/ieshoot.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/ieshoot.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -13,31 +13,32 @@
 static const float iebosstama_speed = 15.0f;
 
 static void
-ieboss_collision(SceneGraphPtr node, int screen_w, int screen_h,
+ieboss_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 		 SceneGraphPtr tree);
 static void
-ieboss_collision_invincibil(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree);
-static void ieboss_move(SceneGraphPtr node, int screen_w, int screen_h);
+ieboss_collision_invincibil(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree);
+static void ieboss_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
 
-static void iebosstama_move(SceneGraphPtr node, int screen_w, int screen_h);
+static void iebosstama_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
 
 
 static void
-iejiki_collision(SceneGraphPtr node, int screen_w, int screen_h,
+iejiki_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 	       SceneGraphPtr tree)
 {
 }
 
 static void
-ietama_collision(SceneGraphPtr node, int screen_w, int screen_h,
+ietama_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 		 SceneGraphPtr tree)
 {
 }
 
 static void
-ieboss_collision(SceneGraphPtr node, int screen_w, int screen_h,
+ieboss_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 		 SceneGraphPtr tree)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     SceneGraphIteratorPtr it = sgroot->getIterator(tree);
     static int damage = 0;
     int ietama = sgroot->getSgid("IETAMA");
@@ -69,7 +70,7 @@
 }
 
 static void
-ieboss_move(SceneGraphPtr node, int screen_w, int screen_h)
+ieboss_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     /**
      * TODO
@@ -99,7 +100,7 @@
 }
 
 static void
-ieboss_collision_invincibil(SceneGraphPtr node, int screen_w, int screen_h,
+ieboss_collision_invincibil(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 			    SceneGraphPtr tree)
 {
     static int frame = 0;
@@ -116,7 +117,7 @@
 }
 
 static void
-iebosstama_move(SceneGraphPtr node, int screen_w, int screen_h)
+iebosstama_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     node->xyz[1] += iebosstama_speed;
 
@@ -127,7 +128,7 @@
 }
 
 static void
-ietama_move(SceneGraphPtr node, int screen_w, int screen_h)
+ietama_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     node->xyz[1] -= tama_speed;
 
@@ -138,8 +139,9 @@
 }
 
 static void
-iejiki_move(SceneGraphPtr node, int screen_w, int screen_h)
+iejiki_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
 
     if (pad->left.isPush()
@@ -216,6 +218,12 @@
     return sgroot;
 }
 
+MainLoopPtr 
+ieshoot::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new ieshoot();
--- a/Renderer/Test/ieshoot.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/ieshoot.h	Fri Nov 27 18:27:32 2009 +0900
@@ -7,6 +7,6 @@
 class ieshoot : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };
 
--- a/Renderer/Test/node.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/node.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -4,13 +4,13 @@
 #include "node.h"
 
 static void
-cube_collision(SceneGraphPtr node, int screen_w, int screen_h,
+cube_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 	       SceneGraphPtr tree)
 {
 }
 
 static void
-cube_move2(SceneGraphPtr node, int screen_w, int screen_h)
+cube_move2(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     node->angle[1] += 1.0f;
     if (node->angle[1] > 360.0f) {
@@ -29,7 +29,7 @@
 }
 
 static void
-cube_move(SceneGraphPtr node, int screen_w, int screen_h)
+cube_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     node->angle[1] += 1.0f;
     if (node->angle[1] > 360.0f) {
@@ -73,6 +73,12 @@
     return sgroot;
 }
 
+MainLoopPtr 
+node::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new node();
--- a/Renderer/Test/node.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/node.h	Fri Nov 27 18:27:32 2009 +0900
@@ -6,6 +6,6 @@
 class node : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };
 
--- a/Renderer/Test/panel.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/panel.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -1,17 +1,17 @@
 #include "SceneGraphRoot.h"
 #include "panel.h"
 
-static void panel_move(SceneGraphPtr node, int screen_w, int screen_h);
-static void panel_collision(SceneGraphPtr node, int screen_w, int screen_h,
+static void panel_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
+static void panel_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 			    SceneGraphPtr tree);
 
 static void
-panel_move(SceneGraphPtr node, int screen_w, int screen_h)
+panel_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
 }
 
 static void
-panel_collision(SceneGraphPtr node, int screen_w, int screen_h,
+panel_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 	       SceneGraphPtr tree)
 {
 }
@@ -40,6 +40,12 @@
     return sgroot;
 }
 
+MainLoopPtr 
+panel::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new panel();
--- a/Renderer/Test/panel.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/panel.h	Fri Nov 27 18:27:32 2009 +0900
@@ -6,6 +6,6 @@
 class panel : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };
 
--- a/Renderer/Test/title.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/title.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -4,9 +4,9 @@
 extern int redcube;
 
 void
-title_collision(SceneGraphPtr node, int w, int h,SceneGraphPtr tree)
+title_collision(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree)
 {
-  
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
   Pad *pad = sgroot->getController();
   
   if(pad->start.isPush()) {
@@ -21,7 +21,7 @@
     
     back->addChild(vacuum);
     
-    add_cubecollision_object(redcube,vacuum,w,h);
+    add_cubecollision_object(redcube,vacuum,w,h, sgroot);
     
     sgroot->setSceneData(back);
       
--- a/Renderer/Test/universe.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/universe.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -3,26 +3,26 @@
 #include "universe.h"
 
 static void
-earth_collision(SceneGraphPtr node, int screen_w, int screen_h,
+earth_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 	       SceneGraphPtr tree)
 {
 }
 
 static void
-moon_collision(SceneGraphPtr node, int screen_w, int screen_h,
+moon_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 	       SceneGraphPtr tree)
 {
 }
 
 static void
-moon_move(SceneGraphPtr node, int screen_w, int screen_h)
+moon_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     node->angle[0] += 3.0f;
 }
 
 
 static void
-earth_move(SceneGraphPtr node, int screen_w, int screen_h)
+earth_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     node->angle[1] += 1.0f;
     if (node->angle[1] > 360.0f) {
@@ -68,6 +68,11 @@
     return sgroot;
 }
 
+MainLoopPtr 
+universe::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
 
 extern Application *
 application() {
--- a/Renderer/Test/universe.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/universe.h	Fri Nov 27 18:27:32 2009 +0900
@@ -7,6 +7,6 @@
 class universe : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };
 
--- a/Renderer/Test/untitled.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/untitled.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -4,20 +4,20 @@
 #include <math.h>
 
 static void
-cubetest_collision(SceneGraphPtr node, int screen_w, int screen_h,
+cubetest_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 	       SceneGraphPtr tree)
 {
 }
 
 static void
-test_collision(SceneGraphPtr node, int screen_w, int screen_h,
+test_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 	       SceneGraphPtr tree)
 {
   // test
 }
 
 static void
-test_move(SceneGraphPtr node, int screen_w, int screen_h)
+test_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
 
   node->angle[0] += 10.0f;
@@ -48,7 +48,7 @@
 }
 
 static void
-cubetest_move(SceneGraphPtr node, int screen_w, int screen_h)
+cubetest_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     node->angle[1] += 10.0f;
     if (node->angle[1] > 360.0f) {
@@ -148,6 +148,12 @@
     return sgroot;    
 }
 
+MainLoopPtr 
+untitled::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new untitled();
--- a/Renderer/Test/untitled.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/untitled.h	Fri Nov 27 18:27:32 2009 +0900
@@ -7,6 +7,6 @@
 class untitled : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };
 
--- a/Renderer/Test/vacuum.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/vacuum.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -15,13 +15,13 @@
 
 
 void
-no_move_idle(SceneGraphPtr node, int screen_w, int screen_h)
+no_move_idle(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
 
 }
 
 void
-no_collision_idle(SceneGraphPtr node, int screen_w, int screen_h,SceneGraphPtr tree)
+no_collision_idle(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,SceneGraphPtr tree)
 {
 
 }
@@ -30,17 +30,18 @@
 int enemy;
 
 void
-vacuum_coll(SceneGraphPtr node, int screen_w, int screen_h,
+vacuum_coll(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
             SceneGraphPtr tree)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     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, sgroot);
       }
       else {
-      add_cubecollision_object(enemy,node,screen_w,screen_h);
+	  add_cubecollision_object(enemy,node,screen_w,screen_h, sgroot);
       }
     }
 
@@ -48,18 +49,18 @@
       SceneGraphIteratorPtr it = sgroot->getIterator(tree);
       collision_red(it,node);
       it = sgroot->getIterator(tree);
-      collision_purple(it,node,screen_w,screen_h);
+      collision_purple(it,node,screen_w,screen_h, sgroot);
     }
 
     else if(pad->circle.isHold()) {
       SceneGraphIteratorPtr it = sgroot->getIterator(tree);
-      lock_attack(node,it);
+      lock_attack(node, it, sgroot);
     }
 
 }
 
 void
-lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it)
+lock_attack(SceneGraphPtr node,SceneGraphIteratorPtr it, SceneGraphRoot *sgroot)
 {
 
   SceneGraphPtr e;
@@ -96,8 +97,8 @@
 }
 
 void
-lockon_collision(SceneGraphPtr node,int w,int h,SceneGraphPtr tree) {
-
+lockon_collision(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree) {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
   Pad *pad = sgroot->getController();
   SceneGraphPtr lockon_enemy = node->parent;
 
@@ -113,8 +114,9 @@
 
 
 void
-vacuum_move(SceneGraphPtr node , int w, int h)
+vacuum_move(SceneGraphPtr node, void *sgroot_, int w, int h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
 
     if (pad->right.isHold() && w > node->xyz[0]) {
@@ -143,7 +145,7 @@
 
 /*cubeをランダムな場所に生成*/
 void
-add_cubecollision_object(int id,SceneGraphPtr root,int w,int h)
+add_cubecollision_object(int id,SceneGraphPtr root,int w,int h, SceneGraphRoot *sgroot)
 {
     SceneGraphPtr object;
     SceneGraphPtr common_move;
@@ -180,6 +182,12 @@
     return sgroot;
 }
 
+MainLoopPtr 
+vacuum::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new vacuum();
--- a/Renderer/Test/vacuum.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/vacuum.h	Fri Nov 27 18:27:32 2009 +0900
@@ -10,29 +10,29 @@
 class vacuum : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_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 cube_move_left(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
+extern void cube_move_right(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
+extern void no_move_idle(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
+extern void cube_collision_idle(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,SceneGraphPtr tree);
+extern void cube_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,SceneGraphPtr tree);
+extern void cube_split(SceneGraphPtr root,SceneGraphPtr tree, SceneGraphRoot *sgroot);
+extern void vacuum_move(SceneGraphPtr node, void *sgroot_, int w, int h);
+extern void vacuum_coll(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree);
+extern void title_idle(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
+extern void title_collision(SceneGraphPtr node, void *sgroot_, 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 gameover_idle(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
+extern void gameover_collision(SceneGraphPtr node, void *sgroot_, 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 collision_purple(SceneGraphIteratorPtr it,SceneGraphPtr node,int w,int h, SceneGraphRoot *sgroot);
+extern void gameover_scene(int w,int h, SceneGraphPtr node, SceneGraphRoot *sgroot);
+extern void add_cubecollision_object(int id,SceneGraphPtr root,int w,int h, SceneGraphRoot *sgroot);
+extern void lock_attack(SceneGraphPtr node, SceneGraphIteratorPtr it, SceneGraphRoot *sgroot);
+extern void lockon_collision(SceneGraphPtr node, void *sgroot_, int w,int h,SceneGraphPtr tree);
 extern void cube_rotate(SceneGraphPtr node,int w,int h);
 
 #endif
--- a/Renderer/Test/viewer.cc	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/viewer.cc	Fri Nov 27 18:27:32 2009 +0900
@@ -6,9 +6,9 @@
 
 
 // prototype
-static void ball_move(SceneGraphPtr node, int screen_w, int screen_h);
-static void ball_collision(SceneGraphPtr node, int screen_w, int screen_h, SceneGraphPtr tree);
-static void ball_collision_idle(SceneGraphPtr, int w, int h, SceneGraphPtr tree);
+static void ball_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
+static void ball_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree);
+static void ball_collision_idle(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree);
 
 
 static float vy = 0.0f; // y 方向速度
@@ -24,8 +24,9 @@
 static float speed = 10.0f;
 
 static void
-ball_move_idle2(SceneGraphPtr node, int screen_w, int screen_h)
+ball_move_idle2(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
 
     if (pad->circle.isHold()) {
@@ -54,8 +55,9 @@
 static int time = 0;
 
 static void
-ball_move_idle(SceneGraphPtr node, int screen_w, int screen_h)
+ball_move_idle(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     Pad *pad = sgroot->getController();
 
     if (pad->circle.isPush()) {
@@ -77,7 +79,7 @@
 }
 
 static void
-ball_move(SceneGraphPtr node, int screen_w, int screen_h)
+ball_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
     vy += g * dt;
     node->xyz[1] += vy * dt;
@@ -85,13 +87,13 @@
 }
 
 static void
-ball_collision_idle(SceneGraphPtr, int w, int h, SceneGraphPtr tree)
+ball_collision_idle(SceneGraphPtr, void *sgroot_, int w, int h, SceneGraphPtr tree)
 {
 }
 
 static void
-ball_collision(SceneGraphPtr node, int screen_w, int screen_h,
-			   SceneGraphPtr tree)
+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;
@@ -139,6 +141,12 @@
     return sgroot;
 }
 
+MainLoopPtr 
+viewer::init_only_sg(SgChange *sgroot, int screen_w, int screen_h)
+{
+    return sgroot;
+}
+
 extern Application *
 application() {
     return new viewer();
--- a/Renderer/Test/viewer.h	Fri Nov 27 18:22:20 2009 +0900
+++ b/Renderer/Test/viewer.h	Fri Nov 27 18:27:32 2009 +0900
@@ -7,5 +7,5 @@
 class viewer : public Application {
 
     MainLoopPtr init(Viewer *viewer, int screen_w, int screen_h);
-
+    MainLoopPtr init_only_sg(SgChange *viewer, int screen_w, int screen_h);
 };