Mercurial > hg > Members > kono > Cerium
annotate Renderer/Engine/SceneGraphRoot.cc @ 994:33616b2789de
SDL mode fix
author | yutaka@charles.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 11 Oct 2010 14:21:02 +0900 |
parents | 9a53faae88d8 |
children | c79651141045 |
rev | line source |
---|---|
507 | 1 #include <SDL.h> |
2 #include <SDL_image.h> | |
3 #include <libxml/parser.h> | |
4 #include "SceneGraphRoot.h" | |
5 #include "xml.h" | |
6 #include "sys.h" | |
7 #include "TextureHash.h" | |
8 #include "texture.h" | |
562 | 9 #include "Application.h" |
507 | 10 |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
11 static int cnt = 0; |
562 | 12 static const int SGLIST_LENGTH = 138; |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
13 static int sg_src_size = SGLIST_LENGTH ; |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
14 static int sg_src_id = -1; |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
15 static SceneGraphPtr *sg_src; |
562 | 16 |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
17 |
558 | 18 SceneGraphRoot *sgroot; |
19 | |
507 | 20 SceneGraphRoot::SceneGraphRoot(float w, float h) |
21 { | |
562 | 22 // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな |
23 // | |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
24 sg_src = (SceneGraphPtr*) malloc(sizeof(SceneGraphPtr)*SGLIST_LENGTH); |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
25 |
656
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
26 camera = new Camera(w, h, this); |
779 | 27 |
507 | 28 iterator = new SceneGraphIterator; |
29 controller = create_controller(); | |
30 | |
31 sg_exec_tree = NULL; | |
32 sg_draw_tree = NULL; | |
33 sg_available_list = NULL; | |
34 sg_remove_list = NULL; | |
35 | |
562 | 36 sgroot = this; |
37 | |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
38 screen_w = (int)w; |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
39 screen_h = (int)h; |
762 | 40 int light_num = 4; |
793 | 41 light_sysswitch = 0; |
762 | 42 |
43 for (int i = 0; i < light_num; i++) { | |
44 light[i] = new SceneGraph; | |
45 light[i]->xyz[0] = 0; | |
46 light[i]->xyz[1] = 0; | |
47 light[i]->xyz[2] = 0; | |
792 | 48 |
793 | 49 light_switch[i] = 0; |
792 | 50 |
762 | 51 } |
748 | 52 |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
53 move_finish_flag = 0; |
678
e201be3f6897
add Load light info for some spe
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents:
656
diff
changeset
|
54 |
507 | 55 // TODO |
56 // 今はとりあえず camera を Root にしています | |
57 // 今はそれすらもしてません | |
58 //sg_exec_tree = camera; | |
59 } | |
60 | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
61 SceneGraphRoot::~SceneGraphRoot() |
507 | 62 { |
63 SceneGraphPtr p = sg_available_list; | |
64 | |
65 while (p) { | |
66 SceneGraphPtr tmp = p->next; | |
67 delete p; | |
68 p = tmp; | |
69 cnt--; | |
70 } | |
71 | |
72 p = sg_remove_list; | |
73 | |
74 while (p) { | |
75 SceneGraphPtr tmp = p->next; | |
76 delete p; | |
77 p = tmp; | |
78 cnt--; | |
79 } | |
80 | |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
81 free(sg_src); |
507 | 82 delete camera; |
762 | 83 int light_num = 4; |
84 for (int i = 0; i < light_num; i++) { | |
85 delete light[i]; | |
86 } | |
507 | 87 delete iterator; |
88 delete controller; | |
89 } | |
90 | |
91 /** | |
92 * xml ファイルから生成された SceneGraph を sg_src に登録する。 | |
93 * | |
94 * @param sg SceneGraph created by xmlfile | |
95 */ | |
96 void | |
97 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg) | |
98 { | |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
99 int dup; |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
100 if ((dup = getSgid(sg->name))>=0) { // while... |
576 | 101 sg_src[dup]->name = ""; |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
102 // we should remove this. but some one may use it... |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
103 } |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
104 if (sg_src_id+1> sg_src_size) { |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
105 sg_src_size *= 2; |
582 | 106 sg_src = (SceneGraphPtr*)realloc(sg_src, sg_src_size*sizeof(SceneGraphPtr)); |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
107 } |
580
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
108 sg->sgid = ++sg_src_id; |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
109 sg_src[sg->sgid] = sg; |
507 | 110 } |
111 | |
848 | 112 |
507 | 113 void |
114 SceneGraphRoot::addNext(SceneGraphPtr sg) | |
115 { | |
116 SceneGraphPtr last = sg_available_list; | |
117 | |
118 if (!last) { | |
119 sg_available_list = sg; | |
120 } else { | |
121 while (last->next) { | |
122 last = last->next; | |
123 } | |
124 last->next = sg; | |
125 sg->prev = last; | |
126 } | |
127 | |
128 cnt++; | |
129 } | |
130 | |
131 /* XMLファイルからポリゴンを作成 */ | |
132 void | |
133 SceneGraphRoot::createFromXMLfile(TaskManager *manager, const char *xmlfile) | |
134 { | |
135 xmlDocPtr doc; | |
136 xmlNodePtr cur; | |
137 SceneGraphPtr tmp; | |
562 | 138 |
507 | 139 /* パース DOM生成 */ |
140 doc = xmlParseFile(xmlfile); | |
141 cur = xmlDocGetRootElement(doc); | |
142 | |
143 /* ?? */ | |
144 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); | |
145 | |
146 /* XMLのノードを一つずつ解析 */ | |
147 for (cur=cur->children; cur; cur=cur->next) { | |
562 | 148 /* 扱うのはsurfaceオンリー */ |
149 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { | |
150 continue; | |
151 } | |
507 | 152 |
562 | 153 /* ポリゴン(SceneGraph)生成 */ |
154 tmp = new SceneGraph(manager, cur); | |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
155 registSceneGraph(tmp); |
507 | 156 } |
157 xmlFreeDoc(doc); | |
580
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
158 } |
562 | 159 |
580
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
160 void |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
161 SceneGraphRoot::createFromXMLmemory(TaskManager *manager, SceneGraph *node, char *data, int len) |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
162 { |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
163 xmlDocPtr doc; |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
164 xmlNodePtr cur; |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
165 |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
166 // size は取れるはず、テスト用に mmap したデータを使う |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
167 /* パース DOM生成 */ |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
168 |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
169 doc = xmlParseMemory(data, len); |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
170 cur = xmlDocGetRootElement(doc); |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
171 |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
172 /* ?? */ |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
173 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
174 |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
175 /* XMLのノードを一つずつ解析 */ |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
176 for (cur=cur->children; cur; cur=cur->next) { |
586 | 177 /* 扱うのはsurfaceオンリー */ |
178 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { | |
179 continue; | |
180 } | |
181 /* ポリゴン(SceneGraph)生成 */ | |
182 SceneGraphPtr original = new SceneGraph(manager, cur); | |
183 registSceneGraph(original); | |
184 SceneGraphPtr clone = createSceneGraph(original->sgid); | |
185 node->addChild(clone); | |
580
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
186 } |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
187 xmlFreeDoc(doc); |
507 | 188 } |
189 | |
190 SceneGraphPtr | |
191 SceneGraphRoot::createSceneGraph(int id) | |
192 { | |
193 SceneGraphPtr src; | |
194 SceneGraphPtr p; | |
195 | |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
196 if (id < 0 || id > sg_src_size) { |
851 | 197 printf("error: createSceneGraph(int id): id not found.\n"); |
198 return NULL; | |
507 | 199 } |
200 | |
201 /* オリジナルの SceneGraph */ | |
562 | 202 src = sg_src[id]; |
507 | 203 |
204 /* ユーザーにはオリジナルの clone を返す */ | |
205 p = src->clone(); | |
206 | |
656
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
207 /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/ |
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
208 p->sgroot = (void *)this; |
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
209 |
507 | 210 addNext(p); |
211 | |
212 return p; | |
213 } | |
214 | |
562 | 215 |
216 | |
217 | |
218 SceneGraphPtr | |
219 SceneGraphRoot::createSceneGraph(const char *name) | |
220 { | |
221 SceneGraphPtr src; | |
222 SceneGraphPtr p; | |
223 | |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
224 int id = getSgid(name); |
562 | 225 if (id < 0) { |
851 | 226 printf("error: createSceneGraph(name): name object not found.\n"); |
227 return NULL; | |
562 | 228 } |
229 | |
230 /* オリジナルの SceneGraph */ | |
231 src = sg_src[id]; | |
232 | |
233 /* ユーザーにはオリジナルの clone を返す */ | |
234 p = src->clone(); | |
656
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
235 |
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
236 /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/ |
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
237 p->sgroot = (void *)this; |
562 | 238 |
239 addNext(p); | |
240 | |
241 return p; | |
242 } | |
243 | |
244 int | |
245 SceneGraphRoot::getSgid(const char *name) | |
246 { | |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
247 for(int i =0;i<= sg_src_id; i++) { |
576 | 248 if (sg_src[i] && strcmp(name,sg_src[i]->name) == 0) |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
249 return i; |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
250 } |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
251 return -1; |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
252 } |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
253 |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
254 int |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
255 SceneGraphRoot::getLast() |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
256 { |
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
257 if (sg_src_id>=0) |
580
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
258 return sg_src[sg_src_id]->sgid; |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
259 return -1; |
562 | 260 } |
261 | |
507 | 262 /** |
263 * 何も表示しない、move,collision もしない SceneGraph を生成 | |
264 * いずれ、Transform3D 的なものに回す予定 | |
265 */ | |
266 SceneGraphPtr | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
267 SceneGraphRoot::createSceneGraph() |
507 | 268 { |
269 SceneGraphPtr p = new SceneGraph; | |
270 | |
656
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
271 /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/ |
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
272 p->sgroot = (void *)this; |
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
273 |
507 | 274 addNext(p); |
275 p->flag_drawable = 0; | |
276 | |
277 return p; | |
278 } | |
279 | |
280 void | |
281 SceneGraphRoot::speExecute(int screen_w, int screen_h) | |
282 { | |
283 | |
284 SceneGraphPtr list = sg_available_list; | |
285 // SceneGraphPtr t = sg_exec_tree; | |
286 // SceneGraphPtr cur_parent = camera; | |
287 | |
288 // 前フレームで描画した SceneGraph は削除 | |
289 allRemove(sg_remove_list); | |
290 | |
291 // 前フレームに作られた SceneGraph は描画用に移行 | |
292 // 現フレームでの操作は以下の tree,list には適用されない | |
293 sg_draw_tree = sg_exec_tree; | |
294 sg_remove_list = sg_available_list; | |
295 | |
296 // 現フレームで新しく SceneGraph がコピーされるので初期化 | |
297 sg_exec_tree = NULL; | |
298 sg_available_list = NULL; | |
299 | |
300 camera->move_execute(screen_w, screen_h); | |
301 camera->update(screen_w, screen_h); | |
302 | |
303 camera->children = NULL; | |
304 camera->lastChild = NULL; | |
305 | |
306 list->move_execute(screen_w, screen_h); | |
307 list->collision_check(screen_w, screen_h, list); | |
308 | |
309 list->frame++; | |
310 list = list->next; | |
311 | |
312 if(sg_exec_tree != NULL) { | |
313 return; | |
314 } | |
315 | |
316 /*removeのflagをもとにtreeを形成*/ | |
317 /* spe から送り返されてきた property の配列を見て生成する for()*/ | |
318 /* | |
562 | 319 for (Property *t = (Property*)app->property[0]; is_end(t); t++){ |
320 SceneGraphPtr s = app->scenegraph_factory(t); // SceneGraphNode を作る | |
321 t->scenegraph = s; // property list には SceneGraphへのポインタが入っている | |
322 app->scenegraph_connector(property[0], s); // add する | |
323 } | |
324 */ | |
325 | |
326 | |
327 // 現在、allExecute が終わった時点では | |
328 // camera->children が User SceneGraph の root になる | |
329 | |
330 /** | |
331 * NULL じゃなかったら、setSceneData が呼ばれてるから | |
332 * そっちを次の Scene にする | |
333 */ | |
334 | |
335 sg_exec_tree = camera->children; | |
336 } | |
337 | |
507 | 338 |
339 | |
340 void | |
341 SceneGraphRoot::allExecute(int screen_w, int screen_h) | |
342 { | |
343 SceneGraphPtr list = sg_available_list; | |
344 SceneGraphPtr t = sg_exec_tree; | |
345 SceneGraphPtr cur_parent = camera; | |
346 | |
347 // 前フレームで描画した SceneGraph は削除 | |
348 allRemove(sg_remove_list); | |
349 | |
350 // 前フレームに作られた SceneGraph は描画用に移行 | |
351 // 現フレームでの操作は以下の tree,list には適用されない | |
352 sg_draw_tree = sg_exec_tree; | |
353 sg_remove_list = sg_available_list; | |
354 | |
355 // 現フレームで新しく SceneGraph がコピーされるので初期化 | |
356 sg_exec_tree = NULL; | |
357 sg_available_list = NULL; | |
358 | |
359 camera->move_execute(screen_w, screen_h); | |
360 camera->update(screen_w, screen_h); | |
361 | |
362 camera->children = NULL; | |
363 camera->lastChild = NULL; | |
364 | |
365 /*まずは全部動作させる*/ | |
366 while (list) { | |
367 | |
368 list->move_execute(screen_w, screen_h); | |
369 list->collision_check(screen_w, screen_h, list); | |
370 | |
656
d0b8860c17f8
remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
597
diff
changeset
|
371 list->frame++; |
507 | 372 list = list->next; |
759 | 373 } |
507 | 374 |
762 | 375 int light_num = 4; |
376 for (int i = 0; i < light_num; i++) { | |
748 | 377 |
762 | 378 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); |
379 | |
380 light_vector[i*4] = 0.0f; | |
381 light_vector[i*4+1] = 0.0f; | |
382 light_vector[i*4+2] = 0.0f; | |
383 light_vector[i*4+3] = 1.0f; | |
748 | 384 |
762 | 385 ApplyMatrix(&light_vector[i*4], light[i]->matrix); |
386 | |
387 light_vector[i*4] /= light_vector[i*4+2]; | |
388 light_vector[i*4+1] /= light_vector[i*4+2]; | |
748 | 389 |
765 | 390 /*SIMD演算のため*/ |
391 light_vector[i*4+2] *= -1; | |
392 light_vector[i*4+3] *= -1; | |
393 | |
762 | 394 } |
395 | |
748 | 396 |
507 | 397 if(sg_exec_tree != NULL) { |
759 | 398 return; |
507 | 399 } |
400 | |
401 /*removeのflagをもとにtreeを形成*/ | |
402 while (t) { | |
752
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
403 SceneGraphPtr c = NULL; |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
404 if (!t->isRemoved()) { |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
405 c = t->clone(); |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
406 addNext(c); |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
407 cur_parent->addChild(c); |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
408 c->frame = t->frame; |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
409 /*親の回転、座標から、子の回転、座標を算出*/ |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
410 get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); |
748 | 411 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ |
752
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
412 get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix); |
845 | 413 //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix); |
908 | 414 |
752
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
415 } |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
416 |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
417 if (t->children != NULL && c != NULL) { |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
418 cur_parent = c; |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
419 t = t->children; |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
420 } else if (t->brother != NULL) { |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
421 t = t->brother; |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
422 } else { |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
423 while (t) { |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
424 if (t->brother != NULL) { |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
425 t = t->brother; |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
426 break; |
507 | 427 } else { |
752
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
428 if (t->parent == NULL) { |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
429 t = NULL; |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
430 break; |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
431 } else { |
507 | 432 cur_parent = cur_parent->parent; |
433 t = t->parent; | |
752
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
434 } |
507 | 435 } |
752
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
436 } |
5d23ffea34e3
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
748
diff
changeset
|
437 } |
507 | 438 } |
439 | |
440 | |
441 | |
442 // 現在、allExecute が終わった時点では | |
443 // camera->children が User SceneGraph の root になる | |
444 | |
445 /** | |
446 * NULL じゃなかったら、setSceneData が呼ばれてるから | |
447 * そっちを次の Scene にする | |
448 */ | |
449 | |
450 sg_exec_tree = camera->children; | |
451 } | |
452 | |
453 void | |
759 | 454 SceneGraphRoot::oneExecute(int screen_w, int screen_h) |
455 { | |
456 SceneGraphPtr list = sg_available_list; | |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
457 //SceneGraphPtr t = sg_exec_tree; |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
458 //SceneGraphPtr cur_parent = camera; |
759 | 459 |
460 // 前フレームで描画した SceneGraph は削除 | |
461 allRemove(sg_remove_list); | |
462 | |
463 // 前フレームに作られた SceneGraph は描画用に移行 | |
464 // 現フレームでの操作は以下の tree,list には適用されない | |
465 sg_draw_tree = sg_exec_tree; | |
466 sg_remove_list = sg_available_list; | |
467 | |
468 // 現フレームで新しく SceneGraph がコピーされるので初期化 | |
469 sg_exec_tree = NULL; | |
470 sg_available_list = NULL; | |
471 | |
472 camera->move_execute(screen_w, screen_h); | |
473 camera->update(screen_w, screen_h); | |
474 | |
475 camera->children = NULL; | |
476 camera->lastChild = NULL; | |
477 | |
478 /* ここから */ | |
479 list->move_execute(screen_w, screen_h); | |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
480 // ここで move_execute から実行される move_task の処理が終わるまで待ちたい |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
481 //while(move_finish_flag == 0) {} |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
482 //move_finish_flag = 0; |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
483 |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
484 list->create_sg_execute(); |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
485 |
759 | 486 list->collision_check(screen_w, screen_h, list); |
487 /* ここまで exec_task にする */ | |
488 | |
489 | |
490 /* ここから下を exec_task の post_func に*/ | |
491 list->frame++; | |
492 list = list->next; | |
493 | |
762 | 494 |
495 int light_num = 4; | |
496 for (int i = 0; i < light_num; i++) { | |
759 | 497 |
762 | 498 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); |
499 | |
500 light_vector[i*4] = 0.0f; | |
501 light_vector[i*4+1] = 0.0f; | |
502 light_vector[i*4+2] = 0.0f; | |
503 light_vector[i*4+3] = 1.0f; | |
759 | 504 |
762 | 505 ApplyMatrix(&light_vector[i*4], light[i]->matrix); |
506 | |
507 light_vector[i*4] /= light_vector[i*4+2]; | |
508 light_vector[i*4+1] /= light_vector[i*4+2]; | |
759 | 509 |
762 | 510 } |
759 | 511 |
512 if(sg_exec_tree != NULL) { | |
513 return; | |
514 } | |
515 } | |
516 | |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
517 /* |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
518 ExecMove task の post func として呼んでやる |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
519 */ |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
520 void |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
521 SceneGraphRoot::move_finish() |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
522 { |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
523 list->collision_check(screen_w, screen_h, list); |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
524 |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
525 list->frame++; |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
526 //list = list->next; |
762 | 527 |
528 int light_num = 4; | |
529 for (int i = 0; i < light_num; i++) { | |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
530 |
762 | 531 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); |
532 | |
533 light_vector[i*4] = 0.0f; | |
534 light_vector[i*4+1] = 0.0f; | |
535 light_vector[i*4+2] = 0.0f; | |
536 light_vector[i*4+3] = 1.0f; | |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
537 |
762 | 538 ApplyMatrix(&light_vector[i*4], light[i]->matrix); |
539 | |
540 light_vector[i*4] /= light_vector[i*4+2]; | |
541 light_vector[i*4+1] /= light_vector[i*4+2]; | |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
542 |
769
2a00c1f470b7
add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
765
diff
changeset
|
543 light_vector[i*4+2] *= -1; |
2a00c1f470b7
add add spe/chain_move Test/property_chain, not workd
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
765
diff
changeset
|
544 light_vector[i*4+3] *= -1; |
762 | 545 } |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
546 |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
547 //sgchange->viewer->light_xyz_stock = getLightVector(); |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
548 } |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
549 |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
550 |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
551 void |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
552 SceneGraphRoot::appTaskRegist(regist_func new_register) |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
553 { |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
554 this->regist = new_register; |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
555 } |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
556 |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
557 void |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
558 SceneGraphRoot::regist_execute() |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
559 { |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
560 (*regist)(this); |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
561 } |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
562 |
759 | 563 void |
507 | 564 SceneGraphRoot::allRemove(SceneGraphPtr list) |
565 { | |
566 SceneGraphPtr p = list; | |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
567 |
507 | 568 while (p) { |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
569 SceneGraphPtr p1 = p->next; |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
570 delete p; |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
571 p = p1; |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
572 cnt--; |
507 | 573 } |
574 } | |
575 | |
576 void | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
577 SceneGraphRoot::checkRemove() |
507 | 578 { |
579 SceneGraphPtr p = sg_available_list; | |
580 SceneGraphPtr p1; | |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
581 |
507 | 582 while (p) { |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
583 p1 = p->next; |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
584 if (p->isRemoved()) { |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
585 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree); |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
586 sg_available_list = p->realRemoveFromList(sg_available_list); |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
587 } |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
588 delete p; |
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
759
diff
changeset
|
589 p = p1; |
507 | 590 } |
591 } | |
592 | |
593 SceneGraphPtr | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
594 SceneGraphRoot::getExecuteSceneGraph() |
507 | 595 { |
596 return sg_exec_tree; | |
597 } | |
598 | |
599 SceneGraphPtr | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
600 SceneGraphRoot::getDrawSceneGraph() |
507 | 601 { |
602 return sg_draw_tree; | |
603 } | |
604 | |
605 void | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
606 SceneGraphRoot::updateControllerState() |
507 | 607 { |
608 controller->check(); | |
609 } | |
610 | |
611 void | |
612 SceneGraphRoot::setSceneData(SceneGraphPtr sg) | |
613 { | |
614 sg_exec_tree = sg; | |
615 } | |
616 | |
617 Pad* | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
618 SceneGraphRoot::getController() |
507 | 619 { |
620 return controller; | |
621 } | |
622 | |
623 SceneGraphIteratorPtr | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
624 SceneGraphRoot::getIterator() |
507 | 625 { |
626 iterator->set(sg_remove_list); | |
627 return iterator; | |
628 } | |
629 | |
630 SceneGraphIteratorPtr | |
631 SceneGraphRoot::getIterator(SceneGraphPtr list) | |
632 { | |
633 iterator->set(list); | |
634 return iterator; | |
635 } | |
636 | |
637 CameraPtr | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
638 SceneGraphRoot::getCamera() |
507 | 639 { |
640 return camera; | |
641 } | |
597 | 642 |
748 | 643 |
644 SceneGraphPtr | |
762 | 645 SceneGraphRoot::getLight(int id) |
597 | 646 { |
647 | |
762 | 648 return light[id]; |
597 | 649 |
650 } | |
748 | 651 |
652 | |
653 float* | |
654 SceneGraphRoot::getLightVector() | |
655 { | |
656 return light_vector; | |
657 } | |
779 | 658 |
792 | 659 int* |
660 SceneGraphRoot::getLightSwitch() | |
661 { | |
662 return light_switch; | |
663 } | |
664 | |
665 int | |
666 SceneGraphRoot::getLightSysSwitch() | |
667 { | |
668 return light_sysswitch; | |
669 } | |
670 | |
793 | 671 void |
672 SceneGraphRoot::OnLightSwitch(int id) | |
673 { | |
674 light_switch[id] = 1; | |
675 } | |
676 | |
677 void | |
678 SceneGraphRoot::OffLightSwitch(int id) | |
679 { | |
680 light_switch[id] = 0; | |
681 } | |
682 | |
683 void | |
684 SceneGraphRoot::OnLightSysSwitch() | |
685 { | |
686 | |
687 light_sysswitch = 1; | |
688 | |
689 } | |
690 | |
691 void | |
692 SceneGraphRoot::OffLightSysSwitch() | |
693 { | |
694 | |
695 light_sysswitch = 0; | |
696 | |
697 } | |
698 | |
869 | 699 |
700 void | |
701 SceneGraphRoot::set_game_task(int id, void *property, int size, PostFunction post_func) | |
702 { | |
703 HTask *task = sgroot->tmanager->create_task(id); | |
704 task->set_cpu(SPE_ANY); | |
870 | 705 task->add_inData(property, size); |
706 task->add_outData(property, size); | |
869 | 707 task->add_param((memaddr)1); |
708 task->set_post(post_func, (void*)property, 0); | |
969
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
709 wait_game_task->wait_for(task); |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
710 task->spawn(); |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
711 } |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
712 |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
713 void |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
714 SceneGraphRoot::set_game_task(int id, void *property, void *pad, int size, PostFunction post_func) |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
715 { |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
716 HTask *task = sgroot->tmanager->create_task(id); |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
717 task->set_cpu(SPE_ANY); |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
718 task->add_inData(property, size); |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
719 task->add_inData(pad, sizeof(Pad)); |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
720 task->add_outData(property, size); |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
721 task->set_post(post_func, (void*)property, 0); |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
722 wait_game_task->wait_for(task); |
869 | 723 task->spawn(); |
724 } | |
725 | |
884 | 726 void |
882 | 727 main_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
728 { | |
729 int size = node->property_size; | |
730 void *e = node->propertyptr; | |
731 int move = node->move_id; | |
732 PostFunction post_func = node->post_func; | |
969
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
733 |
913 | 734 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
735 sgroottmp->set_game_task(move, (void*)e, size, post_func); | |
882 | 736 } |
737 | |
738 void | |
969
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
739 pad_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
740 { |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
741 int size = node->property_size; |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
742 void *e = node->propertyptr; |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
743 int move = node->move_id; |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
744 PostFunction post_func = node->post_func; |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
745 |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
746 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
747 void *pad = (void*)sgroottmp->getController(); |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
748 |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
749 sgroottmp->set_game_task(move, (void*)e, pad, size, post_func); |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
750 } |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
751 |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
752 void |
882 | 753 SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size, |
754 PostFunction post_func) | |
755 { | |
756 node->move = main_task_move; | |
757 node->post_func = post_func; | |
758 node->move_id = move; | |
759 node->propertyptr = property; | |
760 node->property_size = size; | |
761 } | |
869 | 762 |
969
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
763 void |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
764 SceneGraphRoot::set_pad_task(SceneGraphPtr node, int move, void *property, int size, |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
765 PostFunction post_func) |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
766 { |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
767 node->move = pad_task_move; |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
768 node->post_func = post_func; |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
769 node->move_id = move; |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
770 node->propertyptr = property; |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
771 node->property_size = size; |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
772 } |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
773 |
779 | 774 /* end */ |