Mercurial > hg > Game > Cerium
annotate Renderer/Test/universe.cc @ 558:00428ba0ba03 draft
boss1_action
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 22 Oct 2009 18:38:07 +0900 |
parents | 764772be1e3c |
children | 338ad9c856fc |
rev | line source |
---|---|
539 | 1 #include <stdlib.h> |
2 #include "SceneGraphRoot.h" | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
3 #include "universe.h" |
539 | 4 |
5 static void | |
6 earth_collision(SceneGraphPtr node, int screen_w, int screen_h, | |
7 SceneGraphPtr tree) | |
8 { | |
9 } | |
10 | |
11 static void | |
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 | |
25 earth_move(SceneGraphPtr node, int screen_w, int screen_h) | |
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 | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
43 MainLoopPtr |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
44 universe::init(Viewer *sgroot, int screen_w, int screen_h) |
539 | 45 { |
46 SceneGraphPtr earth; | |
47 SceneGraphPtr moon; | |
48 | |
49 sgroot->createFromXMLfile(manager, "xml_file/universe.xml"); | |
50 | |
51 // SGList.h にある SceneGraph ID から SceneGraph を生成する | |
52 earth = sgroot->createSceneGraph(Earth); | |
53 | |
54 // SceneGraph の move と collision を設定 | |
55 earth->set_move_collision(earth_move, earth_collision); | |
56 earth->stack_xyz[0] = 3.0f; | |
57 earth->stack_xyz[1] = 3.0f; | |
58 | |
59 moon = sgroot->createSceneGraph(Moon); | |
60 moon->set_move_collision(moon_move, moon_collision); | |
61 | |
62 // SceneGraph 同士の親子関係を設定 (今回は 親 earth、子 moon) | |
63 earth->addChild(moon); | |
64 | |
65 // SceneGraphRoot に、使用する SceneGraph を設定する | |
66 // このとき、ユーザーが記述した SceneGraph の root を渡す。 | |
67 sgroot->setSceneData(earth); | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
68 return sgroot; |
539 | 69 } |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
70 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
71 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
72 extern Application * |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
73 application() { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
74 return new ball_bound(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
75 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
76 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
77 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
78 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
79 extern int init(TaskManager *manager, int argc, char *argv[]); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
80 extern void task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
81 static void TMend(TaskManager *manager); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
82 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
83 int |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
84 TMmain(TaskManager *manager, int argc, char *argv[]) |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
85 { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
86 task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
87 manager->set_TMend(TMend); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
88 return init(manager, argc, argv); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
89 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
90 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
91 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
92 void |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
93 TMend(TaskManager *manager) |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
94 { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
95 printf("test_nogl end\n"); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
96 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
97 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
98 /* end */ |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
99 |