Mercurial > hg > Game > Cerium
annotate Renderer/Test/untitled.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" | |
3 #include "SGList.h" | |
4 #include <math.h> | |
5 | |
6 static void | |
7 cubetest_collision(SceneGraphPtr node, int screen_w, int screen_h, | |
8 SceneGraphPtr tree) | |
9 { | |
10 } | |
11 | |
12 static void | |
13 test_collision(SceneGraphPtr node, int screen_w, int screen_h, | |
14 SceneGraphPtr tree) | |
15 { | |
16 // test | |
17 } | |
18 | |
19 static void | |
20 test_move(SceneGraphPtr node, int screen_w, int screen_h) | |
21 { | |
22 | |
23 node->angle[0] += 10.0f; | |
24 /* | |
25 node->stack_xyz[0] = 2.0f; | |
26 node->stack_xyz[1] = 2.0f; | |
27 | |
28 //node->xyz[0] += node->stack_xyz[0]; | |
29 node->xyz[0] += node->stack_xyz[0]; | |
30 node->xyz[1] += node->stack_xyz[1]; | |
31 | |
32 if ((int)node->xyz[0] > screen_w | |
33 || (int)node->xyz[0] < 0) { | |
34 node->stack_xyz[0] = -node->stack_xyz[0]; | |
35 } | |
36 | |
37 if ((int)node->xyz[1] > screen_w | |
38 || (int)node->xyz[1] < 0) { | |
39 node->stack_xyz[1] = -node->stack_xyz[1]; | |
40 } | |
41 | |
42 if ((int)node->xyz[2] > 1000 | |
43 || (int)node->xyz[2] < 100) { | |
44 node->stack_xyz[1] = -node->stack_xyz[1]; | |
45 } | |
46 */ | |
47 | |
48 } | |
49 | |
50 static void | |
51 cubetest_move(SceneGraphPtr node, int screen_w, int screen_h) | |
52 { | |
53 node->angle[1] += 10.0f; | |
54 if (node->angle[1] > 360.0f) { | |
55 node->angle[1] = 0.0f; | |
56 } | |
57 //node->xyz[0] = screen_w/2; | |
58 node->xyz[0] += node->stack_xyz[0]; | |
59 if ((int)node->xyz[0] > screen_w || (int)node->xyz[0] < 0) { | |
60 node->stack_xyz[0] = -node->stack_xyz[0]; | |
61 } | |
62 //node->xyz[1] = screen_h/2; | |
63 node->xyz[1] += node->stack_xyz[1]; | |
64 if ((int)node->xyz[1] > screen_h || (int)node->xyz[1] < 0) { | |
65 node->stack_xyz[1] = -node->stack_xyz[1]; | |
66 } | |
67 | |
68 node->xyz[2] = 1000; | |
69 //node->xyz[2] += node->stack_xyz[2]; | |
70 //if ((int)node->xyz[2] > screen_h || (int)node->xyz[2] < 100) { | |
71 //node->stack_xyz[2] = -node->stack_xyz[2]; | |
72 //} | |
73 | |
74 } | |
75 | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
76 MainLoopPtr |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
77 untitled::init(Viewer *sgroot, int screen_w, int screen_h) |
539 | 78 { |
79 SceneGraphPtr test00; | |
80 SceneGraphPtr test01; | |
81 SceneGraphPtr test02; | |
82 SceneGraphPtr test03; | |
83 SceneGraphPtr test04; | |
84 SceneGraphPtr test05; | |
85 SceneGraphPtr test06; | |
86 SceneGraphPtr test07; | |
87 SceneGraphPtr test08; | |
88 SceneGraphPtr test09; | |
89 | |
90 sgroot->createFromXMLfile(manager, "xml_file/Venus.xml"); | |
91 | |
92 // SGList.h にある SceneGraph ID から SceneGraph を生成する | |
93 /* | |
94 test00 = sgroot->createSceneGraph(cubetest000); | |
95 test01 = sgroot->createSceneGraph(cubetest009); | |
96 test02 = sgroot->createSceneGraph(cubetest008); | |
97 test03 = sgroot->createSceneGraph(cubetest007); | |
98 test04 = sgroot->createSceneGraph(cubetest006); | |
99 test05 = sgroot->createSceneGraph(cubetest005); | |
100 test06 = sgroot->createSceneGraph(cubetest004); | |
101 test07 = sgroot->createSceneGraph(cubetest003); | |
102 test08 = sgroot->createSceneGraph(cubetest002); | |
103 test09 = sgroot->createSceneGraph(cubetest001); | |
104 */ | |
105 test00 = sgroot->createSceneGraph(Venus000); | |
106 test01 = sgroot->createSceneGraph(Venus009); | |
107 test02 = sgroot->createSceneGraph(Venus008); | |
108 test03 = sgroot->createSceneGraph(Venus007); | |
109 test04 = sgroot->createSceneGraph(Venus006); | |
110 test05 = sgroot->createSceneGraph(Venus005); | |
111 test06 = sgroot->createSceneGraph(Venus004); | |
112 test07 = sgroot->createSceneGraph(Venus003); | |
113 test08 = sgroot->createSceneGraph(Venus002); | |
114 test09 = sgroot->createSceneGraph(Venus001); | |
115 | |
116 // SceneGraph の move と collision を設定 | |
117 test00->set_move_collision(cubetest_move, cubetest_collision); | |
118 test00->stack_xyz[0] = 3.0f; | |
119 test00->stack_xyz[1] = 3.0f; | |
120 test00->stack_xyz[2] = 3.0f; | |
121 | |
122 | |
123 | |
124 test01->set_move_collision(test_move, test_collision); | |
125 test02->set_move_collision(test_move, test_collision); | |
126 test03->set_move_collision(test_move, test_collision); | |
127 test04->set_move_collision(test_move, test_collision); | |
128 test05->set_move_collision(test_move, test_collision); | |
129 test06->set_move_collision(test_move, test_collision); | |
130 test07->set_move_collision(test_move, test_collision); | |
131 test08->set_move_collision(test_move, test_collision); | |
132 test09->set_move_collision(test_move, test_collision); | |
133 | |
134 // SceneGraph 同士の親子関係を設定 (今回は 親 test00、子 その他) | |
135 test00->addChild(test01); | |
136 test00->addChild(test02); | |
137 test00->addChild(test03); | |
138 test00->addChild(test04); | |
139 test00->addChild(test05); | |
140 test00->addChild(test06); | |
141 test00->addChild(test07); | |
142 test00->addChild(test08); | |
143 test00->addChild(test09); | |
144 | |
145 // SceneGraphRoot に、使用する SceneGraph を設定する | |
146 // このとき、ユーザーが記述した SceneGraph の root を渡す。 | |
147 sgroot->setSceneData(test00); | |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
148 return sgroot; |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
149 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
150 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
151 extern Application * |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
152 application() { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
153 return new untitiled(); |
539 | 154 } |
557
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
155 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
156 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
|
157 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
158 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
|
159 extern void task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
160 static void TMend(TaskManager *manager); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
161 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
162 int |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
163 TMmain(TaskManager *manager, int argc, char *argv[]) |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
164 { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
165 task_initialize(); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
166 manager->set_TMend(TMend); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
167 return init(manager, argc, argv); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
168 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
169 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
170 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
171 void |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
172 TMend(TaskManager *manager) |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
173 { |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
174 printf("test_nogl end\n"); |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
175 } |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
176 |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
177 /* end */ |
764772be1e3c
fix examlples (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
178 |