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