Hi Daniel, I tried getting the WC from the animationpathcallback and concatenating with other matrices along the nodes. I get wierd results. When the vehicle goes diagonally, the bounding box shrinks and otherwise it is correct. I have included two images as to what i mean. Any ideas as to what and why this might happen? I get the reasons why the bounding boxes never intersect!!
http://i226.photobucket.com/albums/dd18/siddharth_univ/ErrorBeforeIntersection.jpg http://i226.photobucket.com/albums/dd18/siddharth_univ/ErrorAtIntersection.jpg Thanks for your help..i havent yet tried getting the transformation matrix from controlPoint .. although i suspect it to give me the same results.. Siddharth ----- Original Message ---- From: Daniel Holz <[EMAIL PROTECTED]> To: OpenSceneGraph Users <[email protected]> Sent: Sunday, December 2, 2007 5:32:12 PM Subject: Re: [osg-users] Getting world coord bounding box hi, i can't tell you much about AnimationPath objects since i never used them but a short glimpse on the api reference tells me that you can easily get a transformation matrix for any point in time of the running animation by using the method osg::AnimationPath::getMatrix(...). (cf. http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01017.html) another way is using a ControlPoint in your TimeControlPointMap: osg::AnimationPath::ControlPoint::getMatrix(...) (cf. http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01018.html) anyway, since you control the hierarchy of the scenegraph you don't need a nodevisitor to find the transform of the vehicle in world cords. you KNOW how the transformations are done: your scenegraph probably looks like this: 'rootNode' | osg::MatrixTransform 'vehicleAnimationX' (with vehicleNode->setUpdateCallback(new osg::AnimationPathCallback(...)) | 'vehicleX' ...whereas X refers to one of your vehicles in the scene, meaning that you have ONE osg::MatrixTransform node for each vehicle. then for every time step you obtain your world transform matrix for vehicle X by multiplying all the matrices of the scenegraph nodes "bottom-up" and "right-to-left" like this: transform of 'rootNode' * transform of 'vehicleAnimationX' * transform of 'vehicleX' probably the rootNode transformation is the identity and the vehicle has no transform node at all so that the transformation in world coords is simply the transformation of 'vehicleAnimation'! i hope this helps. if not, try looking at this example: http://osgcvs.no-ip.com/osgarchiver/archives/February2005/0270.html cheers, daniel Siddharth Palaniappan wrote: > Hi Daniel, > > I tried out a seperate code example and it did work. But i couldnt get > it working for my project. Like i previously mentioned i needed to get > the world coordinates of the boundingboxes of the loaded openflight > models and if the bounding boxes intersected , i wanted to stop the > vehicle on the animation path. The world coordinates matrix that i receive > each time, seems to be correct as i checked the position of the > ControlPointMap by using the write() in the AnimationPath class. I am now trying > to manually get the worldcoordinates and keep altering a geode and > attach it to the root node to see if the transformation made to the local > coordinates do infact match. > > Is there any code snippet around that tells how to get the world > coordinates for a model on an AnimationPath? To get the world coordinates > this is what i did - > > class getWorldCoordOfNodeVisitor : public osg::NodeVisitor > { > public: > getWorldCoordOfNodeVisitor(): > osg::NodeVisitor(NodeVisitor::TRAVERSE_PARENTS), done(false) > { > wcMatrix= new osg::Matrixd() ; > } > virtual void apply(osg::Node &node) > { > if (!done) > { > if ( 0 == node.getNumParents() ) // no parents > { > wcMatrix->set( > osg::computeLocalToWorld(this->getNodePath()) ) ; > done = true ; > } > traverse(node) ; > } > } > osg::Matrixd* giveUpDaMat() > { > return wcMatrix ; > } > private: > bool done ; > osg::Matrix* wcMatrix ; > } ; > > osg::Matrixd* getWorldCoords( osg::Node* node) > { > getWorldCoordOfNodeVisitor* ncv = new getWorldCoordOfNodeVisitor() ; > if (node && ncv) > { > node->accept(*ncv) ; > return ncv->giveUpDaMat() ; > } > else > { > return NULL ; > } > } > > I have two MatrixTransform node above my vehicle model node. And i use > this to get the World Coord transfomation matrix. The first/topmost > transformation node is a static node to set the initial position and its > child node is another transformation matrix which has an > AnimationPathCallback set to(which moves the vehicle on a spline). > > I also see that the animationpathcallback has an update function. Now , does the animationpathcallback automatically update my TransformMatrix to which i have set this as a callback? > > Do you think the workflow is correct? Am i missing anything? ANy > suggestions? > > Thanks for your help... > > Siddharth > > > > ----- Original Message ---- > From: Siddharth Palaniappan <[EMAIL PROTECTED]> > To: OpenSceneGraph Users <[email protected]> > Sent: Saturday, December 1, 2007 2:56:27 PM > Subject: Re: [osg-users] Getting world coord bounding box > > > Hi daniel, > > Yes thats a good idea..I will definitely try that and let you know how > it works out. Thank you. > > Siddharth > > > ----- Original Message ---- > From: Daniel Holz <[EMAIL PROTECTED]> > To: OpenSceneGraph Users <[email protected]> > Sent: Saturday, December 1, 2007 2:50:11 PM > Subject: Re: [osg-users] Getting world coord bounding box > > > hi siddharth, > > i just started being confused reading the link you sent me when i got > this new email of yours :) > if i am in a situation like this what i usually do is i draw what i > can't see. in your case it is the bounding box PRIOR to your > transformation to world coordinates and the one AFTER transforming. > just > render to boxes or render spheres in two different colors marking the > positions of the corners. > i am sure, having something visually, you will be able to figure out > the > problem. > > cheers, > daniel > > Siddharth Palaniappan wrote: > >> Hi Daniel, >> >> Sorry for the misunderstanding...yes you're right, it has to be done >> > on the left side. But i still dont get any valid results. Can you > suggest how i can test if the world coordinates of the box after > multiplication is correct or not? > >> Thank you, >> >> Siddharth >> >> ----- Original Message ---- >> From: Siddharth Palaniappan <[EMAIL PROTECTED]> >> To: OpenSceneGraph Users <[email protected]> >> Sent: Saturday, December 1, 2007 2:41:19 PM >> Subject: Re: [osg-users] Getting world coord bounding box >> >> >> 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 <[EMAIL PROTECTED]> >> To: OpenSceneGraph Users <[email protected]> >> 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 >>> [email protected] >>> >>> >>> >> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > >> >> >>> >>> >>> >> _______________________________________________ >> osg-users mailing list >> [email protected] >> >> > > 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 >> _______________________________________________ >> osg-users mailing list >> [email protected] >> >> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > >> >> >> >> >> > > ____________________________________________________________________________________ > >> Be a better pen pal. >> Text or chat with friends inside Yahoo! Mail. See how. >> > http://overview.mail.yahoo.com/ > >> _______________________________________________ >> osg-users mailing list >> [email protected] >> >> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > >> >> > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > > > > > ____________________________________________________________________________________ > Get easy, one-click access to your favorites. > Make Yahoo! your homepage. > http://www.yahoo.com/r/hs > _______________________________________________ > osg-users mailing list > [email protected] > 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 > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ____________________________________________________________________________________ Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

