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

Reply via email to