Mercurial > hg > Members > kono > Cerium
annotate TaskManager/Test/test_render/SceneGraphRoot.cc @ 537:7014034b8d69
work dynamic_create
author | aaa |
---|---|
date | Wed, 21 Oct 2009 19:03:07 +0900 |
parents | 997d2a73a758 |
children | c5a411c19e7e e7551b50e0e7 9f9d51b60062 |
rev | line source |
---|---|
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
1 #include <SDL.h> |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
2 #include <SDL_image.h> |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
3 #include <libxml/parser.h> |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
4 #include "SceneGraphRoot.h" |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
5 #include "xml.h" |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
6 #include "sys.h" |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
7 #include "TextureHash.h" |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
8 #include "texture.h" |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
9 #include "SGList.h" |
525 | 10 #include "Application.h" |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
11 |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
12 int cnt = 0; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
13 |
221 | 14 SceneGraphRoot::SceneGraphRoot(float w, float h) |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
15 { |
534 | 16 // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
17 sg_src = new SceneGraphPtr[SGLIST_LENGTH]; |
221 | 18 camera = new Camera(w, h); |
201 | 19 iterator = new SceneGraphIterator; |
531 | 20 sglist = new SceneGraphList; |
221 | 21 controller = create_controller(); |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
22 |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
23 sg_exec_tree = NULL; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
24 sg_draw_tree = NULL; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
25 sg_available_list = NULL; |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
26 sg_remove_list = NULL; |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
27 |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
28 // TODO |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
29 // 今はとりあえず camera を Root にしています |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
30 // 今はそれすらもしてません |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
31 //sg_exec_tree = camera; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
32 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
33 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
34 SceneGraphRoot::~SceneGraphRoot(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
35 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
36 SceneGraphPtr p = sg_available_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
37 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
38 while (p) { |
450 | 39 SceneGraphPtr tmp = p->next; |
40 delete p; | |
41 p = tmp; | |
42 cnt--; | |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
43 } |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
44 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
45 p = sg_remove_list; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
46 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
47 while (p) { |
450 | 48 SceneGraphPtr tmp = p->next; |
49 delete p; | |
50 p = tmp; | |
51 cnt--; | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
52 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
53 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
54 delete [] sg_src; |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
55 delete camera; |
201 | 56 delete iterator; |
221 | 57 delete controller; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
58 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
59 |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
60 /** |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
61 * xml ファイルから生成された SceneGraph を sg_src に登録する。 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
62 * |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
63 * @param sg SceneGraph created by xmlfile |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
64 */ |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
65 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
66 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
67 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
68 for (int i = 0; i < SGLIST_LENGTH; i++) { |
450 | 69 if (strcmp(sg->name, sglist_table[i]) == 0) { |
70 sg->sgid = i; | |
71 sg_src[i] = sg; | |
72 return; | |
73 } | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
74 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
75 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
76 fprintf(stderr, "error: (%s:%3d) Can't find Scene \"%s\"\n", |
450 | 77 __FUNCTION__, __LINE__, sg->name); |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
78 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
79 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
80 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
81 SceneGraphRoot::addNext(SceneGraphPtr sg) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
82 { |
449
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
83 SceneGraphPtr last = sg_available_list; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
84 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
85 if (!last) { |
450 | 86 sg_available_list = sg; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
87 } else { |
450 | 88 while (last->next) { |
89 last = last->next; | |
90 } | |
91 last->next = sg; | |
92 sg->prev = last; | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
93 } |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
94 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
95 cnt++; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
96 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
97 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
98 /* XMLファイルからポリゴンを作成 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
99 void |
397
a4f690f44842
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
100 SceneGraphRoot::createFromXMLfile(TaskManager *manager, const char *xmlfile) |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
101 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
102 xmlDocPtr doc; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
103 xmlNodePtr cur; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
104 SceneGraphPtr tmp; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
105 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
106 /* パース DOM生成 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
107 doc = xmlParseFile(xmlfile); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
108 cur = xmlDocGetRootElement(doc); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
109 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
110 /* ?? */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
111 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
112 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
113 /* XMLのノードを一つずつ解析 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
114 for (cur=cur->children; cur; cur=cur->next) { |
450 | 115 /* 扱うのはsurfaceオンリー */ |
116 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { | |
117 continue; | |
118 } | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
119 |
450 | 120 /* ポリゴン(SceneGraph)生成 */ |
121 tmp = new SceneGraph(manager, cur); | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
122 |
450 | 123 registSceneGraph(tmp); |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
124 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
125 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
126 xmlFreeDoc(doc); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
127 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
128 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
129 SceneGraphPtr |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
130 SceneGraphRoot::createSceneGraph(int id) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
131 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
132 SceneGraphPtr src; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
133 SceneGraphPtr p; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
134 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
135 if (id < 0 || id > SGLIST_LENGTH) { |
450 | 136 return NULL; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
137 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
138 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
139 /* オリジナルの SceneGraph */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
140 src = sg_src[id]; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
141 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
142 /* ユーザーにはオリジナルの clone を返す */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
143 p = src->clone(); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
144 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
145 addNext(p); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
146 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
147 return p; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
148 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
149 |
534 | 150 #if 1 |
530 | 151 void |
152 SceneGraphRoot::registSceneGraphList(SceneGraphPtr sg) | |
153 { | |
154 /* | |
155 SceneGraphRoot にメンバ変数 SceneGraphList を持たせておくか | |
156 SceneGraphList sglist | |
531 | 157 sg->name で検索して、有れば sg_src に追加。 |
158 sgid は sglist のメンバ変数 sgid で管理する感じ | |
534 | 159 */ |
160 | |
161 SgStruct *s = sglist->get(sg->name); | |
162 if (s != NULL) { | |
163 sg->sgid = sglist->sgid; | |
164 s->id = sglist->sgid; | |
165 sg_src[sg->sgid] = sg; | |
166 sglist->sgid++; | |
531 | 167 return; |
530 | 168 } |
169 | |
170 fprintf(stderr, "error: (%s:%3d) Can't find Scene \"%s\"\n", | |
171 __FUNCTION__, __LINE__, sg->name); | |
172 } | |
173 | |
174 void | |
537 | 175 //SceneGraphRoot::createFromXMLmemory(TaskManager *manager, const char *xmlfile) |
176 SceneGraphRoot::createFromXMLmemory(TaskManager *manager, st_mmap_t mmap_t) | |
530 | 177 { |
178 xmlDocPtr doc; | |
179 xmlNodePtr cur; | |
180 SceneGraphPtr tmp; | |
181 | |
534 | 182 // size は取れるはず、テスト用に mmap したデータを使う |
530 | 183 /* パース DOM生成 */ |
537 | 184 //doc = xmlParseFile(xmlfile); |
185 int size = (int)mmap_t.size; | |
186 char *xmldata = (char *)mmap_t.file_mmap; | |
187 doc = xmlParseMemory(xmldata, size); | |
530 | 188 cur = xmlDocGetRootElement(doc); |
189 | |
190 /* ?? */ | |
191 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); | |
192 | |
193 /* XMLのノードを一つずつ解析 */ | |
194 for (cur=cur->children; cur; cur=cur->next) { | |
534 | 195 /* 扱うのはsurfaceオンリー */ |
196 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { | |
197 continue; | |
198 } | |
530 | 199 |
534 | 200 /* ポリゴン(SceneGraph)生成 */ |
201 tmp = new SceneGraph(manager, cur); | |
202 | |
203 addSceneGraphList(manager, tmp); | |
204 | |
205 registSceneGraphList(tmp); | |
206 } | |
207 | |
208 xmlFreeDoc(doc); | |
209 } | |
530 | 210 |
534 | 211 /* 生成された SceneGraph のを sglist に登録 */ |
212 void | |
213 SceneGraphRoot::addSceneGraphList(TaskManager *manager, SceneGraphPtr tmp) | |
214 { | |
215 SgStruct *sg_t = (SgStruct *)manager->allocate(sizeof(SgStruct)); | |
216 sg_t->name = tmp->name; | |
217 sglist->addLast(sg_t); | |
530 | 218 } |
219 | |
220 SceneGraphPtr | |
221 SceneGraphRoot::createSceneGraph(char *name) | |
222 { | |
223 SceneGraphPtr src; | |
224 SceneGraphPtr p; | |
225 | |
534 | 226 // SceneGraphList から name を検索して id 取得 |
227 SgStruct *e = sglist->get(name); | |
228 int id = e->id; | |
229 if (id < 0) { | |
230 return NULL; | |
530 | 231 } |
534 | 232 |
530 | 233 /* オリジナルの SceneGraph */ |
234 src = sg_src[id]; | |
235 | |
236 /* ユーザーにはオリジナルの clone を返す */ | |
237 p = src->clone(); | |
238 | |
239 addNext(p); | |
240 | |
241 return p; | |
242 } | |
243 #endif | |
244 | |
203 | 245 /** |
246 * 何も表示しない、move,collision もしない SceneGraph を生成 | |
247 * いずれ、Transform3D 的なものに回す予定 | |
248 */ | |
201 | 249 SceneGraphPtr |
250 SceneGraphRoot::createSceneGraph(void) | |
251 { | |
252 SceneGraphPtr p = new SceneGraph; | |
215
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
253 |
201 | 254 addNext(p); |
203 | 255 p->flag_drawable = 0; |
215
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
256 |
201 | 257 return p; |
258 } | |
259 | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
260 void |
449
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
261 SceneGraphRoot::speExecute(int screen_w, int screen_h) |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
262 { |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
263 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
264 SceneGraphPtr list = sg_available_list; |
463 | 265 // SceneGraphPtr t = sg_exec_tree; |
266 // SceneGraphPtr cur_parent = camera; | |
449
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
267 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
268 // 前フレームで描画した SceneGraph は削除 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
269 allRemove(sg_remove_list); |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
270 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
271 // 前フレームに作られた SceneGraph は描画用に移行 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
272 // 現フレームでの操作は以下の tree,list には適用されない |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
273 sg_draw_tree = sg_exec_tree; |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
274 sg_remove_list = sg_available_list; |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
275 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
276 // 現フレームで新しく SceneGraph がコピーされるので初期化 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
277 sg_exec_tree = NULL; |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
278 sg_available_list = NULL; |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
279 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
280 camera->move_execute(screen_w, screen_h); |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
281 camera->update(screen_w, screen_h); |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
282 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
283 camera->children = NULL; |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
284 camera->lastChild = NULL; |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
285 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
286 list->move_execute(screen_w, screen_h); |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
287 list->collision_check(screen_w, screen_h, list); |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
288 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
289 list->frame++; |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
290 list = list->next; |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
291 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
292 if(sg_exec_tree != NULL) { |
450 | 293 return; |
449
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
294 } |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
295 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
296 /*removeのflagをもとにtreeを形成*/ |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
297 /* spe から送り返されてきた property の配列を見て生成する for()*/ |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
298 /* |
528
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
299 for (Property *t = (Property*)app->property[0]; is_end(t); t++){ |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
300 SceneGraphPtr s = app->scenegraph_factory(t); // SceneGraphNode を作る |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
301 t->scenegraph = s; // property list には SceneGraphへのポインタが入っている |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
302 app->scenegraph_connector(property[0], s); // add する |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
303 } |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
304 */ |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
305 |
449
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
306 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
307 // 現在、allExecute が終わった時点では |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
308 // camera->children が User SceneGraph の root になる |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
309 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
310 /** |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
311 * NULL じゃなかったら、setSceneData が呼ばれてるから |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
312 * そっちを次の Scene にする |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
313 */ |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
314 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
315 sg_exec_tree = camera->children; |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
316 } |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
317 |
525 | 318 void |
319 SceneGraphRoot::speExecute(int screen_w, int screen_h, Application *app) | |
320 { | |
321 // SceneGraphPtr t = sg_exec_tree; | |
322 // SceneGraphPtr cur_parent = camera; | |
323 | |
324 // 前フレームで描画した SceneGraph は削除 | |
325 allRemove(sg_remove_list); | |
326 | |
327 // 前フレームに作られた SceneGraph は描画用に移行 | |
328 // 現フレームでの操作は以下の tree,list には適用されない | |
329 sg_draw_tree = sg_exec_tree; | |
330 sg_remove_list = sg_available_list; | |
331 | |
332 // 現フレームで新しく SceneGraph がコピーされるので初期化 | |
333 sg_exec_tree = NULL; | |
334 sg_available_list = NULL; | |
335 | |
336 camera->move_execute(screen_w, screen_h); | |
337 camera->update(screen_w, screen_h); | |
338 | |
339 camera->children = NULL; | |
340 camera->lastChild = NULL; | |
341 | |
342 | |
343 if(sg_exec_tree != NULL) { | |
528
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
344 return; |
525 | 345 } |
346 | |
347 /*removeのflagをもとにtreeを形成*/ | |
348 /* spe から送り返されてきた property の配列を見て生成する for()*/ | |
528
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
349 /* Application内に移動 */ |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
350 |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
351 app->property_ope(sg_available_list); |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
352 |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
353 /* |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
354 for (Property *t = (Property *)properties[0]; is_end(t); t++){ |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
355 SceneGraphPtr s = app->scenegraph_factory(t); // SceneGraphNode を作る |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
356 t->scenegraph = s; // property list には SceneGraphへのポインタが入っている |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
357 app->scenegraph_connector(property[0], s); // add する |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
358 } |
525 | 359 */ |
528
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
360 |
541013f7015c
Application ander constructing
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
525
diff
changeset
|
361 |
525 | 362 |
363 // 現在、allExecute が終わった時点では | |
364 // camera->children が User SceneGraph の root になる | |
365 | |
366 /** | |
367 * NULL じゃなかったら、setSceneData が呼ばれてるから | |
368 * そっちを次の Scene にする | |
369 */ | |
370 | |
371 sg_exec_tree = camera->children; | |
372 } | |
373 | |
449
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
374 |
4f11245e3504
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
444
diff
changeset
|
375 void |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
376 SceneGraphRoot::allExecute(int screen_w, int screen_h) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
377 { |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
378 SceneGraphPtr list = sg_available_list; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
379 SceneGraphPtr t = sg_exec_tree; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
380 SceneGraphPtr cur_parent = camera; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
381 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
382 // 前フレームで描画した SceneGraph は削除 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
383 allRemove(sg_remove_list); |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
384 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
385 // 前フレームに作られた SceneGraph は描画用に移行 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
386 // 現フレームでの操作は以下の tree,list には適用されない |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
387 sg_draw_tree = sg_exec_tree; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
388 sg_remove_list = sg_available_list; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
389 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
390 // 現フレームで新しく SceneGraph がコピーされるので初期化 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
391 sg_exec_tree = NULL; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
392 sg_available_list = NULL; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
393 |
221 | 394 camera->move_execute(screen_w, screen_h); |
206 | 395 camera->update(screen_w, screen_h); |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
396 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
397 camera->children = NULL; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
398 camera->lastChild = NULL; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
399 |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
400 /*まずは全部動作させる*/ |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
401 while (list) { |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
402 |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
403 list->move_execute(screen_w, screen_h); |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
404 list->collision_check(screen_w, screen_h, list); |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
405 |
450 | 406 list->frame++; |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
407 list = list->next; |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
408 |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
409 } |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
410 |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
411 if(sg_exec_tree != NULL) { |
450 | 412 return; |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
413 } |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
414 |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
415 /*removeのflagをもとにtreeを形成*/ |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
416 while (t) { |
450 | 417 SceneGraphPtr c = NULL; |
418 if (!t->isRemoved()) { | |
419 c = t->clone(); | |
420 addNext(c); | |
421 cur_parent->addChild(c); | |
422 c->frame = t->frame; | |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
423 /*親の回転、座標から、子の回転、座標を算出*/ |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
424 get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
425 } |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
426 |
450 | 427 if (t->children != NULL && c != NULL) { |
428 cur_parent = c; | |
429 t = t->children; | |
430 } else if (t->brother != NULL) { | |
431 t = t->brother; | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
432 } else { |
450 | 433 while (t) { |
434 if (t->brother != NULL) { | |
435 t = t->brother; | |
436 break; | |
437 } else { | |
438 if (t->parent == NULL) { | |
439 t = NULL; | |
440 break; | |
441 } else { | |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
442 cur_parent = cur_parent->parent; |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
443 t = t->parent; |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
444 |
450 | 445 } |
446 } | |
447 } | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
448 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
449 } |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
450 |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
451 |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
452 |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
453 // 現在、allExecute が終わった時点では |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
454 // camera->children が User SceneGraph の root になる |
339
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
455 |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
456 /** |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
457 * NULL じゃなかったら、setSceneData が呼ばれてるから |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
458 * そっちを次の Scene にする |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
459 */ |
be8f785a82e9
change api setSceneDate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
460 |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
461 sg_exec_tree = camera->children; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
462 } |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
463 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
464 void |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
465 SceneGraphRoot::allRemove(SceneGraphPtr list) |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
466 { |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
467 SceneGraphPtr p = list; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
468 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
469 while (p) { |
450 | 470 SceneGraphPtr p1 = p->next; |
471 delete p; | |
472 p = p1; | |
473 cnt--; | |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
474 } |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
475 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
476 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
477 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
478 SceneGraphRoot::checkRemove(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
479 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
480 SceneGraphPtr p = sg_available_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
481 SceneGraphPtr p1; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
482 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
483 while (p) { |
450 | 484 p1 = p->next; |
485 if (p->isRemoved()) { | |
486 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree); | |
487 sg_available_list = p->realRemoveFromList(sg_available_list); | |
488 } | |
489 delete p; | |
490 p = p1; | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
491 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
492 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
493 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
494 SceneGraphPtr |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
495 SceneGraphRoot::getExecuteSceneGraph(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
496 { |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
497 return sg_exec_tree; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
498 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
499 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
500 SceneGraphPtr |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
501 SceneGraphRoot::getDrawSceneGraph(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
502 { |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
503 return sg_draw_tree; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
504 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
505 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
506 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
507 SceneGraphRoot::updateControllerState(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
508 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
509 controller->check(); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
510 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
511 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
512 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
513 SceneGraphRoot::setSceneData(SceneGraphPtr sg) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
514 { |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
515 sg_exec_tree = sg; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
516 } |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
517 |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
518 Pad* |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
519 SceneGraphRoot::getController(void) |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
520 { |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
521 return controller; |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
522 } |
201 | 523 |
524 SceneGraphIteratorPtr | |
525 SceneGraphRoot::getIterator(void) | |
526 { | |
222 | 527 iterator->set(sg_remove_list); |
201 | 528 return iterator; |
529 } | |
530 | |
531 SceneGraphIteratorPtr | |
532 SceneGraphRoot::getIterator(SceneGraphPtr list) | |
533 { | |
534 iterator->set(list); | |
535 return iterator; | |
536 } | |
219
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
537 |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
538 CameraPtr |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
539 SceneGraphRoot::getCamera(void) |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
540 { |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
541 return camera; |
0f1ff7b06157
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
215
diff
changeset
|
542 } |