Mercurial > hg > Members > kono > Cerium
diff Renderer/Application/universe.cc @ 507:735f76483bb2
Reorganization..
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 12 Oct 2009 09:39:35 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Application/universe.cc Mon Oct 12 09:39:35 2009 +0900 @@ -0,0 +1,68 @@ +#include <stdlib.h> +#include "SceneGraphRoot.h" +#include "SGList.h" + +static void +earth_collision(SceneGraphPtr node, int screen_w, int screen_h, + SceneGraphPtr tree) +{ +} + +static void +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; +} + + +static void +earth_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; + } + + 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]; + } + + 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]; + } +} + +void +universe_init(TaskManager *manager) +{ + SceneGraphPtr earth; + SceneGraphPtr moon; + + sgroot->createFromXMLfile(manager, "xml_file/universe.xml"); + + // SGList.h にある SceneGraph ID から SceneGraph を生成する + earth = sgroot->createSceneGraph(Earth); + + // SceneGraph の move と collision を設定 + earth->set_move_collision(earth_move, earth_collision); + earth->stack_xyz[0] = 3.0f; + earth->stack_xyz[1] = 3.0f; + + moon = sgroot->createSceneGraph(Moon); + moon->set_move_collision(moon_move, moon_collision); + + // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) + earth->addChild(moon); + + // SceneGraphRoot に、使用する SceneGraph を設定する + // このとき、ユーザーが記述した SceneGraph の root を渡す。 + sgroot->setSceneData(earth); +}