3Dプログラミングを勉強しようと思い、
新・ゲームプログラミングの館さんの
「3d.1 3Dモデルを表示してみよう」でプロジェクト一式をダウンロードしてみたのですが、
実行するとコンパイルは通るのですが、ミクちゃんがでるとすぐに
「3Dsample.exe は動作を停止しました」と、出てきてプログラムの終了をしなければなりません。
その後、「3d.2 カメラを回転させてみよう」のプログラムを書き足してみたのですが、状況は変わりません。
どうしたらいいのでしょうか?
#include <DxLib.h>
#include <math.h>
static const float ROTATE_SPEED = DX_PI_F/90;
void rotate( float* x, float* y, const float ang, const float mx, const float my )
{
const float ox = * x-mx, oy = * y-my;
* x = ox * cos(ang) + oy * sin(ang);
* y = -ox * sin(ang) + oy * cos(ang);
* x += mx;
* y += my;
}
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK );
float cameraX = 0, cameraZ = -20;
const float targetX = 0, targetZ = 0;
//3Dモデルの読み込み
int ModelHandle = MV1LoadModel( "dat/Lat式ミク/Lat式ミクVer2.3_Normal.pmd" ) ;
//奥行0.1~1000までをカメラの描画範囲とする
SetCameraNearFar( 0.1f, 1000.0f ) ;
while(!ScreenFlip()&&!ProcessMessage()&&!ClearDrawScreen())
{
if( CheckHitKey(KEY_INPUT_LEFT) > 0 )
{
rotate(&cameraX, &cameraZ, +ROTATE_SPEED, targetX, targetZ);
}
if( CheckHitKey(KEY_INPUT_RIGHT) > 0 )
{
rotate(&cameraX, &cameraZ, -ROTATE_SPEED, targetX, targetZ);
}
SetCameraPositionAndTarget_UpVecY( VGet( cameraX, 10, cameraZ ), VGet( targetX, 10.0f, targetZ ) ) ;
// 3Dモデルの描画
MV1DrawModel( ModelHandle ) ;
}
DxLib_End();
return 0;
}
よろしくお願いします。