Archived

This topic is now archived and is closed to further replies.

guts

World/View Matrix

Recommended Posts

hi! i want to use my own view and world matrix instead of using glTranslatef, etc. (i''m using opengl) hi calculate my worldmatrix this way (for each scenenode in the world):
void CSceneNode::MakeTransform(const CVector3& position, const CVector3& scale, const CQuaternion& orientation, CMatrix4& destMatrix) const
{
	destMatrix = CMatrix4::IDENTITY;
	//Reihenfolge:
	//  1. Skalierung
	//  2. Rotatation
	//  3. Translation

	CMatrix3 rot3, scale3;
	orientation.ToMatrix(rot3);

	scale3 = CMatrix3::ZERO;
	scale3.m[0] = scale.x;
	scale3.m[4] = scale.y;
	scale3.m[8] = scale.z;

	destMatrix = rot3 * scale3;
	destMatrix.SetTransform(position);
}
[/CODE]

and my view matrix i calculate this way:
[CODE]
void CCamera::UpdateViewMatrix()
{
	CMatrix3 rot;
	mAbsOrientation.ToMatrix(rot);

	//Translation relativ zu neuer Achse
	CMatrix3 rotT = rot.Transpose();
	CVector3 trans = -rotT * mAbsPos;

	mViewMatrix = rotT;
	mViewMatrix.m[12] = trans.x;
	mViewMatrix.m[13] = trans.y;
	mViewMatrix.m[14] = trans.z;
	mViewMatrix.m[15] = 1.0f;
}
[/CODE]

before rendering the scenenode I set the world and view matrix (so i multiply them)

my problem is that the camera seems to rotate around the 0,0,0 Vector.
do you have any idea what''s wrong?
(the rotations for scenenode work fine, the problem just occurs with the camera ...)

thanks in advance.
cu
guts (you know, the guy form berserk :D)
   

Share this post


Link to post
Share on other sites