ありがとうございます!…ですが…
#include "DxLib.h"
#include <cmath>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
int Mx, My;
float xr=0.0f, yr=0.0f;
MV1_COLL_RESULT_POLY HitPoly; /*あたり判定*/
VECTOR neard,fard;
SetOutApplicationLogValidFlag(FALSE); /*log*/
ChangeWindowMode(TRUE); /*窓表示*/
SetUseDirect3DVersion(DX_DIRECT3D_11); /*directX ver*/
DxLib_Init(); /*init*/
int model = MV1LoadModel("38t/col.mv1");
int ok = MV1SetupCollInfo(model, -1, 4, 4, 4, -1);
while (ProcessMessage() == 0 && CheckHitKeyAll() == 0) {
GetMousePoint(&Mx, &My);
SetDrawScreen(DX_SCREEN_BACK);
xr = 45.0f / 180.0f*DX_PI_F;
yr = 45.0f / 180.0f*DX_PI_F;
SetCameraNearFar(0.01f, 6.0f);
SetCameraPositionAndTargetAndUpVec(VGet(6.0f*sin(yr)*cos(xr), 6.0f*sin(xr), 6.0f*cos(yr)*cos(xr)), VGet(0, 0, 0), VGet(0, 1, 0));
neard = ConvScreenPosToWorldPos(VGet((float)Mx, (float)My, 0.0f));
fard = ConvScreenPosToWorldPos(VGet((float)Mx, (float)My, 1.0f));
HitPoly = MV1CollCheck_Line(model, -1, neard, fard, -1);
SetDrawScreen(DX_SCREEN_BACK);
ClearDrawScreen();
xr = 45.0f / 180.0f*DX_PI_F;
yr = -45.0f / 180.0f*DX_PI_F;
SetCameraNearFar(0.01f, 6.0f);
SetCameraPositionAndTargetAndUpVec(VGet(6.0f*sin(yr)*cos(xr), 6.0f*sin(xr), 6.0f*cos(yr)*cos(xr)), VGet(0, 0, 0), VGet(0, 1, 0));
MV1DrawModel(model);
DrawLine3D(neard, fard, GetColor(255, 0, 0));
DrawFormatString(0, 0, GetColor(255, 255, 255),
"%6.2f,%6.2f,%6.2f \n %6.2f, %6.2f, %6.2f",
neard.x, neard.y, neard.z,
fard.x, fard.y, fard.z
);
DrawFormatString(240, 0, GetColor(255, 255, 255),
"canhit=%d\nHitFlag = %d",
ok,
HitPoly.HitFlag
);
ScreenFlip();
}
DxLib_End();
return 0;
}
このようにテスト用のコードを作ってみたところ、
により 0x00007FF7588968DA で例外がスローされました (test.exe 内): 0xC0000005: 場所 0x000002D065FF05BC の読み取り中にアクセス違反が発生しました が発生しました
とエラーが出てしまいます…
drive.google.com/file/d/1BL5wr7DrR2Hi-1ngfnLLuubU266MqmSs/view?usp=sharing
すべてのファイルはこちらになります。