rate up
1
rate down
How would I go about getting the camera to move with the mouse cursor. - Directx12
Currently I have this; which is Frank Lunas text; void ShapesApp::OnMouseMove(WPARAM btnState, int x, int y) { if((btnState & MK_LBUTTON) != 0) //rotate the cameras look direction { // Make each pixel correspond to a quarter of a degree. float dx = XMConvertToRadians(0.25*static_cast<float>(x - mLastMousePos.x)); float dy = XMConvertToRadians(0.25*static_cast<float>(y - mLastMousePos.y)); mCamera.Pitch(dy); mCamera.RotateY(dx); //Rotate around the Y axis - Worlds "Up" Direction } mLastMousePos.x = x; mLastMousePos.y = y; } This will allow me to click and drag rotate The camera, I am honestly stumped on how to modify this to allow the camera to move in time with the mouse cursor without having to click. Many tutorials are previous versions of directx and Im new to all this. Any help would be aappreciated!
Chosen Answer
rate up
0
rate down
This is just a logic problem, nothing d3d related. But all you have to do is remove the the if statement making sure the mouse button is down. void ShapesApp::OnMouseMove(WPARAM btnState, int x, int y) { // Make each pixel correspond to a quarter of a degree. float dx = XMConvertToRadians(0.25*static_cast<float>(x - mLastMousePos.x)); float dy = XMConvertToRadians(0.25*static_cast<float>(y - mLastMousePos.y)); mCamera.Pitch(dy); mCamera.RotateY(dx); //Rotate around the Y axis - Worlds "Up" Direction }
rate up
1
rate down
Thanks very much! I was over thinking it.
Sign in to answer!