changeset 758:e615e552efa5

change Test/create_task
author hiroki
date Sat, 30 Jan 2010 19:33:16 +0900
parents 5238f3e854fc
children bb47827c04c1
files Renderer/Engine/spe/Property.cc Renderer/Test/create_task.cc Renderer/Test/create_task.h
diffstat 3 files changed, 43 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/spe/Property.cc	Fri Jan 29 14:34:30 2010 +0900
+++ b/Renderer/Engine/spe/Property.cc	Sat Jan 30 19:33:16 2010 +0900
@@ -9,8 +9,8 @@
 SchedDefineTask(PropertyTask);
 
 typedef struct {
-    float x, y, z;
-    int pad;
+    float xyz[3];
+    const char *name;
 } Property, *PropertyPtr;
 
 static int
@@ -19,9 +19,9 @@
     PropertyPtr	property	= (PropertyPtr)s->get_input(rbuf, 0);
     PropertyPtr	update_property = (PropertyPtr)s->get_output(wbuf, 0);
 
-    property->x += 1.0f;
-    property->y += 1.0f;
-    property->z += 1.0f;
+    property->xyz[0] += 1.0f;
+    property->xyz[1] += 1.0f;
+    property->xyz[2] += 1.0f;
 
     memcpy((void*)update_property, (void*)property, sizeof(Property));
     return 0;
--- 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;
 }
 
--- a/Renderer/Test/create_task.h	Fri Jan 29 14:34:30 2010 +0900
+++ b/Renderer/Test/create_task.h	Sat Jan 30 19:33:16 2010 +0900
@@ -6,8 +6,8 @@
 #include "viewer.h"
 
 typedef struct {
-    float x, y, z;
-    int pad;
+    float xyz[3];  // 12 byte
+    const char *name;
 } *PropertyPtr, Property;
 
 class create_task : public Application {