comparison 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
comparison
equal deleted inserted replaced
1395:971d737a329a 1396:ad841dcdbe67
48 48
49 limit = 0; 49 limit = 0;
50 vmember = 0; 50 vmember = 0;
51 vtable_size =0; 51 vtable_size =0;
52 52
53 images_flag=0; 53 images_flag=0;
54 } 54 }
55 int polylist; 55 int polylist;
56 int library_images; 56 int library_images;
57 xmlChar *vertices_id; 57 xmlChar *vertices_id;
58 58
290 texcoord_table = new float[s->vtable_size*2]; 290 texcoord_table = new float[s->vtable_size*2];
291 bzero(vertex_table,sizeof(float)*s->vtable_size*3); 291 bzero(vertex_table,sizeof(float)*s->vtable_size*3);
292 bzero(normal_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); 293 bzero(texcoord_table,sizeof(float)*s->vtable_size*2);
294 294
295 /**
296 * s->vcsum と s->vertex_float->countの値が違うので大きい方をとりあえず使っておく
297 */
298
299 /*
300 if (s->texcoord_offset == 2){
301 for (int i=0,j=0; i < s->limit; i+=3,j++) {
302 normal_table[j] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
303 normal_table[j+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1];
304 normal_table[j+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3+2];
305 texcoord_table[j] = s->texcoord_float->u.array[(int)s->pcount[i+2]*2];
306 texcoord_table[j+1] = s->texcoord_float->u.array[(int)s->pcount[i+2]*2+1];
307 }
308 } else{
309 for (int i=0,j=0; i < s->limit; i+=2,j++) {
310 normal_table[j] = s->normal_float->u.array[(int)s->pcount[i+1]*3];
311 normal_table[j+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1];
312 normal_table[j+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3+2];
313 }
314 }
315 */
316
317 /* p separate vertex position and nomal position. */ 295 /* p separate vertex position and nomal position. */
318 /* make triangle */ 296 /* make triangle */
319 int k=0,size=0; 297 int k=0,j=0,l=0,count=0;
320 if (s->texcoord_offset == 2){ 298 if (s->texcoord_offset == 2){
321 for (int i=0;i<s->vmember;i++) { 299 for (int i=0;i<s->polylist_count;i++) {
322 if (s->vcount[i] == 4) { 300 if (s->vcount[i] == 4) {
323 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3]; 301 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[l]*3];
324 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; 302 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[l]*3+1];
325 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; 303 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[l]*3+2];
326 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+3]*3]; 304 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[l+3]*3];
327 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+1]; 305 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[l+3]*3+1];
328 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+2]; 306 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[l+3]*3+2];
329 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+6]*3]; 307 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[l+6]*3];
330 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1]; 308 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+1];
331 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2]; 309 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+2];
332 vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[i+6]*3]; 310 vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[l+6]*3];
333 vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1]; 311 vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+1];
334 vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2]; 312 vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+2];
335 vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[i+9]*3]; 313 vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[l+9]*3];
336 vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[i+9]*3+1]; 314 vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[l+9]*3+1];
337 vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[i+9]*3+2]; 315 vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[l+9]*3+2];
338 vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[i]*3]; 316 vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[l]*3];
339 vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; 317 vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[l]*3+1];
340 vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; 318 vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[l]*3+2];
341 319
342 normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; 320 normal_table[k] = s->normal_float->u.array[(int)s->pcount[l+1]*3];
343 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1]; 321 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1];
344 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2]; 322 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[l+1]*3*2];
345 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+4]*3]; 323 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[l+4]*3];
346 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+4]*3+1]; 324 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[l+4]*3+1];
347 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+4]*3+2]; 325 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[l+4]*3+2];
348 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 326 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[l+7]*3];
349 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 327 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[l+7]*3+1];
350 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 328 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[l+7]*3+2];
351 normal_table[k+9] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 329 normal_table[k+9] = s->normal_float->u.array[(int)s->pcount[l+7]*3];
352 normal_table[k+10] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 330 normal_table[k+10] = s->normal_float->u.array[(int)s->pcount[l+7]*3+1];
353 normal_table[k+11] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 331 normal_table[k+11] = s->normal_float->u.array[(int)s->pcount[l+7]*3+2];
354 normal_table[k+12] = s->normal_float->u.array[(int)s->pcount[i+10]*3]; 332 normal_table[k+12] = s->normal_float->u.array[(int)s->pcount[l+10]*3];
355 normal_table[k+13] = s->normal_float->u.array[(int)s->pcount[i+10]*3]; 333 normal_table[k+13] = s->normal_float->u.array[(int)s->pcount[l+10]*3+1];
356 normal_table[k+14] = s->normal_float->u.array[(int)s->pcount[i+10]*3]; 334 normal_table[k+14] = s->normal_float->u.array[(int)s->pcount[l+10]*3+2];
357 normal_table[k+15] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; 335 normal_table[k+15] = s->normal_float->u.array[(int)s->pcount[l+1]*3];
358 normal_table[k+16] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; 336 normal_table[k+16] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1];
359 normal_table[k+17] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; 337 normal_table[k+17] = s->normal_float->u.array[(int)s->pcount[l+1]*3+2];
338
339 texcoord_table[j] = s->texcoord_float->u.array[(int)s->pcount[l+2]*2];
340 texcoord_table[j+1] = s->texcoord_float->u.array[(int)s->pcount[l+2]*2+1];
341 texcoord_table[j+2] = s->texcoord_float->u.array[(int)s->pcount[l+5]*2];
342 texcoord_table[j+3] = s->texcoord_float->u.array[(int)s->pcount[l+5]*2+1];
343 texcoord_table[j+4] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2];
344 texcoord_table[j+5] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2+1];
345 texcoord_table[j+6] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2];
346 texcoord_table[j+7] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2+1];
347 l+=12;
348 j+=8;
360 k+=18; 349 k+=18;
361 size +=2; 350 count +=2;
362 } else if (s->vcount[i]==3) { 351 } else if (s->vcount[i]==3) {
363 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3]; 352 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[l]*3];
364 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; 353 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[l]*3+1];
365 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; 354 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[l]*3+2];
366 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+3]*3]; 355 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[l+3]*3];
367 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+1]; 356 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[l+3]*3+1];
368 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+2]; 357 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[l+3]*3+2];
369 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+6]*3]; 358 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[l+6]*3];
370 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1]; 359 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+1];
371 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2]; 360 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+2];
372 361
373 normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; 362 normal_table[k] = s->normal_float->u.array[(int)s->pcount[l+1]*3];
374 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1]; 363 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1];
375 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2]; 364 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[l+1]*3*2];
376 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+4]*3]; 365 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[l+4]*3];
377 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+4]*3+1]; 366 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[l+4]*3+1];
378 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+4]*3+2]; 367 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[l+4]*3+2];
379 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 368 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[l+7]*3];
380 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 369 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[l+7]*3+1];
381 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 370 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[l+7]*3+2];
382 371
372 texcoord_table[j] = s->texcoord_float->u.array[(int)s->pcount[l+2]*2];
373 texcoord_table[j+1] = s->texcoord_float->u.array[(int)s->pcount[l+2]*2+1];
374 texcoord_table[j+2] = s->texcoord_float->u.array[(int)s->pcount[l+5]*2];
375 texcoord_table[j+3] = s->texcoord_float->u.array[(int)s->pcount[l+5]*2+1];
376 texcoord_table[j+4] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2];
377 texcoord_table[j+5] = s->texcoord_float->u.array[(int)s->pcount[l+8]*2+1];
378 l+=9;
379 j+=6;
383 k+=9; 380 k+=9;
384 size++; 381 count++;
385 } 382 }
386 } 383 }
387 }else{ 384 }else{
388 for (int i=0;i<s->vmember;i++) { 385 for (int i=0;i<s->polylist_count;i++) {
389 if (s->vcount[i] == 4) { 386 if (s->vcount[i] == 4) {
390 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3]; 387 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[l]*3];
391 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; 388 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[l]*3+1];
392 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; 389 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[l]*3+2];
393 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+2]*3]; 390 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[l+2]*3];
394 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+1]; 391 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[l+2]*3+1];
395 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+2]; 392 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[l+2]*3+2];
396 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+4]*3]; 393 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[l+4]*3];
397 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+1]; 394 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+1];
398 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+2]; 395 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+2];
399 vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[i+4]*3]; 396 vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[l+4]*3];
400 vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+1]; 397 vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+1];
401 vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+2]; 398 vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+2];
402 vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[i+6]*3]; 399 vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[l+6]*3];
403 vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1]; 400 vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+1];
404 vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2]; 401 vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[l+6]*3+2];
405 vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[i]*3]; 402 vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[l]*3];
406 vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; 403 vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[l]*3+1];
407 vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; 404 vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[l]*3+2];
408 405
409 normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; 406 normal_table[k] = s->normal_float->u.array[(int)s->pcount[l+1]*3];
410 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1]; 407 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1];
411 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2]; 408 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[l+1]*3+2];
412 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+3]*3]; 409 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[l+3]*3];
413 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+3]*3+1]; 410 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[l+3]*3+1];
414 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+3]*3+2]; 411 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[l+3]*3+2];
415 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; 412 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[l+5]*3];
416 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; 413 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[l+5]*3+1];
417 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; 414 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[l+5]*3+2];
418 normal_table[k+9] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; 415 normal_table[k+9] = s->normal_float->u.array[(int)s->pcount[l+5]*3];
419 normal_table[k+10] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; 416 normal_table[k+10] = s->normal_float->u.array[(int)s->pcount[l+5]*3+1];
420 normal_table[k+11] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; 417 normal_table[k+11] = s->normal_float->u.array[(int)s->pcount[l+5]*3+2];
421 normal_table[k+12] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 418 normal_table[k+12] = s->normal_float->u.array[(int)s->pcount[l+7]*3];
422 normal_table[k+13] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 419 normal_table[k+13] = s->normal_float->u.array[(int)s->pcount[l+7]*3+1];
423 normal_table[k+14] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; 420 normal_table[k+14] = s->normal_float->u.array[(int)s->pcount[l+7]*3+2];
424 normal_table[k+15] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; 421 normal_table[k+15] = s->normal_float->u.array[(int)s->pcount[l+1]*3];
425 normal_table[k+16] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; 422 normal_table[k+16] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1];
426 normal_table[k+17] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; 423 normal_table[k+17] = s->normal_float->u.array[(int)s->pcount[l+1]*3+2];
427 424
425 printf ("%f, %f, %f\n",vertex_table[k],vertex_table[k+1],vertex_table[k+2]);
426 printf ("%f, %f, %f\n",vertex_table[k+3],vertex_table[k+4],vertex_table[k+5]);
427 printf ("%f, %f, %f\n",vertex_table[k+6],vertex_table[k+7],vertex_table[k+8]);
428 printf ("%f, %f, %f\n",vertex_table[k+9],vertex_table[k+10],vertex_table[k+11]);
429 printf ("%f, %f, %f\n",vertex_table[k+12],vertex_table[k+13],vertex_table[k+14]);
430 printf ("%f, %f, %f\n",vertex_table[k+15],vertex_table[k+16],vertex_table[k+17]);
431 l+=8;
428 k+=18; 432 k+=18;
429 size +=2; 433 count +=2;
430 } else if (s->vcount[i]==3) { 434 } else if (s->vcount[i]==3) {
431 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3]; 435 vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[l]*3];
432 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; 436 vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[l]*3+1];
433 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; 437 vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[l]*3+2];
434 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+2]*3]; 438 vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[l+2]*3];
435 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+1]; 439 vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[l+2]*3+1];
436 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+2]; 440 vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[l+2]*3+2];
437 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+4]*3]; 441 vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[l+4]*3];
438 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+1]; 442 vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+1];
439 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+2]; 443 vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[l+4]*3+2];
440 444
441 normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; 445 normal_table[k] = s->normal_float->u.array[(int)s->pcount[l+1]*3];
442 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1]; 446 normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[l+1]*3+1];
443 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2]; 447 normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[l+1]*3+22];
444 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+3]*3]; 448 normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[l+3]*3];
445 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+3]*3+1]; 449 normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[l+3]*3+1];
446 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+3]*3+2]; 450 normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[l+3]*3+2];
447 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; 451 normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[l+5]*3];
448 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; 452 normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[l+5]*3+1];
449 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; 453 normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[l+5]*3+2];
454
455 printf ("%f, %f, %f\n",vertex_table[k],vertex_table[k+1],vertex_table[k+2]);
456 printf ("%f, %f, %f\n",vertex_table[k+3],vertex_table[k+4],vertex_table[k+5]);
457 printf ("%f, %f, %f\n",vertex_table[k+6],vertex_table[k+7],vertex_table[k+8]);
458 l+=6;
450 k+=9; 459 k+=9;
451 size++; 460 count++;
452 } 461 }
453 } 462 }
454 } 463 }
464
465
466
467
455 468
456 /** 469 /**
457 * (SceneGraph.cc) 470 * (SceneGraph.cc)
458 * pickup_normal,pickup_coordinate,pickup_textureの処理 471 * pickup_normal,pickup_coordinate,pickup_textureの処理
459 * vcsumは頂点の数,countは面の数 472 * sg->sizeは頂点の数,countは面の数
460 */ 473 */
461 474
462 int count = size / 3;
463 //polygonの作成 475 //polygonの作成
464 sg->pp_num = (count + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE; 476 sg->pp_num = (count + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE;
465 sg->pp = new PolygonPack[sg->pp_num]; 477 sg->pp = new PolygonPack[sg->pp_num];
466 sg->name = s->name; 478 sg->name = s->name;
467 sg->parent_name = "NULL"; 479 sg->parent_name = "NULL";
468 sg->size = size; 480 sg->size = count*3;
469 for (int i = 0;i < sg->pp_num; i++ ){ 481 for (int i = 0;i < sg->pp_num; i++ ){
470 PolygonPackPtr pp = sg->pp; 482 PolygonPackPtr pp = sg->pp;
471 TrianglePackPtr tri = pp[i].tri; 483 TrianglePackPtr tri = pp[i].tri;
472 // TrianglePack の size のチェック 484 // TrianglePack の size のチェック
473 int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ; 485 int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ;
477 char *default_image = "../Test/xml_file/blend/images/ball.jpg"; 489 char *default_image = "../Test/xml_file/blend/images/ball.jpg";
478 get_texture_image(default_image, sg, (xmlNodePtr)NULL, manager); 490 get_texture_image(default_image, sg, (xmlNodePtr)NULL, manager);
479 } 491 }
480 int k = 0; 492 int k = 0;
481 int m = 0; 493 int m = 0;
482 int n = 0; 494 for (int j = 0; j < tri_size; j++,k+=9,m+=6) {
483 for (int j = 0; j < tri_size; j++) { 495 tri[j].ver1.x = vertex_table[k];
484 tri[j].normal1.x = normal_table[k++]; 496 tri[j].ver1.y = vertex_table[k+1];
485 tri[j].normal1.y = normal_table[k++]; 497 tri[j].ver1.z = vertex_table[k+2];
486 tri[j].normal1.z = normal_table[k++];
487 498
488 tri[j].normal2.x = normal_table[k++]; 499 tri[j].ver2.x = vertex_table[k+3];
489 tri[j].normal2.y = normal_table[k++]; 500 tri[j].ver2.y = vertex_table[k+4];
490 tri[j].normal2.z = normal_table[k++]; 501 tri[j].ver2.z = vertex_table[k+5];
491 502
492 tri[j].normal3.x = normal_table[k++]; 503 tri[j].ver3.x = vertex_table[k+6];
493 tri[j].normal3.y = normal_table[k++]; 504 tri[j].ver3.y = vertex_table[k+7];
494 tri[j].normal3.z = normal_table[k++]; 505 tri[j].ver3.z = vertex_table[k+8];
506
507 tri[j].normal1.x = normal_table[k];
508 tri[j].normal1.y = normal_table[k+1];
509 tri[j].normal1.z = normal_table[k+2];
495 510
496 tri[j].ver1.tex_x = texcoord_table[m++]; 511 tri[j].normal2.x = normal_table[k+3];
497 tri[j].ver1.tex_y = texcoord_table[m++]; 512 tri[j].normal2.y = normal_table[k+4];
513 tri[j].normal2.z = normal_table[k+5];
498 514
499 tri[j].ver2.tex_x = texcoord_table[m++]; 515 tri[j].normal3.x = normal_table[k+6];
500 tri[j].ver2.tex_y = texcoord_table[m++]; 516 tri[j].normal3.y = normal_table[k+7];
517 tri[j].normal3.z = normal_table[k+8];
501 518
502 tri[j].ver3.tex_x = texcoord_table[m++]; 519 tri[j].ver1.tex_x = texcoord_table[m];
503 tri[j].ver3.tex_y = texcoord_table[m++]; 520 tri[j].ver1.tex_y = texcoord_table[m+1];
504 521
505 tri[j].ver1.x = vertex_table[n++]; 522 tri[j].ver2.tex_x = texcoord_table[m+2];
506 tri[j].ver1.y = vertex_table[n++]; 523 tri[j].ver2.tex_y = texcoord_table[m+3];
507 tri[j].ver1.z = vertex_table[n++];
508 524
509 tri[j].ver2.x = vertex_table[n++]; 525 tri[j].ver3.tex_x = texcoord_table[m+4];
510 tri[j].ver2.y = vertex_table[n++]; 526 tri[j].ver3.tex_y = texcoord_table[m+5];
511 tri[j].ver2.z = vertex_table[n++];
512
513 tri[j].ver3.x = vertex_table[n++];
514 tri[j].ver3.y = vertex_table[n++];
515 tri[j].ver3.z = vertex_table[n++];
516 527
517 } 528 }
518 529
519 } 530 }
520 sg->c_xyz[0] = sg->c_xyz[1] = sg->c_xyz[2] = 0; 531 sg->c_xyz[0] = sg->c_xyz[1] = sg->c_xyz[2] = 0;