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

Make an object face a position

$
0
0

Hello I have a problem to make the object orient to face a position. To get the angle I'm using the code found in thug1 source code, But it seems to not work.

 

float AngleY(D3DXMATRIX& orient, D3DXVECTOR3& from, D3DXVECTOR3& to)
{
	Vertex tempHeading = *(Vertex*)&(to - from);
	tempHeading.ProjectToPlane(*(Vertex*)&orient.m[Y]);
	if (!tempHeading.Length())
	{
		// If our rot axis is along Y, for example, the
		// target heading is right above us... Can't pick
		// a rotation!
		return (0.0f);
	}
	tempHeading.Normalize();


	// while we have these two vectors, find the angle between them...
	float angCos = D3DXVec3Dot((D3DXVECTOR3*)&orient …

Viewing all articles
Browse latest Browse all 17063

Trending Articles