# 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.

## 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 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 on other sites

You ask sooooo many questions, and it doesn't seem like you at least try to search yourself beforehand..

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 18
• 13
• 9
• 9
• 25