From 267079e4d89d76f4c7b11fb17a1003ecb38fbda1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 2 Mar 2007 16:14:44 +0000 Subject: [PATCH] Added proper maths for distortion correction of pufferfish dome. --- examples/osgdistortion/osgdistortion.cpp | 126 ++++++++++++++++------- 1 file changed, 86 insertions(+), 40 deletions(-) diff --git a/examples/osgdistortion/osgdistortion.cpp b/examples/osgdistortion/osgdistortion.cpp index 3e4d04866..890dda41b 100644 --- a/examples/osgdistortion/osgdistortion.cpp +++ b/examples/osgdistortion/osgdistortion.cpp @@ -287,14 +287,24 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3 osg::ArgumentParser& arguments) { double sphere_radius = 1.0; + if (arguments.read("--radius", sphere_radius)) {} + double collar_radius = 0.45; + if (arguments.read("--collar", collar_radius)) {} + osg::Vec3d center(0.0,0.0,0.0); osg::Vec3d eye(0.0,0.0,0.0); double distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius); + if (arguments.read("--distance", distance)) {} + + bool centerProjection = false; + osg::Vec3d projector = eye - osg::Vec3d(0.0,0.0, distance); + osg::notify(osg::NOTICE)<<"Projector position = "<getClearColor()); + osg::Node* distortionNode = createDistortionSubgraph( osgDB::readNodeFiles(arguments), viewer.getCamera()->getClearColor()); + } - // add model to the viewer. - viewer.setSceneData( distortionNode ); + + // load the nodes from the commandline arguments. + if (!viewer.getSceneData()) + { + osg::notify(osg::NOTICE)<<"Please specify a model filename on the command line."<getOrCreateStateSet()) );