[osg-users] Getting world coord bounding box
Siddharth Palaniappan
siddharth_univ at yahoo.com
Sat Dec 1 11:41:19 PST 2007
Hi daniel,
I read thru this at the osg site :
http://www.openscenegraph.org/projects/osg/wiki/Support/Maths/MatrixTransformations
In the end , robert says ways are defined ... i initially multiplied the matrix on the left side. But after reading this i changed it...am i wrong ?
Siddharth
----- Original Message ----
From: Daniel Holz <danielh at cm-labs.com>
To: OpenSceneGraph Users <osg-users at lists.openscenegraph.org>
Sent: Saturday, December 1, 2007 2:35:52 PM
Subject: Re: [osg-users] Getting world coord bounding box
hi,
don't you have to multiply the matrix from the left side with the
vector, like this:
M * x = x',
whereas M is your 'WorldCoordsMatrix', x is your local BBox vector and
x' is the same in world coords.
hope this helps.
daniel
Siddharth Palaniappan wrote:
> Hi osg users,
>
> I'm currently using openscenegraph for my class project to simulate
traffic. I have a problem in that , i need to find collision detection
between consecutive cars and stop the car if there is a collision. I
have followed the osgExample- for animation. I have used an
animationpath and animationpathcallback and i have implemented my own spline
interpolation for the car to traverse on a spline. I tried to get the world
coordinate of the bounding box like this..
>
> * i have a class Vehicle that stores the node to which an openflight
model is read into.
>
> * the leaf node is the node having the vehicle, the parent node of
this node is a transformation node which has an animationpathcallback set
to, and this also has a parent node to initially set the location and
orientation, (just like in the osgExample animation).
>
> * i have a node visitor that traverses parents..so it goes from the
current node to the root concatenating all the world coordinates.
>
> * then i get the local bounding box of the node and get the minimum
and maximum and multiply the world coord matrix with these points to
form a new min and max point and create a new bounding box. I do this for
every two node to check the intersection of two consecutive nodes.
>
>
> //getWorldCoords() - forwards to a nodevisitor to get world
coords matrix.
> osg::Matrixd* WorldCoordsMatrix = getWorldCoords(this->m_Vehicle)
;
> osg::BoundingBox VehicleBBox ;
>
> VehicleBBox.expandBy(m_Vehicle->getBound()) ;
>
> //Convert the vehicle local coords to world coordinates.
> osg::Vec3f MinPt(VehicleBBox.xMin() , VehicleBBox.yMin() ,
VehicleBBox.zMin()) ;
> osg::Vec3f MaxPt(VehicleBBox.xMax() , VehicleBBox.yMax() ,
VehicleBBox.zMax()) ;
>
> osg::Vec3f NewMinPt , NewMaxPt ;
> NewMinPt = MinPt * (*WorldCoordsMatrix) ;
> NewMaxPt = MaxPt * (*WorldCoordsMatrix) ;
>
> this->m_VehicleBoundingBox = new osg::BoundingBox(NewMinPt ,
NewMaxPt) ;
>
> I am not getting correct results. I get that the bounding boxes dont
intersect at all or sometimes intersect at odd places. Please let me
know if i'm doing something stupid or if i my understanding of anything
wrong.
>
>
> Thank you,
>
> Yours Sincerely,
>
> Siddharth
>
>
>
>
>
>
>
____________________________________________________________________________________
> Never miss a thing. Make Yahoo your home page.
> http://www.yahoo.com/r/hs
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
More information about the osg-users
mailing list