Changeset 13041 for OpenSceneGraph/trunk/include/osgTerrain/Layer
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osgTerrain/Layer (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgTerrain/Layer
r12139 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 */ … … 42 42 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ 43 43 Layer(const Layer&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); 44 44 45 45 META_Object(osgTerrain, Layer); 46 46 47 47 /** Set the name of this layer. */ 48 48 void setSetName(const std::string& setname) { setName(setname); } … … 63 63 Locator* getLocator() { return _locator.get(); } 64 64 const Locator* getLocator() const { return _locator.get(); } 65 65 66 66 void setMinLevel(unsigned int minLevel) { _minLevel = minLevel; } 67 67 unsigned int getMinLevel() const { return _minLevel; } … … 88 88 void setDefaultValue(const osg::Vec4& value) { _defaultValue = value; } 89 89 const osg::Vec4& getDefaultValue() const { return _defaultValue; } 90 90 91 91 92 92 /** Set the minification texture filter to use when a texture is associated with this layer.*/ … … 105 105 106 106 107 /** Return image associated with layer if supported. */ 107 /** Return image associated with layer if supported. */ 108 108 virtual osg::Image* getImage() { return 0; } 109 109 110 /** Return const image associated with layer if supported. */ 110 /** Return const image associated with layer if supported. */ 111 111 virtual const osg::Image* getImage() const { return 0; } 112 112 … … 168 168 ir = ndc_x - double(i); 169 169 jr = ndc_y - double(j); 170 } 170 } 171 171 172 172 /** … … 185 185 double div = 0.0f; 186 186 float v,r; 187 187 188 188 r = (1.0f-ir)*(1.0f-jr); 189 if (r>0.0 && getValue(i,j,v)) 190 { 191 value += v*r; 192 div += r; 193 } 194 189 if (r>0.0 && getValue(i,j,v)) 190 { 191 value += v*r; 192 div += r; 193 } 194 195 195 r = (ir)*(1.0f-jr); 196 if (r>0.0 && getValue(i+1,j,v)) 197 { 198 value += v*r; 199 div += r; 200 } 201 196 if (r>0.0 && getValue(i+1,j,v)) 197 { 198 value += v*r; 199 div += r; 200 } 201 202 202 r = (ir)*(jr); 203 if (r>0.0 && getValue(i+1,j+1,v)) 204 { 205 value += v*r; 206 div += r; 207 } 208 203 if (r>0.0 && getValue(i+1,j+1,v)) 204 { 205 value += v*r; 206 div += r; 207 } 208 209 209 r = (1.0f-ir)*(jr); 210 if (r>0.0 && getValue(i,j+1,v)) 211 { 212 value += v*r; 213 div += r; 214 } 215 210 if (r>0.0 && getValue(i,j+1,v)) 211 { 212 value += v*r; 213 div += r; 214 } 215 216 216 if (div != 0.0) 217 217 { … … 305 305 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ 306 306 ImageLayer(const ImageLayer& imageLayer,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); 307 307 308 308 META_Object(osgTerrain, ImageLayer); 309 309 … … 315 315 void setImage(osg::Image* image); 316 316 317 /** Return image associated with layer. */ 317 /** Return image associated with layer. */ 318 318 virtual osg::Image* getImage() { return _image.get(); } 319 319 … … 349 349 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ 350 350 ContourLayer(const ContourLayer& tfLayer,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); 351 351 352 352 META_Object(osgTerrain, ContourLayer); 353 353 … … 358 358 const osg::TransferFunction1D* getTransferFunction() const { return _tf.get(); } 359 359 360 /** Return image associated with layer. */ 360 /** Return image associated with layer. */ 361 361 virtual osg::Image* getImage() { return _tf.valid() ? _tf->getImage() : 0; } 362 362 … … 393 393 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ 394 394 HeightFieldLayer(const HeightFieldLayer& hfLayer,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); 395 395 396 396 META_Object(osgTerrain, HeightFieldLayer); 397 397 … … 435 435 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ 436 436 ProxyLayer(const ProxyLayer& proxyLayer,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); 437 437 438 438 META_Object(osgTerrain, ProxyLayer); 439 440 /** Return image associated with layer if supported. */ 439 440 /** Return image associated with layer if supported. */ 441 441 virtual osg::Image* getImage() 442 442 { … … 452 452 /** Set the implementation layer that does the actual work.*/ 453 453 void setImplementation(Layer* layer) { _implementation = layer; } 454 454 455 455 /** Get the implementation layer that does the actual work.*/ 456 456 Layer* getImplementation() { return _implementation.get(); } … … 464 464 virtual unsigned int getNumColumns() const; 465 465 virtual unsigned int getNumRows() const; 466 466 467 467 virtual bool transform(float offset, float scale); 468 468 … … 481 481 482 482 virtual ~ProxyLayer(); 483 483 484 484 osg::ref_ptr<Layer> _implementation; 485 485 … … 495 495 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ 496 496 CompositeLayer(const CompositeLayer& compositeLayer,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); 497 497 498 498 META_Object(osgTerrain, CompositeLayer); 499 499 … … 522 522 void addLayer(const std::string& compoundname); 523 523 void addLayer(const std::string& setname, const std::string& filename); 524 524 525 525 void addLayer(Layer* layer) { _layers.push_back(CompoundNameLayer(layer->getName(),layer->getFileName(),layer)); } 526 526 527 527 void removeLayer(unsigned int i) { _layers.erase(_layers.begin()+i); } 528 528 529 529 unsigned int getNumLayers() const { return _layers.size(); } 530 530 … … 536 536 { 537 537 CompoundNameLayer() {} 538 538 539 539 CompoundNameLayer(const CompoundNameLayer& cnl): 540 540 setname(cnl.setname), … … 550 550 { 551 551 if (&cnl==this) return *this; 552 552 553 553 setname = cnl.setname; 554 554 filename = cnl.filename; … … 561 561 osg::ref_ptr<Layer> layer; 562 562 }; 563 563 564 564 typedef std::vector< CompoundNameLayer > Layers; 565 565 566 566 Layers _layers; 567 567 }; … … 576 576 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ 577 577 SwitchLayer(const SwitchLayer& switchLayer,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); 578 578 579 579 META_Object(osgTerrain, SwitchLayer); 580 580 581 581 void setActiveLayer(int i) { _activeLayer = i; } 582 582 int getActiveLayer() const { return _activeLayer; } 583 583 584 /** Return image associated with layer if supported. */ 584 /** Return image associated with layer if supported. */ 585 585 virtual osg::Image* getImage() 586 586 { 587 if (_activeLayer < 0) return 0; 587 if (_activeLayer < 0) return 0; 588 588 if (_activeLayer >= static_cast<int>(getNumLayers())) return 0; 589 return _layers[_activeLayer].layer->getImage(); 589 return _layers[_activeLayer].layer->getImage(); 590 590 } 591 591 … … 593 593 virtual const osg::Image* getImage() const 594 594 { 595 if (_activeLayer < 0) return 0; 595 if (_activeLayer < 0) return 0; 596 596 if (_activeLayer >= static_cast<int>(getNumLayers())) return 0; 597 return _layers[_activeLayer].layer->getImage(); 597 return _layers[_activeLayer].layer->getImage(); 598 598 } 599 599 … … 601 601 602 602 virtual ~SwitchLayer() {} 603 603 604 604 int _activeLayer; 605 605 };
