Changeset 9479 for OpenSceneGraph/trunk/examples/osgvolume/osgvolume.cpp
- Timestamp:
- 01/09/09 16:19:25 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgvolume/osgvolume.cpp
r9395 r9479 61 61 #include <iostream> 62 62 63 #include <osgVolume/ImageUtils> 63 #include <osg/ImageUtils> 64 #include <osgVolume/Volume> 65 #include <osgVolume/VolumeTile> 64 66 65 67 typedef std::vector< osg::ref_ptr<osg::Image> > ImageList; … … 1520 1522 // compute range of values 1521 1523 osg::Vec4 minValue, maxValue; 1522 osg Volume::computeMinMax(image.get(), minValue, maxValue);1523 osg Volume::modifyImage(image.get(),ScaleOperator(1.0f/maxValue.r()));1524 osg::computeMinMax(image.get(), minValue, maxValue); 1525 osg::modifyImage(image.get(),ScaleOperator(1.0f/maxValue.r())); 1524 1526 } 1525 1527 … … 1546 1548 1547 1549 // read the pixels into readOp's _colour array 1548 osg Volume::readRow(sizeS, pixelFormat, dataType, image->data(0,t,r), readOp);1550 osg::readRow(sizeS, pixelFormat, dataType, image->data(0,t,r), readOp); 1549 1551 1550 1552 // pass readOp's _colour array contents over to writeOp (note this is just a pointer swap). 1551 1553 writeOp._colours.swap(readOp._colours); 1552 1554 1553 osg Volume::modifyRow(sizeS, pixelFormat, GL_UNSIGNED_BYTE, new_image->data(0,t,r), writeOp);1555 osg::modifyRow(sizeS, pixelFormat, GL_UNSIGNED_BYTE, new_image->data(0,t,r), writeOp); 1554 1556 1555 1557 // return readOp's _colour array contents back to its rightful owner. … … 1618 1620 { 1619 1621 std::cout<<"doing conversion MODULATE_ALPHA_BY_LUMINANCE"<<std::endl; 1620 osg Volume::modifyImage(image,ModulateAlphaByLuminanceOperator());1622 osg::modifyImage(image,ModulateAlphaByLuminanceOperator()); 1621 1623 return image; 1622 1624 } … … 1624 1626 { 1625 1627 std::cout<<"doing conversion MODULATE_ALPHA_BY_COLOUR"<<std::endl; 1626 osg Volume::modifyImage(image,ModulateAlphaByColourOperator(colour));1628 osg::modifyImage(image,ModulateAlphaByColourOperator(colour)); 1627 1629 return image; 1628 1630 } … … 1630 1632 { 1631 1633 std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANACE"<<std::endl; 1632 osg Volume::modifyImage(image,ReplaceAlphaWithLuminanceOperator());1634 osg::modifyImage(image,ReplaceAlphaWithLuminanceOperator()); 1633 1635 return image; 1634 1636 } … … 1638 1640 osg::Image* newImage = new osg::Image; 1639 1641 newImage->allocateImage(image->s(), image->t(), image->r(), GL_LUMINANCE, image->getDataType()); 1640 osg Volume::copyImage(image, 0, 0, 0, image->s(), image->t(), image->r(),1641 newImage, 0, 0, 0, false);1642 osg::copyImage(image, 0, 0, 0, image->s(), image->t(), image->r(), 1643 newImage, 0, 0, 0, false); 1642 1644 return newImage; 1643 1645 } … … 1695 1697 1696 1698 ApplyTransferFunctionOperator op(transferFunction, output_image->data()); 1697 osg Volume::readImage(image,op);1699 osg::readImage(image,op); 1698 1700 1699 1701 return output_image; … … 1939 1941 while(arguments.read("--num-components", numComponentsDesired)) {} 1940 1942 1943 bool useOsgVolume = true; 1944 while(arguments.read("--osgVolume")) { useOsgVolume = true; } 1945 while(arguments.read("--no-osgVolume")) { useOsgVolume = false; } 1946 1941 1947 bool useShader = true; 1942 1948 while(arguments.read("--shader")) { useShader = true; } … … 2140 2146 { 2141 2147 osg::Vec4 localMinValue, localMaxValue; 2142 if (osg Volume::computeMinMax(itr->get(), localMinValue, localMaxValue))2148 if (osg::computeMinMax(itr->get(), localMinValue, localMaxValue)) 2143 2149 { 2144 2150 if (localMinValue.r()<minValue.r()) minValue.r() = localMinValue.r(); … … 2188 2194 ++itr) 2189 2195 { 2190 osg Volume::offsetAndScaleImage(itr->get(),2196 osg::offsetAndScaleImage(itr->get(), 2191 2197 osg::Vec4(offset, offset, offset, offset), 2192 2198 osg::Vec4(scale, scale, scale, scale)); … … 2202 2208 ++itr) 2203 2209 { 2204 osg Volume::offsetAndScaleImage(itr->get(),2210 osg::offsetAndScaleImage(itr->get(), 2205 2211 osg::Vec4(offset, offset, offset, offset), 2206 2212 osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); … … 2281 2287 osg::Node* rootNode = 0; 2282 2288 2283 if (useShader) 2284 { 2285 rootNode = createShaderModel(shadingModel, 2286 image_3d, normalmap_3d.get(), 2287 (gpuTransferFunction ? transferFunction.get() : 0), 2288 internalFormatMode, 2289 xSize, ySize, zSize, 2290 xMultiplier, yMultiplier, zMultiplier, 2291 numSlices, sliceEnd, alphaFunc); 2289 if (useOsgVolume) 2290 { 2291 2292 osg::ref_ptr<osgVolume::Volume> volume = new osgVolume::Volume; 2293 osg::ref_ptr<osgVolume::VolumeTile> tile = new osgVolume::VolumeTile; 2294 osg::ref_ptr<osgVolume::Layer> layer = new osgVolume::ImageLayer(image_3d); 2295 tile->addLayer(layer.get()); 2296 volume->addChild(tile); 2297 2298 rootNode = volume.get(); 2299 2292 2300 } 2293 2301 else 2294 2302 { 2295 rootNode = createModel(shadingModel, 2296 image_3d, normalmap_3d, 2297 internalFormatMode, 2298 xSize, ySize, zSize, 2299 xMultiplier, yMultiplier, zMultiplier, 2300 numSlices, sliceEnd, alphaFunc); 2301 } 2302 2303 if (matrix && rootNode) 2304 { 2305 osg::MatrixTransform* mt = new osg::MatrixTransform; 2306 mt->setMatrix(*matrix); 2307 mt->addChild(rootNode); 2308 2309 rootNode = mt; 2310 } 2311 2303 if (useShader) 2304 { 2305 rootNode = createShaderModel(shadingModel, 2306 image_3d, normalmap_3d.get(), 2307 (gpuTransferFunction ? transferFunction.get() : 0), 2308 internalFormatMode, 2309 xSize, ySize, zSize, 2310 xMultiplier, yMultiplier, zMultiplier, 2311 numSlices, sliceEnd, alphaFunc); 2312 } 2313 else 2314 { 2315 rootNode = createModel(shadingModel, 2316 image_3d, normalmap_3d, 2317 internalFormatMode, 2318 xSize, ySize, zSize, 2319 xMultiplier, yMultiplier, zMultiplier, 2320 numSlices, sliceEnd, alphaFunc); 2321 } 2322 2323 if (matrix && rootNode) 2324 { 2325 osg::MatrixTransform* mt = new osg::MatrixTransform; 2326 mt->setMatrix(*matrix); 2327 mt->addChild(rootNode); 2328 2329 rootNode = mt; 2330 } 2331 } 2332 2312 2333 if (!outputFile.empty()) 2313 2334 {
