3 basic questions

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.
Post Reply
Guest

3 basic questions

Post by Guest »

Hi for all and congratulations for your great engine.

I have 3 basic questions, (sorry for my bad english)

1.- How to make an object child to another node->addChild(node2) ??
2.- How to get the distance from two objects
3.- How to make an object pointing to another objetc or point in 3d space or how to get the angel beetwen the two objects and modify the axis angle of one to point to another.

thanks a lot in advance.

Jose Luis
Guest

Post by Guest »

sorry, i edit my message again to get out the errors:


1.- How to make an object child to another: node->addChild(node2) ??
2.- How to get the distance from two objects
3.- How to make an object pointing to another object, or point at ome point in 3d space, or how to get the angle beetwen the two objects, and modify the axis angle?.

thanks a lot in advance.

Jose Luis
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

1.- How to make an object child to another: node->addChild(node2) ??
Yes, this will work. Or, you can assign the parent when you create the node.

scenemanager->addAnimatedMeshSceneNode(mesh, parent, id, position, rotation, scale)
2.- How to get the distance from two objects
I think this would work.

Code: Select all

irr::vector3df getDelta(irr::vector3df posSource, irr::vector3df posDestination){
    irr::vector3df tempVector;
    tempVector.X = posSource.X - posDestination.X;
    tempVector.Y = posSource.Y - posDestination.Y;
    tempVector.Z = posSource.Z - posDestination.Z;
    return tempVector;
}
3.- How to make an object pointing to another objetc or point in 3d space or how to get the angel beetwen the two objects and modify the axis angle of one to point to another.
Well, only the camera has "camera->setTarget(vector3df pos)" that you can use to specify the position of the object to be looked at.

Looking through the code, it's just some geometry. You could do something like this, or calculate the angle yourself.

Code: Select all

core::vector3df pos = getAbsolutePosition();
		core::vector3df tgtv = [color=red]Target[/color] - pos;
		tgtv.normalize();

		core::vector3df up = UpVector;
		up.normalize();

		f32 dp = tgtv.dotProduct(up);
		if ((dp > -1.0001f && dp < -0.9999f) ||
			(dp < 1.0001f && dp > 0.9999f))
			up.X += 1.0f;

		View.buildCameraLookAtMatrixLH(pos, Target, up);
		recalculateViewArea();
Crud, how do I do this again?
Guest

Post by Guest »

thanks a lot.

Code: Select all

core::vector3df pos = getAbsolutePosition();
		core::vector3df tgtv = [color=red]Target[/color] - pos;
		tgtv.normalize();

		core::vector3df up = UpVector;
		up.normalize();

		f32 dp = tgtv.dotProduct(up);
		if ((dp > -1.0001f && dp < -0.9999f) ||
			(dp < 1.0001f && dp > 0.9999f))
			up.X += 1.0f;

		View.buildCameraLookAtMatrixLH(pos, Target, up);
		recalculateViewArea();
[/quote]
Post Reply