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.

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

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• Forum Statistics

• Total Topics
634136
• Total Posts
3015756
×