int Render() { int ret; ret = E3DBeginScene( scid, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DRender( scid, groundhsid, 0, 1, 0, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DRender( scid, ci[CHARA_RED].hsid, 0, 1, 0, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DRender( scid, ci[CHARA_BLUE].hsid, 0, 1, 0, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = DrawText(); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DEndScene(); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DPresent( scid ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DWaitbyFPS( 60, &retfps ); if( ret ){ _ASSERT( 0 ); return 1; } E3DSetBeforePos( ci[CHARA_RED].hsid ); E3DSetBeforePos( ci[CHARA_BLUE].hsid ); return 0; }
int Batch_Render::BatchBeforePos(){ /*変数の初期化*/ int ech = 0;//エラーチェック用の確認変数 vector<Model>::iterator it;// イテレータ for( it = Mdl.begin(); it != Mdl.end(); it++ ){ if( (*it).ID != 0){ ech = E3DSetBeforePos( (*it).ID); _ASSERT( ech != 1 );//エラーチェック } } return 0; }
int Render3DEnvironment() { int ret; E3DGetKeyboardCnt( keybuf ); ret = MoveChara(); _ASSERT( !ret ); ret = MoveCamera(); _ASSERT( !ret ); int frameno; ret = E3DSetNewPose( hsid1, &frameno ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DBeginScene( scid, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } //視野内チェック int status; ret = E3DChkInView( scid, hsid0, &status ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DChkInView( scid, hsid1, &status ); if( ret ){ _ASSERT( 0 ); return 1; } //当たり判定( ChkInViewより後で呼ぶ ) ret = ChkConf(); _ASSERT( !ret ); //不透明部分をレンダー ret = E3DRender( scid, hsid0, 0, 1, 0, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DRender( scid, hsid1, 0, 1, 0, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } //半透明部分をレンダー ret = E3DRender( scid, hsid0, 1, 1, 1, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DRender( scid, hsid1, 1, 1, 1, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DRenderBillboard( scid, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } //モーションブラーの描画 if( rendercnt == 0 ){ //E3DSetMotinBlurをしてから初回のレンダー時には必ず必要。 //SetではなくてInitであるところに注意。 ret = E3DInitBeforeBlur( hsid0 ); _ASSERT( !ret ); ret = E3DInitBeforeBlur( hsid1 ); _ASSERT( !ret ); ret = E3DInitBeforeBlur( -1 ); _ASSERT( !ret ); } ret = E3DRenderMotionBlur( scid, blurdisp, 3 ); if( ret ){ _ASSERT( 0 ); return 1; } rendercnt++; //毎フレーム呼び出す E3DSetBeforeBlur( hsid0 ); E3DSetBeforeBlur( hsid1 ); E3DSetBeforeBlur( -1 ); ret = DrawText(); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DEndScene(); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DPresent( scid ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DWaitbyFPS( 60, &retfps ); if( ret ){ _ASSERT( 0 ); return 1; } //位置の記録 ret = E3DGetPos( hsid1, &curpos ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetBeforePos( hsid1 ); if( ret ){ _ASSERT( 0 ); return 1; } befpos = curpos; return 0; }
int OneTimeSceneInit() { int ret; D3DXVECTOR3 campos = D3DXVECTOR3( 53898.0f, 3000.0f, 44982.0f - 2500.0f ); ret = E3DSetCameraPos( campos ); if( ret ){ _ASSERT( 0 ); return 1; } D3DXVECTOR3 camtar = D3DXVECTOR3( 53898.0f, 2500.0f, 44982.0f ); D3DXVECTOR3 camup = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); ret = E3DSetCameraTarget( camtar, camup ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetProjection( 1000.0f, proj_far, 60.0f ); if( ret ){ _ASSERT( 0 ); return 1; } //地面データのロード char name1[MAX_PATH]; sprintf_s( name1, MAX_PATH, "%s\\g_6_20_1.bmp", szMediaDir ); char name2[MAX_PATH]; sprintf_s( name2, MAX_PATH, "%s\\8.bmp", szMediaDir ); char name3[MAX_PATH]; sprintf_s( name3, MAX_PATH, "%s\\g_river_6_20_1.bmp", szMediaDir ); char name4[MAX_PATH]; sprintf_s( name4, MAX_PATH, "%s\\BG43.bmp", szMediaDir ); float mapsize = 120000.0f; int mapdiv = 50; float mapheight = 5500.0f; ret = E3DLoadGroundBMP( name1, name2, name3, name4, mapsize, mapsize, mapdiv, mapdiv, mapheight, &hsid0 ); if( ret ){ _ASSERT( 0 ); return 1; } //モロ星人のロード char signame[MAX_PATH]; sprintf_s( signame, MAX_PATH, "%s\\morob_6_26_r3.sig", szMediaDir ); ret = E3DSigLoad( signame, 0, 1.0f, &hsid1 ); if( ret ){ _ASSERT( 0 ); return 1; } char quaname[MAX_PATH]; sprintf_s( quaname, MAX_PATH, "%s\\morob_6_26_r3.qua", szMediaDir ); int maxframe; ret = E3DAddMotion( hsid1, quaname, 1.0f, &motid1, &maxframe ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetMotionKind( hsid1, motid1 ); if( ret ){ _ASSERT( 0 ); return 1; } curpos = D3DXVECTOR3( 53898.0f, 3000.0f, 44982.0f ); befpos = curpos; ret = E3DSetPos( hsid1, curpos ); if( ret ){ _ASSERT( 0 ); return 1; } D3DXVECTOR3 deg = D3DXVECTOR3( 0.0f, 120.0f, 0.0f ); ret = E3DSetDir( hsid1, deg ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetBeforePos( hsid1 ); if( ret ){ _ASSERT( 0 ); return 1; } //木(ビルボード)の読み込みと設置 // PosOnGround 命令を使うために、ChkInViewを、あらかじめ、呼んでおく必要があります。 int state; ret = E3DChkInView( scid, hsid0, &state ); if( ret ){ _ASSERT( 0 ); return 1; } srand( 321 ); int bbcnt; for( bbcnt = 0; bbcnt < BBNUM; bbcnt++ ){ int treekind; char treename[MAX_PATH]; treekind = rand() % 3; if( treekind == 0 ){ sprintf_s( treename, MAX_PATH, "%s\\tree01S.tga", szMediaDir ); }else if( treekind == 1 ){ sprintf_s( treename, MAX_PATH, "%s\\tree02S.tga", szMediaDir ); }else{ sprintf_s( treename, MAX_PATH, "%s\\tree35S.tga", szMediaDir ); } ret = E3DCreateBillboard( treename, 2000.0f, 3000.0f, 0, 0, 0, bbid + bbcnt ); if( ret ){ _ASSERT( 0 ); return 1; } int divsize; divsize = (int)mapsize / 4; int randx, randz; randx = ( rand() % divsize ) * 4; randz = ( rand() % divsize ) * 4; ret = E3DSetBillboardOnGround( bbid[bbcnt], hsid0, mapheight, -100.0f, (float)randx, (float)randz ); if( ret ){ _ASSERT( 0 ); return 1; } } //ライト ret = E3DCreateLight( &lid1 ); if( ret ){ _ASSERT( 0 ); return 1; } D3DXVECTOR3 ldir( 0.0f, -1.0f, 2.0f ); E3DCOLOR4UC col= {255, 255, 255, 255 }; ret = E3DSetDirectionalLight( lid1, ldir, col ); if( ret ){ _ASSERT( 0 ); return 1; } //フォグ E3DCOLOR4UC fogcol = { 255, 0, 0, 255 }; ret = E3DSetLinearFogParams( 1, fogcol, 1000.0f, proj_far, -1 ); if( ret ){ _ASSERT( 0 ); return 1; } //モーションブラーの準備 //3番目の引数で何フレーム前のデータでブラーを作るかを指定 ret = E3DSetMotionBlur( hsid0, BLUR_CAMERA, 15 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetMotionBlur( hsid1, BLUR_CAMERA, 5 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetMotionBlur( -1, BLUR_CAMERA, 3 );//-1はビルボード if( ret ){ _ASSERT( 0 ); return 1; } blurdisp[0] = hsid0; blurdisp[1] = hsid1; blurdisp[2] = -1; return 0; }
int Render3DEnvironment() { int ret; ret = E3DGetKeyboardState( keybuf ); _ASSERT( !ret ); if( keybuf[VK_ESCAPE] == 1 ){ return 1; } ret = MoveChara(); if( ret ){ _ASSERT( 0 ); return 1; } ret = MoveCamera(); if( ret ){ _ASSERT( 0 ); return 1; } int curframe; ret = E3DSetNewPose( hsid1, &curframe ); if( ret ){ _ASSERT( 0 ); return 1; } int status0, status1, status2; ret = E3DChkInView( scid, hsid0, &status0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DChkInView( scid, hsid1, &status1 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DChkInView( scid, hsid2, &status2 );//壁もChkInViewが必要 if( ret ){ _ASSERT( 0 ); return 1; } ret = ChkConf(); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DBeginScene( scid, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } //不透明 ret = E3DRender( scid, hsid0, 0, 1, 0, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DRender( scid, hsid1, 0, 1, 0, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } //半透明 ret = E3DRender( scid, hsid0, 1, 1, 1, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DRender( scid, hsid1, 1, 1, 1, 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = DrawText(); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DEndScene(); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DPresent( scid ); if( ret ){ _ASSERT( 0 ); return 1; } befpos1 = pos1; ret = E3DGetPos( hsid1, &pos1 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetBeforePos( hsid1 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DPCWait( 60, &retfps ); if( ret ){ _ASSERT( 0 ); return 1; } return 0; }
int OneTimeSceneInit() { int ret; result1 = 0; result2 = 0; adj1 = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); adj2 = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); n1 = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); n2 = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 campos = D3DXVECTOR3( 0.0f, 2500.0f, 0.0f ); ret = E3DSetCameraPos( campos ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetCameraDeg( 180.0f, 0.0f ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetProjection( 1000.0f, 50000.0f, 60.0f ); if( ret ){ _ASSERT( 0 ); return 1; } char gname1[MAX_PATH]; char gname2[MAX_PATH]; char gname3[MAX_PATH]; char gname4[MAX_PATH]; sprintf_s( gname1, MAX_PATH, "%s\\g_6_20_1.bmp", szMediaDir ); sprintf_s( gname2, MAX_PATH, "%s\\8.bmp", szMediaDir ); sprintf_s( gname3, MAX_PATH, "%s\\g_river_6_20_1.bmp", szMediaDir ); sprintf_s( gname4, MAX_PATH, "%s\\BG43.bmp", szMediaDir ); ret = E3DLoadGroundBMP( gname1, gname2, gname3, gname4, MAPSIZE, MAPSIZE, MAPDIV, MAPDIV, MAPHEIGHT, &hsid0 ); if( ret ){ _ASSERT( 0 ); return 1; } char signame[MAX_PATH]; sprintf_s( signame, MAX_PATH, "%s\\morob_6_26_r3.sig", szMediaDir ); ret = E3DSigLoad( signame, 0, 1.0f, &hsid1 ); if( ret ){ _ASSERT( 0 ); return 1; } char motname[MAX_PATH]; sprintf_s( motname, MAX_PATH, "%s\\morob_6_26_r3.qua", szMediaDir ); ret = E3DAddMotion( hsid1, motname, 1.0f, &motid1, &maxframe1 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetMotionKind( hsid1, motid1 ); if( ret ){ _ASSERT( 0 ); return 1; } pos1.x = 53898.0f; pos1.y = 3000.0f;//初期位置は必ず地面よりも上でなければならない。 pos1.z = 44982.0; befpos1 = pos1; D3DXVECTOR3 deg1( 0.0f, 180.0f, 0.0f ); ret = E3DSetPos( hsid1, pos1 ); _ASSERT( !ret ); ret = E3DSetDir( hsid1, deg1 ); _ASSERT( !ret ); ret = E3DSetBeforePos( hsid1 );//位置を初期化した直後に必ず呼ぶこと! if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetMovableArea( gname2, MAPSIZE, MAPSIZE, MAPDIV, MAPDIV, MAPHEIGHT + 1000.0f, &hsid2 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DCreateLight( &lid1 ); if( ret ){ _ASSERT( 0 ); return 1; } D3DXVECTOR3 ldir( 0.0f, 0.0f, 1.0f ); E3DCOLOR4UC col= {255, 255, 255, 255 }; ret = E3DSetDirectionalLight( lid1, ldir, col ); if( ret ){ _ASSERT( 0 ); return 1; } E3DCOLOR4UC fogcol; fogcol.a = 255; fogcol.r = 0; fogcol.g = 0; fogcol.b = 255; ret = E3DSetLinearFogParams( 1, fogcol, 1000.0f, 50000.0f, -1 ); if( ret ){ _ASSERT( 0 ); return 1; } char bgname1[MAX_PATH]; char bgname2[MAX_PATH]; sprintf_s( bgname1, MAX_PATH, "%s\\lake.bmp", szMediaDir ); sprintf_s( bgname2, MAX_PATH, "%s\\cloud3.bmp", szMediaDir ); ret = E3DCreateBG( scid, bgname1, bgname2, 0.001f, 0.0f, 0, 50000.0f ); if( ret ){ _ASSERT( 0 ); return 1; } return 0; }
int OneTimeSceneInit() { int ret; cameradist = 3000.0f; cameraheight = 800.0f; campos.x = (float)GROUND_SIZE * 0.5f; campos.y = (float)GROUND_HEIGHT + cameraheight; campos.z = ( (float)GROUND_SIZE * 0.5f ) - cameradist; ret = E3DSetProjection( 500.0f, 50000.0f, 60.0f ); if( ret ){ _ASSERT( 0 ); return 1; } ZeroMemory( ci, sizeof( CHARAINFO ) * CHARA_MAX ); //赤キャラ初期化 char signame[MAX_PATH]; sprintf_s( signame, MAX_PATH, "%s\\poo\\poo.sig", szMediaDir ); ret = E3DSigLoad( signame, 0, 1.0f, &(ci[CHARA_RED].hsid) ); if( ret ){ _ASSERT( 0 ); return 1; } ci[CHARA_RED].pos = D3DXVECTOR3( 1000.0f, GROUND_HEIGHT, 0.0f ); ret = E3DSetPos( ci[CHARA_RED].hsid, ci[CHARA_RED].pos ); if( ret ){ _ASSERT( 0 ); return 1; } E3DCOLOR4UC redcol = { 255, 255, 0, 0 }; ret = E3DSetToonEdge0Color( ci[CHARA_RED].hsid, -1, "dummy", redcol ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetToonEdge0Width( ci[CHARA_RED].hsid, -1, "dummy", 10.0f ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DRotateY( ci[CHARA_RED].hsid, 90.0f ); if( ret ){ _ASSERT( 0 ); return 1; } char motname[MAX_PATH]; sprintf_s( motname, MAX_PATH, "%s\\poo\\poo.moa", szMediaDir ); ret = E3DLoadMOAFile( ci[CHARA_RED].hsid, motname, 10, 1.0f ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DCreateQ( &(ci[CHARA_RED].qid) ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetBeforePos( ci[CHARA_RED].hsid ); if( ret ){ _ASSERT( 0 ); return 1; } ci[CHARA_RED].hp = HPMAX; //青きゃらの初期化 sprintf_s( signame, MAX_PATH, "%s\\poo\\poo.sig", szMediaDir ); ret = E3DSigLoad( signame, 0, 1.0f, &(ci[CHARA_BLUE].hsid) ); if( ret ){ _ASSERT( 0 ); return 1; } ci[CHARA_BLUE].pos = D3DXVECTOR3( -1000.0f, GROUND_HEIGHT, 0.0f ); ret = E3DSetPos( ci[CHARA_BLUE].hsid, ci[CHARA_BLUE].pos ); if( ret ){ _ASSERT( 0 ); return 1; } E3DCOLOR4UC bcol = { 255, 0, 0, 255 }; ret = E3DSetToonEdge0Color( ci[CHARA_BLUE].hsid, -1, "dummy", bcol ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetToonEdge0Width( ci[CHARA_BLUE].hsid, -1, "dummy", 10.0f ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DRotateY( ci[CHARA_BLUE].hsid, -90.0f ); if( ret ){ _ASSERT( 0 ); return 1; } sprintf_s( motname, MAX_PATH, "%s\\poo\\poo.moa", szMediaDir ); ret = E3DLoadMOAFile( ci[CHARA_BLUE].hsid, motname, 10, 1.0f ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DCreateQ( &(ci[CHARA_BLUE].qid) ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetBeforePos( ci[CHARA_BLUE].hsid ); if( ret ){ _ASSERT( 0 ); return 1; } ci[CHARA_BLUE].hp = HPMAX; /////////////////// E3DGetMotionNum( ci[CHARA_RED].hsid, &motnum ); motionidptr = (int*)malloc( sizeof( int ) * motnum ); if( !motionidptr ){ _ASSERT( 0 ); return 1; } ret = E3DGetMotionIDByName( ci[CHARA_RED].hsid, "idling", motionidptr + MOT_IDLING ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DGetMotionIDByName( ci[CHARA_RED].hsid, "walk", motionidptr + MOT_WALK ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DGetMotionIDByName( ci[CHARA_RED].hsid, "tsuki", motionidptr + MOT_TSUKI ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DGetMotionIDByName( ci[CHARA_RED].hsid, "kick", motionidptr + MOT_KICK ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DGetMotionIDByName( ci[CHARA_RED].hsid, "defence", motionidptr + MOT_DEFENCE ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DGetMotionIDByName( ci[CHARA_RED].hsid, "mochiage", motionidptr + MOT_MOCHIAGE ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DGetMotionIDByName( ci[CHARA_RED].hsid, "jitabata", motionidptr + MOT_JITABATA ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DGetMotionIDByName( ci[CHARA_RED].hsid, "nagerare", motionidptr + MOT_NAGERARE ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DGetMotionIDByName( ci[CHARA_RED].hsid, "tsunagi", motionidptr + MOT_TSUNAGI ); if( ret ){ _ASSERT( 0 ); return 1; } //////////////////// char bgname[MAX_PATH]; sprintf_s( bgname, MAX_PATH, "%s\\bmpfile\\a007bcg.bmp", szMediaDir ); ret = E3DCreateBG( scid, bgname, "dummy", 0.0f, 0.0f, 0, 50000.0f ); if( ret ){ _ASSERT( 0 ); return 1; } char gname[MAX_PATH]; sprintf_s( gname, MAX_PATH, "%s\\bmpfile\\gplane.mqo", szMediaDir ); ret = E3DLoadMQOFileAsGround( gname, 100.0, 0, BONETYPE_RDB2, &groundhsid ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DCreateLight( &lid1 ); if( ret ){ _ASSERT( 0 ); return 1; } D3DXVECTOR3 ldir( 0.0f, -1.0f, 1.0f ); E3DCOLOR4UC col= {255, 255, 255, 255 }; ret = E3DSetDirectionalLight( lid1, ldir, col ); if( ret ){ _ASSERT( 0 ); return 1; } confflag = 0; gameflag = 0; return 0; }