30becd5ed3
Warnings were: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osg/ShapeDrawable.cpp: In member function ‘void PrimitiveShapeVisitor::createHalfSphere(unsigned int, unsigned int, float, int, float, const Matrix&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osg/ShapeDrawable.cpp:1409:11: warning: variable ‘nzBase’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osg/ShapeDrawable.cpp:1410:11: warning: variable ‘nRatioBase’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/DelaunayTriangulator.cpp: In function ‘osgUtil::Triangle_list osgUtil::fillHole(osg::Vec3Array*, std::vector<unsigned int, std::allocator<unsigned int> >)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/DelaunayTriangulator.cpp:569:27: warning: variable ‘ptest’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/DelaunayTriangulator.cpp: In member function ‘bool osgUtil::DelaunayTriangulator::triangulate()’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/DelaunayTriangulator.cpp:979:45: warning: variable ‘curp’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/RenderStage.cpp: In member function ‘void osgUtil::RenderStage::runCameraSetUp(osg::RenderInfo&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/RenderStage.cpp:631:18: warning: variable ‘stencilAttached’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgText/FadeText.cpp: In member function ‘void FadeTextPolytopeData::buildPolytope()’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgText/FadeText.cpp:74:20: warning: variable ‘edge23’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgText/FadeText.cpp:75:20: warning: variable ‘edge30’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgText/Text.cpp: In member function ‘void osgText::Text::computeBackdropPositions(unsigned int) const’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgText/Text.cpp:747:10: warning: variable ‘is_valid_size’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/NodeTrackerManipulator.cpp: In member function ‘virtual bool osgGA::NodeTrackerManipulator::performMovementLeftMouseButton(double, double, double)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/NodeTrackerManipulator.cpp:257:21: warning: variable ‘lookVector’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/NodeTrackerManipulator.cpp:259:21: warning: variable ‘upVector’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/TerrainManipulator.cpp: In member function ‘virtual bool osgGA::TerrainManipulator::performMovementMiddleMouseButton(double, double, double)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/TerrainManipulator.cpp:217:11: warning: variable ‘lookVector’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/TerrainManipulator.cpp:219:11: warning: variable ‘upVector’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgVolume/FixedFunctionTechnique.cpp: In member function ‘virtual void osgVolume::FixedFunctionTechnique::init()’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgVolume/FixedFunctionTechnique.cpp:124:30: warning: variable ‘tf’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgParticle/FluidProgram.cpp: In member function ‘virtual void osgParticle::FluidProgram::execute(double)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgParticle/FluidProgram.cpp:38:23: warning: variable ‘velBefore’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgShadow/ParallelSplitShadowMap.cpp: In member function ‘virtual void osgShadow::ParallelSplitShadowMap::cull(osgUtil::CullVisitor&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgShadow/ParallelSplitShadowMap.cpp:593:22: warning: variable ‘bb’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgTerrain/GeometryTechnique.cpp: In member function ‘virtual void osgTerrain::GeometryTechnique::generateGeometry(osgTerrain::GeometryTechnique::BufferData&, osgTerrain::Locator*, const osg::Vec3d&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgTerrain/GeometryTechnique.cpp:777:12: warning: variable ‘i_sampleFactor’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgTerrain/GeometryTechnique.cpp:778:12: warning: variable ‘j_sampleFactor’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/dds/ReaderWriterDDS.cpp: In function ‘osg::Image* ReadDDSFile(std::istream&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/dds/ReaderWriterDDS.cpp:314:10: warning: variable ‘is3dImage’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/dds/ReaderWriterDDS.cpp: In function ‘bool WriteDDSFile(const osg::Image*, std::ostream&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/dds/ReaderWriterDDS.cpp:721:10: warning: variable ‘is3dImage’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/hdr/hdrloader.cpp: In static member function ‘static bool HDRLoader::load(const char*, bool, HDRLoaderResult&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/hdr/hdrloader.cpp:101:10: warning: variable ‘cmd’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/vtf/ReaderWriterVTF.cpp: In function ‘osg::Image* ReadVTFFile(std::istream&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/vtf/ReaderWriterVTF.cpp:360:23: warning: variable ‘base’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/jp2/ReaderWriterJP2.cpp: In function ‘int putdata(jas_stream_t*, jas_image_t*, int)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/jp2/ReaderWriterJP2.cpp:41:13: warning: variable ‘linelen’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/Inventor/ConvertToInventor.cpp: In member function ‘void ConvertToInventor::processGeometry(const osg::Geometry*, ConvertToInventor::InventorState*)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/Inventor/ConvertToInventor.cpp:1639:10: warning: variable ‘ok’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/Inventor/ConvertFromInventor.cpp: In member function ‘virtual SbBool SoVRMLImageTextureOsg::readInstance(SoInput*, short unsigned int)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/Inventor/ConvertFromInventor.cpp:1264:16: warning: variable ‘retval’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/GeometryRecords.cpp: In member function ‘virtual void flt::Face::readRecord(flt::RecordInputStream&, flt::Document&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/GeometryRecords.cpp:369:19: warning: variable ‘secondaryPackedColor’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/GeometryRecords.cpp: In member function ‘virtual void flt::Mesh::readRecord(flt::RecordInputStream&, flt::Document&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/GeometryRecords.cpp:942:19: warning: variable ‘secondaryPackedColor’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp: In member function ‘virtual osgDB::ReaderWriter::ReadResult FLTReaderWriter::readNode(std::istream&, const Options*) const’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp:427:40: warning: variable ‘pos’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ive/ShapeAttributeList.cpp: In member function ‘void ive::ShapeAttributeList::write(ive::DataOutputStream*)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ive/ShapeAttributeList.cpp:31:48: warning: variable ‘it’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp: In member function ‘void ac3d::Geode::ProcessGeometry(std::ostream&, unsigned int)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp:806:35: warning: variable ‘fRep_s’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp:806:43: warning: variable ‘fRep_t’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp:807:35: warning: variable ‘fOffset_s’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp:807:46: warning: variable ‘fOffset_t’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp:932:38: warning: variable ‘primLength’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_geom.cpp: In member function ‘virtual bool trpgGeometry::Write(trpgWriteBuffer&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_geom.cpp:615:19: warning: variable ‘u’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_material.cpp: In member function ‘int trpgMatTable::AddMaterial(const trpgMaterial&, bool)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_material.cpp:103:10: warning: variable ‘spaceInTable’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_rarchive.cpp: In member function ‘virtual bool trpgr_Archive::ReadHeader(bool)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_rarchive.cpp:261:14: warning: variable ‘headerHasTexTable’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/unzip.cpp: In member function ‘ZRESULT TUnzip::Get(int, ZIPENTRY*)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/unzip.cpp:4055:8: warning: variable ‘hidden’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/unzip.cpp:4055:22: warning: variable ‘system’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/unzip.cpp:4055:36: warning: variable ‘archive’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/ZipArchive.cpp: In member function ‘virtual bool ZipArchive::getFileNames(osgDB::Archive::FileNameList&) const’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/ZipArchive.cpp:91:37: warning: variable ‘iterEnd’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/pvr/ReaderWriterPVR.cpp: In member function ‘osgDB::ReaderWriter::ReadResult ReaderWriterPVR::readPVRStream(std::istream&) const’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/pvr/ReaderWriterPVR.cpp:155:14: warning: variable ‘hasAlpha’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/View.cpp: In function ‘osg::Geometry* create3DSphericalDisplayDistortionMesh(const Vec3&, const Vec3&, const Vec3&, double, double, osg::Image*, const Matrix&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/View.cpp:737:15: warning: variable ‘cursor’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/View.cpp: In function ‘osg::Geometry* createParoramicSphericalDisplayDistortionMesh(const Vec3&, const Vec3&, const Vec3&, double, double, osg::Image*, const Matrix&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/View.cpp:1130:19: warning: variable ‘cursor’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/View.cpp:1118:15: warning: variable ‘dx’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/GraphicsWindowX11.cpp: In member function ‘virtual void osgViewer::GraphicsWindowX11::checkEvents()’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/GraphicsWindowX11.cpp:1181:10: warning: variable ‘destroyWindowRequested’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/cfg/ConfigParser.cpp: In member function ‘bool osgProducer::CameraConfig::parseFile(const string&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/cfg/ConfigParser.cpp:2247:13: warning: variable ‘result’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgQt/QGraphicsViewAdapter.cpp: In member function ‘bool osgQt::QGraphicsViewAdapter::handlePointerEvent(int, int, int)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgQt/QGraphicsViewAdapter.cpp:344:17: warning: variable ‘viewportGeometry’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgdistortion/osgdistortion.cpp: In function ‘osg::Node* createDistortionSubgraph(osg::Node*, const Vec4&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgdistortion/osgdistortion.cpp:125:19: warning: variable ‘cursor’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgdistortion/osgdistortion.cpp:126:19: warning: variable ‘texcoord’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgdistortion/osgdistortion.cpp: In function ‘osg::Geometry* createDomeDistortionMesh(const Vec3&, const Vec3&, const Vec3&, osg::ArgumentParser&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgdistortion/osgdistortion.cpp:358:15: warning: variable ‘cursor’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgposter/osgposter.cpp: In function ‘int main(int, char**)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgposter/osgposter.cpp:253:31: warning: variable ‘outputTiles’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgthreadedterrain/osgthreadedterrain.cpp: In function ‘int main(int, char**)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgthreadedterrain/osgthreadedterrain.cpp:669:10: warning: variable ‘readParameter’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgtext3D/TextNode.cpp: In member function ‘virtual void osgText::Layout::layout(osgText::TextNode&) const’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgtext3D/TextNode.cpp:80:11: warning: variable ‘characterHeightScale’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgvolume/osgvolume.cpp: In function ‘int main(int, char**)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgvolume/osgvolume.cpp:678:38: warning: variable ‘internalFormatMode’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgwidgetcanvas/osgwidgetcanvas.cpp: In function ‘bool windowMouseOver(osgWidget::Event&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgwidgetcanvas/osgwidgetcanvas.cpp:27:24: warning: variable ‘xy’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgwidgetcanvas/osgwidgetcanvas.cpp: In function ‘bool widgetMouseOver(osgWidget::Event&)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgwidgetcanvas/osgwidgetcanvas.cpp:35:24: warning: variable ‘xy’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/p3d/ReaderWriterP3D.cpp: In member function ‘osg::Node* ReaderWriterP3DXML::parseXmlGraph(osgDB::XmlNode*, bool, osgDB::Options*) const’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/p3d/ReaderWriterP3D.cpp:2121:10: warning: variable ‘readSlide’ set but not used [-Wunused-but-set-variable] /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/applications/present3D/present3D.cpp: In function ‘int main(int, char**)’: /home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/applications/present3D/present3D.cpp:639:10: warning: variable ‘sizesSpecified’ set but not used [-Wunused-but-set-variable]
934 lines
31 KiB
C++
934 lines
31 KiB
C++
/* OpenSceneGraph example, osgterrain.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
|
|
#include <OpenThreads/Block>
|
|
|
|
#include <osg/Group>
|
|
#include <osg/Geode>
|
|
#include <osg/ShapeDrawable>
|
|
#include <osg/Texture2D>
|
|
#include <osg/PositionAttitudeTransform>
|
|
#include <osg/MatrixTransform>
|
|
#include <osg/CoordinateSystemNode>
|
|
#include <osg/ClusterCullingCallback>
|
|
#include <osg/ArgumentParser>
|
|
|
|
|
|
#include <osgDB/FileUtils>
|
|
#include <osgDB/fstream>
|
|
#include <osgDB/ReadFile>
|
|
|
|
#include <osgUtil/IncrementalCompileOperation>
|
|
|
|
#include <osgText/FadeText>
|
|
|
|
#include <osgViewer/Viewer>
|
|
#include <osgViewer/ViewerEventHandlers>
|
|
|
|
#include <osgGA/TrackballManipulator>
|
|
#include <osgGA/FlightManipulator>
|
|
#include <osgGA/DriveManipulator>
|
|
#include <osgGA/KeySwitchMatrixManipulator>
|
|
#include <osgGA/StateSetManipulator>
|
|
#include <osgGA/AnimationPathManipulator>
|
|
#include <osgGA/TerrainManipulator>
|
|
|
|
#include <osgTerrain/TerrainTile>
|
|
#include <osgTerrain/GeometryTechnique>
|
|
#include <osgTerrain/Layer>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
typedef std::vector< osg::ref_ptr<osg::GraphicsThread> > GraphicsThreads;
|
|
|
|
struct ReleaseBlockOnCompileCompleted : public osgUtil::IncrementalCompileOperation::CompileCompletedCallback
|
|
{
|
|
|
|
ReleaseBlockOnCompileCompleted(osg::RefBlockCount* block):
|
|
_block(block) {}
|
|
|
|
virtual bool compileCompleted(osgUtil::IncrementalCompileOperation::CompileSet* compileSet)
|
|
{
|
|
if (_block.valid()) _block->completed();
|
|
|
|
// tell IncrementalCompileOperation that it's now safe to remove the compileSet
|
|
|
|
osg::notify(osg::NOTICE)<<"compileCompleted("<<compileSet<<")"<<std::endl;
|
|
|
|
return true;
|
|
}
|
|
|
|
osg::ref_ptr<osg::RefBlockCount> _block;
|
|
};
|
|
|
|
|
|
class LoadAndCompileOperation : public osg::Operation
|
|
{
|
|
public:
|
|
|
|
LoadAndCompileOperation(const std::string& filename, osgUtil::IncrementalCompileOperation* ico , osg::RefBlockCount* block):
|
|
Operation("Load and compile Operation", false),
|
|
_filename(filename),
|
|
_incrementalCompileOperation(ico),
|
|
_block(block) {}
|
|
|
|
virtual void operator () (osg::Object* object)
|
|
{
|
|
// osg::notify(osg::NOTICE)<<"LoadAndCompileOperation "<<_filename<<std::endl;
|
|
|
|
_loadedModel = osgDB::readNodeFile(_filename);
|
|
|
|
if (_loadedModel.valid() && _incrementalCompileOperation.valid())
|
|
{
|
|
osg::ref_ptr<osgUtil::IncrementalCompileOperation::CompileSet> compileSet =
|
|
new osgUtil::IncrementalCompileOperation::CompileSet(_loadedModel.get());
|
|
|
|
compileSet->_compileCompletedCallback = new ReleaseBlockOnCompileCompleted(_block.get());
|
|
|
|
_incrementalCompileOperation->add(compileSet.get());
|
|
}
|
|
else
|
|
{
|
|
if (_block.valid()) _block->completed();
|
|
}
|
|
|
|
// osg::notify(osg::NOTICE)<<"done LoadAndCompileOperation "<<_filename<<std::endl;
|
|
}
|
|
|
|
std::string _filename;
|
|
osg::ref_ptr<osg::Node> _loadedModel;
|
|
osg::ref_ptr<osgUtil::IncrementalCompileOperation> _incrementalCompileOperation;
|
|
osg::ref_ptr<osg::RefBlockCount> _block;
|
|
|
|
};
|
|
|
|
class MasterOperation : public osg::Operation
|
|
{
|
|
public:
|
|
|
|
typedef std::set<std::string> Files;
|
|
typedef std::map<std::string, osg::ref_ptr<osg::Node> > FilenameNodeMap;
|
|
typedef std::vector< osg::ref_ptr<osg::Node> > Nodes;
|
|
|
|
|
|
MasterOperation(const std::string& filename, osgUtil::IncrementalCompileOperation* ico):
|
|
Operation("Master reading operation",true),
|
|
_filename(filename),
|
|
_incrementalCompileOperation(ico)
|
|
{
|
|
}
|
|
|
|
/** Set the OperationQueue that the MasterOperation can use to place tasks like file loading on for other processes to handle.*/
|
|
void setOperationQueue(osg::OperationQueue* oq) { _operationQueue = oq; }
|
|
|
|
osg::OperationQueue* getOperationQueue() { return _operationQueue.get(); }
|
|
|
|
bool readMasterFile(Files& files) const
|
|
{
|
|
osgDB::ifstream fin(_filename.c_str());
|
|
if (fin)
|
|
{
|
|
osgDB::Input fr;
|
|
fr.attach(&fin);
|
|
|
|
bool readFilename = false;
|
|
|
|
while(!fr.eof())
|
|
{
|
|
bool itrAdvanced = false;
|
|
if (fr.matchSequence("file %s") || fr.matchSequence("file %w") )
|
|
{
|
|
files.insert(fr[1].getStr());
|
|
fr += 2;
|
|
itrAdvanced = true;
|
|
readFilename = true;
|
|
}
|
|
|
|
if (!itrAdvanced)
|
|
{
|
|
++fr;
|
|
}
|
|
}
|
|
|
|
return readFilename;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool open(osg::Group* group)
|
|
{
|
|
Files files;
|
|
readMasterFile(files);
|
|
for(Files::iterator itr = files.begin();
|
|
itr != files.end();
|
|
++itr)
|
|
{
|
|
osg::Node* model = osgDB::readNodeFile(*itr);
|
|
if (model)
|
|
{
|
|
osg::notify(osg::NOTICE)<<"open: Loaded file "<<*itr<<std::endl;
|
|
group->addChild(model);
|
|
_existingFilenameNodeMap[*itr] = model;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
virtual void operator () (osg::Object* callingObject)
|
|
{
|
|
// decided which method to call according to whole has called me.
|
|
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(callingObject);
|
|
|
|
if (viewer) update(viewer->getSceneData());
|
|
else load();
|
|
}
|
|
|
|
void load()
|
|
{
|
|
//osg::notify(osg::NOTICE)<<"void load(Object)"<<std::endl;
|
|
Files filesA;
|
|
Files filesB;
|
|
|
|
readMasterFile(filesB);
|
|
// osg::notify(osg::NOTICE)<<"First read "<<filesA.size()<<std::endl;
|
|
|
|
// itererate until the master file is stable
|
|
do
|
|
{
|
|
OpenThreads::Thread::microSleep(100000);
|
|
|
|
filesB.swap(filesA);
|
|
filesB.clear();
|
|
readMasterFile(filesB);
|
|
|
|
// osg::notify(osg::NOTICE)<<"second read "<<filesB.size()<<std::endl;
|
|
|
|
} while (filesA!=filesB);
|
|
|
|
Files files;
|
|
files.swap(filesB);
|
|
|
|
// osg::notify(osg::NOTICE)<<"Now equal "<<files.size()<<std::endl;
|
|
|
|
|
|
Files newFiles;
|
|
Files removedFiles;
|
|
|
|
// find out which files are new, and which ones have been removed.
|
|
{
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
|
|
|
for(Files::iterator fitr = files.begin();
|
|
fitr != files.end();
|
|
++fitr)
|
|
{
|
|
if (_existingFilenameNodeMap.count(*fitr)==0) newFiles.insert(*fitr);
|
|
}
|
|
|
|
for(FilenameNodeMap::iterator litr = _existingFilenameNodeMap.begin();
|
|
litr != _existingFilenameNodeMap.end();
|
|
++litr)
|
|
{
|
|
if (files.count(litr->first)==0)
|
|
{
|
|
removedFiles.insert(litr->first);
|
|
}
|
|
}
|
|
}
|
|
|
|
#if 0
|
|
if (!newFiles.empty() || !removedFiles.empty())
|
|
{
|
|
osg::notify(osg::NOTICE)<<std::endl<<std::endl<<"void operator () files.size()="<<files.size()<<std::endl;
|
|
}
|
|
#endif
|
|
|
|
// first load the new files.
|
|
FilenameNodeMap nodesToAdd;
|
|
if (!newFiles.empty())
|
|
{
|
|
|
|
typedef std::vector< osg::ref_ptr<osg::GraphicsThread> > GraphicsThreads;
|
|
GraphicsThreads threads;
|
|
|
|
for(unsigned int i=0; i<= osg::GraphicsContext::getMaxContextID(); ++i)
|
|
{
|
|
osg::GraphicsContext* gc = osg::GraphicsContext::getCompileContext(i);
|
|
osg::GraphicsThread* gt = gc ? gc->getGraphicsThread() : 0;
|
|
if (gt) threads.push_back(gt);
|
|
}
|
|
|
|
if (_operationQueue.valid())
|
|
{
|
|
// osg::notify(osg::NOTICE)<<"Using OperationQueue"<<std::endl;
|
|
|
|
_endOfLoadBlock = new osg::RefBlockCount(newFiles.size());
|
|
|
|
_endOfLoadBlock->reset();
|
|
|
|
typedef std::list< osg::ref_ptr<LoadAndCompileOperation> > LoadAndCompileList;
|
|
LoadAndCompileList loadAndCompileList;
|
|
|
|
for(Files::iterator nitr = newFiles.begin();
|
|
nitr != newFiles.end();
|
|
++nitr)
|
|
{
|
|
// osg::notify(osg::NOTICE)<<"Adding LoadAndCompileOperation "<<*nitr<<std::endl;
|
|
|
|
osg::ref_ptr<LoadAndCompileOperation> loadAndCompile = new LoadAndCompileOperation( *nitr, _incrementalCompileOperation.get(), _endOfLoadBlock.get() );
|
|
loadAndCompileList.push_back(loadAndCompile);
|
|
_operationQueue->add( loadAndCompile.get() );
|
|
}
|
|
|
|
#if 1
|
|
osg::ref_ptr<osg::Operation> operation;
|
|
while ((operation=_operationQueue->getNextOperation()).valid())
|
|
{
|
|
// osg::notify(osg::NOTICE)<<"Local running of operation"<<std::endl;
|
|
(*operation)(0);
|
|
}
|
|
#endif
|
|
// osg::notify(osg::NOTICE)<<"Waiting for completion of LoadAndCompile operations"<<std::endl;
|
|
_endOfLoadBlock->block();
|
|
// osg::notify(osg::NOTICE)<<"done ... Waiting for completion of LoadAndCompile operations"<<std::endl;
|
|
|
|
for(LoadAndCompileList::iterator litr = loadAndCompileList.begin();
|
|
litr != loadAndCompileList.end();
|
|
++litr)
|
|
{
|
|
if ((*litr)->_loadedModel.valid())
|
|
{
|
|
nodesToAdd[(*litr)->_filename] = (*litr)->_loadedModel;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
_endOfLoadBlock = new osg::RefBlockCount(newFiles.size());
|
|
|
|
_endOfLoadBlock->reset();
|
|
|
|
for(Files::iterator nitr = newFiles.begin();
|
|
nitr != newFiles.end();
|
|
++nitr)
|
|
{
|
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(*nitr);
|
|
|
|
if (loadedModel.get())
|
|
{
|
|
nodesToAdd[*nitr] = loadedModel;
|
|
|
|
if (_incrementalCompileOperation.valid())
|
|
{
|
|
osg::ref_ptr<osgUtil::IncrementalCompileOperation::CompileSet> compileSet =
|
|
new osgUtil::IncrementalCompileOperation::CompileSet(loadedModel.get());
|
|
|
|
compileSet->_compileCompletedCallback = new ReleaseBlockOnCompileCompleted(_endOfLoadBlock.get());
|
|
|
|
_incrementalCompileOperation->add(compileSet.get());
|
|
}
|
|
else
|
|
{
|
|
_endOfLoadBlock->completed();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_endOfLoadBlock->completed();
|
|
}
|
|
}
|
|
|
|
_endOfLoadBlock->block();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool requiresBlock = false;
|
|
|
|
// pass the locally peppared data to MasterOperations shared data
|
|
// so that updated thread can merge these changes with the main scene
|
|
// graph. This merge is carried out via the update(..) method.
|
|
if (!removedFiles.empty() || !nodesToAdd.empty())
|
|
{
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
|
_nodesToRemove.swap(removedFiles);
|
|
_nodesToAdd.swap(nodesToAdd);
|
|
requiresBlock = true;
|
|
}
|
|
|
|
// now block so we don't try to load anything till the new data has been merged
|
|
// otherwise _existingFilenameNodeMap will get out of sync.
|
|
if (requiresBlock)
|
|
{
|
|
_updatesMergedBlock.block();
|
|
}
|
|
else
|
|
{
|
|
OpenThreads::Thread::YieldCurrentThread();
|
|
}
|
|
|
|
}
|
|
|
|
// merge the changes with the main scene graph.
|
|
void update(osg::Node* scene)
|
|
{
|
|
// osg::notify(osg::NOTICE)<<"void update(Node*)"<<std::endl;
|
|
|
|
osg::Group* group = dynamic_cast<osg::Group*>(scene);
|
|
if (!group)
|
|
{
|
|
osg::notify(osg::NOTICE)<<"Error, MasterOperation::update(Node*) can only work with a Group as Viewer::getSceneData()."<<std::endl;
|
|
return;
|
|
}
|
|
|
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
|
|
|
if (!_nodesToRemove.empty() || !_nodesToAdd.empty())
|
|
{
|
|
osg::notify(osg::NOTICE)<<"update().................. "<<std::endl;
|
|
}
|
|
|
|
if (!_nodesToRemove.empty())
|
|
{
|
|
for(Files::iterator itr = _nodesToRemove.begin();
|
|
itr != _nodesToRemove.end();
|
|
++itr)
|
|
{
|
|
FilenameNodeMap::iterator fnmItr = _existingFilenameNodeMap.find(*itr);
|
|
if (fnmItr != _existingFilenameNodeMap.end())
|
|
{
|
|
osg::notify(osg::NOTICE)<<" update():removing "<<*itr<<std::endl;
|
|
|
|
group->removeChild(fnmItr->second.get());
|
|
_existingFilenameNodeMap.erase(fnmItr);
|
|
}
|
|
}
|
|
|
|
_nodesToRemove.clear();
|
|
}
|
|
|
|
if (!_nodesToAdd.empty())
|
|
{
|
|
for(FilenameNodeMap::iterator itr = _nodesToAdd.begin();
|
|
itr != _nodesToAdd.end();
|
|
++itr)
|
|
{
|
|
osg::notify(osg::NOTICE)<<" update():inserting "<<itr->first<<std::endl;
|
|
group->addChild(itr->second.get());
|
|
_existingFilenameNodeMap[itr->first] = itr->second;
|
|
}
|
|
|
|
_nodesToAdd.clear();
|
|
}
|
|
|
|
_updatesMergedBlock.release();
|
|
|
|
}
|
|
|
|
// add release implementation so that any thread cancellation can
|
|
// work even when blocks and barriers are used.
|
|
virtual void release()
|
|
{
|
|
if (_operationQueue.valid()) _operationQueue->removeAllOperations();
|
|
|
|
_updatesMergedBlock.release();
|
|
if (_endOfCompilebarrier.valid()) _endOfCompilebarrier.release();
|
|
if (_endOfLoadBlock.valid()) _endOfLoadBlock.release();
|
|
}
|
|
|
|
|
|
std::string _filename;
|
|
|
|
OpenThreads::Mutex _mutex;
|
|
FilenameNodeMap _existingFilenameNodeMap;
|
|
Files _nodesToRemove;
|
|
FilenameNodeMap _nodesToAdd;
|
|
OpenThreads::Block _updatesMergedBlock;
|
|
|
|
osg::ref_ptr<osgUtil::IncrementalCompileOperation> _incrementalCompileOperation;
|
|
osg::ref_ptr<osg::BarrierOperation> _endOfCompilebarrier;
|
|
osg::ref_ptr<osg::RefBlockCount> _endOfLoadBlock;
|
|
|
|
osg::ref_ptr<osg::OperationQueue> _operationQueue;
|
|
};
|
|
|
|
class FilterHandler : public osgGA::GUIEventHandler
|
|
{
|
|
public:
|
|
|
|
FilterHandler(osgTerrain::GeometryTechnique* gt):
|
|
_gt(gt) {}
|
|
|
|
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
|
|
{
|
|
if (!_gt) return false;
|
|
|
|
switch(ea.getEventType())
|
|
{
|
|
case(osgGA::GUIEventAdapter::KEYDOWN):
|
|
{
|
|
if (ea.getKey() == 'g')
|
|
{
|
|
osg::notify(osg::NOTICE)<<"Gaussian"<<std::endl;
|
|
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::GAUSSIAN);
|
|
return true;
|
|
}
|
|
else if (ea.getKey() == 's')
|
|
{
|
|
osg::notify(osg::NOTICE)<<"Smooth"<<std::endl;
|
|
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::SMOOTH);
|
|
return true;
|
|
}
|
|
else if (ea.getKey() == 'S')
|
|
{
|
|
osg::notify(osg::NOTICE)<<"Sharpen"<<std::endl;
|
|
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::SHARPEN);
|
|
return true;
|
|
}
|
|
else if (ea.getKey() == '+')
|
|
{
|
|
_gt->setFilterWidth(_gt->getFilterWidth()*1.1);
|
|
osg::notify(osg::NOTICE)<<"Filter width = "<<_gt->getFilterWidth()<<std::endl;
|
|
return true;
|
|
}
|
|
else if (ea.getKey() == '-')
|
|
{
|
|
_gt->setFilterWidth(_gt->getFilterWidth()/1.1);
|
|
osg::notify(osg::NOTICE)<<"Filter width = "<<_gt->getFilterWidth()<<std::endl;
|
|
return true;
|
|
}
|
|
else if (ea.getKey() == '>')
|
|
{
|
|
_gt->setFilterBias(_gt->getFilterBias()+0.1);
|
|
osg::notify(osg::NOTICE)<<"Filter bias = "<<_gt->getFilterBias()<<std::endl;
|
|
return true;
|
|
}
|
|
else if (ea.getKey() == '<')
|
|
{
|
|
_gt->setFilterBias(_gt->getFilterBias()-0.1);
|
|
osg::notify(osg::NOTICE)<<"Filter bias = "<<_gt->getFilterBias()<<std::endl;
|
|
return true;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
osg::observer_ptr<osgTerrain::GeometryTechnique> _gt;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LayerHandler : public osgGA::GUIEventHandler
|
|
{
|
|
public:
|
|
|
|
LayerHandler(osgTerrain::Layer* layer):
|
|
_layer(layer) {}
|
|
|
|
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
|
|
{
|
|
if (!_layer) return false;
|
|
|
|
float scale = 1.2;
|
|
|
|
switch(ea.getEventType())
|
|
{
|
|
case(osgGA::GUIEventAdapter::KEYDOWN):
|
|
{
|
|
if (ea.getKey() == 'q')
|
|
{
|
|
_layer->transform(0.0, scale);
|
|
return true;
|
|
}
|
|
else if (ea.getKey() == 'a')
|
|
{
|
|
_layer->transform(0.0, 1.0f/scale);
|
|
return true;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
osg::observer_ptr<osgTerrain::Layer> _layer;
|
|
};
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
osg::ArgumentParser arguments(&argc, argv);
|
|
|
|
// construct the viewer.
|
|
osgViewer::Viewer viewer(arguments);
|
|
|
|
// set up the camera manipulators.
|
|
{
|
|
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
|
|
|
|
keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
|
|
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
|
|
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
|
|
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
|
|
|
|
std::string pathfile;
|
|
char keyForAnimationPath = '5';
|
|
while (arguments.read("-p",pathfile))
|
|
{
|
|
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
|
|
if (apm || !apm->valid())
|
|
{
|
|
unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
|
|
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
|
|
keyswitchManipulator->selectMatrixManipulator(num);
|
|
++keyForAnimationPath;
|
|
}
|
|
}
|
|
|
|
viewer.setCameraManipulator( keyswitchManipulator.get() );
|
|
}
|
|
|
|
|
|
// add the state manipulator
|
|
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
|
|
|
// add the stats handler
|
|
viewer.addEventHandler(new osgViewer::StatsHandler);
|
|
|
|
// add the record camera path handler
|
|
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
|
|
|
|
// attach an IncrementaCompileOperation to allow the master loading
|
|
// to be handled with an incremental compile to avoid frame drops when large objects are added.
|
|
viewer.setIncrementalCompileOperation(new osgUtil::IncrementalCompileOperation());
|
|
|
|
double x = 0.0;
|
|
double y = 0.0;
|
|
double w = 1.0;
|
|
double h = 1.0;
|
|
|
|
unsigned int numLoadThreads = 1;
|
|
while (arguments.read("--load-threads",numLoadThreads)) { }
|
|
|
|
osg::ref_ptr<MasterOperation> masterOperation;
|
|
std::string masterFilename;
|
|
while(arguments.read("-m",masterFilename))
|
|
{
|
|
masterOperation = new MasterOperation(masterFilename, viewer.getIncrementalCompileOperation());
|
|
}
|
|
|
|
|
|
osg::ref_ptr<osgTerrain::TerrainTile> terrainTile = new osgTerrain::TerrainTile;
|
|
osg::ref_ptr<osgTerrain::Locator> locator = new osgTerrain::Locator;
|
|
osg::ref_ptr<osgTerrain::ValidDataOperator> validDataOperator = new osgTerrain::NoDataValue(0.0);
|
|
osg::ref_ptr<osgTerrain::Layer> lastAppliedLayer;
|
|
|
|
locator->setCoordinateSystemType(osgTerrain::Locator::GEOCENTRIC);
|
|
locator->setTransformAsExtents(-osg::PI, -osg::PI*0.5, osg::PI, osg::PI*0.5);
|
|
|
|
unsigned int layerNum = 0;
|
|
|
|
std::string filterName;
|
|
|
|
osg::Texture::FilterMode filter = osg::Texture::LINEAR;
|
|
|
|
float minValue, maxValue;
|
|
float scale = 1.0f;
|
|
float offset = 0.0f;
|
|
|
|
int pos = 1;
|
|
while(pos<arguments.argc())
|
|
{
|
|
std::string filename;
|
|
|
|
if (arguments.read(pos, "--layer",layerNum))
|
|
{
|
|
osg::notify(osg::NOTICE)<<"Set layer number to "<<layerNum<<std::endl;
|
|
}
|
|
|
|
else if (arguments.read(pos, "-b"))
|
|
{
|
|
terrainTile->setTreatBoundariesToValidDataAsDefaultValue(true);
|
|
}
|
|
|
|
else if (arguments.read(pos, "-e",x,y,w,h))
|
|
{
|
|
// define the extents.
|
|
locator->setCoordinateSystemType(osgTerrain::Locator::GEOCENTRIC);
|
|
locator->setTransformAsExtents(x,y,x+w,y+h);
|
|
}
|
|
|
|
else if (arguments.read(pos, "--transform",offset, scale) || arguments.read(pos, "-t",offset, scale))
|
|
{
|
|
// define the extents.
|
|
}
|
|
|
|
else if (arguments.read(pos, "--cartesian",x,y,w,h))
|
|
{
|
|
// define the extents.
|
|
locator->setCoordinateSystemType(osgTerrain::Locator::PROJECTED);
|
|
locator->setTransformAsExtents(x,y,x+w,y+h);
|
|
}
|
|
|
|
else if (arguments.read(pos, "--hf",filename))
|
|
{
|
|
osg::notify(osg::NOTICE)<<"--hf "<<filename<<std::endl;
|
|
|
|
osg::ref_ptr<osg::HeightField> hf = osgDB::readHeightFieldFile(filename);
|
|
if (hf.valid())
|
|
{
|
|
osg::ref_ptr<osgTerrain::HeightFieldLayer> hfl = new osgTerrain::HeightFieldLayer;
|
|
hfl->setHeightField(hf.get());
|
|
|
|
hfl->setLocator(locator.get());
|
|
hfl->setValidDataOperator(validDataOperator.get());
|
|
hfl->setMagFilter(filter);
|
|
|
|
if (offset!=0.0f || scale!=1.0f)
|
|
{
|
|
hfl->transform(offset,scale);
|
|
}
|
|
|
|
terrainTile->setElevationLayer(hfl.get());
|
|
|
|
lastAppliedLayer = hfl.get();
|
|
|
|
osg::notify(osg::NOTICE)<<"created osgTerrain::HeightFieldLayer"<<std::endl;
|
|
}
|
|
else
|
|
{
|
|
osg::notify(osg::NOTICE)<<"failed to create osgTerrain::HeightFieldLayer"<<std::endl;
|
|
}
|
|
|
|
scale = 1.0f;
|
|
offset = 0.0f;
|
|
|
|
}
|
|
|
|
else if (arguments.read(pos, "-d",filename) || arguments.read(pos, "--elevation-image",filename))
|
|
{
|
|
osg::notify(osg::NOTICE)<<"--elevation-image "<<filename<<std::endl;
|
|
|
|
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(filename);
|
|
if (image.valid())
|
|
{
|
|
osg::ref_ptr<osgTerrain::ImageLayer> imageLayer = new osgTerrain::ImageLayer;
|
|
imageLayer->setImage(image.get());
|
|
imageLayer->setLocator(locator.get());
|
|
imageLayer->setValidDataOperator(validDataOperator.get());
|
|
imageLayer->setMagFilter(filter);
|
|
|
|
if (offset!=0.0f || scale!=1.0f)
|
|
{
|
|
imageLayer->transform(offset,scale);
|
|
}
|
|
|
|
terrainTile->setElevationLayer(imageLayer.get());
|
|
|
|
lastAppliedLayer = imageLayer.get();
|
|
|
|
osg::notify(osg::NOTICE)<<"created Elevation osgTerrain::ImageLayer"<<std::endl;
|
|
}
|
|
else
|
|
{
|
|
osg::notify(osg::NOTICE)<<"failed to create osgTerrain::ImageLayer"<<std::endl;
|
|
}
|
|
|
|
scale = 1.0f;
|
|
offset = 0.0f;
|
|
|
|
}
|
|
|
|
else if (arguments.read(pos, "-c",filename) || arguments.read(pos, "--image",filename))
|
|
{
|
|
osg::notify(osg::NOTICE)<<"--image "<<filename<<" x="<<x<<" y="<<y<<" w="<<w<<" h="<<h<<std::endl;
|
|
|
|
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(filename);
|
|
if (image.valid())
|
|
{
|
|
osg::ref_ptr<osgTerrain::ImageLayer> imageLayer = new osgTerrain::ImageLayer;
|
|
imageLayer->setImage(image.get());
|
|
imageLayer->setLocator(locator.get());
|
|
imageLayer->setValidDataOperator(validDataOperator.get());
|
|
imageLayer->setMagFilter(filter);
|
|
|
|
if (offset!=0.0f || scale!=1.0f)
|
|
{
|
|
imageLayer->transform(offset,scale);
|
|
}
|
|
|
|
terrainTile->setColorLayer(layerNum, imageLayer.get());
|
|
|
|
lastAppliedLayer = imageLayer.get();
|
|
|
|
osg::notify(osg::NOTICE)<<"created Color osgTerrain::ImageLayer"<<std::endl;
|
|
}
|
|
else
|
|
{
|
|
osg::notify(osg::NOTICE)<<"failed to create osgTerrain::ImageLayer"<<std::endl;
|
|
}
|
|
|
|
scale = 1.0f;
|
|
offset = 0.0f;
|
|
|
|
}
|
|
|
|
else if (arguments.read(pos, "--filter",filterName))
|
|
{
|
|
if (filterName=="NEAREST")
|
|
{
|
|
osg::notify(osg::NOTICE)<<"--filter "<<filterName<<std::endl;
|
|
filter = osg::Texture::NEAREST;
|
|
}
|
|
else if (filterName=="LINEAR")
|
|
{
|
|
filter = osg::Texture::LINEAR;
|
|
osg::notify(osg::NOTICE)<<"--filter "<<filterName<<std::endl;
|
|
}
|
|
else
|
|
{
|
|
osg::notify(osg::NOTICE)<<"--filter "<<filterName<<" unrecognized filter name, please use LINEAER or NEAREST."<<std::endl;
|
|
}
|
|
|
|
if (terrainTile->getColorLayer(layerNum))
|
|
{
|
|
terrainTile->getColorLayer(layerNum)->setMagFilter(filter);
|
|
}
|
|
|
|
}
|
|
|
|
else if (arguments.read(pos, "--tf",minValue, maxValue))
|
|
{
|
|
osg::ref_ptr<osg::TransferFunction1D> tf = new osg::TransferFunction1D;
|
|
|
|
unsigned int numCells = 6;
|
|
float delta = (maxValue-minValue)/float(numCells-1);
|
|
float v = minValue;
|
|
|
|
tf->allocate(6);
|
|
tf->setColor(v, osg::Vec4(1.0,1.0,1.0,1.0)); v += delta;
|
|
tf->setColor(v, osg::Vec4(1.0,0.0,1.0,1.0)); v += delta;
|
|
tf->setColor(v, osg::Vec4(1.0,0.0,0.0,1.0)); v += delta;
|
|
tf->setColor(v, osg::Vec4(1.0,1.0,0.0,1.0)); v += delta;
|
|
tf->setColor(v, osg::Vec4(0.0,1.0,1.0,1.0)); v += delta;
|
|
tf->setColor(v, osg::Vec4(0.0,1.0,0.0,1.0));
|
|
|
|
osg::notify(osg::NOTICE)<<"--tf "<<minValue<<" "<<maxValue<<std::endl;
|
|
|
|
terrainTile->setColorLayer(layerNum, new osgTerrain::ContourLayer(tf.get()));
|
|
}
|
|
else
|
|
{
|
|
++pos;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
osg::ref_ptr<osg::Group> scene = new osg::Group;
|
|
|
|
if (terrainTile.valid() && (terrainTile->getElevationLayer() || terrainTile->getColorLayer(0)))
|
|
{
|
|
osg::notify(osg::NOTICE)<<"Terrain created"<<std::endl;
|
|
|
|
scene->addChild(terrainTile.get());
|
|
|
|
osg::ref_ptr<osgTerrain::GeometryTechnique> geometryTechnique = new osgTerrain::GeometryTechnique;
|
|
terrainTile->setTerrainTechnique(geometryTechnique.get());
|
|
viewer.addEventHandler(new FilterHandler(geometryTechnique.get()));
|
|
viewer.addEventHandler(new LayerHandler(lastAppliedLayer.get()));
|
|
}
|
|
|
|
if (masterOperation.valid())
|
|
{
|
|
osg::notify(osg::NOTICE)<<"Master operation created"<<std::endl;
|
|
|
|
masterOperation->open(scene.get());
|
|
}
|
|
|
|
if (scene->getNumChildren()==0)
|
|
{
|
|
osg::notify(osg::NOTICE)<<"No model created, please specify terrain or master file on command line."<<std::endl;
|
|
return 0;
|
|
}
|
|
|
|
viewer.setSceneData(scene.get());
|
|
|
|
|
|
// start operation thread if a master file has been used.
|
|
osg::ref_ptr<osg::OperationThread> masterOperationThread;
|
|
|
|
typedef std::list< osg::ref_ptr<osg::OperationThread> > OperationThreadList;
|
|
OperationThreadList generalThreadList;
|
|
|
|
if (masterOperation.valid())
|
|
{
|
|
masterOperationThread = new osg::OperationThread;
|
|
masterOperationThread->startThread();
|
|
|
|
masterOperationThread->add(masterOperation.get());
|
|
|
|
// if (numLoadThreads>0)
|
|
{
|
|
osg::ref_ptr<osg::OperationQueue> operationQueue = new osg::OperationQueue;
|
|
masterOperation->setOperationQueue(operationQueue.get());
|
|
|
|
for(unsigned int i=0; i<numLoadThreads; ++i)
|
|
{
|
|
osg::ref_ptr<osg::OperationThread> thread = new osg::OperationThread;
|
|
thread->setOperationQueue(operationQueue.get());
|
|
thread->startThread();
|
|
generalThreadList.push_back(thread);
|
|
}
|
|
}
|
|
|
|
viewer.addUpdateOperation(masterOperation.get());
|
|
}
|
|
|
|
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
|
|
|
// enable the use of compile contexts and associated threads.
|
|
// osg::DisplaySettings::instance()->setCompileContextsHint(true);
|
|
|
|
// realize the graphics windows.
|
|
viewer.realize();
|
|
|
|
// run the viewers main loop
|
|
return viewer.run();
|
|
|
|
}
|