comparison Renderer/Engine/SceneGraphRoot.cc @ 760:24a37fe8419a

first of all commit, not work Rendering/Test/create_task
author hiroki
date Thu, 04 Feb 2010 14:46:09 +0900
parents bb47827c04c1
children 10a8a80c2ea7
comparison
equal deleted inserted replaced
759:bb47827c04c1 760:24a37fe8419a
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 38
39 screen_w = (int)w;
40 screen_h = (int)h;
39 //int size = 4; 41 //int size = 4;
40 //light_vector = (float*)malloc(sizeof(float)*size); 42 //light_vector = (float*)malloc(sizeof(float)*size);
41 43
42 light->xyz[0] = 0; 44 light->xyz[0] = 0;
43 light->xyz[1] = 0; 45 light->xyz[1] = 0;
44 light->xyz[2] = 0; 46 light->xyz[2] = 0;
45 47
46 48 move_finish_flag = 0;
47 // TODO 49 // TODO
48 // 今はとりあえず camera を Root にしています 50 // 今はとりあえず camera を Root にしています
49 // 今はそれすらもしてません 51 // 今はそれすらもしてません
50 //sg_exec_tree = camera; 52 //sg_exec_tree = camera;
51 } 53 }
481 483
482 void 484 void
483 SceneGraphRoot::oneExecute(int screen_w, int screen_h) 485 SceneGraphRoot::oneExecute(int screen_w, int screen_h)
484 { 486 {
485 SceneGraphPtr list = sg_available_list; 487 SceneGraphPtr list = sg_available_list;
486 SceneGraphPtr t = sg_exec_tree; 488 //SceneGraphPtr t = sg_exec_tree;
487 SceneGraphPtr cur_parent = camera; 489 //SceneGraphPtr cur_parent = camera;
488 490
489 // 前フレームで描画した SceneGraph は削除 491 // 前フレームで描画した SceneGraph は削除
490 allRemove(sg_remove_list); 492 allRemove(sg_remove_list);
491 493
492 // 前フレームに作られた SceneGraph は描画用に移行 494 // 前フレームに作られた SceneGraph は描画用に移行
504 camera->children = NULL; 506 camera->children = NULL;
505 camera->lastChild = NULL; 507 camera->lastChild = NULL;
506 508
507 /* ここから */ 509 /* ここから */
508 list->move_execute(screen_w, screen_h); 510 list->move_execute(screen_w, screen_h);
511 // ここで move_execute から実行される move_task の処理が終わるまで待ちたい
512 //while(move_finish_flag == 0) {}
513 //move_finish_flag = 0;
514
515 list->create_sg_execute();
516
509 list->collision_check(screen_w, screen_h, list); 517 list->collision_check(screen_w, screen_h, list);
510 /* ここまで exec_task にする */ 518 /* ここまで exec_task にする */
511 519
512 520
513 /* ここから下を exec_task の post_func に*/ 521 /* ここから下を exec_task の post_func に*/
529 if(sg_exec_tree != NULL) { 537 if(sg_exec_tree != NULL) {
530 return; 538 return;
531 } 539 }
532 } 540 }
533 541
542 /*
543 ExecMove task の post func として呼んでやる
544 */
545 void
546 SceneGraphRoot::move_finish()
547 {
548 list->collision_check(screen_w, screen_h, list);
549
550 list->frame++;
551 //list = list->next;
552
553 get_matrix(light->matrix, light->angle, light->xyz, camera->matrix);
554
555 light_vector[0] = 0.0f;
556 light_vector[1] = 0.0f;
557 light_vector[2] = 0.0f;
558 light_vector[3] = 1.0f;
559
560 ApplyMatrix(light_vector, light->matrix);
561
562 light_vector[0] /= light_vector[2];
563 light_vector[1] /= light_vector[2];
564
565 //sgchange->viewer->light_xyz_stock = getLightVector();
566 }
567
568
569 void
570 SceneGraphRoot::appTaskRegist(regist_func new_register)
571 {
572 this->regist = new_register;
573 }
574
575 void
576 SceneGraphRoot::regist_execute()
577 {
578 (*regist)(this);
579 }
580
534 void 581 void
535 SceneGraphRoot::allRemove(SceneGraphPtr list) 582 SceneGraphRoot::allRemove(SceneGraphPtr list)
536 { 583 {
537 SceneGraphPtr p = list; 584 SceneGraphPtr p = list;
538 585
539 while (p) { 586 while (p) {
540 SceneGraphPtr p1 = p->next; 587 SceneGraphPtr p1 = p->next;
541 delete p; 588 delete p;
542 p = p1; 589 p = p1;
543 cnt--; 590 cnt--;
544 } 591 }
545 } 592 }
546 593
547 void 594 void
548 SceneGraphRoot::checkRemove() 595 SceneGraphRoot::checkRemove()
549 { 596 {
550 SceneGraphPtr p = sg_available_list; 597 SceneGraphPtr p = sg_available_list;
551 SceneGraphPtr p1; 598 SceneGraphPtr p1;
552 599
553 while (p) { 600 while (p) {
554 p1 = p->next; 601 p1 = p->next;
555 if (p->isRemoved()) { 602 if (p->isRemoved()) {
556 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree); 603 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree);
557 sg_available_list = p->realRemoveFromList(sg_available_list); 604 sg_available_list = p->realRemoveFromList(sg_available_list);
558 } 605 }
559 delete p; 606 delete p;
560 p = p1; 607 p = p1;
561 } 608 }
562 } 609 }
563 610
564 SceneGraphPtr 611 SceneGraphPtr
565 SceneGraphRoot::getExecuteSceneGraph() 612 SceneGraphRoot::getExecuteSceneGraph()