Is there something strange with the ISceneNode->SetPositi

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
exal
Posts: 60
Joined: Tue Feb 24, 2004 9:05 am

Is there something strange with the ISceneNode->SetPositi

Post by exal »

When I am using the code below I get a very strange behavious. When I just set the camera in the startup of the program the character moves like expected.

But when I set the camera according to the position of the character model it seems like the model will start to rotate around the camera position even though it should have nothing to do with the camera matrix. No parent is set or anything like that.

Any ideas about this?

Code: Select all

irr::core::matrix4 modelMat;
	irr::f32 moveSpeed = 100.0f;
	modelMat = myModel->getAbsoluteTransformation();
	
	irr::core::vector3df vecZ(modelMat.M[8] * moveSpeed, 	modelMat.M[9] * moveSpeed, 
		modelMat.M[10] * moveSpeed);
	irr::core::vector3df vecY(modelMat.M[4] * moveSpeed, 	modelMat.M[5] * moveSpeed, 
		modelMat.M[6] * moveSpeed);
	irr::core::vector3df modPos = myModel->getAbsolutePosition();
	modPos.X = modPos.X + vecZ.X;
	modPos.Y= modPos.Y + vecZ.Y;
	modPos.Z = modPos.Z + vecZ.Z;
	modPos.X = modPos.X + vecY.X;
	modPos.Y= modPos.Y + vecY.Y;
	modPos.Z = modPos.Z + vecY.Z;
	aCam->setPosition(modPos);
	//myModel->setPosition(myModel->getAbsolutePosition());
	aCam->setTarget(myModel->getAbsolutePosition());

Guest

Post by Guest »

Hmmm. What does AbsoluteTransformation() do?

The documentation does not say.

But maybe what it does is give you the result of applying both the model matrix and the projection matrix - and the projection matrix depends on the camera location and rotation. Just a guess, though.
Post Reply