Mercurial > hg > Game > Cerium
annotate TaskManager/Test/test_render/universe.cpp @ 228:5bb12a76a335 draft
remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
author | gongo@gendarme.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Thu, 12 Feb 2009 16:31:38 +0900 |
parents | 0351818cf0fe |
children | ce86b0186a4a |
rev | line source |
---|---|
157 | 1 #include <stdlib.h> |
195 | 2 #include "SceneGraphRoot.h" |
3 #include "SGList.h" | |
4 | |
157 | 5 static void |
199
1fd0107ebb25
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
198
diff
changeset
|
6 earth_collision(SceneGraphPtr node, int screen_w, int screen_h, |
157 | 7 SceneGraphPtr tree) |
8 { | |
9 } | |
10 | |
11 static void | |
195 | 12 moon_collision(SceneGraphPtr node, int screen_w, int screen_h, |
13 SceneGraphPtr tree) | |
14 { | |
15 } | |
16 | |
17 static void | |
18 moon_move(SceneGraphPtr node, int screen_w, int screen_h) | |
19 { | |
20 node->angle[0] += 3.0f; | |
21 } | |
22 | |
23 | |
24 static void | |
222 | 25 earth_move(SceneGraphPtr node, int screen_w, int screen_h) |
157 | 26 { |
27 node->angle[1] += 1.0f; | |
28 if (node->angle[1] > 360.0f) { | |
29 node->angle[1] = 0.0f; | |
30 } | |
31 | |
32 node->xyz[0] += node->stack_xyz[0]; | |
33 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
34 node->stack_xyz[0] = -node->stack_xyz[0]; | |
35 } | |
36 | |
37 node->xyz[1] += node->stack_xyz[1]; | |
38 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
39 node->stack_xyz[1] = -node->stack_xyz[1]; | |
40 } | |
41 } | |
42 | |
195 | 43 void |
198
b832e6cff83e
rename snake_bg to panel
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
195
diff
changeset
|
44 universe_init(void) |
157 | 45 { |
195 | 46 SceneGraphPtr earth; |
228
5bb12a76a335
remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
47 SceneGraphPtr moon; |
157 | 48 |
195 | 49 sgroot->createFromXMLfile("xml_file/universe.xml"); |
157 | 50 |
195 | 51 // SGList.h にある SceneGraph ID から SceneGraph を生成する |
52 earth = sgroot->createSceneGraph(Earth); | |
157 | 53 |
195 | 54 // SceneGraph の move と collision を設定 |
222 | 55 earth->set_move_collision(earth_move, earth_collision); |
195 | 56 earth->stack_xyz[0] = 3.0f; |
57 earth->stack_xyz[1] = 3.0f; | |
228
5bb12a76a335
remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
58 |
5bb12a76a335
remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
59 moon = sgroot->createSceneGraph(Moon); |
5bb12a76a335
remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
60 moon->set_move_collision(moon_move, moon_collision); |
222 | 61 |
62 // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) | |
228
5bb12a76a335
remove SceneGraph::data, add SceneGraph::coord_xyz, coord_tex, normal
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
63 earth->addChild(moon); |
195 | 64 |
65 // SceneGraphRoot に、使用する SceneGraph を設定する | |
66 // このとき、ユーザーが記述した SceneGraph の root を渡す。 | |
67 sgroot->setSceneData(earth); | |
157 | 68 } |