how to set accurate ellipsoid values ?

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
muckelzwerg
Posts: 16
Joined: Wed May 04, 2005 11:38 am

how to set accurate ellipsoid values ?

Post by muckelzwerg »

Simple question :
When setting the ellipsoid values for the collisionResponseAnimator,
how do you get "good values" to accurately represent your object/modell etc.?
Just take the boundingboxes heigth, width and legth as the radiuses,
or is there sth. better ?
ayman
Posts: 51
Joined: Sat Feb 05, 2005 7:33 pm
Location: Piefke State

Post by ayman »

I don't know how to create an ellipsoid with Irrlicht besides modelling the mesh with a 3d-modelling tool.

But an ellipsoid is a 3d ellipse form as far as I know. And that is mainly a stretched sphere. You can easily calculate any point on the surface of a sphere using trigonometric functions. Multiply the results with the scaling factors that were used to create the ellipsoid and you'll get any position on the surface of the ellipsoid. Knowing any position on that surface you should be able to check for a collision. You just need pitch and yaw angle from where the other object moves in and that objects boundig box (or bounding sphere or what ever you have).

Regards
Ayman
muckelzwerg
Posts: 16
Joined: Wed May 04, 2005 11:38 am

Post by muckelzwerg »

No thats not what I mean.
Irrlicht uses Triangleselectors to calculate collisions.
And the basic way is to use a CollisionResponseAnimator with a sceneNode,
which takes care of the "movementreactions".
So you "take a node", and a few triangles an tell the Animator
to manage collision betweent the node an the triangles.
But since the node does not have a body that can be used for col. detection,
you have to set an ellipsoid that will collide with the triangles in your
selector.
The API tells to get the values for the ellipsoid like :

Code: Select all

core::aabbox<f32> box = yourSceneNode->getBoundingBox();
core::vector3df radius = box.MaxEdge - box.getCenter();
Which, if I am correct, will result in a sphere, that completely encloses
the boundingbox of the node.
But most meshes won't have a sphere-like body.
So I'm aksing if there are some ways to get better settings for
the ellipsoid.
Maybe using the 3 length values of the bbox and increasing them a bit,
or sth. else.
ayman
Posts: 51
Joined: Sat Feb 05, 2005 7:33 pm
Location: Piefke State

Post by ayman »

Sorry, but I still have problems to get your point. Here I understand your node has no attached mesh:
But since the node does not have a body that can be used for col. detection, you have to set an ellipsoid that will collide with the triangles in your selector.
... but here you are talking about the need to find proper metrics of an attached mesh:
But most meshes won't have a sphere-like body. So I'm aksing if there are some ways to get better settings for the ellipsoid.
Anyhow, maybe it would be a good idea to break down your model into a tree of parts and define separate bounding ellipsoids for the parts. So it would be easier to find a proper ellipsoid shape for each of them?
muckelzwerg
Posts: 16
Joined: Wed May 04, 2005 11:38 am

Post by muckelzwerg »

Code: Select all

virtual ISceneNodeAnimatorCollisionResponse* irr::scene::ISceneManager::createCollisionResponseAnimator  	(   	ITriangleSelector *   	 world,
		ISceneNode *  	sceneNode,
		const core::vector3df &  	ellipsoidRadius = core::vector3df(30, 60, 30),
		const core::vector3df &  	gravityPerSecond = core::vector3df(0,-100.0f, 0),
		const core::vector3df &  	ellipsoidTranslation = core::vector3df(0, 0, 0),
		f32  	slidingValue = 0.0005f
	)  	[pure virtual]
  	

Creates a special scene node animator for doing automatic collision detection and response. See ISceneNodeAnimatorCollisionResponse for details.

Parameters:
world: 	Triangle selector holding all triangles of the world with which the scene node may collide. You can create a triangle selector with ISceneManager::createTriangleSelector();

sceneNode: 	SceneNode which should be manipulated. After you added this animator to the scene node, the scene node will not be able to move through walls and is affected by gravity.

ellipsoidRadius: 	Radius of the ellipsoid with which collision detection and response is done. If you have got a scene node, and you are unsure about how big the radius should be, you could use the following code to determine it:
                    core::aabbox<f32> box = ourSceneNode->getBoundingBox();
                    core::vector3df radius = box.MaxEdge - box.getCenter();

gravityPerSecond: 	Sets the gravity of the environment. A good example value would be core::vector3df(0,-100.0f,0) for letting gravity affect all object to fall down. For bigger gravity, make increase the length of the vector. You can disable gravity by setting it to core::vector3df(0,0,0).

ellipsoidTranslation: 	By default, the ellipsoid for collision detection is created around the center of the scene node, which means that the ellipsoid surrounds it completely. If this is not what you want, you may specify a translation for the ellipsoid.

Returns:
Returns the animator. Attach it to a scene node with ISceneNode::addAnimator() and the animator will cause it to do collision detection and response. If you no longer need the animator, you should call ISceneNodeAnimator::drop(). See IUnknown::drop() for more information. 
....
ellipsoidRadius: Radius of the ellipsoid with which collision detection and response is done. If you have got a scene node, and you are unsure about how big the radius should be, you could use the following code to determine it:
core::aabbox<f32> box = ourSceneNode->getBoundingBox();
core::vector3df radius = box.MaxEdge - box.getCenter();
....
thats what I'm talking about
SARIN
Posts: 139
Joined: Fri Oct 29, 2004 3:53 am

Post by SARIN »

they would not have a sphere like body. only ellipsoid, as is said.
the Extent and Center values are vector3dfs. this means that if Extent equals vector3df(10,5,2) and center equals vector3df(3,2,1) then the result would be vector3df(10-3,5-2,2-1), or vector3df(7,3,1)
also, remember that radius is half the diameter...
Post Reply