Mercurial > hg > Game > Cerium
annotate Renderer/Engine/SceneGraphRoot.cc @ 1299:f0e805c09ed6 draft
minor fix xml_walk and pickup_float, not work yet.
author | Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 04 Dec 2011 18:50:53 +0900 |
parents | bb8b7f179f31 |
children | ab9b7d21b32b |
rev | line source |
---|---|
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
1 |
539 | 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 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
45 light_init(); |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
46 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
47 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
|
48 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
49 gtask_array = NULL; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
50 |
539 | 51 // TODO |
52 // 今はとりあえず camera を Root にしています | |
53 // 今はそれすらもしてません | |
54 //sg_exec_tree = camera; | |
55 } | |
56 | |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
57 |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
58 SceneGraphRoot::~SceneGraphRoot() |
539 | 59 { |
60 SceneGraphPtr p = sg_available_list; | |
61 | |
62 while (p) { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
63 SceneGraphPtr tmp = p->next; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
64 delete p; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
65 p = tmp; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
66 cnt--; |
539 | 67 } |
68 | |
69 p = sg_remove_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 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
78 free(sg_src); |
539 | 79 delete camera; |
761 | 80 int light_num = 4; |
81 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
|
82 delete light[i]; |
761 | 83 } |
539 | 84 delete iterator; |
85 delete controller; | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
86 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
87 if (gtask_array != NULL) { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
88 delete gtask_array; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
89 } |
539 | 90 } |
91 | |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
92 void |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
93 SceneGraphRoot::light_init() |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
94 { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
95 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
96 int light_num = 4; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
97 light_sysswitch = 0; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
98 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
99 for (int i = 0; i < light_num; i++) { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
100 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
101 light[i] = new SceneGraph(sgroot->tmanager); |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
102 light[i]->xyz[0] = 0; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
103 light[i]->xyz[1] = 0; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
104 light[i]->xyz[2] = 0; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
105 light[i]->xyz[3] = 1.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
106 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
107 light_switch[i] = 0; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
108 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
109 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
110 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
111 for (int i = 0; i < 4; i++) { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
112 light_vector[i*4] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
113 light_vector[i*4+1] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
114 light_vector[i*4+2] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
115 light_vector[i*4+3] = 1.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
116 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
117 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
118 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
119 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
120 |
539 | 121 /** |
122 * xml ファイルから生成された SceneGraph を sg_src に登録する。 | |
123 * | |
124 * @param sg SceneGraph created by xmlfile | |
125 */ | |
126 void | |
127 SceneGraphRoot::registSceneGraph(SceneGraphPtr sg) | |
128 { | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
129 int dup; |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
130 if ((dup = getSgid(sg->name))>=0) { // while... |
576 | 131 sg_src[dup]->name = ""; |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
132 // 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
|
133 } |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
134 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
|
135 sg_src_size *= 2; |
582 | 136 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
|
137 } |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
138 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
|
139 sg_src[sg->sgid] = sg; |
1114 | 140 sgid_hash.sg_hash_regist((const char*)sg->name, sg->sgid); |
539 | 141 } |
142 | |
848 | 143 |
539 | 144 void |
145 SceneGraphRoot::addNext(SceneGraphPtr sg) | |
146 { | |
147 SceneGraphPtr last = sg_available_list; | |
148 | |
149 if (!last) { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
150 sg_available_list = sg; |
539 | 151 } else { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
152 while (last->next) { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
153 last = last->next; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
154 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
155 last->next = sg; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
156 sg->prev = last; |
539 | 157 } |
158 | |
159 cnt++; | |
160 } | |
161 | |
1205
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 void |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
164 SceneGraphRoot::createStringFont(TaskManager *manager, SceneGraphPtr root, |
1211 | 165 const char *string,int pixels,int screen_w, |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
166 int screen_h,Uint32 color) |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
167 { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
168 SceneGraphPtr text; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
169 float width_shift = 0; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
170 int i; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
171 int length = strlen(string); |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
172 for (i = 0; i < length;) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
173 int len = 0; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
174 unsigned char initial = string[i]; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
175 while (1) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
176 unsigned char mask = 0x80; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
177 if (mask & initial) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
178 len++; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
179 } else { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
180 if (len == 0) len++; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
181 break; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
182 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
183 initial <<= 1; |
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 char *obj_name; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
186 float scale[] = {1,1,1}; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
187 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
|
188 text = sgroot->createSceneGraph(obj_name); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
189 text->xyz[0] = screen_w/2 + width_shift -100; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
190 text->xyz[1] = screen_h/2; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
191 text->xyz[2] = -100; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
192 width_shift += text->seq; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
193 root->addChild(text); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
194 get_matrix_scale(text->matrix, text->angle, text->xyz, scale, root->matrix); |
1254 | 195 // get_matrix(text->real_matrix, text->angle, text->xyz, root->real_matrix); |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
196 i += len; |
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 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
199 |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
200 void |
1211 | 201 SceneGraphRoot::createFont(TaskManager *manager,const char *font, int pixels, |
202 Uint32 color,const char *string_name, int len, | |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
203 char **obj_name) |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
204 { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
205 *obj_name = (char *)malloc(sizeof(char) * 12); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
206 char sname[] = "char:"; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
207 memcpy(*obj_name, sname, 5); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
208 memcpy(*obj_name + 5, string_name, len); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
209 (*obj_name)[5+len] = '\0'; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
210 printf("%d",sgid_hash.get_sgid(*obj_name)); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
211 if (sgid_hash.get_sgid(*obj_name) != -1) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
212 return; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
213 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
214 SceneGraphPtr tmp = new SceneGraph(manager, font, pixels, color, |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
215 *obj_name); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
216 registSceneGraph(tmp); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
217 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
218 |
539 | 219 /* XMLファイルからポリゴンを作成 */ |
220 void | |
221 SceneGraphRoot::createFromXMLfile(TaskManager *manager, const char *xmlfile) | |
222 { | |
223 xmlDocPtr doc; | |
224 xmlNodePtr cur; | |
225 SceneGraphPtr tmp; | |
562 | 226 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
227 /* パース DOM生成 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
228 xmlParseFile:ファイルに含まれるXML文書を分析する |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
229 xmlDocGetRootElement:ドキュメントルートを指定する。 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
230 よって、以下のcurにはドキュメントルートの位置が入っている |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
231 */ |
539 | 232 doc = xmlParseFile(xmlfile); |
233 cur = xmlDocGetRootElement(doc); | |
234 | |
235 /* ?? */ | |
236 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); | |
237 | |
238 /* XMLのノードを一つずつ解析 */ | |
239 for (cur=cur->children; cur; cur=cur->next) { | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
240 /*初期化:curをドキュメントルートの一個下に設定 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
241 継続条件:curが真である |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
242 再初期化:次のノードへ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
243 */ |
539 | 244 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
245 /* 扱うのはsurfaceオンリーなので、ノードの名前がsurfaceでないなら |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
246 以下の処理を行なわずにスキップする |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
247 */ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
248 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
249 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
250 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
251 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
252 /* ポリゴン(SceneGraph)生成 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
253 SceneGraph:SceneGraph.cc、L186 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
254 */ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
255 tmp = new SceneGraph(manager, cur); |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
256 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
257 //シーングラフを登録 |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
258 registSceneGraph(tmp); |
539 | 259 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
260 //解放 |
539 | 261 xmlFreeDoc(doc); |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
262 } |
562 | 263 |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
264 /*static const char* |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
265 get_property(const char *name, xmlNodePtr cur){ |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
266 xmlAttr *p=cur->properties; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
267 if (p==0) return ""; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
268 for ( ;p; p=p->next) { |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
269 if ( xmlStrcmp(p->name, (xmlChar*)name) !=0 ) { |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
270 xmlNode* n=p->children; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
271 if ( n==NULL ) return ""; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
272 const char * v=(const char*)n->content; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
273 if ( v==NULL ) return ""; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
274 return v; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
275 } |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
276 } |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
277 return ""; |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
278 }*/ |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
279 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
280 typedef struct source { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
281 char *id; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
282 int count; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
283 float *array; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
284 struct source *next; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
285 } SOURCE; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
286 typedef SOURCE *SOURCE_P; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
287 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
288 typedef struct list { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
289 SOURCE_P first; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
290 SOURCE_P end; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
291 } LIST; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
292 typedef LIST *LIST_P; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
293 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
294 static void |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
295 addSource(LIST_P list, SOURCE_P src) { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
296 if (list->first == NULL && list->end == NULL) { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
297 list->first = list->end = src; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
298 return; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
299 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
300 list->end->next = src; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
301 list->end = src; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
302 } |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
303 |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
304 static void |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
305 xml_walk( SceneGraphRoot* self, xmlNodePtr cur, LIST_P list) |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
306 { |
1297 | 307 |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
308 /*get float array.*/ |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
309 printf("name = %s, child:%s\n", (char *)cur->name, (char *)cur->children); |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
310 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
311 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
312 SOURCE_P src = (SOURCE_P)malloc(sizeof(SOURCE)); |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
313 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
314 char *id = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
315 src->id = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
316 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
317 int count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
318 src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
319 src->array = (float*)malloc(sizeof(float) * src->count); |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
320 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
321 char *cont =(char*)xmlNodeGetContent(cur); |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
322 //const char *id = get_property("id", cur); |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
323 //int count = atoi(get_property("count", cur)); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
324 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
325 for (int i = 0; cont != NULL; i++) { |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
326 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
327 //cont = pickup_float(cont, src->array+1); |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
328 // ここ+1じゃなくて、+iじゃない? |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
329 cont = pickup_float(cont, src->array+i); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
330 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
331 |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
332 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
333 src->next = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
334 addSource(list, src); |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
335 printf("id:%s count:%d cont:%s\n", id, count, cont); |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
336 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
337 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
338 char *p = (char*)xmlNodeGetContent(cur); |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
339 printf("p:%s", p); |
1299
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
340 } |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
341 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
342 } |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
343 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
344 for (cur=cur->children; cur; cur=cur->next){ |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
345 xml_walk(self, cur, list); |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
346 } |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
347 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
348 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
349 void |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
350 init_list(LIST_P list) { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
351 list->first = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
352 list->end = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
353 } |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
354 |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
355 void |
1251
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
356 SceneGraphRoot::createFromCOLLADAfile(TaskManager *manager, const char *xmlColladafile) |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
357 { |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
358 /*make parse dom*/ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
359 xmlDocPtr doc; |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
360 xmlNodePtr cur; |
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
361 //,cur_images,cur_effects,cur_geometries,cur_visual_scenes; |
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
362 //SceneGraphPtr tmp; |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
363 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
364 doc = xmlParseFile(xmlColladafile); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
365 cur = xmlDocGetRootElement(doc); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
366 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
367 /*エラー処理……だけど何書けばいいのか謎。とりあえず-1返してみる*/ |
1251
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
368 if(xmlStrcmp(cur->name, (xmlChar*)"COLLADA")){ |
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
369 return ; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
370 }; |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
371 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
372 /* node analyze */ |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
373 for(cur=cur->children; cur; cur=cur->next){ |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
374 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
375 LIST list; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
376 init_list(&list); |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
377 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
378 xml_walk(this, cur, &list); |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
379 /* if(xmlStrcmp(cur->name,(xmlChar*)"library_imeges") != 0){ |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
380 cur_images = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
381 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
382 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
383 if(xmlStrcmp(cur->name,(xmlChar*)"library_effects") != 0){ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
384 cur_effects = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
385 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
386 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
387 if(xmlStrcmp(cur->name,(xmlChar*)"library_geometries") != 0){ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
388 cur_geometries = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
389 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
390 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
391 if(xmlStrcmp(cur->name,(xmlChar*)"library_visual_scenes")!=0){ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
392 cur_visual_scenes = cur; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
393 continue; |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
394 }*/ |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
395 |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
396 //tmp = new SceneGraph(manager, cur); |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
397 //registSceneGraph(tmp); |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
398 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
399 xmlFreeDoc(doc); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
400 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
401 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
402 void |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
403 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
|
404 { |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
405 xmlDocPtr doc; |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
406 xmlNodePtr cur; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
407 |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
408 // size は取れるはず、テスト用に mmap したデータを使う |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
409 /* パース DOM生成 */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
410 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
411 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
|
412 cur = xmlDocGetRootElement(doc); |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
413 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
414 /* ?? */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
415 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
|
416 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
417 /* XMLのノードを一つずつ解析 */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
418 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
|
419 /* 扱うのはsurfaceオンリー */ |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
420 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
|
421 continue; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
422 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
423 /* ポリゴン(SceneGraph)生成 */ |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
424 SceneGraphPtr original = new SceneGraph(manager, cur); |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
425 registSceneGraph(original); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
426 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
|
427 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
|
428 } |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
429 xmlFreeDoc(doc); |
539 | 430 } |
431 | |
432 SceneGraphPtr | |
433 SceneGraphRoot::createSceneGraph(int id) | |
434 { | |
435 SceneGraphPtr src; | |
436 SceneGraphPtr p; | |
437 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
438 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
|
439 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
|
440 return NULL; |
539 | 441 } |
442 | |
443 /* オリジナルの SceneGraph */ | |
562 | 444 src = sg_src[id]; |
539 | 445 |
446 /* ユーザーにはオリジナルの clone を返す */ | |
1136 | 447 p = src->clone(this->tmanager); |
539 | 448 |
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
|
449 /* 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
|
450 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
|
451 |
539 | 452 addNext(p); |
453 | |
454 return p; | |
455 } | |
456 | |
562 | 457 |
458 | |
459 | |
460 SceneGraphPtr | |
461 SceneGraphRoot::createSceneGraph(const char *name) | |
462 { | |
463 SceneGraphPtr src; | |
464 SceneGraphPtr p; | |
465 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
466 int id = getSgid(name); |
562 | 467 if (id < 0) { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
468 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
|
469 return NULL; |
562 | 470 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
471 |
562 | 472 /* オリジナルの SceneGraph */ |
473 src = sg_src[id]; | |
474 | |
475 /* ユーザーにはオリジナルの clone を返す */ | |
1136 | 476 p = src->clone(this->tmanager); |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
477 |
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
|
478 /* 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
|
479 p->sgroot = (void *)this; |
562 | 480 |
481 addNext(p); | |
482 | |
483 return p; | |
484 } | |
485 | |
486 int | |
487 SceneGraphRoot::getSgid(const char *name) | |
488 { | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
489 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
|
490 } |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
491 |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
492 int |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
493 SceneGraphRoot::getLast() |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
494 { |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
495 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
|
496 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
|
497 return -1; |
562 | 498 } |
499 | |
539 | 500 /** |
501 * 何も表示しない、move,collision もしない SceneGraph を生成 | |
502 * いずれ、Transform3D 的なものに回す予定 | |
503 */ | |
504 SceneGraphPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
505 SceneGraphRoot::createSceneGraph() |
539 | 506 { |
1143 | 507 SceneGraphPtr p = new SceneGraph(sgroot->tmanager); |
539 | 508 |
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
|
509 /* 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
|
510 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
|
511 |
539 | 512 addNext(p); |
513 p->flag_drawable = 0; | |
514 | |
515 return p; | |
516 } | |
517 | |
518 | |
519 void | |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
520 SceneGraphRoot::lightCalc() |
539 | 521 { |
761 | 522 int light_num = 4; |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
523 float light_vector_tmp[16]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
524 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
525 for (int i = 0; i < 4; i++) { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
526 light_vector_tmp[i*4] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
527 light_vector_tmp[i*4+1] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
528 light_vector_tmp[i*4+2] = 0.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
529 light_vector_tmp[i*4+3] = 1.0f; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
530 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
531 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
532 |
761 | 533 for (int i = 0; i < light_num; i++) { |
747 | 534 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
535 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
536 ApplyMatrix(&light_vector_tmp[i*4], light[i]->matrix); |
747 | 537 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
538 light_vector_tmp[i*4] /= light_vector_tmp[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
539 light_vector_tmp[i*4+1] /= light_vector_tmp[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
540 light_vector_tmp[i*4+2] /= light_vector_tmp[i*4+3]; |
747 | 541 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
542 /*SIMD演算のため*/ |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
543 light_vector_tmp[i*4+2] *= -1; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
544 light_vector_tmp[i*4+3] *= -1; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
545 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
546 for (int i = 0; i < 4; i++) { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
547 light_vector[i*4] = light_vector_tmp[i*4]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
548 light_vector[i*4+1] = light_vector_tmp[i*4+1]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
549 light_vector[i*4+2] = light_vector_tmp[i*4+2]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
550 light_vector[i*4+3] = light_vector_tmp[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
551 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
552 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
553 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
554 |
764 | 555 |
761 | 556 } |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
557 } |
761 | 558 |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
559 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
560 SceneGraphRoot::flip() |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
561 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
562 // 前フレームで描画した SceneGraph は削除 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
563 allRemove(sg_remove_list); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
564 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
565 // 前フレームに作られた SceneGraph は描画用に移行 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
566 // 現フレームでの操作は以下の tree,list には適用されない |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
567 sg_draw_tree = sg_exec_tree; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
568 sg_remove_list = sg_available_list; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
569 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
570 // 現フレームで新しく SceneGraph がコピーされるので初期化 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
571 sg_exec_tree = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
572 sg_available_list = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
573 } |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
574 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
575 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
576 SceneGraphRoot::allExecute(int screen_w, int screen_h) |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
577 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
578 SceneGraphPtr list = sg_available_list; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
579 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
580 flip(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
581 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
582 camera->move_execute(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
583 camera->update(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
584 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
585 camera->children = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
586 camera->lastChild = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
587 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
588 /*まずは全部動作させる*/ |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
589 while (list) { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
590 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
591 list->move_execute(screen_w, screen_h); |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
592 list->collision_check(screen_w, screen_h, list); |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
593 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
594 list->frame++; |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
595 list = list->next; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
596 } |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
597 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
598 lightCalc(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
599 |
539 | 600 if(sg_exec_tree != NULL) { |
758 | 601 return; |
539 | 602 } |
603 | |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
604 copyTree(sg_draw_tree, camera); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
605 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
606 // 現在、allExecute が終わった時点では |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
607 // camera->children が User SceneGraph の root になる |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
608 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
609 /** |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
610 * NULL じゃなかったら、setSceneData が呼ばれてるから |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
611 * そっちを次の Scene にする |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
612 */ |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
613 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
614 sg_exec_tree = camera->children; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
615 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
616 |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
617 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
618 SceneGraphRoot::copyTree(SceneGraphPtr t, SceneGraphPtr cur_parent) |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
619 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
620 // SceneGraphPtr t = sg_draw_tree; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
621 |
539 | 622 /*removeのflagをもとにtreeを形成*/ |
623 while (t) { | |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
624 SceneGraphPtr c = NULL; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
625 if (!t->isRemoved()) { |
1136 | 626 c = t->clone(this->tmanager); |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
627 addNext(c); |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
628 cur_parent->addChild(c); |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
629 c->frame = t->frame; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
630 /*親の回転、座標から、子の回転、座標を算出*/ |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
631 get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); |
747 | 632 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
633 get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix); |
845 | 634 //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix); |
908 | 635 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
636 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
637 |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
638 if (t->children != NULL && c != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
639 cur_parent = c; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
640 t = t->children; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
641 } else if (t->brother != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
642 t = t->brother; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
643 } else { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
644 while (t) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
645 if (t->brother != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
646 t = t->brother; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
647 break; |
539 | 648 } else { |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
649 if (t->parent == NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
650 t = NULL; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
651 break; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
652 } else { |
539 | 653 cur_parent = cur_parent->parent; |
654 t = t->parent; | |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
655 } |
539 | 656 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
657 } |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
658 } |
539 | 659 } |
660 | |
661 } | |
662 | |
1254 | 663 |
664 void | |
1256 | 665 SceneGraphRoot::treeApply(int screen_w, int screen_h) |
1254 | 666 { |
667 // don't calcurate sg_draw_tree's brother | |
668 transTree(sg_draw_tree->children, camera); | |
669 } | |
670 | |
671 | |
1226
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
672 /** |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
673 * 破壊的に変換行列の親子関係を計算する |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
674 */ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
675 void |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
676 SceneGraphRoot::transTree(SceneGraphPtr t, SceneGraphPtr cur_parent) |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
677 { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
678 // SceneGraphPtr t = sg_draw_tree; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
679 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
680 /*removeのflagをもとにtreeを形成*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
681 while (t) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
682 SceneGraphPtr c = NULL; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
683 if (!t->isRemoved()) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
684 /*親の回転、座標から、子の回転、座標を算出*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
685 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
|
686 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ |
1254 | 687 // matrix4x4(t->real_matrix,t->real_matrix,cur_parent->real_matrix); |
1226
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
688 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
689 if (t->children != NULL && c != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
690 cur_parent = t; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
691 t = t->children; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
692 } else if (t->brother != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
693 t = t->brother; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
694 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
695 while (t) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
696 if (t->brother != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
697 t = t->brother; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
698 break; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
699 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
700 if (t->parent == NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
701 t = NULL; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
702 break; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
703 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
704 cur_parent = cur_parent->parent; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
705 t = t->parent; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
706 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
707 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
708 } |
1226
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
709 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
710 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
711 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
712 } |
758 | 713 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
714 /* |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
715 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
|
716 */ |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
717 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
718 SceneGraphRoot::move_finish() |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
719 { |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
720 list->collision_check(screen_w, screen_h, list); |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
721 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
722 list->frame++; |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
723 //list = list->next; |
761 | 724 |
725 int light_num = 4; | |
726 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
|
727 |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
728 get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
729 ApplyMatrix(&light_vector[i*4], light[i]->matrix); |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
730 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
731 light_vector[i*4] /= light_vector[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
732 light_vector[i*4+1] /= light_vector[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
733 light_vector[i*4+2] /= light_vector[i*4+3]; |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
734 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
735 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
736 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
|
737 light_vector[i*4+3] *= -1; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
738 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
739 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
740 //sgchange->viewer->light_xyz_stock = getLightVector(); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
741 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
742 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
743 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
744 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
745 SceneGraphRoot::appTaskRegist(regist_func new_register) |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
746 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
747 this->regist = new_register; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
748 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
749 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
750 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
751 SceneGraphRoot::regist_execute() |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
752 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
753 (*regist)(this); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
754 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
755 |
758 | 756 void |
539 | 757 SceneGraphRoot::allRemove(SceneGraphPtr list) |
758 { | |
759 SceneGraphPtr p = list; | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
760 |
539 | 761 while (p) { |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
762 SceneGraphPtr p1 = p->next; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
763 delete p; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
764 p = p1; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
765 cnt--; |
539 | 766 } |
767 } | |
768 | |
769 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
770 SceneGraphRoot::checkRemove() |
539 | 771 { |
772 SceneGraphPtr p = sg_available_list; | |
773 SceneGraphPtr p1; | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
774 |
539 | 775 while (p) { |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
776 p1 = p->next; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
777 if (p->isRemoved()) { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
778 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
779 sg_available_list = p->realRemoveFromList(sg_available_list); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
780 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
781 delete p; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
782 p = p1; |
539 | 783 } |
784 } | |
785 | |
786 SceneGraphPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
787 SceneGraphRoot::getExecuteSceneGraph() |
539 | 788 { |
789 return sg_exec_tree; | |
790 } | |
791 | |
1046 | 792 |
793 void | |
794 printSceneGraph(SceneGraphPtr t) | |
795 { | |
796 while (t) { | |
797 if (!t->isRemoved()) { | |
798 if (t->name) printf("name: %s ",t->name); | |
799 printf("x=%g y=%g z=%g\n",t->xyz[0],t->xyz[1],t->xyz[2]); | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
800 } |
1046 | 801 if (t->children != NULL) { |
802 t = t->children; | |
803 } else if (t->brother != NULL) { | |
804 t = t->brother; | |
805 } else { | |
806 while (t) { | |
807 if (t->brother != NULL) { | |
808 t = t->brother; | |
809 break; | |
810 } else { | |
811 if (t->parent == NULL) { | |
812 t = NULL; | |
813 break; | |
814 } else { | |
815 t = t->parent; | |
816 } | |
817 } | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
818 } |
1046 | 819 } |
820 } | |
821 } | |
822 | |
539 | 823 SceneGraphPtr |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
824 SceneGraphRoot::getDrawSceneGraph() |
539 | 825 { |
826 return sg_draw_tree; | |
827 } | |
828 | |
829 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
830 SceneGraphRoot::updateControllerState() |
539 | 831 { |
832 controller->check(); | |
833 } | |
834 | |
835 void | |
836 SceneGraphRoot::setSceneData(SceneGraphPtr sg) | |
837 { | |
838 sg_exec_tree = sg; | |
839 } | |
840 | |
841 Pad* | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
842 SceneGraphRoot::getController() |
539 | 843 { |
844 return controller; | |
845 } | |
846 | |
847 SceneGraphIteratorPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
848 SceneGraphRoot::getIterator() |
539 | 849 { |
850 iterator->set(sg_remove_list); | |
851 return iterator; | |
852 } | |
853 | |
854 SceneGraphIteratorPtr | |
855 SceneGraphRoot::getIterator(SceneGraphPtr list) | |
856 { | |
857 iterator->set(list); | |
858 return iterator; | |
859 } | |
860 | |
861 CameraPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
862 SceneGraphRoot::getCamera() |
539 | 863 { |
864 return camera; | |
865 } | |
597 | 866 |
747 | 867 |
868 SceneGraphPtr | |
761 | 869 SceneGraphRoot::getLight(int id) |
597 | 870 { |
871 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
872 return light[id]; |
597 | 873 |
874 } | |
747 | 875 |
876 | |
877 float* | |
878 SceneGraphRoot::getLightVector() | |
879 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
880 return light_vector; |
747 | 881 } |
779 | 882 |
792 | 883 int* |
884 SceneGraphRoot::getLightSwitch() | |
885 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
886 return light_switch; |
792 | 887 } |
888 | |
889 int | |
890 SceneGraphRoot::getLightSysSwitch() | |
891 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
892 return light_sysswitch; |
792 | 893 } |
894 | |
793 | 895 void |
896 SceneGraphRoot::OnLightSwitch(int id) | |
897 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
898 light_switch[id] = 1; |
793 | 899 } |
900 | |
901 void | |
902 SceneGraphRoot::OffLightSwitch(int id) | |
903 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
904 light_switch[id] = 0; |
793 | 905 } |
906 | |
907 void | |
908 SceneGraphRoot::OnLightSysSwitch() | |
909 { | |
910 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
911 light_sysswitch = 1; |
793 | 912 |
913 } | |
914 | |
915 void | |
916 SceneGraphRoot::OffLightSysSwitch() | |
917 { | |
918 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
919 light_sysswitch = 0; |
793 | 920 |
921 } | |
922 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
923 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
924 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
|
925 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
926 gtask_array = new GTaskArray; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
927 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
|
928 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
929 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
930 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
931 SceneGraphRoot::create_task_array() |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
932 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
933 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
|
934 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
935 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
936 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
937 SceneGraphRoot::task_array_finish() |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
938 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
939 gtask_array->finish(); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
940 } |
869 | 941 |
942 void | |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
943 SceneGraphRoot::set_gtask_array(int id, void *property, int size, PostFunction post_func) |
1002 | 944 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
945 gtask_array->next_task_array(id); |
1002 | 946 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
947 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
|
948 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
|
949 |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
950 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
951 |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
952 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
953 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
|
954 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
955 gtask_array->next_task_array(id); |
1002 | 956 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
957 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
|
958 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
|
959 gtask_array->game_task->set_outData(0, property, size); |
1002 | 960 |
869 | 961 } |
962 | |
884 | 963 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
964 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
|
965 { |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
966 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
|
967 task->set_cpu(SPE_ANY); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
968 task->add_inData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
969 task->add_outData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
970 task->spawn(); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
971 } |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
972 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
973 void |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
974 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
|
975 { |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
976 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
|
977 task->set_cpu(SPE_ANY); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
978 task->add_inData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
979 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
|
980 task->add_outData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
981 task->spawn(); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
982 } |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
983 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
984 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
985 void |
882 | 986 main_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
987 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
988 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
|
989 void *e = node->propertyptr; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
990 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
|
991 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
1006 | 992 /* |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
993 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
994 node->xyz[0] = property->x; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
995 node->xyz[1] = property->y; |
1006 | 996 */ |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
997 sgroottmp->set_game_task(move, (void*)e, size); |
882 | 998 } |
999 | |
1000 void | |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1001 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
|
1002 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1003 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
|
1004 void *e = node->propertyptr; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1005 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
|
1006 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1007 void *pad = (void*)sgroottmp->getController(); |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1008 |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1009 /* |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1010 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1011 property->root = node; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1012 node->xyz[0] = property->x; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1013 node->xyz[1] = property->y; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1014 */ |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1015 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1016 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
|
1017 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1018 |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1019 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1020 SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size) |
882 | 1021 { |
1022 node->move = main_task_move; | |
1023 node->move_id = move; | |
1024 node->propertyptr = property; | |
1025 node->property_size = size; | |
1026 } | |
869 | 1027 |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1028 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1029 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
|
1030 { |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1031 node->move = pad_task_move; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1032 node->move_id = move; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1033 node->propertyptr = property; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1034 node->property_size = size; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1035 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1036 |
779 | 1037 /* end */ |