Mercurial > hg > Game > Cerium
annotate Renderer/Engine/SceneGraphRoot.cc @ 1251:6da91e7cbffb draft
improve create From COLLADA
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 11 Nov 2011 18:17:26 +0900 |
parents | fd9b7519a17b |
children | bb9c885c1cb5 34944900f266 |
rev | line source |
---|---|
539 | 1 #include <SDL.h> |
2 #include <SDL_image.h> | |
3 #include <libxml/parser.h> | |
4 #include "SceneGraphRoot.h" | |
5 #include "xml.h" | |
1050 | 6 #include "matrix_calc.h" |
539 | 7 #include "TextureHash.h" |
8 #include "texture.h" | |
562 | 9 #include "Application.h" |
539 | 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 | 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 | 16 |
17 static TextureHash sgid_hash; | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
18 |
558 | 19 SceneGraphRoot *sgroot; |
20 | |
1143 | 21 SceneGraphRoot::SceneGraphRoot(float w, float h, TaskManager *manager) |
539 | 22 { |
1143 | 23 |
24 sgroot = this; | |
25 sgroot->tmanager = manager; | |
26 | |
562 | 27 // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな |
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 | 31 camera = new Camera(w, h, this, sgroot->tmanager); |
779 | 32 |
539 | 33 iterator = new SceneGraphIterator; |
34 controller = create_controller(); | |
35 | |
36 sg_exec_tree = NULL; | |
37 sg_draw_tree = NULL; | |
38 sg_available_list = NULL; | |
39 sg_remove_list = NULL; | |
40 | |
562 | 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 | 44 int light_num = 4; |
793 | 45 light_sysswitch = 0; |
761 | 46 |
47 for (int i = 0; i < light_num; i++) { | |
1143 | 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 | 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 | 54 |
761 | 55 } |
747 | 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 | 61 // TODO |
62 // 今はとりあえず camera を Root にしています | |
63 // 今はそれすらもしてません | |
64 //sg_exec_tree = camera; | |
65 } | |
66 | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
67 SceneGraphRoot::~SceneGraphRoot() |
539 | 68 { |
69 SceneGraphPtr p = sg_available_list; | |
70 | |
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 | 76 } |
77 | |
78 p = sg_remove_list; | |
79 | |
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 | 85 } |
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 | 88 delete camera; |
761 | 89 int light_num = 4; |
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 | 92 } |
539 | 93 delete iterator; |
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 | 99 } |
100 | |
101 /** | |
102 * xml ファイルから生成された SceneGraph を sg_src に登録する。 | |
103 * | |
104 * @param sg SceneGraph created by xmlfile | |
105 */ | |
106 void | |
107 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg) | |
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 | 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 | 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 | 120 sgid_hash.sg_hash_regist((const char*)sg->name, sg->sgid); |
539 | 121 } |
122 | |
848 | 123 |
539 | 124 void |
125 SceneGraphRoot::addNext(SceneGraphPtr sg) | |
126 { | |
127 SceneGraphPtr last = sg_available_list; | |
128 | |
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 | 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 | 137 } |
138 | |
139 cnt++; | |
140 } | |
141 | |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
142 /*文字列の生成*/ |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
143 void |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
144 SceneGraphRoot::createStringFont(TaskManager *manager, SceneGraphPtr root, |
1211 | 145 const char *string,int pixels,int screen_w, |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
146 int screen_h,Uint32 color) |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
147 { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
148 SceneGraphPtr text; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
149 float width_shift = 0; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
150 int i; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
151 int length = strlen(string); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
152 for (i = 0; i < length;) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
153 int len = 0; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
154 unsigned char initial = string[i]; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
155 while (1) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
156 unsigned char mask = 0x80; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
157 if (mask & initial) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
158 len++; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
159 } else { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
160 if (len == 0) len++; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
161 break; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
162 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
163 initial <<= 1; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
164 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
165 char *obj_name; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
166 float scale[] = {1,1,1}; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
167 sgroot->createFont(manager,"/Library/Fonts/Osaka.ttf", pixels, color, &string[i], len, &obj_name); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
168 text = sgroot->createSceneGraph(obj_name); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
169 text->xyz[0] = screen_w/2 + width_shift -100; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
170 text->xyz[1] = screen_h/2; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
171 text->xyz[2] = -100; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
172 width_shift += text->seq; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
173 root->addChild(text); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
174 get_matrix_scale(text->matrix, text->angle, text->xyz, scale, root->matrix); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
175 get_matrix(text->real_matrix, text->angle, text->xyz, root->real_matrix); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
176 i += len; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
177 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
178 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
179 |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
180 void |
1211 | 181 SceneGraphRoot::createFont(TaskManager *manager,const char *font, int pixels, |
182 Uint32 color,const char *string_name, int len, | |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
183 char **obj_name) |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
184 { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
185 *obj_name = (char *)malloc(sizeof(char) * 12); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
186 char sname[] = "char:"; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
187 memcpy(*obj_name, sname, 5); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
188 memcpy(*obj_name + 5, string_name, len); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
189 (*obj_name)[5+len] = '\0'; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
190 printf("%d",sgid_hash.get_sgid(*obj_name)); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
191 if (sgid_hash.get_sgid(*obj_name) != -1) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
192 return; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
193 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
194 SceneGraphPtr tmp = new SceneGraph(manager, font, pixels, color, |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
195 *obj_name); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
196 registSceneGraph(tmp); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
197 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
198 |
539 | 199 /* XMLファイルからポリゴンを作成 */ |
200 void | |
201 SceneGraphRoot::createFromXMLfile(TaskManager *manager, const char *xmlfile) | |
202 { | |
203 xmlDocPtr doc; | |
204 xmlNodePtr cur; | |
205 SceneGraphPtr tmp; | |
562 | 206 |
539 | 207 /* パース DOM生成 */ |
208 doc = xmlParseFile(xmlfile); | |
209 cur = xmlDocGetRootElement(doc); | |
210 | |
211 /* ?? */ | |
212 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); | |
213 | |
214 /* XMLのノードを一つずつ解析 */ | |
215 for (cur=cur->children; cur; cur=cur->next) { | |
562 | 216 /* 扱うのはsurfaceオンリー */ |
217 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { | |
218 continue; | |
219 } | |
539 | 220 |
562 | 221 /* ポリゴン(SceneGraph)生成 */ |
222 tmp = new SceneGraph(manager, cur); | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
223 registSceneGraph(tmp); |
539 | 224 } |
225 xmlFreeDoc(doc); | |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
226 } |
562 | 227 |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
228 void |
1251
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
229 SceneGraphRoot::createFromCOLLADAfile(TaskManager *manager, const char *xmlColladafile) |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
230 { |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
231 /*make parse dom*/ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
232 xmlDocPtr doc; |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
233 xmlNodePtr cur; |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
234 SceneGraphPtr tmp; |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
235 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
236 doc = xmlParseFile(xmlColladafile); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
237 cur = xmlDocGetRootElement(doc); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
238 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
239 /*エラー処理……だけど何書けばいいのか謎。とりあえず-1返してみる*/ |
1251
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
240 if(xmlStrcmp(cur->name, (xmlChar*)"COLLADA")){ |
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
241 return ; |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
242 }; |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
243 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
244 /* node analyze */ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
245 for(cur=cur->children; cur; cur=cur->next){ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
246 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
247 if(xmlStrcmp(cur->name,(xmlChar*)"library_imeges") != 0){ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
248 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
249 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
250 if(xmlStrcmp(cur->name,(xmlChar*)"library_effects") != 0){ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
251 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
252 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
253 if(xmlStrcmp(cur->name,(xmlChar*)"library_geometries") != 0){ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
254 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
255 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
256 if(xmlStrcmp(cur->name,(xmlChar*)"library_visual_scenes")!=0){ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
257 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
258 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
259 tmp = new SceneGraph(manager, cur); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
260 registSceneGraph(tmp); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
261 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
262 xmlFreeDoc(doc); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
263 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
264 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
265 void |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
266 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
|
267 { |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
268 xmlDocPtr doc; |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
269 xmlNodePtr cur; |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
270 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
271 // size は取れるはず、テスト用に mmap したデータを使う |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
272 /* パース DOM生成 */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
273 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
274 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
|
275 cur = xmlDocGetRootElement(doc); |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
276 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
277 /* ?? */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
278 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
|
279 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
280 /* XMLのノードを一つずつ解析 */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
281 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
|
282 /* 扱うのはsurfaceオンリー */ |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
283 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
|
284 continue; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
285 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
286 /* ポリゴン(SceneGraph)生成 */ |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
287 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
|
288 registSceneGraph(original); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
289 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
|
290 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
|
291 } |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
292 xmlFreeDoc(doc); |
539 | 293 } |
294 | |
295 SceneGraphPtr | |
296 SceneGraphRoot::createSceneGraph(int id) | |
297 { | |
298 SceneGraphPtr src; | |
299 SceneGraphPtr p; | |
300 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
301 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
|
302 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
|
303 return NULL; |
539 | 304 } |
305 | |
306 /* オリジナルの SceneGraph */ | |
562 | 307 src = sg_src[id]; |
539 | 308 |
309 /* ユーザーにはオリジナルの clone を返す */ | |
1136 | 310 p = src->clone(this->tmanager); |
539 | 311 |
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
|
312 /* 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
|
313 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
|
314 |
539 | 315 addNext(p); |
316 | |
317 return p; | |
318 } | |
319 | |
562 | 320 |
321 | |
322 | |
323 SceneGraphPtr | |
324 SceneGraphRoot::createSceneGraph(const char *name) | |
325 { | |
326 SceneGraphPtr src; | |
327 SceneGraphPtr p; | |
328 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
329 int id = getSgid(name); |
562 | 330 if (id < 0) { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
331 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
|
332 return NULL; |
562 | 333 } |
334 | |
335 /* オリジナルの SceneGraph */ | |
336 src = sg_src[id]; | |
337 | |
338 /* ユーザーにはオリジナルの clone を返す */ | |
1136 | 339 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
|
340 |
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
|
341 /* 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
|
342 p->sgroot = (void *)this; |
562 | 343 |
344 addNext(p); | |
345 | |
346 return p; | |
347 } | |
348 | |
349 int | |
350 SceneGraphRoot::getSgid(const char *name) | |
351 { | |
1122 | 352 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
|
353 } |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
354 |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
355 int |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
356 SceneGraphRoot::getLast() |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
357 { |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
358 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
|
359 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
|
360 return -1; |
562 | 361 } |
362 | |
539 | 363 /** |
364 * 何も表示しない、move,collision もしない SceneGraph を生成 | |
365 * いずれ、Transform3D 的なものに回す予定 | |
366 */ | |
367 SceneGraphPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
368 SceneGraphRoot::createSceneGraph() |
539 | 369 { |
1143 | 370 SceneGraphPtr p = new SceneGraph(sgroot->tmanager); |
539 | 371 |
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
|
372 /* 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
|
373 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
|
374 |
539 | 375 addNext(p); |
376 p->flag_drawable = 0; | |
377 | |
378 return p; | |
379 } | |
380 | |
381 | |
382 void | |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
383 SceneGraphRoot::lightCalc() |
539 | 384 { |
761 | 385 int light_num = 4; |
386 for (int i = 0; i < light_num; i++) { | |
747 | 387 |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
388 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); |
761 | 389 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
390 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
|
391 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
|
392 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
|
393 light_vector[i*4+3] = 1.0f; |
747 | 394 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
395 ApplyMatrix(&light_vector[i*4], light[i]->matrix); |
761 | 396 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
397 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
|
398 light_vector[i*4+1] /= light_vector[i*4+2]; |
747 | 399 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
400 /*SIMD演算のため*/ |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
401 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
|
402 light_vector[i*4+3] *= -1; |
764 | 403 |
761 | 404 } |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
405 } |
761 | 406 |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
407 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
408 SceneGraphRoot::flip() |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
409 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
410 // 前フレームで描画した SceneGraph は削除 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
411 allRemove(sg_remove_list); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
412 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
413 // 前フレームに作られた SceneGraph は描画用に移行 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
414 // 現フレームでの操作は以下の tree,list には適用されない |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
415 sg_draw_tree = sg_exec_tree; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
416 sg_remove_list = sg_available_list; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
417 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
418 // 現フレームで新しく SceneGraph がコピーされるので初期化 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
419 sg_exec_tree = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
420 sg_available_list = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
421 } |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
422 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
423 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
424 SceneGraphRoot::allExecute(int screen_w, int screen_h) |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
425 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
426 SceneGraphPtr list = sg_available_list; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
427 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
428 flip(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
429 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
430 camera->move_execute(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
431 camera->update(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
432 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
433 camera->children = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
434 camera->lastChild = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
435 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
436 /*まずは全部動作させる*/ |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
437 while (list) { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
438 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
439 list->move_execute(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
440 list->collision_check(screen_w, screen_h, list); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
441 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
442 list->frame++; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
443 list = list->next; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
444 } |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
445 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
446 lightCalc(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
447 |
539 | 448 if(sg_exec_tree != NULL) { |
758 | 449 return; |
539 | 450 } |
451 | |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
452 copyTree(sg_draw_tree, camera); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
453 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
454 // 現在、allExecute が終わった時点では |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
455 // camera->children が User SceneGraph の root になる |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
456 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
457 /** |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
458 * NULL じゃなかったら、setSceneData が呼ばれてるから |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
459 * そっちを次の Scene にする |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
460 */ |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
461 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
462 sg_exec_tree = camera->children; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
463 } |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
464 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
465 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
466 SceneGraphRoot::copyTree(SceneGraphPtr t, SceneGraphPtr cur_parent) |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
467 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
468 // SceneGraphPtr t = sg_draw_tree; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
469 |
539 | 470 /*removeのflagをもとにtreeを形成*/ |
471 while (t) { | |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
472 SceneGraphPtr c = NULL; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
473 if (!t->isRemoved()) { |
1136 | 474 c = t->clone(this->tmanager); |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
475 addNext(c); |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
476 cur_parent->addChild(c); |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
477 c->frame = t->frame; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
478 /*親の回転、座標から、子の回転、座標を算出*/ |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
479 get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); |
747 | 480 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
481 get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix); |
845 | 482 //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix); |
908 | 483 |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
484 } |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
485 |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
486 if (t->children != NULL && c != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
487 cur_parent = c; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
488 t = t->children; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
489 } else if (t->brother != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
490 t = t->brother; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
491 } else { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
492 while (t) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
493 if (t->brother != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
494 t = t->brother; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
495 break; |
539 | 496 } else { |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
497 if (t->parent == NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
498 t = NULL; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
499 break; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
500 } else { |
539 | 501 cur_parent = cur_parent->parent; |
502 t = t->parent; | |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
503 } |
539 | 504 } |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
505 } |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
506 } |
539 | 507 } |
508 | |
509 } | |
510 | |
1226
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
511 /** |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
512 * 破壊的に変換行列の親子関係を計算する |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
513 */ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
514 void |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
515 SceneGraphRoot::transTree(SceneGraphPtr t, SceneGraphPtr cur_parent) |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
516 { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
517 // SceneGraphPtr t = sg_draw_tree; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
518 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
519 /*removeのflagをもとにtreeを形成*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
520 while (t) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
521 SceneGraphPtr c = NULL; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
522 if (!t->isRemoved()) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
523 /*親の回転、座標から、子の回転、座標を算出*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
524 matrix4x4(t->matrix,t->matrix,cur_parent->matrix); |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
525 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
526 matrix4x4(t->real_matrix,t->real_matrix,cur_parent->real_matrix); |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
527 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
528 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
529 if (t->children != NULL && c != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
530 cur_parent = t; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
531 t = t->children; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
532 } else if (t->brother != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
533 t = t->brother; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
534 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
535 while (t) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
536 if (t->brother != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
537 t = t->brother; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
538 break; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
539 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
540 if (t->parent == NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
541 t = NULL; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
542 break; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
543 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
544 cur_parent = cur_parent->parent; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
545 t = t->parent; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
546 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
547 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
548 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
549 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
550 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
551 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
552 } |
758 | 553 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
554 /* |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
555 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
|
556 */ |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
557 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
558 SceneGraphRoot::move_finish() |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
559 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
560 list->collision_check(screen_w, screen_h, list); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
561 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
562 list->frame++; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
563 //list = list->next; |
761 | 564 |
565 int light_num = 4; | |
566 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
|
567 |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
568 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); |
761 | 569 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
570 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
|
571 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
|
572 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
|
573 light_vector[i*4+3] = 1.0f; |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
574 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
575 ApplyMatrix(&light_vector[i*4], light[i]->matrix); |
761 | 576 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
577 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
|
578 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
|
579 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
580 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
|
581 light_vector[i*4+3] *= -1; |
761 | 582 } |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
583 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
584 //sgchange->viewer->light_xyz_stock = getLightVector(); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
585 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
586 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
587 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
588 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
589 SceneGraphRoot::appTaskRegist(regist_func new_register) |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
590 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
591 this->regist = new_register; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
592 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
593 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
594 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
595 SceneGraphRoot::regist_execute() |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
596 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
597 (*regist)(this); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
598 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
599 |
758 | 600 void |
539 | 601 SceneGraphRoot::allRemove(SceneGraphPtr list) |
602 { | |
603 SceneGraphPtr p = list; | |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
604 |
539 | 605 while (p) { |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
606 SceneGraphPtr p1 = p->next; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
607 delete p; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
608 p = p1; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
609 cnt--; |
539 | 610 } |
611 } | |
612 | |
613 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
614 SceneGraphRoot::checkRemove() |
539 | 615 { |
616 SceneGraphPtr p = sg_available_list; | |
617 SceneGraphPtr p1; | |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
618 |
539 | 619 while (p) { |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
620 p1 = p->next; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
621 if (p->isRemoved()) { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
622 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
623 sg_available_list = p->realRemoveFromList(sg_available_list); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
624 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
625 delete p; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
626 p = p1; |
539 | 627 } |
628 } | |
629 | |
630 SceneGraphPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
631 SceneGraphRoot::getExecuteSceneGraph() |
539 | 632 { |
633 return sg_exec_tree; | |
634 } | |
635 | |
1046 | 636 |
637 void | |
638 printSceneGraph(SceneGraphPtr t) | |
639 { | |
640 while (t) { | |
641 if (!t->isRemoved()) { | |
642 if (t->name) printf("name: %s ",t->name); | |
643 printf("x=%g y=%g z=%g\n",t->xyz[0],t->xyz[1],t->xyz[2]); | |
644 } | |
645 if (t->children != NULL) { | |
646 t = t->children; | |
647 } else if (t->brother != NULL) { | |
648 t = t->brother; | |
649 } else { | |
650 while (t) { | |
651 if (t->brother != NULL) { | |
652 t = t->brother; | |
653 break; | |
654 } else { | |
655 if (t->parent == NULL) { | |
656 t = NULL; | |
657 break; | |
658 } else { | |
659 t = t->parent; | |
660 } | |
661 } | |
662 } | |
663 } | |
664 } | |
665 } | |
666 | |
539 | 667 SceneGraphPtr |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
668 SceneGraphRoot::getDrawSceneGraph() |
539 | 669 { |
670 return sg_draw_tree; | |
671 } | |
672 | |
673 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
674 SceneGraphRoot::updateControllerState() |
539 | 675 { |
676 controller->check(); | |
677 } | |
678 | |
679 void | |
680 SceneGraphRoot::setSceneData(SceneGraphPtr sg) | |
681 { | |
682 sg_exec_tree = sg; | |
683 } | |
684 | |
685 Pad* | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
686 SceneGraphRoot::getController() |
539 | 687 { |
688 return controller; | |
689 } | |
690 | |
691 SceneGraphIteratorPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
692 SceneGraphRoot::getIterator() |
539 | 693 { |
694 iterator->set(sg_remove_list); | |
695 return iterator; | |
696 } | |
697 | |
698 SceneGraphIteratorPtr | |
699 SceneGraphRoot::getIterator(SceneGraphPtr list) | |
700 { | |
701 iterator->set(list); | |
702 return iterator; | |
703 } | |
704 | |
705 CameraPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
706 SceneGraphRoot::getCamera() |
539 | 707 { |
708 return camera; | |
709 } | |
597 | 710 |
747 | 711 |
712 SceneGraphPtr | |
761 | 713 SceneGraphRoot::getLight(int id) |
597 | 714 { |
715 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
716 return light[id]; |
597 | 717 |
718 } | |
747 | 719 |
720 | |
721 float* | |
722 SceneGraphRoot::getLightVector() | |
723 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
724 return light_vector; |
747 | 725 } |
779 | 726 |
792 | 727 int* |
728 SceneGraphRoot::getLightSwitch() | |
729 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
730 return light_switch; |
792 | 731 } |
732 | |
733 int | |
734 SceneGraphRoot::getLightSysSwitch() | |
735 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
736 return light_sysswitch; |
792 | 737 } |
738 | |
793 | 739 void |
740 SceneGraphRoot::OnLightSwitch(int id) | |
741 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
742 light_switch[id] = 1; |
793 | 743 } |
744 | |
745 void | |
746 SceneGraphRoot::OffLightSwitch(int id) | |
747 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
748 light_switch[id] = 0; |
793 | 749 } |
750 | |
751 void | |
752 SceneGraphRoot::OnLightSysSwitch() | |
753 { | |
754 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
755 light_sysswitch = 1; |
793 | 756 |
757 } | |
758 | |
759 void | |
760 SceneGraphRoot::OffLightSysSwitch() | |
761 { | |
762 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
763 light_sysswitch = 0; |
793 | 764 |
765 } | |
766 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
767 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
768 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
|
769 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
770 gtask_array = new GTaskArray; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
771 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
|
772 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
773 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
774 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
775 SceneGraphRoot::create_task_array() |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
776 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
777 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
|
778 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
779 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
780 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
781 SceneGraphRoot::task_array_finish() |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
782 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
783 gtask_array->finish(); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
784 } |
869 | 785 |
786 void | |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
787 SceneGraphRoot::set_gtask_array(int id, void *property, int size, PostFunction post_func) |
1002 | 788 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
789 gtask_array->next_task_array(id); |
1002 | 790 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
791 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
|
792 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
|
793 |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
794 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
795 |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
796 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
797 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
|
798 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
799 gtask_array->next_task_array(id); |
1002 | 800 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
801 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
|
802 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
|
803 gtask_array->game_task->set_outData(0, property, size); |
1002 | 804 |
869 | 805 } |
806 | |
884 | 807 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
808 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
|
809 { |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
810 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
|
811 task->set_cpu(SPE_ANY); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
812 task->add_inData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
813 task->add_outData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
814 task->spawn(); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
815 } |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
816 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
817 void |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
818 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
|
819 { |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
820 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
|
821 task->set_cpu(SPE_ANY); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
822 task->add_inData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
823 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
|
824 task->add_outData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
825 task->spawn(); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
826 } |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
827 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
828 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
829 void |
882 | 830 main_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
831 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
832 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
|
833 void *e = node->propertyptr; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
834 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
|
835 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
1006 | 836 /* |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
837 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
838 node->xyz[0] = property->x; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
839 node->xyz[1] = property->y; |
1006 | 840 */ |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
841 sgroottmp->set_game_task(move, (void*)e, size); |
882 | 842 } |
843 | |
844 void | |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
845 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
|
846 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
847 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
|
848 void *e = node->propertyptr; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
849 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
|
850 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
851 void *pad = (void*)sgroottmp->getController(); |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
852 |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
853 /* |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
854 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
855 property->root = node; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
856 node->xyz[0] = property->x; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
857 node->xyz[1] = property->y; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
858 */ |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
859 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
860 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
|
861 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
862 |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
863 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
864 SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size) |
882 | 865 { |
866 node->move = main_task_move; | |
867 node->move_id = move; | |
868 node->propertyptr = property; | |
869 node->property_size = size; | |
870 } | |
869 | 871 |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
872 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
873 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
|
874 { |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
875 node->move = pad_task_move; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
876 node->move_id = move; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
877 node->propertyptr = property; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
878 node->property_size = size; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
879 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
880 |
779 | 881 /* end */ |