Look at point in 3d

Started by
1 comment, last by GameDev.net 24 years, 5 months ago
You need to do some linear algebra! If you don't want to do the math, and you're using DirectX 7, the new utility library has this function.

D3DXMATRIX* D3DXMatrixLookAt(
D3DXMATRIX* pOut,
const D3DXVECTOR3* pEye,
const D3DXVECTOR3* pAt,
const D3DXVECTOR3* pUp
);

It builds a matrix that will rotate an object at the "pEye" point to look at the "pAt" point. "pUp" is, I think probably (the docs don't actually say :-), a rotation axis.

Advertisement

Hi,

I want to make a character that look to a point (x,y,z). Like Tombraider and Grim Fandango.
And if I move the point, the character move his/her head always looking the point.
Is there some code or ideas about it.

Thanks in advance.

Leo.

pUp is the relative "up" axis of the object. For example, as you are reading this on your computer screen, your "up" axis is pointing against the direction of gravity. On the other hand, if for some reason you tilt your head to the right, then your "up" axis is now different.

I didn't do the greatest job of explaining, but it should be enough for you to figure it out. :-)

This topic is closed to new replies.

Advertisement