Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Yaw and Pitch against the skyplane

$
0
0
I need to obtain the correct yaw and pitch against the skyplane which is located at the camera position plus the far distance times the look direction, I can handle the yaw, I got the skyplane yaw'ed between 0 and 1.57 radians, which is good only when the camera is looking in a direction without elevations. If I do elevations, let's pretend the original pitch of the skyplane is 1.57 because I have the plane sitting flat, if I raise the camera up to right above to the sky, the camera is pitching from 0 to 4.7, and the skyplane is 1.57->3.14... There is no problem when I don't yaw the camera, I don't need to yaw the camera when I look right up to the sky above me. So the the yaw is 0 and the pitch is 3.14 when looking up. When looking forward, the skyplane's yaw is 0->1.57 Camera: (Pitch) 0(flat)->4.7(vertically upwards) (Yaw): N/A Skyplane: (Pitch) 1.57(Facing camera)-3.14(facing down to camera) (Yaw): 0-1.57-> 0 Now the problem is when I pitch the camera to 4.7, I don't really want to yaw the skyplane, but as you know, I have to tell the camera the up vector, it will orientate the camera somehow which then gives me a yaw, so when I look up vertically, the sky is skewed. Another option to calculate the matrix for the skyplane is this: const D3DXMATRIX* v = m_pCam->GetViewMatrix(); const D3DXMATRIX* p = m_pCam->GetProjMatrix(); D3DXMATRIX vp = *v * *p; D3DXVECTOR3 camPos = m_pCam->GetPos(); D3DXVECTOR4 camPosVec4(camPos.x, camPos.y, camPos.z, 1); // camPosVec4 * vp; D3DXVECTOR4 targetVec4; D3DXVec4Transform(&targetVec4, &camPosVec4, &vp); D3DXVECTOR3 targetPos(targetVec4.x, targetVec4.y, targetVec4.z);

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>