/* 影を作成するために関係する処理を行ないます */ int Batch_Render::BatchCreateShadow(){ /* 変数の初期化 */ int ech = 0;// エラーチェック変数 int ShadowCRTFlug = 0;// 影を描画するテクスチャが作られたかどうか const D3DXVECTOR3 ldir1( -1.0, -1.0, -1.0); const SIZE TextureSize = { 1028, 1028}; // Zバッファのバイアスを設定 ech = E3DSetShadowBias( 0.005f); if( ech != 0){ _ASSERT( 0 ); }; // 影の方向を指定します ech = E3DSetShadowMapLightDir( ldir1); if( ech != 0){ _ASSERT( 0 ); }; // テクスチャの作成 ech = E3DCreateRenderTargetTexture( TextureSize, D3DFMT_A8R8G8B8, &ShadowScid, &ShadowTexture, &ShadowCRTFlug); if( ech != 0){ _ASSERT( 0 ); }; if( ShadowCRTFlug == 1){// 作成に成功したら ShadowFlag = 1; } return 0; }
int OneTimeSceneInit() { int ret; D3DXVECTOR3 campos = D3DXVECTOR3( 0.0f, 800.0f, -2000.0 ); 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, 30000.0f, 60.0f ); if( ret ){ _ASSERT( 0 ); return 1; } char signame[MAX_PATH]; sprintf_s( signame, MAX_PATH, "%s\\poo\\poo.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\\poo\\idling.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; } ret = E3DCreateLight( &lid1 ); if( ret ){ _ASSERT( 0 ); return 1; } D3DXVECTOR3 ldir( 0.0f, 0.0f, 1.0f ); E3DCOLOR4UC col= {255, 200, 200, 200 }; ret = E3DSetDirectionalLight( lid1, ldir, col ); if( ret ){ _ASSERT( 0 ); return 1; } int okflag; SIZE largesize = { 256, 256 }; SIZE smallsize = { 64, 64 }; ret = E3DCreateRenderTargetTexture( largesize, D3DFMT_X8R8G8B8, &scid_org, &texid_org, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } E3DCOLOR4UC clearcol = { 0, 0, 0, 0 }; ret = E3DSetClearCol( scid_org, clearcol ); _ASSERT( !ret ); ret = E3DCreateRenderTargetTexture( smallsize, D3DFMT_A8R8G8B8, &scid_small, &texid_small, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } ret = E3DCreateRenderTargetTexture( smallsize, D3DFMT_A8R8G8B8, &scid_work, &texid_work, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } ret = E3DCreateRenderTargetTexture( smallsize, D3DFMT_A8R8G8B8, &scid_blur, &texid_blur, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } ret = E3DCreateRenderTargetTexture( largesize, D3DFMT_A8R8G8B8, &scid_final, &texid_final, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } char spname[MAX_PATH]; sprintf_s( spname, MAX_PATH, "%s\\dummy256.png", szMediaDir ); ret = E3DCreateSprite( spname, 0, 0, &spid1 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetTextureToDispObj( -2, spid1, texid_org ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DCreateSprite( spname, 0, 0, &spid2 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetTextureToDispObj( -2, spid2, texid_blur ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DCreateSprite( spname, 0, 0, &spid3 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetTextureToDispObj( -2, spid3, texid_final ); if( ret ){ _ASSERT( 0 ); return 1; } return 0; }
int OneTimeSceneInit() { int ret; D3DXVECTOR3 campos = D3DXVECTOR3( -546.0f, 400.0f, -1845.0f ); ret = E3DSetCameraPos( campos ); if( ret ){ _ASSERT( 0 ); return 1; } D3DXVECTOR3 camtar = D3DXVECTOR3( 3.2733f, 450.0f, 70.6515f ); D3DXVECTOR3 camup = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); ret = E3DSetCameraTarget( camtar, camup ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetProjection( 1000.0f, 30000.0f, 60.0f ); if( ret ){ _ASSERT( 0 ); return 1; } char mqoname[MAX_PATH]; sprintf_s( mqoname, MAX_PATH, "%s\\hdrscene3.mqo", szMediaDir ); ret = E3DLoadMQOFileAsGround( mqoname, 10.0f, 0, BONETYPE_RDB2, &hsid0 ); if( ret ){ _ASSERT( 0 ); return 1; } //ピクセル単位のPhongライティングにする ret = E3DSetShaderType( hsid0, COL_PPHONG ); _ASSERT( !ret ); ret = E3DCreateLight( &lid1 ); if( ret ){ _ASSERT( 0 ); return 1; } D3DXVECTOR3 lpos( 1000.0f, 0.0f, 3500.0f ); E3DCOLOR4UC col= {255, 255, 255, 255 }; ret = E3DSetPointLight( lid1, lpos, 9000.0f, col ); if( ret ){ _ASSERT( 0 ); return 1; } //HDR用の強い光をセット E3DCOLOR4F diffuse = { 10.0f, 10.0f, 10.0f, 1.0f }; E3DCOLOR4F specular = { 0.2f, 0.2f, 0.2f, 1.0f }; ret = E3DSetHDRLightDiffuse( lid1, diffuse ); _ASSERT( !ret ); ret = E3DSetHDRLightSpecular( lid1, specular ); _ASSERT( !ret ); //トーンマップのテクスチャを作成 int toneok = 0; ret = E3DCreateToneMapTexture( 4, toneformat, &tonemapid, &toneok ); if( ret ){ _ASSERT( 0 ); return 1; } int okflag; SIZE orgsize = { 640 / 2, 480 }; SIZE small4 = { orgsize.cx / 4, orgsize.cy / 4 }; SIZE small8 = { orgsize.cx / 8, orgsize.cy / 8 }; ret = E3DCreateRenderTargetTexture( orgsize, hdrformat, &scid_org, &texid_org, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } ret = E3DCreateRenderTargetTexture( small4, hdrformat, &scid_small, &texid_small, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } ret = E3DCreateRenderTargetTexture( small4, D3DFMT_A8R8G8B8, &scid_bright, &texid_bright, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } ret = E3DCreateRenderTargetTexture( small8, D3DFMT_A8R8G8B8, &scid_bloom0, &texid_bloom0, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } ret = E3DCreateRenderTargetTexture( small8, D3DFMT_A8R8G8B8, &scid_bloom1, &texid_bloom1, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } ret = E3DCreateRenderTargetTexture( small8, D3DFMT_A8R8G8B8, &scid_work, &texid_work, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } ret = E3DCreateRenderTargetTexture( small8, D3DFMT_A8R8G8B8, &scid_bloom2, &texid_bloom2, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } ret = E3DCreateRenderTargetTexture( orgsize, D3DFMT_A8R8G8B8, &scid_final, &texid_final, &okflag ); if( ret || !okflag ){ _ASSERT( 0 ); return 1; } char spname[MAX_PATH]; sprintf_s( spname, MAX_PATH, "%s\\dummy256.png", szMediaDir ); ret = E3DCreateSprite( spname, 0, 0, &spid1 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetTextureToDispObj( -2, spid1, texid_org ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DGetSpriteSize( spid1, &spw1, &sph1 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DCreateSprite( spname, 0, 0, &spid2 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DSetTextureToDispObj( -2, spid2, texid_final ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DGetSpriteSize( spid2, &spw2, &sph2 ); if( ret ){ _ASSERT( 0 ); return 1; } keydir = 0; middlegray = 0.1f; threshold = 9.5f; offset = 7.0f; return 0; }