annotate Renderer/Engine/SceneGraphRoot.cc @ 1143:786e800abfb4 draft

minor fix
author Yutaka_Kinjyo
date Sat, 19 Feb 2011 01:59:14 +0900
parents f326494ffdc7
children b8adf4e95e96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <SDL.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <SDL_image.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <libxml/parser.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "SceneGraphRoot.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include "xml.h"
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1046
diff changeset
6 #include "matrix_calc.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "TextureHash.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "texture.h"
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
9 #include "Application.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
11 static int cnt = 0;
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
12 static const int SGLIST_LENGTH = 138;
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
13 static int sg_src_size = SGLIST_LENGTH ;
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
14 static int sg_src_id = -1;
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
15 static SceneGraphPtr *sg_src;
1114
ee481853d5dd SgidHash remove.
tkaito
parents: 1109
diff changeset
16
ee481853d5dd SgidHash remove.
tkaito
parents: 1109
diff changeset
17 static TextureHash sgid_hash;
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
18
558
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
19 SceneGraphRoot *sgroot;
00428ba0ba03 boss1_action
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 544
diff changeset
20
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
21 SceneGraphRoot::SceneGraphRoot(float w, float h, TaskManager *manager)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 {
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
23
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
24 sgroot = this;
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
25 sgroot->tmanager = manager;
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
26
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
27 // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
28 //
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
29 sg_src = (SceneGraphPtr*) malloc(sizeof(SceneGraphPtr)*SGLIST_LENGTH);
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
30
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
31 camera = new Camera(w, h, this, sgroot->tmanager);
779
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 738 768
diff changeset
32
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 iterator = new SceneGraphIterator;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 controller = create_controller();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 sg_exec_tree = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 sg_draw_tree = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 sg_available_list = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 sg_remove_list = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
41
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
42 screen_w = (int)w;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
43 screen_h = (int)h;
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
44 int light_num = 4;
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
45 light_sysswitch = 0;
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
46
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
47 for (int i = 0; i < light_num; i++) {
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
48 light[i] = new SceneGraph(sgroot->tmanager);
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
49 light[i]->xyz[0] = 0;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
50 light[i]->xyz[1] = 0;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
51 light[i]->xyz[2] = 0;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
52
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
53 light_switch[i] = 0;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
54
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
55 }
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
56
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
57 move_finish_flag = 0;
677
24054155368c add Load light info for some spe
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 653
diff changeset
58
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
59 gtask_array = NULL;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
60
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 // TODO
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 // 今はとりあえず camera を Root にしています
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 // 今はそれすらもしてません
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 //sg_exec_tree = camera;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
67 SceneGraphRoot::~SceneGraphRoot()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 SceneGraphPtr p = sg_available_list;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 while (p) {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
72 SceneGraphPtr tmp = p->next;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
73 delete p;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
74 p = tmp;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
75 cnt--;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 p = sg_remove_list;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 while (p) {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
81 SceneGraphPtr tmp = p->next;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
82 delete p;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
83 p = tmp;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
84 cnt--;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
87 free(sg_src);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 delete camera;
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
89 int light_num = 4;
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
90 for (int i = 0; i < light_num; i++) {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
91 delete light[i];
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
92 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 delete iterator;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 delete controller;
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
95
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
96 if (gtask_array != NULL) {
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
97 delete gtask_array;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
98 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 * xml ファイルから生成された SceneGraph を sg_src に登録する。
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 * @param sg SceneGraph created by xmlfile
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 {
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
109 int dup;
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
110 if ((dup = getSgid(sg->name))>=0) { // while...
576
9b6d0da1c12d minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
111 sg_src[dup]->name = "";
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
112 // we should remove this. but some one may use it...
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
113 }
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
114 if (sg_src_id+1> sg_src_size) {
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
115 sg_src_size *= 2;
582
4ee1d40823b8 fix realloc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
116 sg_src = (SceneGraphPtr*)realloc(sg_src, sg_src_size*sizeof(SceneGraphPtr));
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
117 }
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
118 sg->sgid = ++sg_src_id;
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
119 sg_src[sg->sgid] = sg;
1114
ee481853d5dd SgidHash remove.
tkaito
parents: 1109
diff changeset
120 sgid_hash.sg_hash_regist((const char*)sg->name, sg->sgid);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122
848
a033d464c812 addChild fix
tkaito
parents: 845
diff changeset
123
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 SceneGraphRoot::addNext(SceneGraphPtr sg)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 SceneGraphPtr last = sg_available_list;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 if (!last) {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
130 sg_available_list = sg;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 } else {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
132 while (last->next) {
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
133 last = last->next;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
134 }
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
135 last->next = sg;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
136 sg->prev = last;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 cnt++;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 /* XMLファイルからポリゴンを作成 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 SceneGraphRoot::createFromXMLfile(TaskManager *manager, const char *xmlfile)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 xmlDocPtr doc;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 xmlNodePtr cur;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 SceneGraphPtr tmp;
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
149
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 /* パース DOM生成 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 doc = xmlParseFile(xmlfile);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 cur = xmlDocGetRootElement(doc);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 /* ?? */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D");
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 /* XMLのノードを一つずつ解析 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 for (cur=cur->children; cur; cur=cur->next) {
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
159 /* 扱うのはsurfaceオンリー */
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
160 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
161 continue;
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
162 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
164 /* ポリゴン(SceneGraph)生成 */
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
165 tmp = new SceneGraph(manager, cur);
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
166 registSceneGraph(tmp);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 xmlFreeDoc(doc);
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
169 }
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
170
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
171 void
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
172 SceneGraphRoot::createFromXMLmemory(TaskManager *manager, SceneGraph *node, char *data, int len)
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
173 {
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
174 xmlDocPtr doc;
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
175 xmlNodePtr cur;
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
176
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
177 // size は取れるはず、テスト用に mmap したデータを使う
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
178 /* パース DOM生成 */
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
179
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
180 doc = xmlParseMemory(data, len);
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
181 cur = xmlDocGetRootElement(doc);
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
182
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
183 /* ?? */
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
184 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D");
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
185
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
186 /* XMLのノードを一つずつ解析 */
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
187 for (cur=cur->children; cur; cur=cur->next) {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
188 /* 扱うのはsurfaceオンリー */
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
189 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
190 continue;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
191 }
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
192 /* ポリゴン(SceneGraph)生成 */
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
193 SceneGraphPtr original = new SceneGraph(manager, cur);
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
194 registSceneGraph(original);
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
195 SceneGraphPtr clone = createSceneGraph(original->sgid);
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
196 node->addChild(clone);
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
197 }
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
198 xmlFreeDoc(doc);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 SceneGraphPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 SceneGraphRoot::createSceneGraph(int id)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 SceneGraphPtr src;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 SceneGraphPtr p;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
207 if (id < 0 || id > sg_src_size) {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
208 printf("error: createSceneGraph(int id): id not found.\n");
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
209 return NULL;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 /* オリジナルの SceneGraph */
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
213 src = sg_src[id];
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 /* ユーザーにはオリジナルの clone を返す */
1136
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1122
diff changeset
216 p = src->clone(this->tmanager);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 597
diff changeset
218 /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 597
diff changeset
219 p->sgroot = (void *)this;
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 597
diff changeset
220
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 addNext(p);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 return p;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
226
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
227
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
228
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
229 SceneGraphPtr
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
230 SceneGraphRoot::createSceneGraph(const char *name)
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
231 {
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
232 SceneGraphPtr src;
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
233 SceneGraphPtr p;
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
234
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
235 int id = getSgid(name);
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
236 if (id < 0) {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
237 printf("error: createSceneGraph(name): name object not found.\n");
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
238 return NULL;
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
239 }
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
240
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
241 /* オリジナルの SceneGraph */
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
242 src = sg_src[id];
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
243
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
244 /* ユーザーにはオリジナルの clone を返す */
1136
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1122
diff changeset
245 p = src->clone(this->tmanager);
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 597
diff changeset
246
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 597
diff changeset
247 /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 597
diff changeset
248 p->sgroot = (void *)this;
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
249
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
250 addNext(p);
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
251
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
252 return p;
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
253 }
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
254
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
255 int
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
256 SceneGraphRoot::getSgid(const char *name)
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
257 {
1122
ec6b55aed337 CreateSpan ver 1118. (can work Mac)
tkaito
parents: 1114
diff changeset
258 return sgid_hash.get_sgid(name);
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
259 }
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
260
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
261 int
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
262 SceneGraphRoot::getLast()
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
263 {
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
264 if (sg_src_id>=0)
580
ec9dd24c2dc8 add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 576
diff changeset
265 return sg_src[sg_src_id]->sgid;
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
266 return -1;
562
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
267 }
d65f21b18165 name search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
268
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 * 何も表示しない、move,collision もしない SceneGraph を生成
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 * いずれ、Transform3D 的なものに回す予定
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 SceneGraphPtr
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
274 SceneGraphRoot::createSceneGraph()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 {
1143
786e800abfb4 minor fix
Yutaka_Kinjyo
parents: 1136
diff changeset
276 SceneGraphPtr p = new SceneGraph(sgroot->tmanager);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277
653
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 597
diff changeset
278 /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 597
diff changeset
279 p->sgroot = (void *)this;
7a311860a76e remove global variable "sgroot" , add SgChange.{cc, h} SgMain.cc SgRootChange.{cc, h}
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 597
diff changeset
280
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 addNext(p);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 p->flag_drawable = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 return p;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 void
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
289 SceneGraphRoot::lightCalc()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 {
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
291 int light_num = 4;
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
292 for (int i = 0; i < light_num; i++) {
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
293
1094
f10ec9bbd3f6 separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
294 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix);
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
295
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
296 light_vector[i*4] = 0.0f;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
297 light_vector[i*4+1] = 0.0f;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
298 light_vector[i*4+2] = 0.0f;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
299 light_vector[i*4+3] = 1.0f;
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
300
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
301 ApplyMatrix(&light_vector[i*4], light[i]->matrix);
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
302
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
303 light_vector[i*4] /= light_vector[i*4+2];
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
304 light_vector[i*4+1] /= light_vector[i*4+2];
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
305
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
306 /*SIMD演算のため*/
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
307 light_vector[i*4+2] *= -1;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
308 light_vector[i*4+3] *= -1;
764
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 763
diff changeset
309
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
310 }
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
311 }
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
312
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
313 void
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
314 SceneGraphRoot::flip()
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
315 {
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
316 // 前フレームで描画した SceneGraph は削除
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
317 allRemove(sg_remove_list);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
318
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
319 // 前フレームに作られた SceneGraph は描画用に移行
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
320 // 現フレームでの操作は以下の tree,list には適用されない
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
321 sg_draw_tree = sg_exec_tree;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
322 sg_remove_list = sg_available_list;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
323
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
324 // 現フレームで新しく SceneGraph がコピーされるので初期化
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
325 sg_exec_tree = NULL;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
326 sg_available_list = NULL;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
327 }
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
328
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
329 void
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
330 SceneGraphRoot::allExecute(int screen_w, int screen_h)
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
331 {
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
332 SceneGraphPtr list = sg_available_list;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
333
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
334 flip();
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
335
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
336 camera->move_execute(screen_w, screen_h);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
337 camera->update(screen_w, screen_h);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
338
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
339 camera->children = NULL;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
340 camera->lastChild = NULL;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
341
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
342 /*まずは全部動作させる*/
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
343 while (list) {
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
344
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
345 list->move_execute(screen_w, screen_h);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
346 list->collision_check(screen_w, screen_h, list);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
347
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
348 list->frame++;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
349 list = list->next;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
350 }
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
351
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
352 lightCalc();
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
353
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 if(sg_exec_tree != NULL) {
758
77f936380930 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 751
diff changeset
355 return;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
357
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
358 copyTree(sg_draw_tree, camera);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
359
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
360 // 現在、allExecute が終わった時点では
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
361 // camera->children が User SceneGraph の root になる
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
362
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
363 /**
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
364 * NULL じゃなかったら、setSceneData が呼ばれてるから
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
365 * そっちを次の Scene にする
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
366 */
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
367
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
368 sg_exec_tree = camera->children;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
369 }
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
370
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
371 void
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
372 SceneGraphRoot::copyTree(SceneGraphPtr t, SceneGraphPtr cur_parent)
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
373 {
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
374 // SceneGraphPtr t = sg_draw_tree;
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1033
diff changeset
375
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 /*removeのflagをもとにtreeを形成*/
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 while (t) {
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
378 SceneGraphPtr c = NULL;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
379 if (!t->isRemoved()) {
1136
f326494ffdc7 not work ieshoot. not check Cell
Yutaka_Kinjyo
parents: 1122
diff changeset
380 c = t->clone(this->tmanager);
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
381 addNext(c);
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
382 cur_parent->addChild(c);
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
383 c->frame = t->frame;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
384 /*親の回転、座標から、子の回転、座標を算出*/
1094
f10ec9bbd3f6 separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
385 get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
386 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
1094
f10ec9bbd3f6 separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
387 get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix);
845
71afabd4ba5c light bug fix.
Yutaka_Kinjyo
parents: 793
diff changeset
388 //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix);
908
Yutaka_Kinjyo
parents: 884
diff changeset
389
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
390 }
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
391
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
392 if (t->children != NULL && c != NULL) {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
393 cur_parent = c;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
394 t = t->children;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
395 } else if (t->brother != NULL) {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
396 t = t->brother;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
397 } else {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
398 while (t) {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
399 if (t->brother != NULL) {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
400 t = t->brother;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
401 break;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 } else {
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
403 if (t->parent == NULL) {
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
404 t = NULL;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
405 break;
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
406 } else {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 cur_parent = cur_parent->parent;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 t = t->parent;
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
409 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 }
751
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
411 }
1666dba6f6d9 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 747
diff changeset
412 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416
758
77f936380930 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 751
diff changeset
417
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
418 /*
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
419 ExecMove task の post func として呼んでやる
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
420 */
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
421 void
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
422 SceneGraphRoot::move_finish()
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
423 {
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
424 list->collision_check(screen_w, screen_h, list);
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
425
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
426 list->frame++;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
427 //list = list->next;
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
428
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
429 int light_num = 4;
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
430 for (int i = 0; i < light_num; i++) {
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
431
1094
f10ec9bbd3f6 separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
432 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix);
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
433
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
434 light_vector[i*4] = 0.0f;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
435 light_vector[i*4+1] = 0.0f;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
436 light_vector[i*4+2] = 0.0f;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
437 light_vector[i*4+3] = 1.0f;
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
438
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
439 ApplyMatrix(&light_vector[i*4], light[i]->matrix);
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
440
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
441 light_vector[i*4] /= light_vector[i*4+2];
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
442 light_vector[i*4+1] /= light_vector[i*4+2];
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
443
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
444 light_vector[i*4+2] *= -1;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
445 light_vector[i*4+3] *= -1;
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
446 }
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
447
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
448 //sgchange->viewer->light_xyz_stock = getLightVector();
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
449 }
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
450
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
451
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
452 void
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
453 SceneGraphRoot::appTaskRegist(regist_func new_register)
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
454 {
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
455 this->regist = new_register;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
456 }
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
457
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
458 void
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
459 SceneGraphRoot::regist_execute()
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
460 {
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
461 (*regist)(this);
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
462 }
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
463
758
77f936380930 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 751
diff changeset
464 void
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 SceneGraphRoot::allRemove(SceneGraphPtr list)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
467 SceneGraphPtr p = list;
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
468
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 while (p) {
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
470 SceneGraphPtr p1 = p->next;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
471 delete p;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
472 p = p1;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
473 cnt--;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
476
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 void
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
478 SceneGraphRoot::checkRemove()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 SceneGraphPtr p = sg_available_list;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 SceneGraphPtr p1;
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
482
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 while (p) {
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
484 p1 = p->next;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
485 if (p->isRemoved()) {
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
486 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree);
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
487 sg_available_list = p->realRemoveFromList(sg_available_list);
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
488 }
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
489 delete p;
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 758
diff changeset
490 p = p1;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
493
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 SceneGraphPtr
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
495 SceneGraphRoot::getExecuteSceneGraph()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 return sg_exec_tree;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
499
1046
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
500
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
501 void
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
502 printSceneGraph(SceneGraphPtr t)
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
503 {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
504 while (t) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
505 if (!t->isRemoved()) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
506 if (t->name) printf("name: %s ",t->name);
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
507 printf("x=%g y=%g z=%g\n",t->xyz[0],t->xyz[1],t->xyz[2]);
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
508 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
509 if (t->children != NULL) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
510 t = t->children;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
511 } else if (t->brother != NULL) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
512 t = t->brother;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
513 } else {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
514 while (t) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
515 if (t->brother != NULL) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
516 t = t->brother;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
517 break;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
518 } else {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
519 if (t->parent == NULL) {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
520 t = NULL;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
521 break;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
522 } else {
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
523 t = t->parent;
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
524 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
525 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
526 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
527 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
528 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
529 }
a4d00a3c4fb7 print_scenegraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042
diff changeset
530
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 SceneGraphPtr
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
532 SceneGraphRoot::getDrawSceneGraph()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 return sg_draw_tree;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
536
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 void
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
538 SceneGraphRoot::updateControllerState()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 controller->check();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
542
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 SceneGraphRoot::setSceneData(SceneGraphPtr sg)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 sg_exec_tree = sg;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
548
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 Pad*
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
550 SceneGraphRoot::getController()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 return controller;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
554
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
555 SceneGraphIteratorPtr
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
556 SceneGraphRoot::getIterator()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 iterator->set(sg_remove_list);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 return iterator;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
561
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 SceneGraphIteratorPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 SceneGraphRoot::getIterator(SceneGraphPtr list)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 iterator->set(list);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 return iterator;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
568
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 CameraPtr
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
570 SceneGraphRoot::getCamera()
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
572 return camera;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 }
597
1bfa45a08fa7 add Light Object
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 586
diff changeset
574
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
575
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
576 SceneGraphPtr
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
577 SceneGraphRoot::getLight(int id)
597
1bfa45a08fa7 add Light Object
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 586
diff changeset
578 {
1bfa45a08fa7 add Light Object
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 586
diff changeset
579
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
580 return light[id];
597
1bfa45a08fa7 add Light Object
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 586
diff changeset
581
1bfa45a08fa7 add Light Object
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 586
diff changeset
582 }
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
583
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
584
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
585 float*
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
586 SceneGraphRoot::getLightVector()
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
587 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
588 return light_vector;
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 653
diff changeset
589 }
779
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 738 768
diff changeset
590
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
591 int*
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
592 SceneGraphRoot::getLightSwitch()
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
593 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
594 return light_switch;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
595 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
596
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
597 int
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
598 SceneGraphRoot::getLightSysSwitch()
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
599 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
600 return light_sysswitch;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
601 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
602
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
603 void
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
604 SceneGraphRoot::OnLightSwitch(int id)
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
605 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
606 light_switch[id] = 1;
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
607 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
608
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
609 void
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
610 SceneGraphRoot::OffLightSwitch(int id)
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
611 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
612 light_switch[id] = 0;
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
613 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
614
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
615 void
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
616 SceneGraphRoot::OnLightSysSwitch()
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
617 {
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
618
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
619 light_sysswitch = 1;
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
620
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
621 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
622
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
623 void
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
624 SceneGraphRoot::OffLightSysSwitch()
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
625 {
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
626
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
627 light_sysswitch = 0;
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
628
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
629 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
630
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
631 void
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
632 SceneGraphRoot::task_array_init(int id, int task_num, int param, int inData_num, int outData_num)
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
633 {
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
634 gtask_array = new GTaskArray;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
635 gtask_array->init(id, task_num, param, inData_num, outData_num);
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
636 }
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
637
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
638 void
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
639 SceneGraphRoot::create_task_array()
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
640 {
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
641 gtask_array->create_task_array(this->tmanager);
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
642 }
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
643
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
644 void
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
645 SceneGraphRoot::task_array_finish()
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
646 {
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
647 gtask_array->finish();
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
648 }
869
a215927a9885 set_game_task add to SceneGraphRoot.
tkaito
parents: 851
diff changeset
649
a215927a9885 set_game_task add to SceneGraphRoot.
tkaito
parents: 851
diff changeset
650 void
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
651 SceneGraphRoot::set_gtask_array(int id, void *property, int size, PostFunction post_func)
1002
ceca625af064 many changes.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 969
diff changeset
652 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
653 gtask_array->next_task_array(id);
1002
ceca625af064 many changes.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 969
diff changeset
654
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
655 gtask_array->game_task->set_inData(0, property, size);
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
656 gtask_array->game_task->set_outData(0, property, size);
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
657
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
658 }
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
659
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
660 void
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
661 SceneGraphRoot::set_gtask_array(int id, void *property, void *pad, int size, PostFunction post_func)
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
662 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
663 gtask_array->next_task_array(id);
1002
ceca625af064 many changes.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 969
diff changeset
664
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
665 gtask_array->game_task->set_inData(0, property, size);
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
666 gtask_array->game_task->set_inData(1, pad, sizeof(Pad));
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
667 gtask_array->game_task->set_outData(0, property, size);
1002
ceca625af064 many changes.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 969
diff changeset
668
869
a215927a9885 set_game_task add to SceneGraphRoot.
tkaito
parents: 851
diff changeset
669 }
a215927a9885 set_game_task add to SceneGraphRoot.
tkaito
parents: 851
diff changeset
670
884
efefbff1fd45 obj_move fix
tkaito
parents: 882
diff changeset
671 void
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
672 SceneGraphRoot::set_game_task(int id, void *property, int size)
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
673 {
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
674 HTask *task = sgroot->tmanager->create_task(id);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
675 task->set_cpu(SPE_ANY);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
676 task->add_inData(property, size);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
677 task->add_outData(property, size);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
678 task->spawn();
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
679 }
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
680
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
681 void
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
682 SceneGraphRoot::set_game_task(int id, void *property, void *pad, int size)
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
683 {
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
684 HTask *task = sgroot->tmanager->create_task(id);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
685 task->set_cpu(SPE_ANY);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
686 task->add_inData(property, size);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
687 task->add_inData(pad, sizeof(Pad));
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
688 task->add_outData(property, size);
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
689 task->spawn();
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
690 }
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
691
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
692
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
693 void
882
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
694 main_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
695 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
696 int size = node->property_size;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
697 void *e = node->propertyptr;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
698 int move = node->move_id;
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
699 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_;
1006
66f1d3d328a7 correct code.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1003
diff changeset
700 /*
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
701 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
702 node->xyz[0] = property->x;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
703 node->xyz[1] = property->y;
1006
66f1d3d328a7 correct code.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1003
diff changeset
704 */
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
705 sgroottmp->set_game_task(move, (void*)e, size);
882
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
706 }
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
707
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
708 void
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
709 pad_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
710 {
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
711 int size = node->property_size;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
712 void *e = node->propertyptr;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
713 int move = node->move_id;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
714 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_;
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
715 void *pad = (void*)sgroottmp->getController();
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
716
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
717 /*
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
718 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
719 property->root = node;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
720 node->xyz[0] = property->x;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
721 node->xyz[1] = property->y;
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
722 */
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
723
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
724 sgroottmp->set_game_task(move, (void*)e, pad, size);
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
725 }
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
726
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
727 void
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
728 SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size)
882
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
729 {
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
730 node->move = main_task_move;
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
731 node->move_id = move;
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
732 node->propertyptr = property;
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
733 node->property_size = size;
1cb89ec2e796 SceneGraphRoot::set_move_task add.
tkaito
parents: 870
diff changeset
734 }
869
a215927a9885 set_game_task add to SceneGraphRoot.
tkaito
parents: 851
diff changeset
735
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
736 void
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1006
diff changeset
737 SceneGraphRoot::set_pad_task(SceneGraphPtr node, int move, void *property, int size)
969
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
738 {
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
739 node->move = pad_task_move;
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
740 node->move_id = move;
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
741 node->propertyptr = property;
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
742 node->property_size = size;
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
743 }
52c4353308e7 add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 913
diff changeset
744
779
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 738 768
diff changeset
745 /* end */