Mercurial > hg > Members > kono > Cerium
comparison Renderer/Engine/SceneGraphRoot.cc @ 748:b7376415fa5f
TaskManager changeset 683, Renderer changeset 746
author | hiroki |
---|---|
date | Mon, 25 Jan 2010 18:01:19 +0900 |
parents | d0b8860c17f8 |
children | 5d23ffea34e3 |
comparison
equal
deleted
inserted
replaced
677:fd3492a767c7 | 748:b7376415fa5f |
---|---|
23 // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな | 23 // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな |
24 // | 24 // |
25 sg_src = (SceneGraphPtr*) malloc(sizeof(SceneGraphPtr)*SGLIST_LENGTH); | 25 sg_src = (SceneGraphPtr*) malloc(sizeof(SceneGraphPtr)*SGLIST_LENGTH); |
26 | 26 |
27 camera = new Camera(w, h, this); | 27 camera = new Camera(w, h, this); |
28 light = new Light(w, h); | 28 light = new SceneGraph; |
29 iterator = new SceneGraphIterator; | 29 iterator = new SceneGraphIterator; |
30 controller = create_controller(); | 30 controller = create_controller(); |
31 | 31 |
32 sg_exec_tree = NULL; | 32 sg_exec_tree = NULL; |
33 sg_draw_tree = NULL; | 33 sg_draw_tree = NULL; |
34 sg_available_list = NULL; | 34 sg_available_list = NULL; |
35 sg_remove_list = NULL; | 35 sg_remove_list = NULL; |
36 | 36 |
37 sgroot = this; | 37 sgroot = this; |
38 | |
39 //int size = 4; | |
40 //light_vector = (float*)malloc(sizeof(float)*size); | |
41 | |
42 light->xyz[0] = 0; | |
43 light->xyz[1] = 0; | |
44 light->xyz[2] = 0; | |
45 | |
38 | 46 |
39 // TODO | 47 // TODO |
40 // 今はとりあえず camera を Root にしています | 48 // 今はとりあえず camera を Root にしています |
41 // 今はそれすらもしてません | 49 // 今はそれすらもしてません |
42 //sg_exec_tree = camera; | 50 //sg_exec_tree = camera; |
403 | 411 |
404 list->frame++; | 412 list->frame++; |
405 list = list->next; | 413 list = list->next; |
406 } | 414 } |
407 | 415 |
416 get_matrix(light->matrix, light->angle, light->xyz, camera->matrix); | |
417 | |
418 light_vector[0] = 0.0f; | |
419 light_vector[1] = 0.0f; | |
420 light_vector[2] = 0.0f; | |
421 light_vector[3] = 1.0f; | |
422 | |
423 ApplyMatrix(light_vector, light->matrix); | |
424 | |
425 light_vector[0] /= light_vector[2]; | |
426 light_vector[1] /= light_vector[2]; | |
427 | |
408 if(sg_exec_tree != NULL) { | 428 if(sg_exec_tree != NULL) { |
409 return; | 429 return; |
410 } | 430 } |
411 | 431 |
412 /*removeのflagをもとにtreeを形成*/ | 432 /*removeのflagをもとにtreeを形成*/ |
417 addNext(c); | 437 addNext(c); |
418 cur_parent->addChild(c); | 438 cur_parent->addChild(c); |
419 c->frame = t->frame; | 439 c->frame = t->frame; |
420 /*親の回転、座標から、子の回転、座標を算出*/ | 440 /*親の回転、座標から、子の回転、座標を算出*/ |
421 get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); | 441 get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); |
442 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ | |
443 get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix); | |
422 } | 444 } |
423 | 445 |
424 if (t->children != NULL && c != NULL) { | 446 if (t->children != NULL && c != NULL) { |
425 cur_parent = c; | 447 cur_parent = c; |
426 t = t->children; | 448 t = t->children; |
536 SceneGraphRoot::getCamera() | 558 SceneGraphRoot::getCamera() |
537 { | 559 { |
538 return camera; | 560 return camera; |
539 } | 561 } |
540 | 562 |
541 LightPtr | 563 |
564 SceneGraphPtr | |
542 SceneGraphRoot::getLight() | 565 SceneGraphRoot::getLight() |
543 { | 566 { |
544 | 567 |
545 return light; | 568 return light; |
546 | 569 |
547 } | 570 } |
571 | |
572 | |
573 float* | |
574 SceneGraphRoot::getLightVector() | |
575 { | |
576 return light_vector; | |
577 } |