Mercurial > hg > Members > kono > Cerium
annotate Renderer/Engine/SceneGraph.cc @ 603:42c94f85c779
long -> memaddr (64 or 32)
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 07 Nov 2009 14:13:29 +0900 |
parents | da82a47ece92 |
children | d0b8860c17f8 |
rev | line source |
---|---|
507 | 1 #include <iostream> |
2 #include <SDL.h> | |
3 #include <SDL_opengl.h> | |
4 #include <SDL_image.h> | |
5 #include <libxml/parser.h> | |
6 #include "SceneGraph.h" | |
7 #include "xml.h" | |
8 #include "sys.h" | |
9 #include "TextureHash.h" | |
10 #include "texture.h" | |
11 #include "TaskManager.h" | |
12 | |
13 using namespace std; | |
14 | |
15 SceneGraphPtr scene_graph = NULL; | |
16 SceneGraphPtr scene_graph_viewer = NULL; | |
17 | |
18 static TextureHash texture_hash; | |
19 struct texture_list list[TABLE_SIZE]; | |
20 | |
21 extern int decode(char *cont, FILE *outfile); | |
22 | |
23 static void | |
24 no_move(SceneGraphPtr self, int screen_w, int screen_h) {} | |
25 | |
26 static void | |
27 no_collision(SceneGraphPtr self, int screen_w, int screen_h, | |
28 SceneGraphPtr tree) {} | |
29 | |
30 /** | |
31 * 事前に計算したテクスチャの最大縮小率 scale まで、 | |
32 * テクスチャを 1/2 縮小していく。 | |
33 * このとき、テクスチャは TEXTURE_SPLIT_PIXELx2 のブロック (Tile) で分割し、 | |
34 * これらを連続したメモリ領域に格納していく。 | |
35 * 以下の (1), (2), (3) を Tapestry と呼ぶ | |
36 * | |
37 * 例 scale = 4 の場合 | |
38 * | |
39 * Tapestry(1) 1/1 | |
40 * +---+---+---+---+ | |
41 * | 0 | 1 | 2 | 3 | | |
42 * +---+---+---+---+ | |
43 * | 4 | 5 | 6 | 7 | (2) 1/2 | |
44 * +---+---+---+---+ +---+---+ | |
45 * | 8 | 9 | 10| 11| | 16| 17| (3) 1/4 | |
46 * +---+---+---+---+ +---+---+ +---+ | |
47 * | 12| 13| 14| 15| | 18| 19| | 20| | |
48 * +---+---+---+---+ +---+---+ +---| | |
49 * | |
50 * (1) (2) (3) | |
51 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | |
52 * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * | * | * | 14| 15| 16| 17| 18| 19| 20| | |
53 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | |
54 * | |
55 * @param[in] tex_w Width of orignal texture | |
56 * @param[in] tex_h Height of orignal texture | |
57 * @param[in] tex_src Original texture | |
58 * @param[in] all_pixel_num Tapestry の合計 pixel 数 | |
59 * @param[in] scale テクスチャの最大縮小率 (= 2^n) | |
60 * @return (1) のアドレス | |
61 */ | |
62 static uint32* | |
63 makeTapestry(TaskManager *manager, int tex_w, int tex_h, uint32 *tex_src, | |
64 int all_pixel_num, int scale_cnt) | |
65 { | |
66 | |
67 int t = 0; | |
68 int diff = TEXTURE_SPLIT_PIXEL; | |
69 int p_diff = 1; | |
70 | |
71 uint32 *tex_dest = (uint32*)manager->allocate(sizeof(int)*all_pixel_num); | |
72 | |
73 while (scale_cnt) { | |
74 for (int y = 0; y < tex_h; y += diff) { | |
75 for (int x = 0; x < tex_w; x += diff) { | |
76 for (int j = 0; j < diff; j += p_diff) { | |
77 for (int i = 0; i < diff; i += p_diff) { | |
78 tex_dest[t++] | |
79 = tex_src[(x+i) + tex_w*(y+j)]; | |
80 } | |
81 } | |
82 } | |
83 } | |
84 | |
85 diff <<= 1; | |
86 p_diff <<= 1; | |
87 scale_cnt >>= 1; | |
88 } | |
89 | |
90 return tex_dest; | |
91 } | |
92 | |
93 | |
94 /** | |
95 * 何の情報も持ってない SceneGraph の生成 | |
96 * 今のところ、とりあえず木構造の繋がりに使うぐらい | |
97 */ | |
98 SceneGraph::SceneGraph(void) | |
99 { | |
100 init(); | |
101 finalize = &SceneGraph::finalize_copy; | |
102 | |
103 this->name = "NULLPO"; | |
104 } | |
105 | |
106 /** | |
107 * orig のコピーとして SceneGraph を生成する | |
108 */ | |
109 SceneGraph::SceneGraph(SceneGraphPtr orig) | |
110 { | |
111 init(); | |
112 memcpy(this, orig, sizeof(SceneGraph)); | |
113 | |
114 // コピーしない | |
115 //flag_remove = 0; | |
116 //flag_drawable = 1; | |
117 next = NULL; | |
118 prev = NULL; | |
119 last = NULL; | |
120 | |
121 parent = NULL; | |
122 brother = NULL; | |
123 children = NULL; | |
124 lastChild = NULL; | |
125 | |
126 finalize = &SceneGraph::finalize_copy; | |
127 | |
128 | |
129 frame = 0; | |
130 } | |
131 | |
132 | |
133 /* construct polygon from xmlNode. */ | |
134 SceneGraph::SceneGraph(TaskManager *manager, xmlNodePtr surface) | |
135 { | |
136 init(); | |
137 | |
138 size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size")); | |
139 name = (char *)xmlGetProp(surface,(xmlChar *)"name"); | |
140 parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent"); | |
141 | |
142 //data = new float[size*3*3]; | |
143 coord_xyz = (float*)manager->allocate(sizeof(float)*size*3); | |
144 coord_tex = (float*)manager->allocate(sizeof(float)*size*3); | |
145 normal = (float*)manager->allocate(sizeof(float)*size*3); | |
146 | |
147 get_data(manager, surface->children); | |
148 | |
149 finalize = &SceneGraph::finalize_original; | |
150 } | |
151 | |
152 void | |
153 SceneGraph::init(void) | |
154 { | |
155 next = NULL; | |
156 prev = NULL; | |
157 last = NULL; | |
158 | |
159 parent = NULL; | |
160 brother = NULL; | |
161 children = NULL; | |
162 lastChild = NULL; | |
163 | |
164 stack_xyz[0] = 0.0f; | |
165 stack_xyz[2] = 0.0f; | |
166 stack_xyz[1] = 0.0f; | |
167 stack_angle[0] = 0.0f; | |
168 stack_angle[1] = 0.0f; | |
169 stack_angle[2] = 0.0f; | |
170 | |
171 size = 0; | |
172 //data = NULL; | |
173 coord_xyz = NULL; | |
174 normal = NULL; | |
175 coord_tex = NULL; | |
176 | |
177 texture_id = -1; | |
178 move = no_move; | |
179 collision = no_collision; | |
180 | |
181 flag_remove = 0; | |
182 flag_drawable = 1; | |
183 sgid = -1; | |
184 gid = -1; | |
185 | |
186 frame = 0; | |
187 } | |
188 | |
189 SceneGraph::~SceneGraph(void) | |
190 { | |
191 (this->*finalize)(); | |
192 } | |
193 | |
194 /** | |
195 * xml ファイルから生成されたオリジナル SceneGraph なので | |
196 * polygon data を削除 | |
197 */ | |
198 void | |
199 SceneGraph::finalize_original(void) | |
200 { | |
201 //delete [] data; | |
202 free(coord_xyz); | |
203 free(coord_tex); | |
204 free(normal); | |
205 } | |
206 | |
207 /** | |
208 * SceneGraph ID から生成された、コピー SceneGraph なので | |
209 * polygon data は削除しない。オリジナルの方で削除する。 | |
210 */ | |
211 void | |
212 SceneGraph::finalize_copy(void) | |
213 { | |
214 } | |
215 | |
216 | |
217 /** | |
218 * add Children | |
219 * 親の登録と、brother のリストへ加える | |
220 * | |
221 * @param child new child | |
222 */ | |
223 SceneGraphPtr | |
224 SceneGraph::addChild(SceneGraphPtr child) | |
225 { | |
226 /* childrenのリストの最後に加える (brother として)*/ | |
227 if (this->lastChild != NULL) { | |
228 SceneGraphPtr last = this->lastChild; | |
229 last->brother = child; | |
230 } | |
231 | |
232 this->lastChild = child; | |
233 | |
234 if (this->children == NULL) { | |
235 this->children = child; | |
236 } | |
237 | |
238 child->parent = this; | |
239 | |
240 return child; | |
241 } | |
242 | |
243 | |
244 /** | |
245 * add Brother | |
246 * addChild() でも brother の操作をしないといけないので、そっちに回す | |
247 * | |
248 * @param bro new Brother | |
249 */ | |
250 SceneGraphPtr | |
251 SceneGraph::addBrother(SceneGraphPtr bro) | |
252 { | |
253 if (this->parent) { | |
254 parent->addChild(bro); | |
255 } else { | |
256 fprintf(stderr, "error : SceneGraph::%s : %s doesn't have parent\n", | |
257 __FUNCTION__, this->name); | |
258 } | |
259 | |
260 return bro; | |
261 } | |
262 | |
263 /* thisの子や子孫にnameのものが存在すればそいつを返す なければNULL. */ | |
264 SceneGraphPtr | |
265 SceneGraph::searchSceneGraph(const char *name) | |
266 { | |
267 SceneGraphPtr tmp; | |
268 SceneGraphPtr result; | |
269 | |
270 /* 本人か */ | |
271 if( 0==strcmp(this->name, name) ) return this; | |
272 | |
273 /* 子供から再帰的に探す */ | |
274 for(tmp = this->children; tmp; tmp = tmp->next) { | |
275 if ((result=tmp->searchSceneGraph(name)) != NULL) | |
276 return result; | |
277 } | |
278 | |
279 /* 無かったら NULL. */ | |
280 return NULL; | |
281 } | |
282 | |
283 void | |
284 SceneGraph::tree_check(void) | |
285 { | |
286 SceneGraphPtr t = this; | |
287 | |
288 while(t) | |
289 { | |
290 cout << "my_name : " << t->name << endl; | |
291 if(t->children != NULL) | |
292 { | |
293 cout << "--move children : " << t->children->name << endl; | |
294 t = t->children; | |
295 } | |
296 else if(t->brother != NULL) | |
297 { | |
298 cout << "--move brother : " << t->brother->name << endl; | |
299 t = t->brother; | |
300 } | |
301 else | |
302 { | |
303 while(t) | |
304 { | |
305 if(t->brother != NULL) | |
306 { | |
307 cout << "--move brother : " << t->brother->name << endl; | |
308 t = t->brother; | |
309 break; | |
310 } | |
311 else | |
312 { | |
313 if(t->parent) | |
314 { | |
315 cout << "--move parent : " << t->parent->name << endl; | |
316 } | |
317 t = t->parent; | |
318 } | |
319 } | |
320 } | |
321 } | |
322 } | |
323 | |
324 | |
325 void | |
326 SceneGraph::print_member(void) | |
327 { | |
328 cout << "size = " << size << endl; | |
329 cout << "name = " << name << endl; | |
330 cout << "parent_name = " << parent_name << endl; | |
331 | |
332 if (parent != NULL) { | |
333 cout << "parent->name = " << parent->name << endl; | |
334 } | |
335 | |
336 if (children != NULL) { | |
337 cout << "children->name = " << children->name << endl; | |
338 } | |
339 } | |
340 | |
341 | |
342 /* | |
343 * surface nodeからポリゴンの情報を読み出す 再帰しない | |
344 */ | |
345 void | |
346 SceneGraph::get_data(TaskManager *manager, xmlNodePtr cur) | |
347 { | |
348 //char *image_name; | |
349 | |
350 for(;cur;cur=cur->next) | |
351 { | |
352 if(!xmlStrcmp(cur->name,(xmlChar*)"coordinate")) | |
353 { | |
354 char *cont = (char *)xmlNodeGetContent(cur); | |
355 pickup_coordinate(cont); | |
356 } | |
357 else if(!xmlStrcmp(cur->name,(xmlChar*)"normal")) | |
358 { | |
359 char *cont = (char *)xmlNodeGetContent(cur); | |
360 pickup_normal(cont); | |
361 } | |
362 else if(!xmlStrcmp(cur->name,(xmlChar*)"model")) | |
363 { | |
364 char *cont = (char *)xmlNodeGetContent(cur); | |
365 pickup_model(cont); | |
366 } | |
367 else if(!xmlStrcmp(cur->name,(xmlChar*)"texture")) | |
368 { | |
369 char *cont = (char *)xmlNodeGetContent(cur); | |
370 pickup_texture(cont); | |
371 } | |
372 else if(!xmlStrcmp(cur->name,(xmlChar*)"imageflag")) | |
373 { | |
374 int id; | |
375 char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name"); | |
376 texture_hash.hash_regist(filename, id); | |
377 } | |
378 else if(!xmlStrcmp(cur->name,(xmlChar*)"image")) | |
379 { | |
380 get_image(manager, cur); | |
381 } | |
382 } | |
383 } | |
384 | |
385 SDL_Surface* | |
386 SceneGraph::load_decode_image(char *image_name, xmlNodePtr cur) | |
387 { | |
388 int fd = mkstemp(image_name); | |
389 FILE *outfile = fdopen(fd, "wb"); | |
390 | |
391 if (NULL == outfile) { | |
392 cout << "error open file\n"; | |
393 return 0; | |
394 } | |
395 | |
396 char *cont = (char *)xmlNodeGetContent(cur); | |
397 //decode(cont, image_name); | |
398 decode(cont, outfile); | |
399 fclose(outfile); | |
400 | |
401 | |
402 /** | |
403 * image を 32bit(RGBA) に変換する | |
404 */ | |
405 SDL_Surface *texture_image = IMG_Load(image_name); | |
580
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
406 if (!texture_image) return 0; |
507 | 407 SDL_Surface *tmpImage |
408 = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w, | |
409 texture_image->h, 32, redMask, | |
410 greenMask, blueMask, alphaMask); | |
411 SDL_Surface *converted; | |
412 converted = SDL_ConvertSurface(texture_image, tmpImage->format, | |
413 SDL_HWSURFACE); | |
414 if (converted != NULL) { | |
415 SDL_FreeSurface(texture_image); | |
416 texture_image = converted; | |
417 } | |
418 | |
419 return texture_image; | |
420 } | |
421 | |
422 int | |
423 SceneGraph::makeTapestries(TaskManager *manager, SDL_Surface *texture_image, int id) { | |
424 uint32 *tapestry; | |
425 int scale = 1; | |
426 int tex_w = texture_image->w; | |
427 int tex_h = texture_image->h; | |
428 int all_pixel_num = 0; | |
429 | |
430 /** | |
431 * テクスチャの w or h が 8 pixel で分割できる間、 | |
432 * 1/2 の縮小画像を作る。 | |
433 * ここでは、最大の scale (1/scale) を見つける | |
434 * | |
435 * (ex) | |
436 * (128,128) => 64,64 : 32,32: 16,16 : 8,8 | |
437 * scale = 16 | |
438 * (128, 64) => 64,32 : 32,16: 16,8 | |
439 * scale = 8 | |
440 */ | |
441 while (tex_w % TEXTURE_SPLIT_PIXEL == 0 && | |
442 tex_h % TEXTURE_SPLIT_PIXEL == 0) { | |
443 all_pixel_num += tex_w*tex_h; | |
444 tex_w >>= 1; /* tex_w /= 2 */ | |
445 tex_h >>= 1; | |
446 scale <<= 1; /* scale *= 2 */ | |
447 } | |
448 | |
449 scale >>= 1; | |
450 | |
451 tapestry = makeTapestry(manager, texture_image->w, texture_image->h, | |
452 (uint32*)texture_image->pixels, | |
453 all_pixel_num, scale); | |
454 | |
455 list[id].t_w = texture_image->w; | |
456 list[id].t_h = texture_image->h; | |
457 list[id].pixels_orig = (Uint32*)texture_image->pixels; | |
458 list[id].pixels = tapestry; | |
459 list[id].scale_max = scale; | |
460 | |
461 return id; | |
462 } | |
463 | |
464 void | |
465 SceneGraph::get_image(TaskManager *manager, xmlNodePtr cur) | |
466 { | |
467 char image_name[20] = "/tmp/image_XXXXXX"; | |
468 char *filename = (char *)xmlGetProp(cur, (xmlChar *)"name"); | |
469 | |
470 if (filename == NULL || filename[0] == 0) { | |
471 return; | |
472 } | |
473 | |
474 /** | |
475 * image_name を既に Load していれば何もしない | |
476 */ | |
477 int tex_id; | |
478 if (!texture_hash.hash_regist(filename, tex_id)) { | |
479 | |
480 SDL_Surface *texture_image = load_decode_image(image_name, cur); | |
580
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
481 if (texture_image==0) { |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
482 printf("Can't load image %s\n",filename); |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
483 exit(0); |
da82a47ece92
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
484 } |
507 | 485 |
486 texture_id = makeTapestries(manager, texture_image, tex_id); | |
487 | |
488 if (unlink(image_name)) { | |
489 cout << "unlink error\n"; | |
490 } | |
491 } else { | |
492 /** | |
493 * 以前に Load されている Texture を共用 | |
494 */ | |
495 texture_id = tex_id; | |
496 } | |
497 | |
498 // こんなことすると list[] のいみあるのかなーと | |
499 // 微妙に思う、自分で書き換えた感想 by gongo | |
500 texture_info.t_w = list[texture_id].t_w; | |
501 texture_info.t_h = list[texture_id].t_h;; | |
502 texture_info.pixels_orig = list[texture_id].pixels_orig; | |
503 texture_info.pixels = list[texture_id].pixels; | |
504 texture_info.scale_max = list[texture_id].scale_max; | |
505 } | |
506 | |
507 | |
508 void | |
509 SceneGraph::delete_data(void) | |
510 { | |
511 SceneGraphPtr n = this->next, m; | |
512 | |
513 //n = this; | |
514 //delete [] n->data; | |
515 | |
516 if (next) { | |
517 while (n) { | |
518 m = n->next; | |
519 delete n; | |
520 n = m; | |
521 } | |
522 } | |
523 } | |
524 | |
525 void | |
526 SceneGraph::move_execute(int w, int h) | |
527 { | |
528 (*move)(this, w, h); | |
529 } | |
530 | |
531 void | |
532 SceneGraph::collision_check(int w, int h, SceneGraphPtr tree) | |
533 { | |
534 (*collision)(this, w, h, tree); | |
535 } | |
536 | |
537 void | |
538 SceneGraph::all_execute(int screen_w, int screen_h) | |
539 { | |
540 SceneGraphPtr top = this; | |
541 SceneGraphPtr t = top; | |
542 | |
543 while (t) { | |
544 t->move_execute(screen_w, screen_h); | |
545 t->collision_check(screen_w, screen_h, top); | |
546 | |
547 t->frame++; | |
548 | |
549 if (t->parent != NULL) { | |
550 get_matrix(t->matrix, t->angle, t->xyz, t->parent->matrix); | |
551 } else { | |
552 get_matrix(t->matrix, t->angle, t->xyz, NULL); | |
553 } | |
554 | |
555 if (t->children != NULL) { | |
556 t = t->children; | |
557 } else if (t->brother != NULL) { | |
558 t = t->brother; | |
559 } else { | |
560 while (t) { | |
561 if (t->brother != NULL) { | |
562 t = t->brother; | |
563 break; | |
564 } else { | |
565 if (t->parent == NULL) { | |
566 t = NULL; | |
567 break; | |
568 } else { | |
569 t = t->parent; | |
570 } | |
571 } | |
572 } | |
573 } | |
574 } | |
575 } | |
576 | |
577 void | |
578 SceneGraph::set_move_collision(SceneGraphPtr node, move_func new_move, | |
579 collision_func new_collision) | |
580 { | |
581 node->move = new_move; | |
582 node->collision = new_collision; | |
583 } | |
584 | |
585 void | |
586 SceneGraph::set_move_collision(move_func new_move, | |
587 collision_func new_collision) | |
588 { | |
589 this->move = new_move; | |
590 this->collision = new_collision; | |
591 } | |
592 | |
593 void | |
594 SceneGraph::add_next(SceneGraphPtr next) | |
595 { | |
596 /* next のリストの最後に加える */ | |
597 if (this->next != NULL) { | |
598 SceneGraphPtr tmp = this->last; | |
599 tmp->next = next; | |
600 } else { | |
601 this->next = next; | |
602 } | |
603 | |
604 this->last = next; | |
605 } | |
606 | |
607 /** | |
608 * SceneGraph の clone | |
609 * @return clone SceneGraph | |
610 */ | |
611 SceneGraphPtr | |
612 SceneGraph::clone(void) { | |
613 SceneGraphPtr p = new SceneGraph(this); | |
614 return p; | |
615 } | |
616 | |
617 /** | |
618 * SceneGraph の clone | |
619 * 予め allocate されてる領域への placement new を行う | |
620 * | |
621 * @param buf clone 領域 | |
622 * @return clone SceneGraph | |
623 */ | |
624 SceneGraphPtr | |
625 SceneGraph::clone(void *buf) { | |
626 SceneGraphPtr p = new(buf) SceneGraph(this); | |
627 return p; | |
628 } | |
629 | |
630 void | |
631 SceneGraph::remove(void) | |
632 { | |
633 this->flag_remove = 1; | |
634 } | |
635 | |
636 /** | |
637 * tree から node を削除する | |
638 * | |
639 * @param tree SceneGraphTree | |
640 * @return node削除後の SceneGraphTree | |
641 */ | |
642 SceneGraphPtr | |
643 SceneGraph::realRemoveFromTree(SceneGraphPtr tree) | |
644 { | |
645 SceneGraphPtr node = this; | |
646 SceneGraphPtr parent = node->parent; | |
647 SceneGraphPtr ret = tree; | |
648 | |
649 if (parent) { | |
650 SceneGraphPtr brother = parent->children; | |
651 SceneGraphPtr p, p1 = NULL; | |
652 | |
653 p = brother; | |
654 if (p) { | |
655 if (p == node) { | |
656 parent->children = NULL; | |
657 parent->lastChild = NULL; | |
658 } else { | |
659 p1 = p->brother; | |
660 | |
661 while (p1 && p1 != node) { | |
662 p1 = p1->brother; | |
663 p = p->brother; | |
664 } | |
665 | |
666 if (p1) { | |
667 p->brother = p1->brother; | |
668 | |
669 // node が最後尾なら、lastChild を変更 | |
670 if (parent->lastChild == p1) { | |
671 parent->lastChild = p; | |
672 } | |
673 } else { | |
674 // Can't find remove node | |
675 } | |
676 } | |
677 } | |
678 } else { | |
679 // 親が居ない = tree root なので | |
680 // NULL を返す | |
681 ret = NULL; | |
682 } | |
683 | |
684 return ret; | |
685 } | |
686 | |
687 /** | |
688 * list から node を削除する | |
689 * | |
690 * @param list SceneGraphList | |
691 * @return node削除後の SceneGraphList | |
692 */ | |
693 SceneGraphPtr | |
694 SceneGraph::realRemoveFromList(SceneGraphPtr list) | |
695 { | |
696 SceneGraphPtr node = this; | |
697 SceneGraphPtr prev = node->prev; | |
698 SceneGraphPtr next = node->next; | |
699 SceneGraphPtr ret = list; | |
700 | |
701 if (prev) { | |
702 prev->next = next; | |
703 } else { | |
704 ret = next; | |
705 } | |
706 | |
707 if (next) { | |
708 next->prev = prev; | |
709 } | |
710 | |
711 return ret; | |
712 } | |
713 | |
714 int | |
715 SceneGraph::isRemoved(void) | |
716 { | |
717 return flag_remove; | |
718 } | |
719 | |
720 /** | |
721 * 平行移動 | |
722 * | |
723 * @param x Ttranslate in the x direction | |
724 * @param y Ttranslate in the y direction | |
725 * @param z Ttranslate in the z direction | |
726 */ | |
727 void | |
728 SceneGraph::translate(float x, float y, float z) | |
729 { | |
730 this->xyz[0] = x; | |
731 this->xyz[1] = y; | |
732 this->xyz[2] = z; | |
733 } | |
734 | |
735 /** | |
736 * x 軸方向への平行移動 | |
737 * | |
738 * @param x Ttranslate in the x direction | |
739 */ | |
740 void | |
741 SceneGraph::translateX(float x) | |
742 { | |
743 this->xyz[0] = x; | |
744 } | |
745 | |
746 /** | |
747 * y 軸方向への平行移動 | |
748 * | |
749 * @param y Ttranslate in the y direction | |
750 */ | |
751 void | |
752 SceneGraph::translateY(float y) | |
753 { | |
754 this->xyz[1] = y; | |
755 } | |
756 | |
757 /** | |
758 * z 軸方向への平行移動 | |
759 * | |
760 * @param z Ttranslate in the z direction | |
761 */ | |
762 void | |
763 SceneGraph::translateZ(float z) | |
764 { | |
765 this->xyz[2] = z; | |
766 } |