Mercurial > hg > Game > Cerium
diff TaskManager/Test/test_render/universe.cpp @ 195:4e66b3327c50 draft
fix
author | gongo@gendarme.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Sun, 25 Jan 2009 17:44:17 +0900 |
parents | 121b08b64b44 |
children | b832e6cff83e |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/universe.cpp Tue Jan 20 14:50:41 2009 +0900 +++ b/TaskManager/Test/test_render/universe.cpp Sun Jan 25 17:44:17 2009 +0900 @@ -1,6 +1,9 @@ #include <stdlib.h> -#include "SceneGraph.h" -#include "xml_file/universe.h" +#include "SceneGraphRoot.h" +#include "SGList.h" + +SceneGraphRootPtr sgroot; +int moonrem = 0; static void cube_collision(SceneGraphPtr node, int screen_w, int screen_h, @@ -9,11 +12,36 @@ } static void -cube_move2(SceneGraphPtr node, int screen_w, int screen_h) +moon_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +static void +moon_move(SceneGraphPtr node, int screen_w, int screen_h) +{ + node->angle[0] += 3.0f; + printf("%f\n", node->angle[0]); + if (node->angle[0] > 360.0f) { + node->remove(); + //node->angle[0] = 0.0f; + moonrem = 1; + } +} + + +static void +cube_move(SceneGraphPtr node, int screen_w, int screen_h) { node->angle[1] += 1.0f; if (node->angle[1] > 360.0f) { node->angle[1] = 0.0f; + if (moonrem) { + SceneGraphPtr moon = sgroot->createSceneGraph(Moon); + moon->set_move_collision(moon_move, moon_collision); + node->addChild(moon); + moonrem = 0; + } } node->xyz[0] += node->stack_xyz[0]; @@ -27,40 +55,30 @@ } } -static void -cube_move(SceneGraphPtr node, int screen_w, int screen_h) +void +universe_init(SceneGraphRootPtr _sgroot) { - node->angle[1] += 1.0f; - if (node->angle[1] > 360.0f) { - node->angle[1] = 0.0f; - } + SceneGraphPtr earth; + SceneGraphPtr moon; - node->xyz[0] += node->stack_xyz[0]; - if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { - node->stack_xyz[0] = -node->stack_xyz[0]; - } + sgroot = _sgroot; + + sgroot->createFromXMLfile("xml_file/universe.xml"); - node->xyz[1] += node->stack_xyz[1]; - if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { - node->stack_xyz[1] = -node->stack_xyz[1]; - } -} + // SGList.h にある SceneGraph ID から SceneGraph を生成する + earth = sgroot->createSceneGraph(Earth); + moon = sgroot->createSceneGraph(Moon); -static void -moon_move(SceneGraphPtr node, int screen_w, int screen_h) -{ - node->angle[1] += 1.0f; - if (node->angle[0] > 360.0f) { - node->angle[0] = 0.0f; - } -} + // SceneGraph の move と collision を設定 + earth->set_move_collision(cube_move, cube_collision); + earth->stack_xyz[0] = 3.0f; + earth->stack_xyz[1] = 3.0f; + moon->set_move_collision(moon_move, moon_collision); -void -universe_init(void) -{ - SceneGraph::createFromXMLfile("xml_file/universe.xml"); - Earth->set_move_collision(cube_move, cube_collision); - Earth->stack_xyz[0] = 3.0f; - Earth->stack_xyz[1] = 3.0f; - Moon->set_move_collision(moon_move, cube_collision); + // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) + earth->addChild(moon); + + // SceneGraphRoot に、使用する SceneGraph を設定する + // このとき、ユーザーが記述した SceneGraph の root を渡す。 + sgroot->setSceneData(earth); }