Mercurial > hg > Members > kono > Cerium
view Renderer/Test/create_task.cc @ 759:bb47827c04c1
fix create_task
author | hiroki@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 01 Feb 2010 17:08:36 +0900 |
parents | e615e552efa5 |
children | 24a37fe8419a |
line wrap: on
line source
#include <math.h> #include <stdlib.h> #include "SceneGraphRoot.h" #include "MainLoop.h" #include "create_task.h" #include "types.h" #include "Func.h" #include "SgChange.h" Property *property, *update_property; // 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) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; TaskManager *manager = sgroot->tmanager; HTaskPtr property_task = manager->create_task(PropertyTask); 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, (void *)sgroot, 0); property_task->spawn(); } static void collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { } static void createSceneGraphFromProperty(SchedTask *s, void *sgroot_, void *arg1) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; SceneGraphPtr node; node = sgroot->createSceneGraph(update_property->name); //node = sgroot->createSceneGraph("Ball"); 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 *viewer, int screen_w, int screen_h) { // SgChange を使うための2行 SgChange *sgroot = new SgChange(viewer); sgroot->run_init(); property = (Property *)sgroot->manager->allocate(sizeof(Property)); update_property = (Property *)sgroot->manager->allocate(sizeof(Property)); 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; set_property(property, ball); 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 */