Mercurial > hg > Game > Cerium
annotate Renderer/Engine/Collada.cc @ 1396:ad841dcdbe67 draft
collada moved. But only cube.
author | e095732 <e095732@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 31 Jan 2012 17:10:53 +0900 |
parents | 555d2a31cf0c |
children | e19296785c07 |
rev | line source |
---|---|
1376 | 1 #include "polygon.h" |
2 #include "SceneGraph.h" | |
3 #include "SceneGraph.cc" | |
4 #include "TextureHash.h" | |
5 #include "xml.h" | |
6 #include "SceneGraphRoot.h" | |
7 #include <iostream> | |
8 #include <SDL_image.h> | |
9 | |
10 using namespace std; | |
11 static TextureHash sgid_hash; | |
12 | |
13 extern int is_bmp(const char* name); | |
14 extern void make_black_alpha(SDL_Surface *texture_image); | |
15 | |
16 typedef struct source { | |
17 char *id; | |
18 union { | |
19 float *array; | |
20 char *alias; | |
21 }u; | |
22 int count; | |
23 struct source *next; | |
24 } SOURCE; | |
25 typedef SOURCE *SOURCE_P; | |
26 | |
27 typedef struct list { | |
28 SOURCE_P first; | |
29 SOURCE_P end; | |
30 } LIST; | |
31 typedef LIST *LIST_P; | |
32 | |
33 struct collada_state { | |
34 collada_state(){ | |
35 polylist = 0; | |
36 | |
37 vertex_offset = -1; | |
38 vertex_count = 0; | |
39 | |
40 normal_offset = -1; | |
41 normal_count = 0; | |
42 | |
43 texcoord_offset = -1; | |
44 texcoord_count = 0; | |
45 | |
46 polylist_count = 0; | |
47 vcsum = 0; | |
48 | |
49 limit = 0; | |
50 vmember = 0; | |
1390 | 51 vtable_size =0; |
1376 | 52 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
53 images_flag=0; |
1376 | 54 } |
55 int polylist; | |
56 int library_images; | |
57 xmlChar *vertices_id; | |
58 | |
59 char *vertex_src; | |
60 int vertex_offset; | |
61 int vertex_count; | |
62 | |
63 char *normal_src; | |
64 int normal_offset; | |
65 int normal_count; | |
66 | |
67 char *texcoord_src; | |
68 int texcoord_offset; | |
69 int texcoord_count; | |
70 | |
71 float *vcount; | |
72 float *pcount; | |
73 | |
74 SOURCE_P normal_float; | |
75 SOURCE_P vertex_float; | |
76 SOURCE_P texcoord_float; | |
77 | |
78 char *vertices_src; | |
79 int polylist_count; | |
80 | |
81 char *name; | |
82 char *tex_picname; | |
83 | |
84 int images_flag; | |
85 | |
86 int vcsum; | |
87 int limit; | |
88 int vmember; | |
1390 | 89 int vtable_size; |
1376 | 90 }; |
91 | |
92 /*static const char* | |
93 get_property(const char *name, xmlNodePtr cur){ | |
94 xmlAttr *p=cur->properties; | |
95 if (p==0) return ""; | |
96 for ( ;p; p=p->next) { | |
97 if ( xmlStrcmp(p->name, (xmlChar*)name) !=0 ) { | |
98 xmlNode* n=p->children; | |
99 if ( n==NULL ) return ""; | |
100 const char * v=(const char*)n->content; | |
101 if ( v==NULL ) return ""; | |
102 return v; | |
103 } | |
104 } | |
105 return ""; | |
106 }*/ | |
107 | |
108 SDL_Surface* | |
109 load_image(const char *file_name, const char *image_name) | |
110 { | |
111 int alpha_black = is_bmp(file_name); | |
112 /** | |
113 * image を 32bit(RGBA) に変換する | |
114 */ | |
115 SDL_Surface *texture_image = IMG_Load(file_name); | |
116 if (!texture_image) return 0; | |
117 SDL_Surface *tmpImage | |
118 = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w, | |
119 texture_image->h, 32, redMask, | |
120 greenMask, blueMask, alphaMask); | |
121 //= SDL_CreateRGBSurface(SDL_HWSURFACE, 0, | |
122 // 0, 32, redMask, | |
123 // greenMask, blueMask, alphaMask); | |
124 SDL_Surface *converted; | |
125 converted = SDL_ConvertSurface(texture_image, tmpImage->format, | |
126 SDL_HWSURFACE); | |
127 //SDL_SetAlpha(converted, 0, 0); | |
128 | |
129 if (converted != NULL) { | |
130 SDL_FreeSurface(texture_image); | |
131 texture_image = converted; | |
132 } | |
133 if (alpha_black) { | |
134 make_black_alpha(texture_image); | |
135 } | |
136 // this->gl_tex = SDL_GL_LoadTexture(texture_image); | |
137 return texture_image; | |
138 } | |
139 | |
140 /* add source list */ | |
141 static void | |
142 addSource(LIST_P list, SOURCE_P src) { | |
143 if (list->first == NULL && list->end == NULL) { | |
144 list->first = list->end = src; | |
145 return; | |
146 } | |
147 list->end->next = src; | |
148 list->end = src; | |
149 } | |
150 | |
151 /* compare a with b. Using to compare id */ | |
152 /* | |
153 static int | |
154 strcmp_a(const char *a, const char *b) | |
155 { | |
156 while (*a && *a++ == *b++); | |
157 if (*a) return 0; | |
158 return a[-1] > b[-1] ? 1:-1; | |
159 } | |
160 static float | |
161 get_point(char *id, int position, LIST_P list) | |
162 { | |
163 SOURCE_P cur = list->first; | |
164 for (;cur ; cur=cur->next) { | |
165 if (!strcmp_a(id, cur->id)) { | |
166 if (cur->count == 0) //alias | |
167 return get_point(cur->u.alias, position, list); | |
168 float *a = cur->u.array; | |
169 if (position <= cur->count) { | |
170 return a[position]; | |
171 } | |
172 } | |
173 } | |
174 } | |
175 */ | |
176 | |
177 static SOURCE_P | |
178 most_match(const char *id , LIST_P list) | |
179 { | |
180 SOURCE_P src = NULL; | |
181 SOURCE_P cur = NULL; | |
182 int tmplength = 0; | |
183 int strlength; | |
184 | |
185 for (cur=list->first ;cur!=list->end ;cur=cur->next) { | |
186 for (strlength=0;id[strlength]==cur->id[strlength];strlength++); | |
187 if (tmplength < strlength) { | |
188 tmplength = strlength; | |
189 src = cur; | |
190 } | |
191 } | |
1378 | 192 if (src == NULL){ |
193 fprintf(stderr,"not match"); | |
194 } | |
1376 | 195 return src; |
196 } | |
197 | |
198 void get_texture_image(char *filename, SceneGraphPtr sg, xmlNodePtr cur, TaskManager *manager) | |
199 { | |
200 char image_name[20] = "/tmp/image_XXXXXX"; | |
201 if (filename == NULL || filename[0] == 0) { | |
202 return; | |
203 } | |
204 /** | |
205 * image_name を既に Load していれば何もしない | |
206 */ | |
1391 | 207 int tex_id; |
1376 | 208 /* ball test */ |
1382 | 209 if (sgid_hash.sg_hash_regist(filename, tex_id) == -1) { |
210 SDL_Surface *texture_image = load_image(filename, image_name); | |
211 if (texture_image==0) { | |
1376 | 212 printf("Can't load image %s\n",filename); |
213 exit(0); | |
1382 | 214 } |
1376 | 215 sg->texture_info->texture_id = sg->makeTapestries(manager, texture_image, tex_id); |
1382 | 216 tex_id = sg->texture_info->texture_id; |
1376 | 217 if (unlink(image_name)) { |
1382 | 218 printf("unlink error\n"); |
1376 | 219 } |
220 } else { | |
221 /** | |
222 * 以前に Load されている Texture を共用 | |
223 */ | |
224 sg->texture_info->texture_id = tex_id; | |
225 } | |
1382 | 226 // 微妙に思う、自分で書き換えた感想 by gongo |
227 sg->texture_info->t_w = list[tex_id].t_w; | |
228 sg->texture_info->t_h = list[tex_id].t_h;; | |
229 sg->texture_info->pixels_orig = list[tex_id].pixels_orig; | |
230 sg->texture_info->pixels = list[tex_id].pixels; | |
231 sg->texture_info->scale_max = list[tex_id].scale_max; | |
232 sg->texture_info->texture_image = list[tex_id].texture_image; | |
1376 | 233 } |
234 | |
235 void decode_float_array(xmlNodePtr cur,LIST_P list){ | |
236 SOURCE_P src = (SOURCE_P)malloc(sizeof(SOURCE)); | |
237 src->id = (char*)xmlGetProp(cur, (xmlChar*)"id"); | |
238 | |
239 src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); | |
240 src->u.array = new float[src->count]; | |
241 char *cont =(char*)xmlNodeGetContent(cur); | |
1384 | 242 |
1376 | 243 /* store float inpoint list */ |
244 for (int i = 0; cont != NULL; i++) { | |
245 cont = pickup_float(cont, src->u.array+i); | |
246 } | |
247 | |
248 src->next = NULL; | |
249 addSource(list, src); | |
1382 | 250 //printf("id:%s count:%d cont:%s\n", id, count, cont); |
1376 | 251 } |
252 | |
253 | |
254 void | |
255 get_points(xmlNodePtr cur, collada_state *s, TaskManager *manager){ | |
256 char *pcont = (char*)xmlNodeGetContent(cur); | |
257 for (int i = 0;i < s->polylist_count;i++){ | |
258 s->vcsum += s->vcount[i]; | |
259 s->vmember = i; | |
1390 | 260 if (s->vcount[i]==4){ |
261 s->vtable_size +=6; | |
262 } else { | |
263 s->vtable_size +=3; | |
264 } | |
1376 | 265 } |
266 s->limit = s->vcsum * 2; | |
267 if (s->texcoord_offset == 2){ | |
268 s->limit = s->vcsum * 3; | |
269 } | |
270 s->pcount = new float[s->limit]; | |
271 for (int i=0;i<s->limit;i++){ | |
272 s->pcount[i] = 0; | |
273 } | |
274 for (int i=0; pcont != NULL; i++) { | |
275 pcont = pickup_float(pcont, s->pcount+i); | |
276 } | |
277 } | |
278 SceneGraph* | |
279 decode_points(collada_state *s, TaskManager *manager, SceneGraphPtr sg){ | |
1390 | 280 |
1376 | 281 /* |
282 * vertex_tableだけはpolygonを作る際にvcountが4の場合重複する点が | |
283 * 出てくるのでサイズを2倍用意しておく | |
284 */ | |
285 float *vertex_table; | |
286 float *normal_table; | |
287 float *texcoord_table; | |
1390 | 288 vertex_table = new float[s->vtable_size*3]; |
289 normal_table = new float[s->vtable_size*3]; | |
290 texcoord_table = new float[s->vtable_size*2]; | |
291 bzero(vertex_table,sizeof(float)*s->vtable_size*3); | |
292 bzero(normal_table,sizeof(float)*s->vtable_size*3); | |
293 bzero(texcoord_table,sizeof(float)*s->vtable_size*2); | |
1376 | 294 |
1392 | 295 /* p separate vertex position and nomal position. */ |
1376 | 296 /* make triangle */ |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
297 int k=0,j=0,l=0,count=0; |
1392 | 298 if (s->texcoord_offset == 2){ |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
299 for (int i=0;i<s->polylist_count;i++) { |
1392 | 300 if (s->vcount[i] == 4) { |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
301 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[l]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
302 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[l]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
303 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[l]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
304 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[l+3]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
305 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[l+3]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
306 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[l+3]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
307 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[l+6]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
308 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
309 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
310 vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[l+6]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
311 vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
312 vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
313 vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[l+9]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
314 vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[l+9]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
315 vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[l+9]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
316 vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[l]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
317 vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[l]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
318 vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[l]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
319 |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
320 normal_table[k] = s->normal_float->u.array[(int)s->pcount[l+1]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
321 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
322 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[l+1]*3*2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
323 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[l+4]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
324 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[l+4]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
325 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[l+4]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
326 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[l+7]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
327 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[l+7]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
328 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[l+7]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
329 normal_table[k+9] = s->normal_float->u.array[(int)s->pcount[l+7]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
330 normal_table[k+10] = s->normal_float->u.array[(int)s->pcount[l+7]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
331 normal_table[k+11] = s->normal_float->u.array[(int)s->pcount[l+7]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
332 normal_table[k+12] = s->normal_float->u.array[(int)s->pcount[l+10]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
333 normal_table[k+13] = s->normal_float->u.array[(int)s->pcount[l+10]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
334 normal_table[k+14] = s->normal_float->u.array[(int)s->pcount[l+10]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
335 normal_table[k+15] = s->normal_float->u.array[(int)s->pcount[l+1]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
336 normal_table[k+16] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
337 normal_table[k+17] = s->normal_float->u.array[(int)s->pcount[l+1]*3+2]; |
1392 | 338 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
339 texcoord_table[j] = s->texcoord_float->u.array[(int)s->pcount[l+2]*2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
340 texcoord_table[j+1] = s->texcoord_float->u.array[(int)s->pcount[l+2]*2+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
341 texcoord_table[j+2] = s->texcoord_float->u.array[(int)s->pcount[l+5]*2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
342 texcoord_table[j+3] = s->texcoord_float->u.array[(int)s->pcount[l+5]*2+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
343 texcoord_table[j+4] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
344 texcoord_table[j+5] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
345 texcoord_table[j+6] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
346 texcoord_table[j+7] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
347 l+=12; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
348 j+=8; |
1392 | 349 k+=18; |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
350 count +=2; |
1392 | 351 } else if (s->vcount[i]==3) { |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
352 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[l]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
353 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[l]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
354 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[l]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
355 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[l+3]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
356 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[l+3]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
357 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[l+3]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
358 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[l+6]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
359 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
360 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+2]; |
1392 | 361 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
362 normal_table[k] = s->normal_float->u.array[(int)s->pcount[l+1]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
363 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
364 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[l+1]*3*2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
365 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[l+4]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
366 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[l+4]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
367 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[l+4]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
368 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[l+7]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
369 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[l+7]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
370 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[l+7]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
371 |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
372 texcoord_table[j] = s->texcoord_float->u.array[(int)s->pcount[l+2]*2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
373 texcoord_table[j+1] = s->texcoord_float->u.array[(int)s->pcount[l+2]*2+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
374 texcoord_table[j+2] = s->texcoord_float->u.array[(int)s->pcount[l+5]*2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
375 texcoord_table[j+3] = s->texcoord_float->u.array[(int)s->pcount[l+5]*2+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
376 texcoord_table[j+4] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
377 texcoord_table[j+5] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
378 l+=9; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
379 j+=6; |
1392 | 380 k+=9; |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
381 count++; |
1392 | 382 } |
383 } | |
384 }else{ | |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
385 for (int i=0;i<s->polylist_count;i++) { |
1392 | 386 if (s->vcount[i] == 4) { |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
387 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[l]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
388 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[l]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
389 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[l]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
390 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[l+2]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
391 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[l+2]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
392 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[l+2]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
393 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[l+4]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
394 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
395 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
396 vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[l+4]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
397 vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
398 vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
399 vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[l+6]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
400 vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
401 vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
402 vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[l]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
403 vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[l]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
404 vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[l]*3+2]; |
1392 | 405 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
406 normal_table[k] = s->normal_float->u.array[(int)s->pcount[l+1]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
407 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
408 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[l+1]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
409 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[l+3]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
410 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[l+3]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
411 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[l+3]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
412 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[l+5]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
413 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[l+5]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
414 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[l+5]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
415 normal_table[k+9] = s->normal_float->u.array[(int)s->pcount[l+5]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
416 normal_table[k+10] = s->normal_float->u.array[(int)s->pcount[l+5]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
417 normal_table[k+11] = s->normal_float->u.array[(int)s->pcount[l+5]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
418 normal_table[k+12] = s->normal_float->u.array[(int)s->pcount[l+7]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
419 normal_table[k+13] = s->normal_float->u.array[(int)s->pcount[l+7]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
420 normal_table[k+14] = s->normal_float->u.array[(int)s->pcount[l+7]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
421 normal_table[k+15] = s->normal_float->u.array[(int)s->pcount[l+1]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
422 normal_table[k+16] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
423 normal_table[k+17] = s->normal_float->u.array[(int)s->pcount[l+1]*3+2]; |
1392 | 424 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
425 printf ("%f, %f, %f\n",vertex_table[k],vertex_table[k+1],vertex_table[k+2]); |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
426 printf ("%f, %f, %f\n",vertex_table[k+3],vertex_table[k+4],vertex_table[k+5]); |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
427 printf ("%f, %f, %f\n",vertex_table[k+6],vertex_table[k+7],vertex_table[k+8]); |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
428 printf ("%f, %f, %f\n",vertex_table[k+9],vertex_table[k+10],vertex_table[k+11]); |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
429 printf ("%f, %f, %f\n",vertex_table[k+12],vertex_table[k+13],vertex_table[k+14]); |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
430 printf ("%f, %f, %f\n",vertex_table[k+15],vertex_table[k+16],vertex_table[k+17]); |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
431 l+=8; |
1392 | 432 k+=18; |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
433 count +=2; |
1392 | 434 } else if (s->vcount[i]==3) { |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
435 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[l]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
436 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[l]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
437 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[l]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
438 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[l+2]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
439 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[l+2]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
440 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[l+2]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
441 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[l+4]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
442 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
443 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+2]; |
1392 | 444 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
445 normal_table[k] = s->normal_float->u.array[(int)s->pcount[l+1]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
446 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
447 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[l+1]*3+22]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
448 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[l+3]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
449 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[l+3]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
450 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[l+3]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
451 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[l+5]*3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
452 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[l+5]*3+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
453 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[l+5]*3+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
454 |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
455 printf ("%f, %f, %f\n",vertex_table[k],vertex_table[k+1],vertex_table[k+2]); |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
456 printf ("%f, %f, %f\n",vertex_table[k+3],vertex_table[k+4],vertex_table[k+5]); |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
457 printf ("%f, %f, %f\n",vertex_table[k+6],vertex_table[k+7],vertex_table[k+8]); |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
458 l+=6; |
1392 | 459 k+=9; |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
460 count++; |
1392 | 461 } |
462 } | |
1376 | 463 } |
464 | |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
465 |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
466 |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
467 |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
468 |
1376 | 469 /** |
470 * (SceneGraph.cc) | |
471 * pickup_normal,pickup_coordinate,pickup_textureの処理 | |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
472 * sg->sizeは頂点の数,countは面の数 |
1376 | 473 */ |
1384 | 474 |
1376 | 475 //polygonの作成 |
476 sg->pp_num = (count + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE; | |
477 sg->pp = new PolygonPack[sg->pp_num]; | |
1379
13065ad17328
collada moved but only my mac.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1378
diff
changeset
|
478 sg->name = s->name; |
13065ad17328
collada moved but only my mac.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1378
diff
changeset
|
479 sg->parent_name = "NULL"; |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
480 sg->size = count*3; |
1376 | 481 for (int i = 0;i < sg->pp_num; i++ ){ |
482 PolygonPackPtr pp = sg->pp; | |
483 TrianglePackPtr tri = pp[i].tri; | |
484 // TrianglePack の size のチェック | |
485 int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ; | |
486 pp[i].info.size = tri_size; | |
487 /* default texture peste */ | |
488 if (s->images_flag==0) { | |
1384 | 489 char *default_image = "../Test/xml_file/blend/images/ball.jpg"; |
490 get_texture_image(default_image, sg, (xmlNodePtr)NULL, manager); | |
1376 | 491 } |
492 int k = 0; | |
493 int m = 0; | |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
494 for (int j = 0; j < tri_size; j++,k+=9,m+=6) { |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
495 tri[j].ver1.x = vertex_table[k]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
496 tri[j].ver1.y = vertex_table[k+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
497 tri[j].ver1.z = vertex_table[k+2]; |
1376 | 498 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
499 tri[j].ver2.x = vertex_table[k+3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
500 tri[j].ver2.y = vertex_table[k+4]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
501 tri[j].ver2.z = vertex_table[k+5]; |
1376 | 502 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
503 tri[j].ver3.x = vertex_table[k+6]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
504 tri[j].ver3.y = vertex_table[k+7]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
505 tri[j].ver3.z = vertex_table[k+8]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
506 |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
507 tri[j].normal1.x = normal_table[k]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
508 tri[j].normal1.y = normal_table[k+1]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
509 tri[j].normal1.z = normal_table[k+2]; |
1376 | 510 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
511 tri[j].normal2.x = normal_table[k+3]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
512 tri[j].normal2.y = normal_table[k+4]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
513 tri[j].normal2.z = normal_table[k+5]; |
1376 | 514 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
515 tri[j].normal3.x = normal_table[k+6]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
516 tri[j].normal3.y = normal_table[k+7]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
517 tri[j].normal3.z = normal_table[k+8]; |
1376 | 518 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
519 tri[j].ver1.tex_x = texcoord_table[m]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
520 tri[j].ver1.tex_y = texcoord_table[m+1]; |
1376 | 521 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
522 tri[j].ver2.tex_x = texcoord_table[m+2]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
523 tri[j].ver2.tex_y = texcoord_table[m+3]; |
1376 | 524 |
1396
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
525 tri[j].ver3.tex_x = texcoord_table[m+4]; |
ad841dcdbe67
collada moved. But only cube.
e095732 <e095732@ie.u-ryukyu.ac.jp>
parents:
1392
diff
changeset
|
526 tri[j].ver3.tex_y = texcoord_table[m+5]; |
1376 | 527 |
528 } | |
529 | |
530 } | |
531 sg->c_xyz[0] = sg->c_xyz[1] = sg->c_xyz[2] = 0; | |
1384 | 532 |
1376 | 533 delete []vertex_table; |
534 delete []normal_table; | |
535 delete []texcoord_table; | |
536 | |
537 /* got out of polylist */ | |
538 s->polylist = 0; | |
539 return sg; | |
540 } | |
541 | |
542 static void | |
543 xml_walk(xmlNodePtr cur, struct collada_state *s, LIST_P list,SceneGraphPtr sg, SceneGraphRoot *root) | |
544 { | |
545 int in_polylist=0; | |
546 if (!xmlStrcmp(cur->name, (xmlChar*)"polylist")) { | |
547 s->polylist_count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); | |
548 s->polylist=1; | |
549 in_polylist=1; | |
550 } else if (!xmlStrcmp(cur->name, (xmlChar*)"vertices")) { | |
551 s->vertices_id = xmlGetProp(cur, (xmlChar*)"id"); | |
552 } else if (!xmlStrcmp(cur->name, (xmlChar*)"library_images")) { | |
1378 | 553 s->library_images=1; |
554 //library_images is wrote at texture image name. only use one image file | |
1376 | 555 } else if (s->library_images && !xmlStrcmp(cur->name, (xmlChar*)"init_from")) { |
556 s->tex_picname = (char*)xmlGetProp(cur, (xmlChar*)"init_from"); | |
557 get_texture_image(s->tex_picname, sg, cur , root->tmanager); | |
558 s->library_images=0; | |
559 s->images_flag=1; | |
560 } else if (!s->polylist && !xmlStrcmp(cur->name, (xmlChar*)"input")) { | |
561 char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic"); | |
562 if (!xmlStrcmp((xmlChar*)semantic, (xmlChar*)"POSITION")) { | |
563 s->vertices_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); | |
564 } | |
565 } else if (s->polylist && !xmlStrcmp(cur->name, (xmlChar*)"input")) { | |
566 char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic"); | |
567 if (!xmlStrcmp((xmlChar*)semantic, (xmlChar*)"VERTEX")) { | |
568 s->vertex_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); | |
569 s->vertex_float = most_match(s->vertices_src+1, list); | |
570 } else if (!xmlStrcmp((xmlChar*)semantic, (xmlChar*)"NORMAL")) { | |
571 s->normal_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); | |
572 s->normal_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); | |
573 s->normal_float = most_match(s->normal_src+1, list); | |
574 } else if (!xmlStrcmp((xmlChar*)semantic, (xmlChar*)"TEXCOORD")) { | |
575 s->texcoord_src = (char*)xmlGetProp(cur, (xmlChar*)"source"); | |
576 s->texcoord_offset = atoi((char*)xmlGetProp(cur, (xmlChar*)"offset")); | |
577 s->texcoord_float = most_match(s->texcoord_src+1, list); | |
578 } | |
579 } else if (!xmlStrcmp(cur->name, (xmlChar*)"vcount")) { | |
580 char *vcont = (char*)xmlNodeGetContent(cur); | |
581 s->vcount = new float[s->polylist_count]; | |
582 for (int i=0; vcont!=NULL; i++) { | |
583 /* store vcount list */ | |
584 vcont = pickup_float(vcont, s->vcount+i); | |
585 } | |
586 } else if (!xmlStrcmp(cur->name, (xmlChar*)"p")) { | |
587 get_points(cur,s,root->tmanager); | |
588 in_polylist = 0; | |
589 } else if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { | |
590 decode_float_array(cur,list); | |
591 } else if (!xmlStrcmp(cur->name, (xmlChar*)"node" )) { | |
592 s->name = (char*)xmlGetProp(cur, (xmlChar*)"id"); | |
593 } | |
594 for (cur=cur->children; cur; cur=cur->next){ | |
595 xml_walk(cur,s,list,sg,root); | |
596 } | |
597 } | |
598 void | |
599 init_list(LIST_P list) { | |
600 list->first = NULL; | |
601 list->end = NULL; | |
602 } | |
603 | |
604 | |
605 void | |
606 SceneGraphRoot::createFromCOLLADAfile(TaskManager *manager, const char *xmlColladafile) | |
607 { | |
608 /*make parse dom*/ | |
609 xmlDocPtr doc; | |
610 xmlNodePtr cur; | |
611 | |
612 doc = xmlParseFile(xmlColladafile); | |
613 cur = xmlDocGetRootElement(doc); | |
614 | |
615 if (xmlStrcmp(cur->name, (xmlChar*)"COLLADA")){ | |
616 return ; | |
617 } | |
618 | |
619 /* node analyze */ | |
620 struct collada_state s; | |
621 SceneGraphPtr sg = new SceneGraph(manager); | |
622 for (cur=cur->children; cur; cur=cur->next){ | |
623 LIST list; | |
624 init_list(&list); | |
625 xml_walk(cur,&s,&list,sg,this); | |
626 } | |
627 registSceneGraph(decode_points(&s,manager,sg)); | |
628 xmlFreeDoc(doc); | |
629 } |