Jump to content
  • Advertisement
Sign in to follow this  

3D Yaw and Pitch against the skyplane

This topic is 811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);
Edited by lucky6969b

Share this post

Link to post
Share on other sites

I like the other option more.

Is that code C++? That looks ugly. Don't they have namespaces there like
using D3DLinAlg; ?
How do the dare overload the  operator * where it does not commute?
Did they hear of CamelCase?
What is this Transform? Do they mean: Multiplication? Why do they order the args in such a strange way?

Maybe switch to unity and see the beauty buried below that C++? dunno..

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!