Mercurial > hg > Members > kono > Cerium
annotate TaskManager/Test/test_render/SceneGraphRoot.cpp @ 215:7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
author | gongo@gendarme.local |
---|---|
date | Sun, 01 Feb 2009 22:14:44 +0900 |
parents | 159519cdca1f |
children | 0f1ff7b06157 |
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" |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
10 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
11 SceneGraphRoot::SceneGraphRoot(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
12 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
13 sg_src = new SceneGraphPtr[SGLIST_LENGTH]; |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
14 camera = new Camera; |
201 | 15 iterator = new SceneGraphIterator; |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
16 |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
17 sg_exec_list = NULL; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
18 sg_draw_list = NULL; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
19 sg_available_list = NULL; |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
20 |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
21 // TODO |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
22 // 今はとりあえず camera を Root にしています |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
23 sg_exec_list = camera; |
201 | 24 |
25 addNext(camera); | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
26 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
27 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
28 SceneGraphRoot::~SceneGraphRoot(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
29 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
30 SceneGraphPtr p = sg_available_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
31 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
32 while (p) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
33 SceneGraphPtr tmp = p->next; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
34 delete p; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
35 p = tmp; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
36 } |
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 delete [] sg_src; |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
39 delete camera; |
201 | 40 delete iterator; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
41 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
42 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
43 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
44 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
45 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
46 for (int i = 0; i < SGLIST_LENGTH; i++) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
47 if (strcmp(sg->name, sglist_table[i]) == 0) { |
215
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
48 sg->sgid = i; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
49 sg_src[i] = sg; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
50 return; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
51 } |
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 fprintf(stderr, "error: (%s:%3d) Can't find Scene \"%s\"\n", |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
55 __FUNCTION__, __LINE__, sg->name); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
56 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
57 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
58 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
59 SceneGraphRoot::addNext(SceneGraphPtr sg) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
60 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
61 SceneGraphPtr last = sg_available_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
62 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
63 if (!last) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
64 sg_available_list = sg; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
65 } else { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
66 while (last->next) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
67 last = last->next; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
68 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
69 last->next = sg; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
70 sg->prev = last; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
71 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
72 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
73 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
74 /* XMLファイルからポリゴンを作成 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
75 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
76 SceneGraphRoot::createFromXMLfile(const char *xmlfile) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
77 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
78 xmlDocPtr doc; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
79 xmlNodePtr cur; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
80 SceneGraphPtr tmp; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
81 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
82 /* パース DOM生成 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
83 doc = xmlParseFile(xmlfile); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
84 cur = xmlDocGetRootElement(doc); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
85 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
86 /* ?? */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
87 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
88 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
89 /* XMLのノードを一つずつ解析 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
90 for (cur=cur->children; cur; cur=cur->next) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
91 /* 扱うのはsurfaceオンリー */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
92 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
93 continue; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
94 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
95 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
96 /* ポリゴン(SceneGraph)生成 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
97 tmp = new SceneGraph(cur); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
98 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
99 registSceneGraph(tmp); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
100 } |
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 xmlFreeDoc(doc); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
103 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
104 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
105 SceneGraphPtr |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
106 SceneGraphRoot::createSceneGraph(int id) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
107 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
108 SceneGraphPtr src; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
109 SceneGraphPtr p; |
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 if (id < 0 || id > SGLIST_LENGTH) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
112 return NULL; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
113 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
114 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
115 /* オリジナルの SceneGraph */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
116 src = sg_src[id]; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
117 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
118 /* ユーザーにはオリジナルの clone を返す */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
119 p = src->clone(); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
120 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
121 addNext(p); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
122 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
123 return p; |
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 |
203 | 126 /** |
127 * 何も表示しない、move,collision もしない SceneGraph を生成 | |
128 * いずれ、Transform3D 的なものに回す予定 | |
129 */ | |
201 | 130 SceneGraphPtr |
131 SceneGraphRoot::createSceneGraph(void) | |
132 { | |
133 SceneGraphPtr p = new SceneGraph; | |
215
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
134 |
201 | 135 addNext(p); |
203 | 136 p->flag_drawable = 0; |
215
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
137 |
201 | 138 return p; |
139 } | |
140 | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
141 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
142 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
|
143 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
144 SceneGraphPtr top = sg_exec_list; |
206 | 145 SceneGraphPtr t = top; /* top = Camera (090128 現在) */ |
146 CameraPtr camera = (CameraPtr)t; | |
147 | |
215
7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
gongo@gendarme.local
parents:
213
diff
changeset
|
148 camera->move_execute(screen_w, screen_h); |
206 | 149 camera->update(screen_w, screen_h); |
150 | |
151 t = camera->children; | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
152 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
153 while (t) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
154 t->move_execute(screen_w, screen_h); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
155 t->collision_check(screen_w, screen_h, top); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
156 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
157 t->frame++; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
158 |
206 | 159 //if (t->parent != NULL) { |
160 get_matrix(t->matrix, t->angle, t->xyz, t->parent->matrix); | |
161 //} else { | |
162 //get_matrix(t->matrix, t->angle, t->xyz, NULL); | |
163 //} | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
164 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
165 if (t->children != NULL) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
166 t = t->children; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
167 } else if (t->brother != NULL) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
168 t = t->brother; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
169 } else { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
170 while (t) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
171 if (t->brother != NULL) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
172 t = t->brother; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
173 break; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
174 } else { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
175 if (t->parent == NULL) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
176 t = NULL; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
177 break; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
178 } else { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
179 t = t->parent; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
180 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
181 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
182 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
183 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
184 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
185 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
186 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
187 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
188 SceneGraphRoot::checkRemove(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
189 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
190 SceneGraphPtr p = sg_available_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
191 SceneGraphPtr p1; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
192 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
193 while (p) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
194 p1 = p->next; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
195 if (p->isRemoved()) { |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
196 sg_exec_list = p->realRemoveFromTree(sg_exec_list); |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
197 sg_available_list = p->realRemoveFromList(sg_available_list); |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
198 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
199 p = p1; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
200 } |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
201 |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
202 // 現在、exec と draw は別で処理できてないので、一緒にする |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
203 sg_draw_list = sg_exec_list; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
204 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
205 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
206 SceneGraphPtr |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
207 SceneGraphRoot::getExecuteSceneGraph(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
208 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
209 return sg_exec_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
210 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
211 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
212 SceneGraphPtr |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
213 SceneGraphRoot::getDrawSceneGraph(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
214 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
215 return sg_draw_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
216 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
217 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
218 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
219 SceneGraphRoot::updateControllerState(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
220 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
221 controller->check(); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
222 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
223 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
224 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
225 SceneGraphRoot::setSceneData(SceneGraphPtr sg) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
226 { |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
227 //sg_draw_list = sg_exec_list = sg; |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
228 sg_exec_list->addChild(sg); |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
229 sg_draw_list = sg_exec_list; |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
230 } |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
231 |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
232 Pad* |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
233 SceneGraphRoot::getController(void) |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
234 { |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
235 return controller; |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
236 } |
201 | 237 |
238 SceneGraphIteratorPtr | |
239 SceneGraphRoot::getIterator(void) | |
240 { | |
241 iterator->set(sg_available_list); | |
242 return iterator; | |
243 } | |
244 | |
245 SceneGraphIteratorPtr | |
246 SceneGraphRoot::getIterator(SceneGraphPtr list) | |
247 { | |
248 iterator->set(list); | |
249 return iterator; | |
250 } |