Distance between two objects

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
levan
Halfling
Posts: 41
Joined: Sun Oct 27, 2013 11:57 pm
x 1

Distance between two objects

Post by levan »

I have a two SceneNode (NodePsiRot and NodeFiRot) that are constantly moving on a scene. I need to know a distance between these two objects on every frame while they are moving. Is it correct how I am doint that :

Ogre::Vector3 r=NodePsiRot->getPosition();
Ogre::Vector3 f=NodeFiRot->getPosition();

Ogre::Real Dist = r.distance(f);


Or may be there is a easier way ?


best

levan
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: Distance between two objects

Post by tod »

Ogre Node position is relative to parent node. In this case it doesn't matter though. :D
It's ok to get distance that way, but it's better to use square distance.
Post Reply