> > Or you could make a small function that would find the bounding box of the > model
There's an app for that :) http://code.google.com/p/osgworks/ *osgwbvv:* A bounding volume visualizer to display bounding spheres and boxes. K. On 4 March 2011 02:49, Jean-Sébastien Guay <[email protected]>wrote: > Hi Tim, > > > I still would like to know the whys and wherefors and how comes >> surrounding this effect.... do different models have built in heights with >> respect to 0,0,0? >> > > It all depends on how the model was built in the modeling program... > Clearly if one model's local origin (its own (0,0,0)) is 10 meters below the > bottom of the hull, then when just naively placing it in the scene at the > world origin, it will look like it's floating in the air... > > If you can't load the boat model in a modeling program, you can easily make > a model that is just a plane at Z=0. Then load that along with your boat > model, and see if the boat model floats high above that plane. > > There are a few solutions you could adopt to make sure this doesn't happen. > You could make sure your models are built with a local origin that makes > sense. For a boat it could be the center in XY, and Z at the "normal" > waterline. For a car it might be in the center in XY, and Z at the bottom of > the wheels. > > Or you could make a small function that would find the bounding box of the > model (try the osg::ComputeBoundsVisitor) and then from that tries to find a > correct position to move the local origin to, using a MatrixTransform to > decorate your model's subgraph and setting that matrix to translate the > local origin. For example if your boat was 10m higher than you wanted, the > MatrixTransform would have a translation by (0,0,-10). Then you just pass > that node as the new root of the model, and from then on the model will be > placed correctly. This offset could also be stored in a config file, or you > can save out the transform I just mentioned and use that instead of your > previous model with a bad local origin. > > So, it's all about how your data was created. Hope this helps, > > J-S > -- > ______________________________________________________ > Jean-Sebastien Guay [email protected] > http://www.cm-labs.com/ > http://whitestar02.webhop.org/ > > _______________________________________________ > 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

