Mercurial > hg > Game > Cerium
view Renderer/Test/light_test.cc @ 1479:163220e54cc0 draft
remove hard code for TaskLog
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Jul 2012 17:15:15 +0900 |
parents | e92f00ed2fc0 |
children |
line wrap: on
line source
#include <stdlib.h> #include "SceneGraphRoot.h" #include "light_test.h" // prototype static void light_move_translation(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h); static void light_move_rotation(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h); static void light_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree); static void object_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h); static void object_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree); static void object_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { } static void object_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { } static void light_move_translation(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; Pad *pad = sgroot->getController(); if (pad->circle.isPush()) { node->set_move_collision(light_move_rotation, light_collision); } if (pad->left.isHold()) { node->xyz[0] -= 10; } else if (pad->right.isHold()) { node->xyz[0] += 10; } if (pad->up.isHold()) { node->xyz[1] -= 10; } else if (pad->down.isHold()) { node->xyz[1] += 10; } } static void light_move_rotation(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; Pad *pad = sgroot->getController(); if (pad->circle.isPush()) { node->set_move_collision(light_move_translation, light_collision); } if (pad->up.isHold()) { node->xyz[2] += 10; } else if (pad->down.isHold()) { node->xyz[2] -= 10; } if (pad->up.isHold()) { node->angle[0] += 10; } else if (pad->down.isHold()) { node->angle[0] -= 10; } } static void light_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { } MainLoopPtr light_test::init(Viewer *sgroot, int screen_w, int screen_h) { sgroot->createFromXMLfile( "xml_file/universe.xml"); sgroot->createFromXMLfile( "xml_file/cube.xml"); sgroot->OnLightSysSwitch(); SceneGraphPtr light = sgroot->getLight(0); //光源のスイッチON sgroot->OnLightSwitch(1); // SceneGraph ID から SceneGraph を生成する SceneGraphPtr light_object = sgroot->createSceneGraph("Cube"); light_object->set_move_collision(light_move_translation, light_collision); light_object->xyz[0] = screen_w / 2; light_object->xyz[1] = screen_h / 2; SceneGraphPtr moon = sgroot->createSceneGraph("Moon"); moon->set_move_collision(object_move, object_collision); moon->xyz[0] = screen_w / 2; moon->xyz[1] = screen_h / 2; // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) SceneGraphPtr root = sgroot->createSceneGraph(); root->addChild(light_object); light_object->addChild(light); root->addChild(moon); // SceneGraphRoot に、使用する SceneGraph を設定する // このとき、ユーザーは SceneGraph の root を渡す。 sgroot->setSceneData(root); return sgroot; } extern Application * application() { return new light_test(); } 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 */