comparison TaskDandy.cc @ 29:d2e627af7f61

fix.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Tue, 28 Dec 2010 16:22:22 +0900
parents 813f5461daab
children 427e1aac0bd7
comparison
equal deleted inserted replaced
28:813f5461daab 29:d2e627af7f61
529 m->w = w; 529 m->w = w;
530 m->h = h; 530 m->h = h;
531 m->color = (color & 32); 531 m->color = (color & 32);
532 m->mx = w / 2; 532 m->mx = w / 2;
533 m->my = h / 2; 533 m->my = h / 2;
534 m->tex_w = power_of_two(sptable[number].w); 534 m->tex_w = power_of_two(m->w);
535 m->tex_h = power_of_two(sptable[number].h); 535 m->tex_h = power_of_two(m->h);
536 //texMinX[number] = 0.0f; 536
537 //texMinY[number] = 0.0f;
538 //texMaxX[number] = (GLfloat)sptable[number].w / sptable[number].tex_w;
539 //texMaxY[number] = (GLfloat)sptable[number].h / sptable[number].tex_h;
540 // printf("texMaxX = %f, w = %d, tex_w = %d\n", texMaxX[number], sptable[number].w, sptable[number].tex_w);
541 m->texture = (int *)name; 537 m->texture = (int *)name;
542 538 }
543 } 539
540 static float my_scale = 5;
544 541
545 void 542 void
546 PutSprite(int zorder, short x, short y, int number) 543 PutSprite(int zorder, short x, short y, int number)
547 { 544 {
548 SpriteTable *m = &sptable[number]; 545 SpriteTable *m = &sptable[number];
550 if (!name) { 547 if (!name) {
551 printf("PutSprite %d unknown\n",number); 548 printf("PutSprite %d unknown\n",number);
552 return; 549 return;
553 } 550 }
554 SceneGraphPtr object = sgroot->createSceneGraph(name); 551 SceneGraphPtr object = sgroot->createSceneGraph(name);
555 object->xyz[0] = x; 552 object->xyz[0] = x - object->c_xyz[0]*my_scale;
556 object->xyz[1] = y; 553 object->xyz[1] = y - object->c_xyz[1]*my_scale;
557 object->xyz[2] = 0; 554 object->xyz[2] = 0;
558 root->addChild(object); 555 root->addChild(object);
559 556
560 float scale[] = {5,5,1}; 557 float scale[] = {my_scale,my_scale,1};
561 /*親の回転、座標から、子の回転、座標を算出*/ 558 /*親の回転、座標から、子の回転、座標を算出*/
562 get_matrix(object->matrix, object->angle, object->xyz, scale, root->matrix); 559 get_matrix(object->matrix, object->angle, object->xyz, scale, root->matrix);
563 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ 560 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
564 get_matrix(object->real_matrix, object->angle, object->xyz, scale, root->real_matrix); 561 get_matrix(object->real_matrix, object->angle, object->xyz, scale, root->real_matrix);
565 562
573 if (!name) { 570 if (!name) {
574 printf("PutSpriteEx %d unknown\n",number); 571 printf("PutSpriteEx %d unknown\n",number);
575 return; 572 return;
576 } 573 }
577 SceneGraphPtr object = sgroot->createSceneGraph(name); 574 SceneGraphPtr object = sgroot->createSceneGraph(name);
578 object->xyz[0] = x; 575 object->xyz[0] = x - object->c_xyz[0]*my_scale - m->w*my_scale;
579 object->xyz[1] = y; 576 object->xyz[1] = y - object->c_xyz[0]*my_scale - m->w*my_scale;
580 object->xyz[2] = 0; 577 object->xyz[2] = 0;
581 object->c_xyz[0] = m->mx; 578 object->c_xyz[0] = m->mx;
582 object->c_xyz[1] = m->my; 579 object->c_xyz[1] = m->my;
583 object->angle[3] = angle; 580 object->angle[3] = angle;
584 root->addChild(object); 581 root->addChild(object);