Mercurial > hg > Members > kono > Cerium
annotate TaskManager/Test/test_render/SceneGraphRoot.cpp @ 201:b257e27d995c
add SceneGraphIterator
author | gongo@gendarme.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 26 Jan 2009 16:46:59 +0900 (2009-01-26) |
parents | eb20274baa7c |
children | 3f4c6a75d7e0 |
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) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
48 sg_src[i] = sg; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
49 return; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
50 } |
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 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
|
54 __FUNCTION__, __LINE__, sg->name); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
55 } |
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 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
58 SceneGraphRoot::addNext(SceneGraphPtr sg) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
59 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
60 SceneGraphPtr last = sg_available_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
61 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
62 if (!last) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
63 sg_available_list = sg; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
64 } else { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
65 while (last->next) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
66 last = last->next; |
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 last->next = sg; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
69 sg->prev = last; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
70 } |
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 /* XMLファイルからポリゴンを作成 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
74 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
75 SceneGraphRoot::createFromXMLfile(const char *xmlfile) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
76 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
77 xmlDocPtr doc; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
78 xmlNodePtr cur; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
79 SceneGraphPtr tmp; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
80 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
81 /* パース DOM生成 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
82 doc = xmlParseFile(xmlfile); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
83 cur = xmlDocGetRootElement(doc); |
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 /* ?? */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
86 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
87 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
88 /* XMLのノードを一つずつ解析 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
89 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
|
90 /* 扱うのはsurfaceオンリー */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
91 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
|
92 continue; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
93 } |
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 /* ポリゴン(SceneGraph)生成 */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
96 tmp = new SceneGraph(cur); |
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 registSceneGraph(tmp); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
99 } |
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 xmlFreeDoc(doc); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
102 } |
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 SceneGraphPtr |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
105 SceneGraphRoot::createSceneGraph(int id) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
106 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
107 SceneGraphPtr src; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
108 SceneGraphPtr p; |
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 if (id < 0 || id > SGLIST_LENGTH) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
111 return NULL; |
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 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
114 /* オリジナルの SceneGraph */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
115 src = sg_src[id]; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
116 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
117 /* ユーザーにはオリジナルの clone を返す */ |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
118 p = src->clone(); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
119 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
120 addNext(p); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
121 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
122 return p; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
123 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
124 |
201 | 125 SceneGraphPtr |
126 SceneGraphRoot::createSceneGraph(void) | |
127 { | |
128 SceneGraphPtr p = new SceneGraph; | |
129 addNext(p); | |
130 return p; | |
131 } | |
132 | |
196
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
133 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
134 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
|
135 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
136 SceneGraphPtr top = sg_exec_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
137 SceneGraphPtr t = top; |
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 while (t) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
140 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
|
141 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
|
142 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
143 t->frame++; |
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 if (t->parent != NULL) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
146 get_matrix(t->matrix, t->angle, t->xyz, t->parent->matrix); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
147 } else { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
148 get_matrix(t->matrix, t->angle, t->xyz, NULL); |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
149 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
150 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
151 if (t->children != NULL) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
152 t = t->children; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
153 } else if (t->brother != NULL) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
154 t = t->brother; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
155 } else { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
156 while (t) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
157 if (t->brother != NULL) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
158 t = t->brother; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
159 break; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
160 } else { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
161 if (t->parent == NULL) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
162 t = NULL; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
163 break; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
164 } else { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
165 t = t->parent; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
166 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
167 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
168 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
169 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
170 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
171 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
172 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
173 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
174 SceneGraphRoot::checkRemove(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
175 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
176 SceneGraphPtr p = sg_available_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
177 SceneGraphPtr p1; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
178 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
179 while (p) { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
180 p1 = p->next; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
181 if (p->isRemoved()) { |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
182 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
|
183 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
|
184 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
185 p = p1; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
186 } |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
187 |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
188 // 現在、exec と draw は別で処理できてないので、一緒にする |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
189 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
|
190 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
191 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
192 SceneGraphPtr |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
193 SceneGraphRoot::getExecuteSceneGraph(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
194 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
195 return sg_exec_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
196 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
197 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
198 SceneGraphPtr |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
199 SceneGraphRoot::getDrawSceneGraph(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
200 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
201 return sg_draw_list; |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
202 } |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
203 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
204 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
205 SceneGraphRoot::updateControllerState(void) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
206 { |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
207 controller->check(); |
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 |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
210 void |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
211 SceneGraphRoot::setSceneData(SceneGraphPtr sg) |
932a05a7a1db
add SceneGraphRoot, tools/create_sglist.pl
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
212 { |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
213 //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
|
214 sg_exec_list->addChild(sg); |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
215 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
|
216 } |
199
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
217 |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
218 Pad* |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
219 SceneGraphRoot::getController(void) |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
220 { |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
221 return controller; |
eb20274baa7c
add SceneGraph(ieshoot), add SystemSceneGraph(Camera)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
196
diff
changeset
|
222 } |
201 | 223 |
224 SceneGraphIteratorPtr | |
225 SceneGraphRoot::getIterator(void) | |
226 { | |
227 iterator->set(sg_available_list); | |
228 return iterator; | |
229 } | |
230 | |
231 SceneGraphIteratorPtr | |
232 SceneGraphRoot::getIterator(SceneGraphPtr list) | |
233 { | |
234 iterator->set(list); | |
235 return iterator; | |
236 } |