Mercurial > hg > Members > koba > t_dandy
comparison Dandy.cc @ 68:b99e4366b913
fix position
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 21 May 2011 21:22:48 +0900 |
parents | fce767bb5e25 |
children | cee55c8365e9 |
comparison
equal
deleted
inserted
replaced
67:21ac9f57a6d4 | 68:b99e4366b913 |
---|---|
606 void | 606 void |
607 PutSprite(int zorder, short x, short y, int number) | 607 PutSprite(int zorder, short x, short y, int number) |
608 { | 608 { |
609 SpriteTable *m = &sptable[number]; | 609 SpriteTable *m = &sptable[number]; |
610 char *name = (char *) m->texture; | 610 char *name = (char *) m->texture; |
611 | 611 if (!name) { |
612 if (!name) { | 612 printf("PutSprite %d unknown\n",number); |
613 // printf("PutSprite %d unknown\n",number); | 613 return; |
614 return; | 614 } |
615 } | |
616 | |
617 SceneGraphPtr object = sgroot->createSceneGraph(name); | 615 SceneGraphPtr object = sgroot->createSceneGraph(name); |
618 object->xyz[0] = x; | 616 //object->c_xyz[0] = m->mx; |
619 object->xyz[1] = y; | 617 //object->c_xyz[1] = m->my; |
620 object->xyz[2] = 0; | |
621 root->addChild(object); | 618 root->addChild(object); |
622 | 619 |
620 object->xyz[0] -= object->c_xyz[0]*my_scale; | |
621 object->xyz[1] -= object->c_xyz[1]*my_scale; | |
622 object->xyz[2] -= object->c_xyz[2]; | |
623 | |
624 object->xyz[0] += x; | |
625 object->xyz[1] += y; | |
626 object->xyz[2] += zorder * 0.01; | |
627 | |
623 float scale[] = {my_scale,my_scale,1}; | 628 float scale[] = {my_scale,my_scale,1}; |
629 | |
624 /*親の回転、座標から、子の回転、座標を算出*/ | 630 /*親の回転、座標から、子の回転、座標を算出*/ |
625 get_matrix(object->matrix, object->angle, object->xyz, root->matrix); | 631 get_matrix_scale(object->matrix, object->angle, object->xyz, scale, root->matrix); |
626 scale_matrix(object->matrix, scale, object->c_xyz); | 632 |
627 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ | 633 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ |
628 get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); | 634 // get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); |
629 scale_matrix(object->real_matrix, scale, object->c_xyz); | |
630 } | 635 } |
631 | 636 |
632 void | 637 void |
633 PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle) | 638 PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle) |
634 { | 639 { |
640 if (0) { | |
641 PutSprite(1, x, y, number); | |
642 return; | |
643 } | |
644 | |
645 int zorder = count++; | |
646 | |
635 SpriteTable *m = &sptable[number]; | 647 SpriteTable *m = &sptable[number]; |
636 char *name = (char *) m->texture; | 648 char *name = (char *) m->texture; |
637 if (!name) { | 649 if (!name) { |
638 // printf("PutSpriteEx %d unknown\n",number); | 650 printf("PutSpriteEx %d unknown\n",number); |
639 return; | 651 return; |
640 } | 652 } |
641 | |
642 SceneGraphPtr object = sgroot->createSceneGraph(name); | 653 SceneGraphPtr object = sgroot->createSceneGraph(name); |
643 object->xyz[0] = x - m->w*my_scale; | |
644 object->xyz[1] = y - m->h*my_scale; | |
645 object->xyz[2] = 0; | |
646 object->c_xyz[0] = m->mx; | |
647 object->c_xyz[1] = m->my; | |
648 object->angle[3] = angle; | |
649 root->addChild(object); | 654 root->addChild(object); |
650 | 655 |
651 float scale[] = {5*scalex,5*scaley,1}; | 656 object->xyz[0] -= object->c_xyz[0]*my_scale*scalex; |
657 object->xyz[1] -= object->c_xyz[1]*my_scale*scaley; | |
658 object->xyz[2] -= object->c_xyz[2]; | |
659 | |
660 object->xyz[0] += x; | |
661 object->xyz[1] += y; | |
662 object->xyz[2] += zorder * 0.01; | |
663 | |
664 | |
665 float scale[] = {my_scale*scalex,my_scale*scaley,1}; | |
652 /*親の回転、座標から、子の回転、座標を算出*/ | 666 /*親の回転、座標から、子の回転、座標を算出*/ |
653 get_matrix(object->matrix, object->angle, object->xyz, root->matrix); | 667 get_matrix_scale(object->matrix, object->angle, object->xyz, scale, root->matrix); |
654 scale_matrix(object->matrix, scale, object->c_xyz); | 668 |
655 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ | 669 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ |
656 get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); | 670 // get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); |
657 scale_matrix(object->real_matrix, scale, object->c_xyz); | 671 |
658 } | 672 } |
659 | 673 |
660 | 674 |
661 struct SGO_PAD pad[2]; | 675 struct SGO_PAD pad[2]; |
662 | 676 |