Advertisement Jump to content
Sign in to follow this  
LukeSkyRunner

Point object to...

This topic is 5272 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 wrote this function that points the camera according to the DX SDK:
SG_M4X4  m4x4LookAt(SG_VECTOR3 v3Eye,
					SG_VECTOR3 v3Center,
					SG_VECTOR3 v3Up = SG_VECTOR3(0,1,0))
{
	SG_VECTOR3 v3Z = sgNormalize3(v3Center - v3Eye);
	SG_VECTOR3 v3X = sgNormalize3(sgCross3(v3Up, v3Z));
	SG_VECTOR3 v3Y = sgCross3(v3Z, v3X);

	SG_M4X4 r
	(
		v3X.x,            v3Y.x,            v3Z.x,            0,
		v3X.y,            v3Y.y,            v3Z.y,            0,
		v3X.z,            v3Y.z,            v3Z.z,            0,
	   -sgDP3(v3X,v3Eye),-sgDP3(v3Y,v3Eye),-sgDP3(v3Z,v3Eye), 1
	);

	return r;
}
But, how can I use this function to point the world matrix instead of view?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by LukeSkyRunner But, how can I use this function to point the world matrix instead of view?


Simple. They are the inverse of each other.
	SG_M4X4 r
(
v3X.x, v3X.y, v3X.z, 0,
v3Y.x, v3Y.y, v3Y.z, 0,
v3Z.x, v3Z.y, v3Z.z, 0,
v3Eye.x, v3Eye.y, v3Eye.z, 1
);

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!