From c3bad2bd0406ac92c39a7400a72fde6f6647a1f1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 12 Feb 2009 13:57:18 +0000 Subject: [PATCH] Fixed handling of xSize, ySize and zSize --- examples/osgvolume/osgvolume.cpp | 42 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/examples/osgvolume/osgvolume.cpp b/examples/osgvolume/osgvolume.cpp index f525e126e..c4ea17155 100644 --- a/examples/osgvolume/osgvolume.cpp +++ b/examples/osgvolume/osgvolume.cpp @@ -890,16 +890,11 @@ int main( int argc, char **argv ) while (arguments.read("--light")) shadingModel = Light; - float xSize=1.0f, ySize=1.0f, zSize=1.0f; + float xSize=0.0f, ySize=0.0f, zSize=0.0f; while (arguments.read("--xSize",xSize)) {} while (arguments.read("--ySize",ySize)) {} while (arguments.read("--zSize",zSize)) {} - float xMultiplier=1.0f, yMultiplier=1.0f, zMultiplier=1.0f; - while (arguments.read("--xMultiplier",xMultiplier)) {} - while (arguments.read("--yMultiplier",yMultiplier)) {} - while (arguments.read("--zMultiplier",zMultiplier)) {} - osg::ref_ptr testSupportOperation = new TestSupportOperation; viewer.setRealizeOperation(testSupportOperation.get()); @@ -1123,16 +1118,16 @@ int main( int argc, char **argv ) Images::iterator sizeItr = images.begin(); - xSize = (*sizeItr)->s(); - ySize = (*sizeItr)->t(); - zSize = (*sizeItr)->r(); + int image_s = (*sizeItr)->s(); + int image_t = (*sizeItr)->t(); + int image_r = (*sizeItr)->r(); ++sizeItr; for(;sizeItr != images.end(); ++sizeItr) { - if ((*sizeItr)->s() != xSize || - (*sizeItr)->t() != ySize || - (*sizeItr)->r() != zSize) + if ((*sizeItr)->s() != image_s || + (*sizeItr)->t() != image_t || + (*sizeItr)->r() != image_r) { std::cout<<"Images in sequence are not of the same dimensions."<(images.front()->getUserData()); + osg::ref_ptr matrix = dynamic_cast(images.front()->getUserData()); + + if (!matrix) + { + if (xSize==0.0) xSize = static_cast(image_s); + if (ySize==0.0) ySize = static_cast(image_t); + if (zSize==0.0) zSize = static_cast(image_r); + + matrix = new osg::RefMatrix(xSize, 0.0, 0.0, 0.0, + 0.0, ySize, 0.0, 0.0, + 0.0, 0.0, zSize, 0.0, + 0.0, 0.0, 0.0, 1.0); + } osg::Vec4 minValue(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX); osg::Vec4 maxValue(-FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX); @@ -1272,12 +1279,9 @@ int main( int argc, char **argv ) osg::ref_ptr layer = new osgVolume::ImageLayer(image_3d.get()); - if (matrix) - { - osgVolume::Locator* locator = new osgVolume::Locator(*matrix); - layer->setLocator(locator); - tile->setLocator(locator); - } + osgVolume::Locator* locator = new osgVolume::Locator(*matrix); + layer->setLocator(locator); + tile->setLocator(locator); tile->setLayer(layer.get());