diff Renderer/Test/create_task.cc @ 756:2575791a333a

add Test/create_task {spe, task}/Property
author hiroki@henri.cr.ie.u-ryukyu.ac.jp
date Fri, 29 Jan 2010 11:34:43 +0900
parents
children 5238f3e854fc
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Test/create_task.cc	Fri Jan 29 11:34:43 2010 +0900
@@ -0,0 +1,81 @@
+#include <math.h>
+#include <stdlib.h>
+#include "SceneGraphRoot.h"
+#include "MainLoop.h"
+#include "create_task.h"
+#include "sys.h"
+#include "Func.h"
+
+// 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
+move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
+{
+    SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
+    TaskManager *manager = sgroot->tmanager;
+    HTaskPtr property_task = manager->create_task(PropertyTask);
+
+    Property *property        = (Property *)manager->allocate(sizeof(Property));
+    Property *property_update = (Property *)manager->allocate(sizeof(Property));
+
+    property_task->add_inData(property, sizeof(Property));
+    property_task->add_outData(property_update, sizeof(Property));
+    property_task->set_cpu(SPE_ANY);
+
+    property_task->spawn();
+}
+
+static void
+collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
+	  SceneGraphPtr tree)
+{
+}
+
+MainLoopPtr 
+create_task::init(Viewer *sgroot, int screen_w, int screen_h)
+{
+    SceneGraphPtr ball;
+
+    sgroot->createFromXMLfile("xml_file/Ball.xml");
+
+    ball = sgroot->createSceneGraph("Ball");
+    ball->set_move_collision(move, collision);
+
+    ball->xyz[0] = screen_w/2;
+    ball->xyz[1] = screen_h/2;
+    ball->xyz[2] = 30.0f;
+
+    sgroot->setSceneData(ball);
+
+    return sgroot;
+}
+
+extern Application *
+application() {
+    return new create_task();
+}
+
+const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n";
+
+extern int 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 init(manager, argc, argv);
+
+}
+
+void
+TMend(TaskManager *manager)
+{
+    printf("test_nogl end\n");
+}
+
+/* end */