Mercurial > hg > Game > Cerium
view Renderer/Test/create_task.cc @ 757:2aa6e7150588 draft
change Test/create_task
author | hiroki |
---|---|
date | Sat, 30 Jan 2010 19:33:16 +0900 |
parents | a871b0d9c9ae |
children | 77f936380930 |
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" 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, update_property, sgroot); 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->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"); 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 */