Could someone explain wht this worked.
Just want to understand what I have done, didnt know how to fix something and done something random and it worked. haha. So below I had an issue that when I placed the cursor on screen the camera would view everything upside down and the right/left was inversed. I randomly added the second mCamera.Pitch(dy) and it sorted the problem. Just would like to know how. void ShapesApp::OnMouseMove(WPARAM btnState, int x, int y) { // Make each pixel correspond to a quarter of a degree. float dx = XMConvertToRadians(0.25f*static_cast<float>(x - mLastMousePos.x)); //0.25f is related with the sensitivity float dy = XMConvertToRadians(0.25f*static_cast<float>(y - mLastMousePos.y)); mCamera.Pitch(dy); mCamera.RotateY(dx); //Rotate around the Y axis - Worlds "Up" Direction mCamera.Pitch(dy); } mLastMousePos.x = x; mLastMousePos.y = y; Pitch; void Camera::Pitch(float angle) { // Rotate up and look vector about the right vector. XMMATRIX R = XMMatrixRotationAxis(XMLoadFloat3(&mRight), angle); XMStoreFloat3(&mUp, XMVector3TransformNormal(XMLoadFloat3(&mUp), R)); XMStoreFloat3(&mLook, XMVector3TransformNormal(XMLoadFloat3(&mLook), R)) mViewDirty = true; } Rotate void Camera::RotateY(float angle) { // Rotate the basis vectors about the world y-axis. XMMATRIX R = XMMatrixRotationY(angle); XMStoreFloat3(&mRight, XMVector3TransformNormal(XMLoadFloat3(&mRight), R)); XMStoreFloat3(&mUp, XMVector3TransformNormal(XMLoadFloat3(&mUp), R)); XMStoreFloat3(&mLook, XMVector3TransformNormal(XMLoadFloat3(&mLook), R)); mViewDirty = true; }
what is mRight? It's going to be difficult to figure out whats going on unless you show some results. Did you debug and look at what all your values were before and after you added the second pitch() call?
on May 01 `17
iedoc
Sign in to comment