From 9dd94646382ece829089a3c87268df4fe73dddf6 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 7 Apr 2005 16:09:34 +0000 Subject: [PATCH] Fix to compute coordinate frame callback so that it can handle scaled coordinate frames, rescaling as required. --- src/osgProducer/Viewer.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/osgProducer/Viewer.cpp b/src/osgProducer/Viewer.cpp index e7906bbbc..8e873c1fe 100644 --- a/src/osgProducer/Viewer.cpp +++ b/src/osgProducer/Viewer.cpp @@ -203,11 +203,27 @@ public: if (csn) { osg::Vec3 local_position = position*osg::computeWorldToLocal(tmpPath); - osg::notify(osg::INFO)<<"local postion "<computeLocalCoordinateFrame(position)* osg::computeLocalToWorld(tmpPath)"<computeLocalCoordinateFrame(local_position)* osg::computeLocalToWorld(tmpPath); + + // keep the position of the coordinate frame to reapply after rescale. + osg::Vec3d pos = coordinateFrame.getTrans(); + + // compensate for any scaling, so that the coordinate frame is a unit size + osg::Vec3d x(1.0,0.0,0.0); + osg::Vec3d y(0.0,1.0,0.0); + osg::Vec3d z(0.0,0.0,1.0); + x = osg::Matrixd::transform3x3(x,coordinateFrame); + y = osg::Matrixd::transform3x3(y,coordinateFrame); + z = osg::Matrixd::transform3x3(z,coordinateFrame); + coordinateFrame.preMult(osg::Matrixd::scale(1.0/x.length(),1.0/y.length(),1.0/z.length())); + + // reapply the position. + coordinateFrame.setTrans(pos); + + osg::notify(osg::INFO)<<"csn->computeLocalCoordinateFrame(position)* osg::computeLocalToWorld(tmpPath)"<