# HG changeset patch # User Shinji KONO # Date 1305980568 -32400 # Node ID b99e4366b91354c51a5e9660e2ed66be379cccd1 # Parent 21ac9f57a6d4e092490343daf55111379489f8de fix position diff -r 21ac9f57a6d4 -r b99e4366b913 Dandy.cc --- a/Dandy.cc Sat May 21 16:27:41 2011 +0900 +++ b/Dandy.cc Sat May 21 21:22:48 2011 +0900 @@ -608,53 +608,67 @@ { SpriteTable *m = &sptable[number]; char *name = (char *) m->texture; - - if (!name) { -// printf("PutSprite %d unknown\n",number); - return; - } - +if (!name) { + printf("PutSprite %d unknown\n",number); + return; +} SceneGraphPtr object = sgroot->createSceneGraph(name); - object->xyz[0] = x; - object->xyz[1] = y; - object->xyz[2] = 0; + //object->c_xyz[0] = m->mx; + //object->c_xyz[1] = m->my; root->addChild(object); + object->xyz[0] -= object->c_xyz[0]*my_scale; + object->xyz[1] -= object->c_xyz[1]*my_scale; + object->xyz[2] -= object->c_xyz[2]; + + object->xyz[0] += x; + object->xyz[1] += y; + object->xyz[2] += zorder * 0.01; + float scale[] = {my_scale,my_scale,1}; + /*親の回転、座標から、子の回転、座標を算出*/ - get_matrix(object->matrix, object->angle, object->xyz, root->matrix); - scale_matrix(object->matrix, scale, object->c_xyz); + get_matrix_scale(object->matrix, object->angle, object->xyz, scale, root->matrix); + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ - get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); - scale_matrix(object->real_matrix, scale, object->c_xyz); + // get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); } void PutSpriteEx(int number, int x, int y, float scalex, float scaley, float angle) { + if (0) { + PutSprite(1, x, y, number); + return; + } + + int zorder = count++; + SpriteTable *m = &sptable[number]; char *name = (char *) m->texture; - if (!name) { -// printf("PutSpriteEx %d unknown\n",number); - return; - } - +if (!name) { + printf("PutSpriteEx %d unknown\n",number); + return; +} SceneGraphPtr object = sgroot->createSceneGraph(name); - object->xyz[0] = x - m->w*my_scale; - object->xyz[1] = y - m->h*my_scale; - object->xyz[2] = 0; - object->c_xyz[0] = m->mx; - object->c_xyz[1] = m->my; - object->angle[3] = angle; root->addChild(object); - float scale[] = {5*scalex,5*scaley,1}; + object->xyz[0] -= object->c_xyz[0]*my_scale*scalex; + object->xyz[1] -= object->c_xyz[1]*my_scale*scaley; + object->xyz[2] -= object->c_xyz[2]; + + object->xyz[0] += x; + object->xyz[1] += y; + object->xyz[2] += zorder * 0.01; + + + float scale[] = {my_scale*scalex,my_scale*scaley,1}; /*親の回転、座標から、子の回転、座標を算出*/ - get_matrix(object->matrix, object->angle, object->xyz, root->matrix); - scale_matrix(object->matrix, scale, object->c_xyz); + get_matrix_scale(object->matrix, object->angle, object->xyz, scale, root->matrix); + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ - get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); - scale_matrix(object->real_matrix, scale, object->c_xyz); + // get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); + }