Thanks for the quick reply.
I'm fairly certain the transform node is 2 nodes up from the faces.
3ds Max's exporter created chains of "transform -> material ->
geometry" for all the objects.
I don't think I actually need the Node* at all, as I think calling
getToWorld on the NodePtr itself compiles just fine.
Perhaps I am storing the wrong matrix... but I don't think I am :-/
-Austin
On Wed, Feb 13, 2008 at 12:41 PM, Carsten Neumann
<[EMAIL PROTECTED]> wrote:
> Hello Austin,
>
>
> Austin Baker wrote:
> > In this application, I must be able to 'flatten' the scene graph
> > and break all dependencies, yet retain each objects position. I do
> > this with a depth-first tree-traversal and successively add all
> > objects to a new root (hence flattening the tree). It works great,
> > except for one issue...
> >
> > It seems the sphere and cone are stored relative to the box and
> > when I break that link between the box and its children, the sphere
> > and cone both get moved back to the position where they were
> > originally created.
>
> yes, at least on the OpenSG side children are positioned relative to
> their parent.
>
>
> > I have attempted to store the matrix of the sphere
> > and cone before breaking the link, and then set their matrix to it
> > after the operation is complete, but they still remain at their
> > creation location, instead of where they should be (located near the
> > box).
>
> Hm, from your description and code I can not see any obvious problem;
> just some comments/questions:
>
>
> > Here is how I store and overwrite the matrix:
> >
> > [code]
> > if (numChildren <= 0) // Do we have a leaf node?
> > {
> > // We only care about leaf nodes with Geometry Cores for now
> > if(nodeCore != osg::NullFC &&
> > nodeCore->getType().isDerivedFrom(osg::Geometry::getClassType()))
> > {
> > // save current world matrix of the object (the transform
> > node is located 2 levels up from the actual geometry faces)
>
> I guess you checked this, but are you sure this is where the transform
> is located ?
>
>
> > osg::NodePtr parentPtr = node->getParent()->getParent();
> > osg::Node* parentNode = parentPtr.getCPtr();
>
> why do you use/need the Node * here ?
>
>
> > osg::Matrix worldMatrix = parentNode->getToWorld();
>
> you can ask any Node for the toWorld matrix, so just using
> node->getToWorld() should give you the transformation matrix that
> applies to the geometry. You would store the wrong matrix if there is
> another transform below this one.
>
>
> > // move parent node with transform core to new root and
> > overwrite its matrix
> > osg::beginEditCP(newRoot);
> > newRoot->addChild(parentPtr);
> > osg::TransformPtr parent_xform =
> > osg::TransformPtr::dcast(parentNode->getCore());
> > osg::beginEditCP(parent_xform);
> > parent_xform->setMatrix(worldMatrix); osg::endEditCP(parent_xform);
> > osg::endEditCP(newRoot);
> > }
> > }
> > [/code]
>
> Hm, basically I would expect this to work. As stated above I'm just a
> bit curious if the assumptions you make on where the transforms are
> located are valid.
>
> Sorry for not being more helpful,
> Carsten
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users