Mercurial > hg > Members > kono > Cerium
annotate TaskManager/Test/test_render/universe.cpp @ 224:ebfb9e389716
SceneGraph.cpp xmlcreate
author | tkaito@nw0534.st.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 10 Feb 2009 20:45:51 +0900 |
parents | 5ffee529dc59 |
children | c254a2bd1b34 |
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; | |
213
159519cdca1f
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
199
diff
changeset
|
23 #if 0 |
195 | 24 if (node->angle[0] > 360.0f) { |
25 node->remove(); | |
26 //node->angle[0] = 0.0f; | |
27 moonrem = 1; | |
28 } | |
213
159519cdca1f
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
199
diff
changeset
|
29 #endif |
195 | 30 } |
31 | |
32 | |
33 static void | |
222 | 34 earth_move(SceneGraphPtr node, int screen_w, int screen_h) |
157 | 35 { |
222 | 36 return; |
37 | |
157 | 38 node->angle[1] += 1.0f; |
39 if (node->angle[1] > 360.0f) { | |
40 node->angle[1] = 0.0f; | |
213
159519cdca1f
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
199
diff
changeset
|
41 #if 0 |
195 | 42 if (moonrem) { |
43 SceneGraphPtr moon = sgroot->createSceneGraph(Moon); | |
44 moon->set_move_collision(moon_move, moon_collision); | |
45 node->addChild(moon); | |
46 moonrem = 0; | |
47 } | |
213
159519cdca1f
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
199
diff
changeset
|
48 #endif |
157 | 49 } |
50 | |
51 node->xyz[0] += node->stack_xyz[0]; | |
52 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
53 node->stack_xyz[0] = -node->stack_xyz[0]; | |
54 } | |
55 | |
56 node->xyz[1] += node->stack_xyz[1]; | |
57 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
58 node->stack_xyz[1] = -node->stack_xyz[1]; | |
59 } | |
60 } | |
61 | |
195 | 62 void |
198
57921c8d21c5
rename snake_bg to panel
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
195
diff
changeset
|
63 universe_init(void) |
157 | 64 { |
195 | 65 SceneGraphPtr earth; |
222 | 66 //SceneGraphPtr moon; |
157 | 67 |
195 | 68 sgroot->createFromXMLfile("xml_file/universe.xml"); |
157 | 69 |
195 | 70 // SGList.h にある SceneGraph ID から SceneGraph を生成する |
71 earth = sgroot->createSceneGraph(Earth); | |
157 | 72 |
195 | 73 // SceneGraph の move と collision を設定 |
222 | 74 earth->set_move_collision(earth_move, earth_collision); |
75 earth->xyz[0] = 960.0f; | |
76 earth->xyz[1] = 540.0f; | |
195 | 77 earth->stack_xyz[0] = 3.0f; |
78 earth->stack_xyz[1] = 3.0f; | |
213
159519cdca1f
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
199
diff
changeset
|
79 |
222 | 80 //moon = sgroot->createSceneGraph(Moon); |
81 //moon->set_move_collision(moon_move, moon_collision); | |
82 | |
83 // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) | |
84 //earth->addChild(moon); | |
195 | 85 |
86 // SceneGraphRoot に、使用する SceneGraph を設定する | |
87 // このとき、ユーザーが記述した SceneGraph の root を渡す。 | |
88 sgroot->setSceneData(earth); | |
157 | 89 } |