トップページ > 過去ログ > 記事閲覧
3D空間内で動画を再生することは可能か
名前:PATOLE 日時: 2010/07/19 18:04

題名どおりですが、3Dの空間の中で、 3Dモデルを描画するのと同じように、動画を再生することって可能でしょうか。 可能であれば、方法を教えていただけると嬉しいです。

Page: 1 |

Re: 3D空間内で動画を再生することは可能か ( No.1 )
名前:いっち 日時:2010/07/19 20:42

普通に動画をLoadGraphして、グラフィックハンドルをテクスチャに指定すれば良いのではないでしょうか? 具体的には以下のような感じです。 //- 以下、サンプルコード ("clock.avi"を使用) -// #include "DxLib.h" const float CAM_MOVE_RATE = 5.0f; int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { ChangeWindowMode( TRUE ); if ( DxLib_Init( ) == -1 ) return -1; SetDrawScreen( DX_SCREEN_BACK ); int StrColor = GetColor( 255, 255, 255 ); VERTEX3D Vertex[4]; WORD Index[6] = { 0, 1, 2, 3, 2, 1 }; Vertex[0].pos = VGet( -200.0f, 200.0f, 0.0f ); Vertex[0].u = 0.0f; Vertex[0].v = 0.0f; Vertex[1].pos = VGet( 200.0f, 200.0f, 0.0f ) ; Vertex[1].u = 1.0f; Vertex[1].v = 0.0f; Vertex[2].pos = VGet( -200.0f, -200.0f, 0.0f ) ; Vertex[2].u = 0.0f; Vertex[2].v = 1.0f; Vertex[3].pos = VGet( 200.0f, -200.0f, 0.0f ) ; Vertex[3].u = 1.0f; Vertex[3].v = 1.0f; Vertex[0].norm = Vertex[1].norm = Vertex[2].norm = Vertex[3].norm = VGet( 0.0f, 0.0f, -1.0f ); Vertex[0].dif = Vertex[1].dif = Vertex[2].dif = Vertex[3].dif = GetColorU8( 255, 255, 255, 255 ); Vertex[0].spc = Vertex[1].spc = Vertex[2].spc = Vertex[3].spc = GetColorU8( 0, 0, 0, 0 ); Vertex[0].su = Vertex[1].su = Vertex[2].su = Vertex[3].su = 0.0f; Vertex[0].sv = Vertex[1].sv = Vertex[2].sv = Vertex[3].sv = 0.0f; int mgh = LoadGraph( "clock.avi" ); PlayMovieToGraph( mgh ); int tgh = MakeScreen( 128, 128 ); float cx = 0.0f, cy = 0.0f; while ( ProcessMessage( ) == 0 && CheckHitKey( KEY_INPUT_ESCAPE ) == 0 ) { if ( !GetMovieStateToGraph( mgh ) ) break; if ( CheckHitKey( KEY_INPUT_UP ) ) cy -= CAM_MOVE_RATE; if ( CheckHitKey( KEY_INPUT_DOWN ) ) cy += CAM_MOVE_RATE; if ( CheckHitKey( KEY_INPUT_LEFT ) ) cx -= CAM_MOVE_RATE; if ( CheckHitKey( KEY_INPUT_RIGHT ) ) cx += CAM_MOVE_RATE; SetDrawScreen( tgh ); ClearDrawScreen( ); DrawExtendGraph( 0, 0, 128, 128, mgh, FALSE ); SetDrawScreen( DX_SCREEN_BACK ); SetCameraPositionAndTargetAndUpVec( VGet( cx, cy, -800.0f ), VGet( 0.0f, 0.0f, 0.0f ), VGet( 0.0f, 1.0f, 0.0f ) ); ClearDrawScreen( ); DrawFormatString( 0, 0, StrColor, "test" ); DrawPolygonIndexed3D( Vertex, 4, Index, 2, tgh, FALSE ); ScreenFlip( ); } DxLib_End( ); return 0; }
Re: 3D空間内で動画を再生することは可能か ( No.2 )
名前:PATOLE 日時:2010/07/21 14:48

なるほど!その方法があったのですね。 ありがとうございます!

Page: 1 |