# HG changeset patch # User Shinji KONO # Date 1291754383 -32400 # Node ID 9f2eb8b9d23a34c1e969aa1b76753e0e9857ac39 # Parent 4c9c5cbd47c5d4d164cff01e9a53826dcc6979d4 First working version. diff -r 4c9c5cbd47c5 -r 9f2eb8b9d23a Dandy.cc --- a/Dandy.cc Wed Dec 08 02:12:27 2010 +0900 +++ b/Dandy.cc Wed Dec 08 05:39:43 2010 +0900 @@ -26,6 +26,7 @@ #include "LoadSprite.h" #include #include "error.h" +#include "sys.h" #include "Character.h" #include "Character_state.h" @@ -108,7 +109,7 @@ HTaskPtr Dandy::application_task(HTaskPtr next, Viewer* viewer){ -printf("gamef = %d\n",gamef); + // printf("gamef = %d\n",gamef); switch (gamef) { case 0: gamef= dandy_main_init(gamef); break; case 1: gamef= gamesyokika(gamef); break; @@ -143,6 +144,18 @@ printf("game end\n"); } +static int light_sysswitch = 1; +static int light_num = 4; + +static void +LightSysSwitch(Viewer *sgroot) { + if (light_sysswitch == 1) { + sgroot->OnLightSysSwitch(); + } else if (light_sysswitch == 0) { + sgroot->OffLightSysSwitch(); + } +} + static int dandy_main_init(int gamef) @@ -160,6 +173,15 @@ sgroot->createFromXMLfile("xml/effect.xml"); sgroot->createFromXMLfile("xml/boss.xml"); + LightSysSwitch(sgroot); + for (int i = 0; i < light_num; i++) { + SceneGraphPtr light = sgroot->getLight(i); + sgroot->OnLightSwitch(i); + light->xyz[0] = screen_w / 2; + light->xyz[1] = screen_h / 2; + light->xyz[2] = -100; + } + init_sprite(0,0,0,0); @@ -207,12 +229,29 @@ return 1; } +SceneGraphPtr root; + +extern void get_matrix(float *matrix, float *rxyz, float *txyz, float *stack); + static void flip() { - sgroot->sgroot->sg_exec_tree = sgroot->sgroot->sg_available_list; + CameraPtr camera = sgroot->sgroot->getCamera(); + sgroot->sgroot->flip(); sgroot->sgroot->lightCalc(); + + root = sgroot->createSceneGraph(); + root->xyz[0] = screen_w/2; + root->xyz[1] = screen_h/2;; + root->xyz[2] = 30.0f; + + /*親の回転、座標から、子の回転、座標を算出*/ + get_matrix(root->matrix, root->angle, root->xyz, camera->matrix); + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ + get_matrix(root->real_matrix, root->angle, root->xyz, camera->real_matrix); + + sgroot->setSceneData(root); } @@ -269,8 +308,9 @@ } else { Pad(joy); } + filpcount++; + count = 0; - count = 0; return gamef; } @@ -326,6 +366,7 @@ SoundStop(); SoundPlay(7); gamef = 2; + flip(); return gamef; } @@ -373,6 +414,7 @@ static int game_pause(int gamef) { + gamef = 3; if (jiki.zanki != 0 && jiki.bf != FALSE) { if (pad[0].se == 1) { //Mix_Pause(BGM); @@ -511,9 +553,16 @@ return; } SceneGraphPtr object = sgroot->createSceneGraph(name); - object->xyz[0] = x + screen_w /2; - object->xyz[1] = y + screen_h /2; - object->xyz[2] = -100; + object->xyz[0] = x; + object->xyz[1] = y; + object->xyz[2] = 0; + root->addChild(object); + + /*親の回転、座標から、子の回転、座標を算出*/ + get_matrix(object->matrix, object->angle, object->xyz, root->matrix); + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ + get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); + } void @@ -526,9 +575,16 @@ return; } SceneGraphPtr object = sgroot->createSceneGraph(name); - object->xyz[0] = x + screen_w /2; - object->xyz[1] = y + screen_h /2; - object->xyz[2] = -100; + object->xyz[0] = x; + object->xyz[1] = y; + object->xyz[2] = 0; + object->angle[3] = angle; + root->addChild(object); + + /*親の回転、座標から、子の回転、座標を算出*/ + get_matrix(object->matrix, object->angle, object->xyz, root->matrix); + /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ + get_matrix(object->real_matrix, object->angle, object->xyz, root->real_matrix); }