Hi! I would:
1 Read your data into a Vec3Darray - as doubles 2 Decide upon a local origin - "best" may be the centroid of your data, but the first point is somewhat quicker to find. 3 Subtract the local origin from all the points in your array - they are now still doubles, but each is a much smaller number which can be accurately represented by a float 4 Build a osg::Geometry with a Vec3Array for vertices, using your translated points 5 Put the Geometry under an osg::MatrixTransform, set the MT translation to your local origin return the MT You *can* keep the original Vec3DArray if you want, but you probably don't need to, you'd have to compare the values there against the values of (local origin+p) to see if the difference is a problem for you, I doubt it will be. HTH, Mike On 3 November 2014 20:09, Émeric MASCHINO <[email protected]> wrote: > Hi Robert, > > 2014-10-31 14:50 GMT+01:00 Robert Osfield <[email protected]>: > > If you really do need to handle double data then the best way is to load > it > > in doubles then post process the loaded subgraph to convert the double > data > > to floats in the way that is appropriate for that data - such as > decorating > > subgraphs with MatrixTransform and convert the osg::Geometry's > Vec3dArray in > > world coords to a Vec3Array in local coordinates. > > Well, this is where I'm lost ;-) > > Say I'm loading my data as double. My reader will thus store these > data as Vec3dArray in the osg::Geometry::_vertexArray member variable > of the geometry attached to the returned osg::Node. > > Now, I need to transform these double data as float for rendering. So, > you create an osg::MatrixTransform node, attach it the osg::Node > returned by the reader and create yet another osg::Node, also attached > to the same osg::MatrixTransform node, but with an > osg::Geometry::_vertexArray containing the data as float in a > Vec3Array? > > Or is there only one osg::Node (the one returned by the loader, still > attached to an osg::MatrixTransform node) with two vertex arrays: the > osg::Geometry::_vertexArray member variable with the data as float for > rendering, and yet another Vec3dArray with the data as double, stored > as osg::Node's UserDataContainer (since an osg::Geometry can't hold > two vertex arrays)? > > > If you want good rendering performance you'll need to convert to float > > arrays at somepoint so after loaded is typically the best time. > > I'm OK with this, this is how the conversion procedure takes place > that puzzles me. > > Émeric > _______________________________________________ > 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

