Mercurial > hg > Members > koba > t_dandy
comparison Dandy.cc @ 33:39e643fc4f90
moving stage1.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 05 Jan 2011 14:41:26 +0900 |
parents | 00c3272a801f |
children | 6626e451a09d |
comparison
equal
deleted
inserted
replaced
32:1b161e808240 | 33:39e643fc4f90 |
---|---|
528 m->w = w; | 528 m->w = w; |
529 m->h = h; | 529 m->h = h; |
530 m->color = (color & 32); | 530 m->color = (color & 32); |
531 m->mx = w / 2; | 531 m->mx = w / 2; |
532 m->my = h / 2; | 532 m->my = h / 2; |
533 m->tex_w = power_of_two(sptable[number].w); | 533 m->tex_w = power_of_two(m->w); |
534 m->tex_h = power_of_two(sptable[number].h); | 534 m->tex_h = power_of_two(m->h); |
535 //texMinX[number] = 0.0f; | 535 |
536 //texMinY[number] = 0.0f; | |
537 //texMaxX[number] = (GLfloat)sptable[number].w / sptable[number].tex_w; | |
538 //texMaxY[number] = (GLfloat)sptable[number].h / sptable[number].tex_h; | |
539 // printf("texMaxX = %f, w = %d, tex_w = %d\n", texMaxX[number], sptable[number].w, sptable[number].tex_w); | |
540 m->texture = (int *)name; | 536 m->texture = (int *)name; |
541 | 537 |
542 } | 538 } |
539 | |
540 static float my_scale = 5; | |
543 | 541 |
544 void | 542 void |
545 PutSprite(int zorder, short x, short y, int number) | 543 PutSprite(int zorder, short x, short y, int number) |
546 { | 544 { |
547 SpriteTable *m = &sptable[number]; | 545 SpriteTable *m = &sptable[number]; |
548 char *name = (char *) m->texture; | 546 char *name = (char *) m->texture; |
549 if (!name) { | 547 if (!name) { |
550 printf("PutSprite %d unknown\n",number); | 548 printf("PutSprite %d unknown\n",number); |
551 return; | 549 return; |
552 } | 550 } |
553 SceneGraphPtr object = sgroot->createSceneGraph(name); | 551 SceneGraphPtr object = sgroot->createSceneGraph(name); |
554 object->xyz[0] = x; | 552 object->xyz[0] = x - object->c_xyz[0]*my_scale; |
555 object->xyz[1] = y; | 553 object->xyz[1] = y - object->c_xyz[1]*my_scale; |
556 object->xyz[2] = 0; | 554 object->xyz[2] = 0; |
557 root->addChild(object); | 555 root->addChild(object); |
558 | 556 |
559 float scale[] = {5,5,1}; | 557 float scale[] = {my_scale,my_scale,1}; |
560 /*親の回転、座標から、子の回転、座標を算出*/ | 558 /*親の回転、座標から、子の回転、座標を算出*/ |
561 get_matrix(object->matrix, object->angle, object->xyz, scale, root->matrix); | 559 get_matrix(object->matrix, object->angle, object->xyz, scale, root->matrix); |
562 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ | 560 /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ |
563 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); |
564 | 562 |
572 if (!name) { | 570 if (!name) { |
573 printf("PutSpriteEx %d unknown\n",number); | 571 printf("PutSpriteEx %d unknown\n",number); |
574 return; | 572 return; |
575 } | 573 } |
576 SceneGraphPtr object = sgroot->createSceneGraph(name); | 574 SceneGraphPtr object = sgroot->createSceneGraph(name); |
577 object->xyz[0] = x; | 575 object->xyz[0] = x - object->c_xyz[0]*my_scale - m->w*my_scale; |
578 object->xyz[1] = y; | 576 object->xyz[1] = y - object->c_xyz[0]*my_scale - m->w*my_scale; |
579 object->xyz[2] = 0; | 577 object->xyz[2] = 0; |
580 object->c_xyz[0] = m->mx; | 578 object->c_xyz[0] = m->mx; |
581 object->c_xyz[1] = m->my; | 579 object->c_xyz[1] = m->my; |
582 object->angle[3] = angle; | 580 object->angle[3] = angle; |
583 root->addChild(object); | 581 root->addChild(object); |