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