I've been browsing the mail archive to find the answer to my question but I haven't found anything at all. I basically want to manipulate the vertices of a model loaded by the osgDB::ReadNodeFile() function. ReadNodeFile() returns a osg::Node. I was hoping this might actually be a osg::Geode, but apparently it isn't.
Reason I want to do this is because I have 1600 different building models. But all of these building models are already positioned in their correct position and rotation (instead of each building being built around 0,0,0). So basically if I load my 1600 models and all position them on 0,0,0 I have a complete and perfectly aligned town. I want to move every building back to 0,0,0 so that I can re-use them. I've already used osg to find their position by finding the center of their bounding box. And now I want to substract that position from the vertices of every building and save them. Anyone know how to achieve this?
Thank you in advance,
Rene
----------------------------------------------------------------
Op deze e-mail zijn de volgende voorwaarden van toepassing:
http://www.fontys.nl/disclaimer
The above disclaimer applies to this e-mail message.
----------------------------------------------------------------
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Bokhorst,Rene R. wrote:
> I've been browsing the mail archive to find the answer to my question but I haven't found anything at all. I basically want to manipulate the vertices of a model loaded by the osgDB::ReadNodeFile() function. ReadNodeFile() returns a osg::Node. I was hoping this might actually be a osg::Geode, but apparently it isn't.
>
A Geode is a subclass of Node, but osgDB::readNodeFile always returns a
Node*. You can check if you actually get back a Geode by doing a dynamic
cast, e.g.
osg::Node* node = osgDB::readNodeFile(...);
osg::Geode* geode = dynamic_cast<osg::Geode*>(node);
if (geode) { // it's a Geode... }
> Reason I want to do this is because I have 1600 different building models. But all of these building models are already positioned in their correct position and rotation (instead of each building being built around 0,0,0). So basically if I load my 1600 models and all position them on 0,0,0 I have a complete and perfectly aligned town. I want to move every building back to 0,0,0 so that I can re-use them. I've already used osg to find their position by finding the center of their bounding box. And now I want to substract that position from the vertices of every building and save them. Anyone know how to achieve this?
>
You can try to add a separate MatrixTransform above each building's root
node and set its DataVariance to STATIC followed by running
osgUtil::Optimizer on the subgraph with option
FLATTEN_STATIC_TRANSFORMS. If all other transforms in the subgraph also
have static variance then this should 'push' the transform into the
vertices by transforming them to their final positions. You can then
save each building's subgraph with writeNodeFile()
Paul
________________________________
From: osg-user...@lists.openscenegraph.org on behalf of Serge Lages
Sent: Thu 6/26/2008 4:07 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] manipulating vertices from a node loaded byReadNodeFile()
Hi Rene,
--
Serge Lages
http://www.tharsis-software.com <http://www.tharsis-software.com/>
> I've been browsing the mail archive to find the answer to my question but I haven't found anything at all. I basically want to manipulate the vertices of a model loaded by the osgDB::ReadNodeFile() function. ReadNodeFile() returns a osg::Node. I was hoping this might actually be a osg::Geode, but apparently it isn't.
To add to what Paul Melis said, in addition to the osg::Node* actually
pointing to an osg::Geode*, it could be that there are some transforms
above the geode itself. So you may need to use a NodeVisitor to find
your actual Geode, and then do whatever you want to do with the
underlying Geometry objects (which you will also dynamic_cast from the
osg::Drawable* returned from geode->getDrawable(i) ).
It could be a useful exercise to convert your models to .osg format,
which is plain text and can be inspected.
osgconv model.flt model.osg (for example, if it's an flt)
This will tell you what the structure will be once the model is loaded
into OSG. readNodeFile returns the top node in that structure.
Hope this helps,
J-S
--
______________________________________________________
Jean-Sebastien Guay jean-seba...@cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/
_____
From: osg-user...@lists.openscenegraph.org
[mailto:osg-user...@lists.openscenegraph.org] On Behalf Of
Bokhorst,Rene R.
Sent: Thursday, June 26, 2008 12:25 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] manipulating vertices from a node
loadedbyReadNodeFile()
thanks for replying, but the problem is that the osg::Node* returned by
ReadNodeFile() is not a osg::Geode().
_____
From: osg-user...@lists.openscenegraph.org on behalf of Serge Lages
Date: Thu, 26 Jun 2008 18:25:09 +0200
From: r.bok...@fontys.nl
To: osg-...@lists.openscenegraph.org
________________________________
Regards,
Cg
________________________________
________________________________
--
Serge Lages
http://www.tharsis-software.co m <http://www.tharsis-software.com/>
________________________________
Always-on security tools provide safer ways to connect and share anywhere. Find out more. Windows Live <http://get.live.com/familysafety/overview>
________________________________
Van: osg-user...@lists.openscenegraph.org namens Gordon Tomlinson
Verzonden: do 26-6-2008 20:24
Aan: 'OpenSceneGraph Users'
Onderwerp: Re: [osg-users] manipulating vertices from a nodeloadedbyReadNodeFile()
Well you will have to walk the node returned by ReadNodeFile scenegraph, typically with a nodevisitor
until you find osg::geode, look through the sample and examples they show how to walk a scenegraph and how to create nodes and geom, the mail archives while also contain pointers if not code on how to do this
heres an old example from my faq's of a nodevisitor http://www.vis-sim.com/osg/code/osgcode_bbox1.htm which also shows how to get the geodes
________________________________
From: osg-user...@lists.openscenegraph.org [mailto:osg-user...@lists.openscenegraph.org] On Behalf Of Bokhorst,Rene R.
Sent: Thursday, June 26, 2008 12:25 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] manipulating vertices from a node loadedbyReadNodeFile()
thanks for replying, but the problem is that the osg::Node* returned by ReadNodeFile() is not a osg::Geode().
________________________________