Mercurial > hg > Members > kono > Cerium
comparison TaskManager/Test/test_render/SceneGraph.cpp @ 215:7ca6a2ef5be9
fix SceneGraph Constructor, Destructor
author | gongo@gendarme.local |
---|---|
date | Sun, 01 Feb 2009 22:14:44 +0900 |
parents | fe2cc32cd94d |
children | 961dec5912ef |
comparison
equal
deleted
inserted
replaced
214:5bd1425fb561 | 215:7ca6a2ef5be9 |
---|---|
93 | 93 |
94 return tex_dest; | 94 return tex_dest; |
95 } | 95 } |
96 | 96 |
97 | 97 |
98 /** | |
99 * 何の情報も持ってない SceneGraph の生成 | |
100 * 今のところ、とりあえず木構造の繋がりに使うぐらい | |
101 */ | |
98 SceneGraph::SceneGraph(void) | 102 SceneGraph::SceneGraph(void) |
99 { | 103 { |
100 init(); | 104 init(); |
105 finalize = &SceneGraph::finalize_copy; | |
106 } | |
107 | |
108 /** | |
109 * orig のコピーとして SceneGraph を生成する | |
110 */ | |
111 SceneGraph::SceneGraph(SceneGraphPtr orig) | |
112 { | |
113 init(); | |
114 finalize = &SceneGraph::finalize_copy; | |
115 | |
116 memcpy(this, orig, sizeof(SceneGraph)); | |
117 | |
118 // コピーしない | |
119 flag_remove = 0; | |
120 flag_drawable = 1; | |
121 frame = 0; | |
122 } | |
123 | |
124 | |
125 /* construct polygon from xmlNode. */ | |
126 SceneGraph::SceneGraph(xmlNodePtr surface) | |
127 { | |
128 init(); | |
129 | |
130 size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size")); | |
131 name = (char *)xmlGetProp(surface,(xmlChar *)"name"); | |
132 parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent"); | |
133 | |
134 data = new float[size*3*3]; | |
135 | |
136 get_data(surface->children); | |
137 | |
138 finalize = &SceneGraph::finalize_original; | |
101 } | 139 } |
102 | 140 |
103 void | 141 void |
104 SceneGraph::init(void) | 142 SceneGraph::init(void) |
105 { | 143 { |
131 sgid = -1; | 169 sgid = -1; |
132 | 170 |
133 frame = 0; | 171 frame = 0; |
134 } | 172 } |
135 | 173 |
136 /* construct polygon from xmlNode. */ | |
137 SceneGraph::SceneGraph(xmlNodePtr surface) | |
138 { | |
139 init(); | |
140 | |
141 size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size")); | |
142 name = (char *)xmlGetProp(surface,(xmlChar *)"name"); | |
143 parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent"); | |
144 | |
145 data = new float[size*3*3]; | |
146 | |
147 get_data(surface->children); | |
148 } | |
149 | |
150 SceneGraph::~SceneGraph(void) | 174 SceneGraph::~SceneGraph(void) |
151 { | 175 { |
152 delete [] data; | 176 (this->*finalize)(); |
177 } | |
178 | |
179 /** | |
180 * xml ファイルから生成されたオリジナル SceneGraph なので | |
181 * polygon data を削除 | |
182 */ | |
183 void | |
184 SceneGraph::finalize_original(void) | |
185 { | |
186 delete [] data; | |
187 } | |
188 | |
189 /** | |
190 * SceneGraph ID から生成された、コピー SceneGraph なので | |
191 * polygon data は削除しない。オリジナルの方で削除する。 | |
192 */ | |
193 void | |
194 SceneGraph::finalize_copy(void) | |
195 { | |
153 } | 196 } |
154 | 197 |
155 /* XMLファイルからポリゴンを作成 */ | 198 /* XMLファイルからポリゴンを作成 */ |
156 void | 199 void |
157 SceneGraph::createFromXMLfile(const char *xmlfile) | 200 SceneGraph::createFromXMLfile(const char *xmlfile) |
559 this->last = next; | 602 this->last = next; |
560 } | 603 } |
561 | 604 |
562 SceneGraphPtr | 605 SceneGraphPtr |
563 SceneGraph::clone(void) { | 606 SceneGraph::clone(void) { |
564 SceneGraphPtr p = new SceneGraph; | 607 SceneGraphPtr p = new SceneGraph(this); |
565 | |
566 memcpy(p, this, sizeof(SceneGraph)); | |
567 | |
568 // ポリゴンデータはとりあえずそのまま memcpy | |
569 p->data = new float[p->size*3*3]; | |
570 memcpy(p->data, this->data, sizeof(float)*p->size*3*3); | |
571 | |
572 return p; | 608 return p; |
573 } | 609 } |
574 | 610 |
575 void | 611 void |
576 SceneGraph::remove(void) | 612 SceneGraph::remove(void) |