- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/ive/DataOutputStream.cpp
r13034 r13041 169 169 { 170 170 std::string optionsString = _options->getOptionString(); 171 171 172 172 if(optionsString.find("noTexturesInIVEFile")!=std::string::npos) { 173 173 setIncludeImageMode(IMAGE_REFERENCE_FILE); … … 199 199 std::string::size_type endOfToken = optionsString.find_first_of('=', terrainErrorPos); 200 200 std::string::size_type endOfNumber = optionsString.find_first_of(' ', endOfToken); 201 std::string::size_type numOfCharInNumber = (endOfNumber != std::string::npos) ? 201 std::string::size_type numOfCharInNumber = (endOfNumber != std::string::npos) ? 202 202 endOfNumber-endOfToken-1 : 203 203 optionsString.size()-endOfToken-1; … … 207 207 std::string numberString = optionsString.substr(endOfToken+1, numOfCharInNumber); 208 208 _maximumErrorToSizeRatio = osg::asciiToDouble(numberString.c_str()); 209 209 210 210 OSG_DEBUG<<"TerrainMaximumErrorToSizeRatio = "<<_maximumErrorToSizeRatio<<std::endl; 211 211 } … … 235 235 writeUInt(ENDIAN_TYPE) ; 236 236 writeUInt(getVersion()); 237 237 238 238 writeInt(_compressionLevel); 239 239 240 240 if (_compressionLevel>0) 241 241 { 242 243 _ostream = &_compressionStream; 242 243 _ostream = &_compressionStream; 244 244 } 245 245 } … … 248 248 { 249 249 if (_compressionLevel>0) 250 { 250 { 251 251 _ostream = _output_ostream; 252 252 253 253 std::string compressionString(_compressionStream.str()); 254 254 writeUInt(compressionString.size()); 255 255 256 256 compress(*_output_ostream, compressionString); 257 257 } … … 269 269 z_stream strm; 270 270 unsigned char out[CHUNK]; 271 271 272 272 int level = 6; 273 273 int stategy = Z_DEFAULT_STRATEGY; // looks to be the best for .osg/.ive files … … 280 280 strm.zfree = Z_NULL; 281 281 strm.opaque = Z_NULL; 282 ret = deflateInit2(&strm, 282 ret = deflateInit2(&strm, 283 283 level, 284 284 Z_DEFLATED, … … 308 308 309 309 if (have>0) fout.write((const char*)out, have); 310 310 311 311 if (fout.fail()) 312 312 { … … 660 660 writeInt(size); 661 661 if (size==0) return; 662 662 663 663 float minValue = (*a)[0]; 664 float maxValue = minValue; 664 float maxValue = minValue; 665 665 for(int i=1; i<size; ++i) 666 666 { … … 668 668 if ((*a)[i]>maxValue) maxValue = (*a)[i]; 669 669 } 670 670 671 671 if (minValue==maxValue) 672 672 { … … 679 679 680 680 writeBool(false); 681 681 682 682 int packingSize = 4; 683 683 if (maxError>0.0f) 684 684 { 685 685 686 686 //float byteError = 0.0f; 687 687 float byteMultiplier = 255.0f/(maxValue-minValue); … … 724 724 { 725 725 writeInt(1); 726 726 727 727 writeFloat(minValue); 728 728 writeFloat(maxValue); 729 729 730 730 float byteMultiplier = 255.0f/(maxValue-minValue); 731 731 … … 742 742 writeFloat(minValue); 743 743 writeFloat(maxValue); 744 744 745 745 float shortMultiplier = 65535.0f/(maxValue-minValue); 746 746 … … 752 752 } 753 753 else 754 { 754 { 755 755 writeInt(4); 756 756 … … 759 759 writeFloat((*a)[i]); 760 760 } 761 761 762 762 } 763 763 … … 1435 1435 if (image) 1436 1436 { 1437 if (image->getWriteHint()==osg::Image::STORE_INLINE) 1437 if (image->getWriteHint()==osg::Image::STORE_INLINE) 1438 1438 { 1439 1439 return IMAGE_INCLUDE_DATA; 1440 1440 } 1441 else if (image->getWriteHint()==osg::Image::EXTERNAL_FILE) 1441 else if (image->getWriteHint()==osg::Image::EXTERNAL_FILE) 1442 1442 { 1443 1443 return IMAGE_REFERENCE_FILE; … … 1451 1451 { 1452 1452 IncludeImageMode mode = getIncludeImageMode(image); 1453 1453 1454 1454 if ( getVersion() >= VERSION_0029) 1455 1455 { … … 1854 1854 { 1855 1855 const osg::Node* node = dynamic_cast<const osg::Node*>(object); 1856 if (node) 1856 if (node) 1857 1857 { 1858 1858 writeInt(IVENODE); … … 1862 1862 1863 1863 const osg::StateSet* stateset = dynamic_cast<const osg::StateSet*>(object); 1864 if (stateset) 1864 if (stateset) 1865 1865 { 1866 1866 writeInt(IVESTATESET); … … 1870 1870 1871 1871 const osg::StateAttribute* sa = dynamic_cast<const osg::StateAttribute*>(object); 1872 if (sa) 1872 if (sa) 1873 1873 { 1874 1874 writeInt(IVESTATEATTRIBUTE); … … 1878 1878 1879 1879 const osg::Drawable* drawable = dynamic_cast<const osg::Drawable*>(object); 1880 if (drawable) 1880 if (drawable) 1881 1881 { 1882 1882 writeInt(IVEDRAWABLE); … … 1886 1886 1887 1887 const osgSim::ShapeAttributeList* sal = dynamic_cast<const osgSim::ShapeAttributeList*>(object); 1888 if (sal) 1888 if (sal) 1889 1889 { 1890 1890 writeInt(IVESHAPEATTRIBUTELIST); … … 1906 1906 fileName += o.str(); 1907 1907 } 1908 1908 1909 1909 fileName += ".dds"; 1910 1910 ++_textureFileNameNumber; 1911 1911 1912 1912 return fileName; 1913 1913 }
