Changeset 13041 for OpenSceneGraph/trunk/src/osgTerrain/Layer.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgTerrain/Layer.cpp (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgTerrain/Layer.cpp
r12292 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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 */ … … 26 26 return; 27 27 } 28 28 29 29 if (compoundstring.size()==4) 30 30 { … … 33 33 return; 34 34 } 35 35 36 36 std::string::size_type secondcolonpos = compoundstring.find_first_of(':', setcolonpos+4); 37 37 if (secondcolonpos==std::string::npos) … … 79 79 osg::BoundingSphere bs; 80 80 if (!getLocator()) return bs; 81 81 82 82 if (treatAsElevationLayer) 83 83 { … … 91 91 float value = 0.0f; 92 92 bool validValue = getValidValue(c,r, value); 93 if (validValue) 93 if (validValue) 94 94 { 95 95 osg::Vec3d ndc, v; 96 ndc.x() = ((double)c)/(double)(numColumns-1), 96 ndc.x() = ((double)c)/(double)(numColumns-1), 97 97 ndc.y() = ((double)r)/(double)(numRows-1); 98 98 ndc.z() = value; … … 109 109 else 110 110 { 111 111 112 112 osg::Vec3d v; 113 113 if (getLocator()->convertLocalToModel(osg::Vec3d(0.5,0.5,0.0), v)) … … 122 122 123 123 } 124 124 125 125 return bs; 126 126 } … … 147 147 } 148 148 149 template <typename T, class O> 149 template <typename T, class O> 150 150 void _processRow(unsigned int num, GLenum pixelFormat, T* data,const O& operation) 151 151 { … … 162 162 } 163 163 164 template <class O> 164 template <class O> 165 165 void processRow(unsigned int num, GLenum pixelFormat, GLenum dataType, unsigned char* data, const O& operation) 166 166 { … … 177 177 } 178 178 179 template <class O> 179 template <class O> 180 180 void processImage(osg::Image* image, const O& operation) 181 181 { 182 182 if (!image) return; 183 183 184 184 for(int r=0;r<image->r();++r) 185 185 { … … 204 204 inline void operator() (int& v) const { v = (int)(_offset + (float)v * _scale); } 205 205 inline void operator() (float& v) const { v = _offset + v * _scale; } 206 206 207 207 float _offset, _scale; 208 208 }; … … 216 216 217 217 processImage(_image.get(), TransformOperator(offset,scale)); 218 218 219 219 dirty(); 220 220 … … 227 227 switch(_image->getDataType()) 228 228 { 229 case(GL_BYTE): 230 value = *((const char*)data); 229 case(GL_BYTE): 230 value = *((const char*)data); 231 231 // OSG_NOTICE<<"byte "<<value<<std::endl; 232 232 break; 233 case(GL_UNSIGNED_BYTE): 233 case(GL_UNSIGNED_BYTE): 234 234 value = *data; 235 235 // OSG_NOTICE<<"Unsigned byte "<<value<<std::endl; … … 255 255 value = *((const float*)data); 256 256 break; 257 default: 258 value = _defaultValue.x(); 257 default: 258 value = _defaultValue.x(); 259 259 return false; 260 260 } … … 438 438 osg::FloatArray* heights = _heightField->getFloatArray(); 439 439 if (!heights) return false; 440 440 441 441 OSG_INFO<<"HeightFieldLayer::transform("<<offset<<","<<scale<<")"<<std::endl;; 442 442 … … 447 447 *itr = offset + (*itr) * scale; 448 448 } 449 449 450 450 dirty(); 451 451 … … 614 614 std::string filename; 615 615 extractSetNameAndFileName(compoundname, setname, filename); 616 616 617 617 _layers[i].setname = setname; 618 618 _layers[i].filename = filename;
