- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/ive/HeightFieldLayer.cpp
r12292 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 37 37 { 38 38 osg::HeightField* hf = getHeightField(); 39 39 40 40 // using inline heightfield 41 out->writeBool(true); 41 out->writeBool(true); 42 42 if (out->getVersion()>=VERSION_0035) 43 43 { … … 53 53 54 54 float maxError = 0.0f; 55 55 56 56 if (getLocator()) 57 57 { 58 58 osg::Vec3d world_origin, world_corner; 59 59 60 60 getLocator()->convertLocalToModel(osg::Vec3d(0.0,0.0,0.0), world_origin); 61 61 getLocator()->convertLocalToModel(osg::Vec3d(1.0,1.0,0.0), world_corner); 62 62 63 63 double distance = (world_origin-world_corner).length(); 64 64 65 65 maxError = distance * out->getTerrainMaximumErrorToSizeRatio(); 66 66 } … … 71 71 { 72 72 out->writeShape(getHeightField()); 73 } 73 } 74 74 75 75 } … … 77 77 { 78 78 // using external heightfield file 79 out->writeBool(false); 80 out->writeString(getFileName()); 79 out->writeBool(false); 80 out->writeString(getFileName()); 81 81 } 82 82 … … 89 89 if (id != IVEHEIGHTFIELDLAYER) 90 90 in_THROW_EXCEPTION("HeightFieldLayer::read(): Expected HeightFieldLayer identification."); 91 91 92 92 // Read Layer's identification. 93 93 id = in->readInt(); … … 102 102 103 103 bool useInlineHeightField = in->readBool(); 104 104 105 105 if (useInlineHeightField) 106 106 { 107 107 108 108 if (in->getVersion()>=VERSION_0035) 109 109 { 110 110 osg::HeightField* hf = new osg::HeightField; 111 111 112 112 // Read HeightField's properties 113 113 //setColor(in->readVec4()); 114 114 unsigned int col = in->readUInt(); 115 unsigned int row = in->readUInt(); 115 unsigned int row = in->readUInt(); 116 116 hf->allocate(col,row); 117 117 … … 128 128 in->readPackedFloatArray(hf->getFloatArray()); 129 129 } 130 130 131 131 setHeightField(hf); 132 132 … … 136 136 osg::Shape* shape = in->readShape(); 137 137 setHeightField(dynamic_cast<osg::HeightField*>(shape)); 138 } 138 } 139 139 140 140 } … … 143 143 std::string filename = in->readString(); 144 144 setFileName(filename); 145 145 146 146 setHeightField(osgDB::readHeightFieldFile(filename,in->getOptions())); 147 147 }
