Mercurial > hg > Game > Cerium
annotate Renderer/Engine/SceneGraphRoot.cc @ 1318:a788b093ef79 draft
minor changes.
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 16 Dec 2011 18:16:48 +0900 |
parents | afe66d75f48a |
children | 31455d34e502 |
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); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
195 i += len; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
196 } |
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 void |
1211 | 200 SceneGraphRoot::createFont(TaskManager *manager,const char *font, int pixels, |
201 Uint32 color,const char *string_name, int len, | |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
202 char **obj_name) |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
203 { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
204 *obj_name = (char *)malloc(sizeof(char) * 12); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
205 char sname[] = "char:"; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
206 memcpy(*obj_name, sname, 5); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
207 memcpy(*obj_name + 5, string_name, len); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
208 (*obj_name)[5+len] = '\0'; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
209 printf("%d",sgid_hash.get_sgid(*obj_name)); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
210 if (sgid_hash.get_sgid(*obj_name) != -1) { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
211 return; |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
212 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
213 SceneGraphPtr tmp = new SceneGraph(manager, font, pixels, color, |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
214 *obj_name); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
215 registSceneGraph(tmp); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
216 } |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1143
diff
changeset
|
217 |
539 | 218 /* XMLファイルからポリゴンを作成 */ |
219 void | |
220 SceneGraphRoot::createFromXMLfile(TaskManager *manager, const char *xmlfile) | |
221 { | |
222 xmlDocPtr doc; | |
223 xmlNodePtr cur; | |
224 SceneGraphPtr tmp; | |
562 | 225 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
226 /* パース DOM生成 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
227 xmlParseFile:ファイルに含まれるXML文書を分析する |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
228 xmlDocGetRootElement:ドキュメントルートを指定する。 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
229 よって、以下のcurにはドキュメントルートの位置が入っている |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
230 */ |
539 | 231 doc = xmlParseFile(xmlfile); |
232 cur = xmlDocGetRootElement(doc); | |
233 | |
234 /* ?? */ | |
235 xmlStrcmp(cur->name,(xmlChar*)"OBJECT-3D"); | |
236 | |
237 /* XMLのノードを一つずつ解析 */ | |
238 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
|
239 /*初期化:curをドキュメントルートの一個下に設定 |
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 再初期化:次のノードへ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
242 */ |
539 | 243 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
244 /* 扱うのはsurfaceオンリーなので、ノードの名前がsurfaceでないなら |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
245 以下の処理を行なわずにスキップする |
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 if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
248 continue; |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
249 } |
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 /* ポリゴン(SceneGraph)生成 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
252 SceneGraph:SceneGraph.cc、L186 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
253 */ |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
254 tmp = new SceneGraph(manager, cur); |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
255 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
256 //シーングラフを登録 |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
257 registSceneGraph(tmp); |
539 | 258 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
259 //解放 |
539 | 260 xmlFreeDoc(doc); |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
261 } |
562 | 262 |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
263 /*static const char* |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
264 get_property(const char *name, xmlNodePtr cur){ |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
265 xmlAttr *p=cur->properties; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
266 if (p==0) return ""; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
267 for ( ;p; p=p->next) { |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
268 if ( xmlStrcmp(p->name, (xmlChar*)name) !=0 ) { |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
269 xmlNode* n=p->children; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
270 if ( n==NULL ) return ""; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
271 const char * v=(const char*)n->content; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
272 if ( v==NULL ) return ""; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
273 return v; |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
274 } |
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 return ""; |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
277 }*/ |
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
|
278 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
279 typedef struct source { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
280 char *id; |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
281 union { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
282 float *array; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
283 char *alias; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
284 }u; |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
285 int count; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
286 struct source *next; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
287 } SOURCE; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
288 typedef SOURCE *SOURCE_P; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
289 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
290 typedef struct list { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
291 SOURCE_P first; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
292 SOURCE_P end; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
293 } LIST; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
294 typedef LIST *LIST_P; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
295 |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
296 /* add source list */ |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
297 static void |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
298 addSource(LIST_P list, SOURCE_P src) { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
299 if (list->first == NULL && list->end == NULL) { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
300 list->first = list->end = src; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
301 return; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
302 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
303 list->end->next = src; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
304 list->end = src; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
305 } |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
306 |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
307 /* compare a with b. Using to compare id */ |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
308 static int |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
309 strcmp_a(const char *a, const char *b) |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
310 { |
1313
857d3feaeb75
collada file reader minor change.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1308
diff
changeset
|
311 while (*a && *a++ == *b++); |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
312 if (*a) return 0; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
313 return a[-1] > b[-1] ? 1:-1; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
314 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
315 |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
316 static float |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
317 get_point(char *id, int position, LIST_P list) |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
318 { |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
319 SOURCE_P cur = list->first; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
320 for (;cur ; cur=cur->next) { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
321 if (!strcmp_a(id, cur->id)) { |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
322 if (cur->count == 0) //alias |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
323 return get_point(cur->u.alias, position, list); |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
324 float *a = cur->u.array; |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
325 if (position <= cur->count) { |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
326 return a[position]; |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
327 } |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
328 } |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
329 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
330 } |
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
331 |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
332 /** |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
333 * co |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
334 */ |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
335 static SOURCE |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
336 must_match_id(const char *id_1 ,const char *id_2) |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
337 { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
338 int tmplength; |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
339 char *tmpsrc; |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
340 for (int strlength=0;id_1[i+1]==id_2[i];str_length++); |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
341 if (tmplength < strlength) { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
342 tmplength = strlength; |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
343 tmpsrc = cur; |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
344 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
345 return cur; |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
346 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
347 |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
348 static struct collada_state { |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
349 int polylist; |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
350 const char *polylist_normal; |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
351 xmlChar *pid; |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
352 float *vcount; |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
353 float *pcount; |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
354 const char *polylist_vertex; |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
355 }; |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
356 |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
357 static void |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
358 xml_walk(SceneGraphRoot* self, xmlNodePtr cur, struct collada_state *s, LIST_P list) |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
359 { |
1297 | 360 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
361 int in_polylist=0; |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
362 |
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
|
363 printf("name = %s, child:%s\n", (char *)cur->name, (char *)cur->children); |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
364 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
365 |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
366 if (!xmlStrcmp(cur->name, (xmlChar*)"polylist")) { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
367 int polylist_count = atoi((char*)xmlGetProp(cur, (xmlChar*)"source")); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
368 |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
369 s->polylist=1; |
1305
b8248a728fc0
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1302
diff
changeset
|
370 in_polylist=1; |
1318 | 371 } else if (!xmlStrcmp(cur->name, (xmlChar*)"vertices")) { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
372 char *vertices_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
373 |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
374 s->pid = xmlGetProp(cur, (xmlChar*)"id"); |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
375 s->vcount = malloc(sizeof(int)*count); |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
376 s->pcount = malloc(sizeof(float)*sum); |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
377 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
378 |
1318 | 379 } else if (s->polylist && !xmlStrcmp(cur->name, (xmlChar*)"input")) { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
380 char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic"); |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
381 if (!xmlStrcmp(semantic, "VERTEX")) { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
382 char *vertex_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
383 int vertex_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
384 |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
385 s->vertex_float = get_hash(vertices_src, s->pid) |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
386 |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
387 } else if (!xmlStrcmp(semantic, "NORMAL")) { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
388 char *normal_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
389 int normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
390 |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
391 s->normal_float = get_hash(normal_src, cur->id); |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
392 } |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
393 |
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
394 } else if (!xmlStrcmp(cur->name, (xmlChar*)"vcount")) { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
395 char *vcont = (char*)xmlNodeGetContent(cur); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
396 for (int i=0; vcount!=NULL; i++) { |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
397 /* store vcount list */ |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
398 vcont = pickup_float(vcont, vcount+i); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
399 } |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
400 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
401 |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
402 } else if (!xmlStrcmp(cur->name, (xmlChar*)"p")) { |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
403 char *pcont = (char*)xmlNodeGetContent(cur); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
404 for (int i=0; pcont != NULL; i++) { |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
405 pcont = pickup_float(pcont, pcount+i); |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
406 } |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
407 } |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
408 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
409 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
410 get_point(pid, , cur); |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
411 |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
412 int vertexp[]; |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
413 int normalp[]; |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
414 |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
415 float *vertex_table; |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
416 float *normal_table; |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
417 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
418 for (int i = 0; i<polylist_count; i++) { |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
419 vertexp[i] = pcount[2*i]; |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
420 normalp[i] = pcount[2*i+1]; |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
421 } |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
422 |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
423 for (int i=0; ;i++) { |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
424 for (int j=0 ; j > vcont[i] ;j++) { |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
425 if (vcount[i] == 4) { |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
426 |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
427 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
428 |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
429 } else if (vcount[i] == 3) { |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
430 vertex_table[i] = vertex; |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
431 |
1316
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
432 |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
433 } |
53f6855985f6
collada file reader minor changes.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1315
diff
changeset
|
434 } |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
435 } |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
436 |
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
437 |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
438 } else 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
|
439 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
440 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
|
441 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
442 char *id = (char*)xmlGetProp(cur, (xmlChar*)"id"); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
443 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
|
444 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
445 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
|
446 src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
447 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
|
448 |
f0e805c09ed6
minor fix xml_walk and pickup_float, not work yet.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1298
diff
changeset
|
449 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
|
450 //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
|
451 //int count = atoi(get_property("count", cur)); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
452 |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
453 /* store float inpoint list */ |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
454 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
|
455 cont = pickup_float(cont, src->array+i); |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
456 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
457 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
458 src->next = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
459 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
|
460 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
|
461 |
1315
c0a5a9abff9c
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1313
diff
changeset
|
462 } |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
463 |
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
|
464 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
|
465 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
|
466 } |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
467 } |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
468 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
469 void |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
470 init_list(LIST_P list) { |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
471 list->first = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
472 list->end = NULL; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
473 } |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
474 |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
475 void |
1251
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
476 SceneGraphRoot::createFromCOLLADAfile(TaskManager *manager, const char *xmlColladafile) |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
477 { |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
478 /*make parse dom*/ |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
479 xmlDocPtr doc; |
1289
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
480 xmlNodePtr cur; |
6fc9fd03a4fd
can read collada file of float_array.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
481 //,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
|
482 //SceneGraphPtr tmp; |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
483 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
484 doc = xmlParseFile(xmlColladafile); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
485 cur = xmlDocGetRootElement(doc); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
486 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
487 /*エラー処理……だけど何書けばいいのか謎。とりあえず-1返してみる*/ |
1251
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
488 if(xmlStrcmp(cur->name, (xmlChar*)"COLLADA")){ |
6da91e7cbffb
improve create From COLLADA
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1249
diff
changeset
|
489 return ; |
1307
5b1589ce972e
improve collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1306
diff
changeset
|
490 } |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
491 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
492 /* node analyze */ |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
493 struct collada_state s={}; |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1277
diff
changeset
|
494 for(cur=cur->children; cur; cur=cur->next){ |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
495 |
1298
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
496 LIST list; |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
497 init_list(&list); |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
498 |
bb8b7f179f31
improve collada file.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1297
diff
changeset
|
499 xml_walk(this, cur, &list); |
1317
afe66d75f48a
destroid collada file reader.
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1316
diff
changeset
|
500 } |
1249
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
501 xmlFreeDoc(doc); |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
502 } |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
503 |
fd9b7519a17b
add createFromCOLLADAfile
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1226
diff
changeset
|
504 void |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
505 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
|
506 { |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
507 xmlDocPtr doc; |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
508 xmlNodePtr cur; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
509 |
580
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
510 // size は取れるはず、テスト用に mmap したデータを使う |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
511 /* パース DOM生成 */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
512 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
513 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
|
514 cur = xmlDocGetRootElement(doc); |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
515 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
516 /* ?? */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
517 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
|
518 |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
519 /* XMLのノードを一つずつ解析 */ |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
520 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
|
521 /* 扱うのはsurfaceオンリー */ |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
522 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
|
523 continue; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
524 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
525 /* ポリゴン(SceneGraph)生成 */ |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
526 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
|
527 registSceneGraph(original); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
528 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
|
529 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
|
530 } |
ec9dd24c2dc8
add all object in file in dynamic_create
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
576
diff
changeset
|
531 xmlFreeDoc(doc); |
539 | 532 } |
533 | |
534 SceneGraphPtr | |
535 SceneGraphRoot::createSceneGraph(int id) | |
536 { | |
537 SceneGraphPtr src; | |
538 SceneGraphPtr p; | |
539 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
540 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
|
541 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
|
542 return NULL; |
539 | 543 } |
544 | |
545 /* オリジナルの SceneGraph */ | |
562 | 546 src = sg_src[id]; |
539 | 547 |
548 /* ユーザーにはオリジナルの clone を返す */ | |
1136 | 549 p = src->clone(this->tmanager); |
539 | 550 |
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
|
551 /* 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
|
552 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
|
553 |
539 | 554 addNext(p); |
555 | |
556 return p; | |
557 } | |
558 | |
562 | 559 |
560 | |
561 | |
562 SceneGraphPtr | |
563 SceneGraphRoot::createSceneGraph(const char *name) | |
564 { | |
565 SceneGraphPtr src; | |
566 SceneGraphPtr p; | |
567 | |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
568 int id = getSgid(name); |
562 | 569 if (id < 0) { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
570 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
|
571 return NULL; |
562 | 572 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
573 |
562 | 574 /* オリジナルの SceneGraph */ |
575 src = sg_src[id]; | |
576 | |
577 /* ユーザーにはオリジナルの clone を返す */ | |
1136 | 578 p = src->clone(this->tmanager); |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
579 |
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
|
580 /* 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
|
581 p->sgroot = (void *)this; |
562 | 582 |
583 addNext(p); | |
584 | |
585 return p; | |
586 } | |
587 | |
588 int | |
589 SceneGraphRoot::getSgid(const char *name) | |
590 { | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
591 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
|
592 } |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
593 |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
594 int |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
595 SceneGraphRoot::getLast() |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
596 { |
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
565
diff
changeset
|
597 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
|
598 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
|
599 return -1; |
562 | 600 } |
601 | |
539 | 602 /** |
603 * 何も表示しない、move,collision もしない SceneGraph を生成 | |
604 * いずれ、Transform3D 的なものに回す予定 | |
605 */ | |
606 SceneGraphPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
607 SceneGraphRoot::createSceneGraph() |
539 | 608 { |
1143 | 609 SceneGraphPtr p = new SceneGraph(sgroot->tmanager); |
539 | 610 |
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
|
611 /* 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
|
612 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
|
613 |
539 | 614 addNext(p); |
615 p->flag_drawable = 0; | |
616 | |
617 return p; | |
618 } | |
619 | |
620 | |
621 void | |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
622 SceneGraphRoot::lightCalc() |
539 | 623 { |
761 | 624 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
|
625 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
|
626 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
627 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
|
628 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
|
629 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
|
630 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
|
631 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
|
632 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
633 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
634 |
761 | 635 for (int i = 0; i < light_num; i++) { |
747 | 636 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
637 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
|
638 ApplyMatrix(&light_vector_tmp[i*4], light[i]->matrix); |
747 | 639 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
640 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
|
641 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
|
642 light_vector_tmp[i*4+2] /= light_vector_tmp[i*4+3]; |
747 | 643 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
644 /*SIMD演算のため*/ |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
645 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
|
646 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
|
647 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
648 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
|
649 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
|
650 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
|
651 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
|
652 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
|
653 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
654 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
655 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
656 |
764 | 657 |
761 | 658 } |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
659 } |
761 | 660 |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
661 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
662 SceneGraphRoot::flip() |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
663 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
664 // 前フレームで描画した SceneGraph は削除 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
665 allRemove(sg_remove_list); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
666 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
667 // 前フレームに作られた SceneGraph は描画用に移行 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
668 // 現フレームでの操作は以下の tree,list には適用されない |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
669 sg_draw_tree = sg_exec_tree; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
670 sg_remove_list = sg_available_list; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
671 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
672 // 現フレームで新しく SceneGraph がコピーされるので初期化 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
673 sg_exec_tree = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
674 sg_available_list = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
675 } |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
676 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
677 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
678 SceneGraphRoot::allExecute(int screen_w, int screen_h) |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
679 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
680 SceneGraphPtr list = sg_available_list; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
681 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
682 flip(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
683 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
684 camera->move_execute(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
685 camera->update(screen_w, screen_h); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
686 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
687 camera->children = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
688 camera->lastChild = NULL; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
689 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
690 /*まずは全部動作させる*/ |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
691 while (list) { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
692 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
693 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
|
694 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
|
695 |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
696 list->frame++; |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
697 list = list->next; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
698 } |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
699 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
700 lightCalc(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
701 |
539 | 702 if(sg_exec_tree != NULL) { |
758 | 703 return; |
539 | 704 } |
705 | |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
706 /* ここで、scenegraph node の matrix に演算する座標変換は、 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
707 * world->view->perspective まで。 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
708 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
709 * CreatePolygonFromSceneGraph で perspective の座標系で lighting の演算を行い、その後 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
710 * screen 変換をするので。 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
711 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
712 * その際に、camera がもつ screen matrix を Task に渡す必要がある |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
713 * Task に screen matrix を渡す部分は viewer.cc にある |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
714 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
715 * world 変換は node が持つ matrix で行う |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
716 * view->perspective 変換は camera が持つ matrix で行う |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
717 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
718 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
719 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
720 * (w) = world matrix |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
721 * (v) = view matrix |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
722 * (p) = perspective matrix |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
723 * (s) = screen matrix |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
724 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
725 * --- copyTree --- |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
726 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
727 * node->(wvp) = node->(w) * node->parent->(w) * ..... camera->(v) * camera->(p) |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
728 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
729 * --- CreatePolygonFromSceneGraph --- |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
730 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
731 * (polygon_vertex) * node->(wvp) |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
732 * (light_position) * node->(wvp) |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
733 * (normal_vector) * normal_matrix |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
734 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
735 * lighting(polygon_vertex, light_position, normal_vector) |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
736 * |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
737 * (polygon_vertex) * camera->(s) |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
738 */ |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
739 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
740 matrix4x4(camera->matrix, camera->m_view, camera->m_pers); |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
741 copyTree(sg_draw_tree, camera); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
742 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
743 // 現在、allExecute が終わった時点では |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
744 // camera->children が User SceneGraph の root になる |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
745 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
746 /** |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
747 * NULL じゃなかったら、setSceneData が呼ばれてるから |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
748 * そっちを次の Scene にする |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
749 */ |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
750 |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
751 sg_exec_tree = camera->children; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
752 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
753 |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
754 void |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
755 SceneGraphRoot::copyTree(SceneGraphPtr t, SceneGraphPtr cur_parent) |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
756 { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
757 // SceneGraphPtr t = sg_draw_tree; |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1033
diff
changeset
|
758 |
539 | 759 /*removeのflagをもとにtreeを形成*/ |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
760 |
539 | 761 while (t) { |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
762 SceneGraphPtr c = NULL; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
763 if (!t->isRemoved()) { |
1136 | 764 c = t->clone(this->tmanager); |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
765 addNext(c); |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
766 cur_parent->addChild(c); |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
767 c->frame = t->frame; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
768 /*親の回転、座標から、子の回転、座標を算出*/ |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
769 get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1299
diff
changeset
|
770 } |
908 | 771 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
772 |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
773 if (t->children != NULL && c != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
774 cur_parent = c; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
775 t = t->children; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
776 } else if (t->brother != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
777 t = t->brother; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
778 } else { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
779 while (t) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
780 if (t->brother != NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
781 t = t->brother; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
782 break; |
539 | 783 } else { |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
784 if (t->parent == NULL) { |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
785 t = NULL; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
786 break; |
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
787 } else { |
539 | 788 cur_parent = cur_parent->parent; |
789 t = t->parent; | |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
790 } |
539 | 791 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
792 } |
751
1666dba6f6d9
rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
747
diff
changeset
|
793 } |
539 | 794 } |
795 | |
796 } | |
797 | |
1254 | 798 |
799 void | |
1256 | 800 SceneGraphRoot::treeApply(int screen_w, int screen_h) |
1254 | 801 { |
802 // don't calcurate sg_draw_tree's brother | |
803 transTree(sg_draw_tree->children, camera); | |
804 } | |
805 | |
806 | |
1226
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
807 /** |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
808 * 破壊的に変換行列の親子関係を計算する |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
809 */ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
810 void |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
811 SceneGraphRoot::transTree(SceneGraphPtr t, SceneGraphPtr cur_parent) |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
812 { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
813 // SceneGraphPtr t = sg_draw_tree; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
814 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
815 /*removeのflagをもとにtreeを形成*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
816 while (t) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
817 SceneGraphPtr c = NULL; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
818 if (!t->isRemoved()) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
819 /*親の回転、座標から、子の回転、座標を算出*/ |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
820 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
|
821 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
822 if (t->children != NULL && c != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
823 cur_parent = t; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
824 t = t->children; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
825 } else if (t->brother != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
826 t = t->brother; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
827 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
828 while (t) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
829 if (t->brother != NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
830 t = t->brother; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
831 break; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
832 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
833 if (t->parent == NULL) { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
834 t = NULL; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
835 break; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
836 } else { |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
837 cur_parent = cur_parent->parent; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
838 t = t->parent; |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
839 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
840 } |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
841 } |
1226
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
842 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
843 } |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
844 |
636dfdc30176
new API for SceneGraph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
845 } |
758 | 846 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
847 /* |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
848 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
|
849 */ |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
850 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
851 SceneGraphRoot::move_finish() |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
852 { |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
853 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
|
854 |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
855 list->frame++; |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
856 //list = list->next; |
761 | 857 |
858 int light_num = 4; | |
859 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
|
860 |
1094
f10ec9bbd3f6
separate scale matrix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
861 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
|
862 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
|
863 |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
864 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
|
865 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
|
866 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
|
867 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
868 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
869 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
|
870 light_vector[i*4+3] *= -1; |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
871 } |
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
872 |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
873 //sgchange->viewer->light_xyz_stock = getLightVector(); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
874 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
875 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
876 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
877 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
878 SceneGraphRoot::appTaskRegist(regist_func new_register) |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
879 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
880 this->regist = new_register; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
881 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
882 |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
883 void |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
884 SceneGraphRoot::regist_execute() |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
885 { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
886 (*regist)(this); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
887 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
888 |
758 | 889 void |
539 | 890 SceneGraphRoot::allRemove(SceneGraphPtr list) |
891 { | |
892 SceneGraphPtr p = list; | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
893 |
539 | 894 while (p) { |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
895 SceneGraphPtr p1 = p->next; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
896 delete p; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
897 p = p1; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
898 cnt--; |
539 | 899 } |
900 } | |
901 | |
902 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
903 SceneGraphRoot::checkRemove() |
539 | 904 { |
905 SceneGraphPtr p = sg_available_list; | |
906 SceneGraphPtr p1; | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
907 |
539 | 908 while (p) { |
759
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
909 p1 = p->next; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
910 if (p->isRemoved()) { |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
911 sg_exec_tree = p->realRemoveFromTree(sg_exec_tree); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
912 sg_available_list = p->realRemoveFromList(sg_available_list); |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
913 } |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
914 delete p; |
45f7ab7101ea
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
758
diff
changeset
|
915 p = p1; |
539 | 916 } |
917 } | |
918 | |
919 SceneGraphPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
920 SceneGraphRoot::getExecuteSceneGraph() |
539 | 921 { |
922 return sg_exec_tree; | |
923 } | |
924 | |
1046 | 925 |
926 void | |
927 printSceneGraph(SceneGraphPtr t) | |
928 { | |
929 while (t) { | |
930 if (!t->isRemoved()) { | |
931 if (t->name) printf("name: %s ",t->name); | |
932 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
|
933 } |
1046 | 934 if (t->children != NULL) { |
935 t = t->children; | |
936 } else if (t->brother != NULL) { | |
937 t = t->brother; | |
938 } else { | |
939 while (t) { | |
940 if (t->brother != NULL) { | |
941 t = t->brother; | |
942 break; | |
943 } else { | |
944 if (t->parent == NULL) { | |
945 t = NULL; | |
946 break; | |
947 } else { | |
948 t = t->parent; | |
949 } | |
950 } | |
1253
bb9c885c1cb5
COLLADA add read node
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents:
1251
diff
changeset
|
951 } |
1046 | 952 } |
953 } | |
954 } | |
955 | |
539 | 956 SceneGraphPtr |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
957 SceneGraphRoot::getDrawSceneGraph() |
539 | 958 { |
959 return sg_draw_tree; | |
960 } | |
961 | |
962 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
963 SceneGraphRoot::updateControllerState() |
539 | 964 { |
965 controller->check(); | |
966 } | |
967 | |
968 void | |
969 SceneGraphRoot::setSceneData(SceneGraphPtr sg) | |
970 { | |
971 sg_exec_tree = sg; | |
972 } | |
973 | |
974 Pad* | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
975 SceneGraphRoot::getController() |
539 | 976 { |
977 return controller; | |
978 } | |
979 | |
980 SceneGraphIteratorPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
981 SceneGraphRoot::getIterator() |
539 | 982 { |
983 iterator->set(sg_remove_list); | |
984 return iterator; | |
985 } | |
986 | |
987 SceneGraphIteratorPtr | |
988 SceneGraphRoot::getIterator(SceneGraphPtr list) | |
989 { | |
990 iterator->set(list); | |
991 return iterator; | |
992 } | |
993 | |
994 CameraPtr | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
995 SceneGraphRoot::getCamera() |
539 | 996 { |
997 return camera; | |
998 } | |
597 | 999 |
747 | 1000 |
1001 SceneGraphPtr | |
761 | 1002 SceneGraphRoot::getLight(int id) |
597 | 1003 { |
1004 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1005 return light[id]; |
597 | 1006 |
1007 } | |
747 | 1008 |
1009 | |
1010 float* | |
1011 SceneGraphRoot::getLightVector() | |
1012 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1013 return light_vector; |
747 | 1014 } |
779 | 1015 |
792 | 1016 int* |
1017 SceneGraphRoot::getLightSwitch() | |
1018 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1019 return light_switch; |
792 | 1020 } |
1021 | |
1022 int | |
1023 SceneGraphRoot::getLightSysSwitch() | |
1024 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1025 return light_sysswitch; |
792 | 1026 } |
1027 | |
793 | 1028 void |
1029 SceneGraphRoot::OnLightSwitch(int id) | |
1030 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1031 light_switch[id] = 1; |
793 | 1032 } |
1033 | |
1034 void | |
1035 SceneGraphRoot::OffLightSwitch(int id) | |
1036 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1037 light_switch[id] = 0; |
793 | 1038 } |
1039 | |
1040 void | |
1041 SceneGraphRoot::OnLightSysSwitch() | |
1042 { | |
1043 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1044 light_sysswitch = 1; |
793 | 1045 |
1046 } | |
1047 | |
1048 void | |
1049 SceneGraphRoot::OffLightSysSwitch() | |
1050 { | |
1051 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1052 light_sysswitch = 0; |
793 | 1053 |
1054 } | |
1055 | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1056 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1057 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
|
1058 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1059 gtask_array = new GTaskArray; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1060 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
|
1061 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1062 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1063 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1064 SceneGraphRoot::create_task_array() |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1065 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1066 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
|
1067 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1068 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1069 void |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1070 SceneGraphRoot::task_array_finish() |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1071 { |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1072 gtask_array->finish(); |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1073 } |
869 | 1074 |
1075 void | |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1076 SceneGraphRoot::set_gtask_array(int id, void *property, int size, PostFunction post_func) |
1002 | 1077 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1078 gtask_array->next_task_array(id); |
1002 | 1079 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1080 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
|
1081 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
|
1082 |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1083 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1084 |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1085 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1086 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
|
1087 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1088 gtask_array->next_task_array(id); |
1002 | 1089 |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1090 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
|
1091 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
|
1092 gtask_array->game_task->set_outData(0, property, size); |
1002 | 1093 |
869 | 1094 } |
1095 | |
884 | 1096 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1097 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
|
1098 { |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1099 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
|
1100 task->set_cpu(SPE_ANY); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1101 task->add_inData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1102 task->add_outData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1103 task->spawn(); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1104 } |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1105 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1106 void |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1107 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
|
1108 { |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1109 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
|
1110 task->set_cpu(SPE_ANY); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1111 task->add_inData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1112 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
|
1113 task->add_outData(property, size); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1114 task->spawn(); |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1115 } |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1116 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1117 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1118 void |
882 | 1119 main_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
1120 { | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1121 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
|
1122 void *e = node->propertyptr; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1123 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
|
1124 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
1006 | 1125 /* |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1126 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1127 node->xyz[0] = property->x; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1128 node->xyz[1] = property->y; |
1006 | 1129 */ |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1130 sgroottmp->set_game_task(move, (void*)e, size); |
882 | 1131 } |
1132 | |
1133 void | |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1134 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
|
1135 { |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1136 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
|
1137 void *e = node->propertyptr; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1138 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
|
1139 SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
1140 void *pad = (void*)sgroottmp->getController(); |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1141 |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1142 /* |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1143 ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1144 property->root = node; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1145 node->xyz[0] = property->x; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1146 node->xyz[1] = property->y; |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1147 */ |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1148 |
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1149 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
|
1150 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1151 |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1152 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1153 SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size) |
882 | 1154 { |
1155 node->move = main_task_move; | |
1156 node->move_id = move; | |
1157 node->propertyptr = property; | |
1158 node->property_size = size; | |
1159 } | |
869 | 1160 |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1161 void |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1006
diff
changeset
|
1162 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
|
1163 { |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1164 node->move = pad_task_move; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1165 node->move_id = move; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1166 node->propertyptr = property; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1167 node->property_size = size; |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1168 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
913
diff
changeset
|
1169 |
779 | 1170 /* end */ |