Sign in to follow this  
LukeSkyRunner

Point object to...

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this