Matrixes??

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Yes ...you can create chains of object from as much objects as you wish
r2d2
Posts: 211
Joined: Mon Nov 24, 2003 5:22 pm

Post by r2d2 »

So i only have to set a matrix for the moon if i want it to rotate around itself or do i have to set the same matrix as the center planet?
Do i have to use the getRelativeTransformation() = matrix command to set the matrix of the moon so that it rotates around itself or do i have to use getAbsoluteTransformation() = matrix?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

its simple like this: if you manypulate parent (in any way) you manipulate its childs and theyr childs ...its like limbs of model.

If you have parent and child and you rotate parent, child is rotated around parents centre and same angle like parent ...like limb would do. But if you rotate only child than it is rotated around its own centre and parent is unafected.
r2d2
Posts: 211
Joined: Mon Nov 24, 2003 5:22 pm

Post by r2d2 »

Well i think the matrices don't like me ^^ i just can get two object to work(md3 loader) if i add the head then it moves completely wrong it rotates right but if the body falls onto the floor and doesn't stand anymore the head is still a bit above the body and the head is not where it should be (shoulders) it is somwhere around the ass of the model the body just moves fine and the legs are the main parent like in our example the earth

Code: Select all

scene::ISceneNode* upper_n = lower->getMD3TagNode("tag_torso");
	upper_n->setParent(lower);
	lower->updateMD3TagNode("tag_torso"); // here he updates the matrix the first time because the matrix will change during animation
	upper->setPosition(upper_n->getAbsolutePosition());
	upper_n->addChild(upper);

	scene::ISceneNode* head_n = smgr->addEmptySceneNode(upper);
	head_n->setPosition(core::vector3df(0,0,15));
	head_n->addChild(head);
and now for the main part:

Code: Select all

lower->updateMD3TagNode("tag_torso"); // here he updates the matrix of the tag every time he runs through the while loop
if i add the following to the main loop:

Code: Select all

upper->getAbsoluteTransformation() = upper_n->getAbsoluteTransformation();
then the body translates correctly but the head still doesn't do what he should and if i use the upper->getRelativeTr... then the body doesn't translate then it just goes up and down like without the code
if i add the same for the head the head just turns around it's own axis(absolute) or does nothing(Relative) like the body
r2d2
Posts: 211
Joined: Mon Nov 24, 2003 5:22 pm

Post by r2d2 »

BTW this is the Code that set's the matrix for each frame, it is called one time when the mesh is loaded and reads in all the matrices:

Code: Select all


				tag.Name = Tags.Name;
				tag.Origin = core::vector3df(Tags.Postition[0],Tags.Postition[1],Tags.Postition[2]);
				tag.Rotation[0] = core::vector3df(Tags.Rotation[0][0],Tags.Rotation[0][1],Tags.Rotation[0][2]);
				tag.Rotation[1] = core::vector3df(Tags.Rotation[1][0],Tags.Rotation[1][1],Tags.Rotation[1][2]);
				tag.Rotation[2] = core::vector3df(Tags.Rotation[2][0],Tags.Rotation[2][1],Tags.Rotation[2][2]);

							tag.Transformation.makeIdentity ();
				tag.Transformation (0, 0) = tag.Rotation[0].X;
				tag.Transformation (0, 1) = tag.Rotation[1].X;
				tag.Transformation (0, 2) = tag.Rotation[2].X;
				tag.Transformation (0, 3) = tag.Origin.X;

				tag.Transformation (1, 0) = tag.Rotation[0].Y;
				tag.Transformation (1, 1) = tag.Rotation[1].Y;
				tag.Transformation (1, 2) = tag.Rotation[2].Y;
				tag.Transformation (1, 3) = tag.Origin.Y;

				tag.Transformation (2, 0) = tag.Rotation[0].Z;
				tag.Transformation (2, 1) = tag.Rotation[1].Z;
				tag.Transformation (2, 2) = tag.Rotation[2].Z;
				tag.Transformation (2, 3) = tag.Origin.Z;

				tag.Transformation (3, 0) = 0;
				tag.Transformation (3, 1) = 0;
				tag.Transformation (3, 2) = 0;
				tag.Transformation (3, 3) = 1;

				TagData[numtags].push_back(tag);
r2d2
Posts: 211
Joined: Mon Nov 24, 2003 5:22 pm

Post by r2d2 »

sorry for triple posting but here is a pic:
Image

like you can see the body is lying where it should but the head only translated around itself
r2d2
Posts: 211
Joined: Mon Nov 24, 2003 5:22 pm

Post by r2d2 »

Someone? Any idea? Plz help
jl0206
Posts: 55
Joined: Mon Jun 07, 2004 4:56 am

Post by jl0206 »

I think the directx sdk and the msdn of the d3d has a good tutorials .
Post Reply