Hi,
Thanks for info. The problem was the currmat was always identity. So bounding box was always aligned to axis of world rather then to current "transformation" world axis.

Pozdav ;-)

2006/9/24, Sinisa Popovic <[EMAIL PROTECTED]>:
Hi Ivan,
 
It appears to me that you are not using your 'currmat' variable, once you get down to Geodes. As another approach, this might be of interest to you.
 
 
Pozdrav ("Regards" for English speaking folks),
Sinisa
 
----- Original Message -----
Sent: Sunday, September 24, 2006 9:33 PM
Subject: [osg-users] Break up object

Hi. Regarding my previous post, how to get bounding boxes around subnodes of some object, I almost got it.

But all boxes are still XYZ aligned, internal matrix transformation are always identities, but I am sure, in the 3ds file they are rotated.

Why is my transformation matrix always identity???


void HelloWorld::Razbij(Object * obj,osg::Node * node, osg::Matrixd currmat)
{
  osg::Group * grp=node->asGroup();
  osg::Transform * tr =node->asTransform();
  osg::Matrixd nextmat=currmat;
  if (tr!=0)
  {
    osg::Matrixd mt=tr->asMatrixTransform()->getMatrix();
    nextmat=currmat*mt;
  }
  if (grp!=0)
  {
    for (int i=0;i<grp->getNumChildren();i++)
    {
      Razbij(obj,grp->getChild(i),nextmat);
    }
  }

  if (node->className()==std::string("Geode"))
  {
    osg::Geode * tmp=(osg::Geode *) node;
   
    osg::BoundingBox box1=tmp->getBoundingBox();

    osg::Box *b=new osg::Box(box1.center(),
      box1.xMax()-box1.xMin(),
      box1.yMax()-box1.yMin(),
      box1.zMax()-box1.zMin());

    osg::ShapeDrawable *sd=new osg::ShapeDrawable();
    sd->setShape(b);
    sd->setColor(osg::Vec4(1,1,1,0.5));
    osg::Geode * ne=new osg::Geode();
    ne->addDrawable(sd);
    GetScene()->GetSceneNode()->addChild(ne);
  }

}


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to