diff Renderer/Test/create_task.cc @ 758:e615e552efa5

change Test/create_task
author hiroki
date Sat, 30 Jan 2010 19:33:16 +0900
parents 5238f3e854fc
children bb47827c04c1
line wrap: on
line diff
--- a/Renderer/Test/create_task.cc	Fri Jan 29 14:34:30 2010 +0900
+++ b/Renderer/Test/create_task.cc	Sat Jan 30 19:33:16 2010 +0900
@@ -12,6 +12,7 @@
 // prototype
 static void move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h);
 static void collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree);
+static void createSceneGraphFromProperty(SchedTask *s, void *sgroot, void *arg1);
 
 static void
 move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
@@ -20,16 +21,12 @@
     TaskManager *manager = sgroot->tmanager;
     HTaskPtr property_task = manager->create_task(PropertyTask);
 
-    printf("%f, %f, %f\n", update_property->x, update_property->y, update_property->z);
-    property->x = update_property->x;
-    property->y = update_property->y;
-    property->z = update_property->z;    
-
     property_task->add_inData(property, sizeof(Property));
     property_task->add_outData(update_property, sizeof(Property));
     property_task->set_cpu(SPE_ANY);
+
+    property_task->set_post(createSceneGraphFromProperty, update_property, sgroot);
     property_task->spawn();
-
 }
 
 static void
@@ -38,9 +35,40 @@
 {
 }
 
+static void
+createSceneGraphFromProperty(SchedTask *s, void *sgroot_, void *arg1)
+{
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
+    SceneGraphPtr node;
+
+    node = sgroot->createSceneGraph(update_property->name);
+    node->set_move_collision(move, collision);
+    node->xyz[0] = update_property->xyz[0];
+    node->xyz[1] = update_property->xyz[1];
+    node->xyz[2] = update_property->xyz[2];
+    sgroot->setSceneData(node);
+
+    Property *tmp = property;
+    property = update_property;
+    update_property = tmp;
+    
+}
+
+static void
+set_property(Property *p, SceneGraphPtr sg)
+{
+    p->xyz[0] = sg->xyz[0];
+    p->xyz[1] = sg->xyz[1];
+    p->xyz[2] = sg->xyz[2];
+    p->name = sg->name;
+}
+
 MainLoopPtr 
 create_task::init(Viewer *sgroot, int screen_w, int screen_h)
 {
+    property        = (Property *)sgroot->manager->allocate(sizeof(Property));
+    update_property = (Property *)sgroot->manager->allocate(sizeof(Property));
+
     SceneGraphPtr ball;
 
     sgroot->createFromXMLfile("xml_file/Ball.xml");
@@ -52,11 +80,10 @@
     ball->xyz[1] = screen_h/2;
     ball->xyz[2] = 30.0f;
 
+    set_property(property, ball);
+    
     sgroot->setSceneData(ball);
 
-    property        = (Property *)sgroot->manager->allocate(sizeof(Property));
-    update_property = (Property *)sgroot->manager->allocate(sizeof(Property));
-
     return sgroot;
 }