> sagariさん
もしかしたら、動き的にはこんな感じでしょうか?
(MV1SetMatrixの実験用に書いたコードなので色々おかしいかもしれません・・・)
> PATOLEさん
PATOLEさんの場合、Y軸回転はモデル視点、X軸回転はカメラ視点なのかも?
なんにしても、完全に的外れだったらごめんなさい。
//- 以下、テストコード ("DxChara.x"を使用) -//
const float PITCH_RATE = TWO_PHI_F / 360.0f * 2.0f;
const float YAW_RATE = TWO_PHI_F / 360.0f * 2.0f;
const float ROLL_RATE = TWO_PHI_F / 360.0f * 2.0f;
const float MOVE_RATE = 10.0f;
void DrawMatrix( int x, int y, int color, const MATRIX& mt ) {
for ( int l = 0; l < 4; l++ ) {
DrawFormatString( x, y + 20 * l, color, "MATRIX%1d %f %6f %f %f",
l, mt.m[l][0], mt.m[l][1], mt.m[l][2], mt.m[l][3] );
}
return;
}
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 );
int mh = MV1LoadModel( "DxChara.x" );
MV1SetPosition( mh, VGet( 320.0f, -300.0f, 600.0f ) );
while ( ProcessMessage( ) == 0 && CheckHitKey( KEY_INPUT_ESCAPE ) == 0 )
{
if ( CheckHitKey( KEY_INPUT_UP ) == 1 ) {
MV1SetMatrix( mh, MMult( MGetRotAxis( VGet( 1.0f, 0.0f, 0.0f ), -PITCH_RATE ), MV1GetMatrix( mh ) ) );
}
if ( CheckHitKey( KEY_INPUT_DOWN ) == 1 ) {
MV1SetMatrix( mh, MMult( MGetRotAxis( VGet( 1.0f, 0.0f, 0.0f ), +PITCH_RATE ), MV1GetMatrix( mh ) ) );
}
if ( CheckHitKey( KEY_INPUT_Z ) == 1 ) {
MV1SetMatrix( mh, MMult( MGetRotAxis( VGet( 0.0f, 1.0f, 0.0f ), -YAW_RATE ), MV1GetMatrix( mh ) ) );
}
if ( CheckHitKey( KEY_INPUT_X ) == 1 ) {
MV1SetMatrix( mh, MMult( MGetRotAxis( VGet( 0.0f, 1.0f, 0.0f ), +YAW_RATE ), MV1GetMatrix( mh ) ) );
}
if ( CheckHitKey( KEY_INPUT_LEFT ) == 1 ) {
MV1SetMatrix( mh, MMult( MGetRotAxis( VGet( 0.0f, 0.0f, 1.0f ), -ROLL_RATE ), MV1GetMatrix( mh ) ) );
}
if ( CheckHitKey( KEY_INPUT_RIGHT ) == 1 ) {
MV1SetMatrix( mh, MMult( MGetRotAxis( VGet( 0.0f, 0.0f, 1.0f ), +ROLL_RATE ), MV1GetMatrix( mh ) ) );
}
if ( CheckHitKey( KEY_INPUT_C ) == 1 ) {
MV1SetMatrix( mh, MMult( MGetTranslate( VGet( 0.0f, 0.0f, -MOVE_RATE ) ), MV1GetMatrix( mh ) ) );
}
if ( CheckHitKey( KEY_INPUT_V ) == 1 ) {
MV1SetMatrix( mh, MMult( MGetTranslate( VGet( 0.0f, 0.0f, +MOVE_RATE ) ), MV1GetMatrix( mh ) ) );
}
if ( CheckHitKey( KEY_INPUT_SPACE ) == 1 ) {
MV1SetMatrix( mh, MGetIdent( ) );
}
ClearDrawScreen( );
MV1DrawModel( mh );
DrawFormatString( 0, 0, StrColor, "test" );
DrawMatrix( 0, 40, StrColor, MV1GetMatrix( mh ) );
ScreenFlip( );
}
DxLib_End( );
return 0;
}