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