Game Development Community

Object extent x,y,z (width, depth, height)

by Peterjohn Griffiths · in Torque Game Engine · 01/08/2007 (8:08 pm) · 2 replies

I am trying to create a trigger object and have two waypointmarker objects created at the same time in relation to the position and size of the trigger object.
In order to do this I need to get the trigger objects width, depth and height but can only seem to get the scale.
I have looked around and was expecting to find an extent method with the width, depth and height in x,y,z format but there isn't one.
I found a method getObjectBox() and thought this might give me the information for the bounding box and that would of done but it doesn't seem to return anything useful.
I have now run out of ideas, and would think this would be as simple as the getPosition() method but I just can't seem to find the correct method to return this information.
I have tried trigger.dump but can't see anything available that might help further.
Any help is appriciated.
Many thanks.
Pejayuk.

#1
01/11/2007 (2:36 am)
I have found a better way of doing this using object groupings posted http://www.garagegames.com/mg/forums/result.thread.php?qt=56024
This will allow me to create a group of objects and have them all move relative to each other so the size of the bounding box or object isn't needed any more.
Thanks for reading.
#2
01/16/2007 (11:59 pm)
While working on the local postion system for the object groupings, I created the following functions incase someone else needs them.
Place them as they are in sceneObject.cc and recompile.

getObjectExtent //Returns the extent of the object from its position. X,Y,Z can be in plus or minus depending on rotation of the object from the position.

getObjectBoxCenter //Returns the center position of the object.

These should work fine, but I havn't stress tested them yet.


ConsoleMethod( SceneObject, getObjectExtent, const char*, 2, 2, "Returns the Extent of the objects bounding box in x, y, z.")
{
   char *returnBuffer = Con::getReturnBuffer(256);
   const Box3F& box = object->getObjBox();
   Point3F center;
   box.getCenter(&center);
   Point3F objPos = object->getPosition();
   //To work out the extent we take the objects Position X,Y,Z away from the objects Center X,Y,Z and times it by 2.
   //With will give us the width, depth and hieght in world coordinates in relavant + or - values.
   dSprintf(returnBuffer,256,"%g %g %g", ((center.x - objPos.x)*2), ((center.y - objPos.y)*2), ((center.z - objPos.z)*2));
   return returnBuffer;
}

ConsoleMethod( SceneObject, getObjectBoxCenter, const char*, 2, 2, "Returns the center of the objects bounding box.")
{
   char *returnBuffer = Con::getReturnBuffer(256);
   const Box3F& box = object->getObjBox();
   Point3F center;
   box.getCenter(&center);

   dSprintf(returnBuffer,256,"%g %g %g", center.x, center.y, center.z);
   return returnBuffer;
}