root/OpenSceneGraph/trunk/examples/osgposter/osgposter.cpp @ 12597

Revision 12597, 16.1 kB (checked in by robert, 3 years ago)

Resolved warnings reported by g++ 4.6's -Wunused-but-set-variable.

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]

  • Property svn:eol-style set to native
Line 
1/* -*-c++-*- OpenSceneGraph example, osgposter.
2*
3*  Permission is hereby granted, free of charge, to any person obtaining a copy
4*  of this software and associated documentation files (the "Software"), to deal
5*  in the Software without restriction, including without limitation the rights
6*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7*  copies of the Software, and to permit persons to whom the Software is
8*  furnished to do so, subject to the following conditions:
9*
10*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16*  THE SOFTWARE.
17*/
18
19#include <osg/ArgumentParser>
20#include <osg/Texture2D>
21#include <osg/Switch>
22#include <osgDB/ReadFile>
23#include <osgDB/WriteFile>
24#include <osgGA/TrackballManipulator>
25#include <osgGA/StateSetManipulator>
26#include <osgViewer/Renderer>
27#include <osgViewer/Viewer>
28#include <osgViewer/ViewerEventHandlers>
29#include <iostream>
30#include "PosterPrinter.h"
31
32/* Computing view matrix helpers */
33template<class T>
34class FindTopMostNodeOfTypeVisitor : public osg::NodeVisitor
35{
36public:
37    FindTopMostNodeOfTypeVisitor()
38    :   osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
39        _foundNode(0)
40    {}
41   
42    void apply( osg::Node& node )
43    {
44        T* result = dynamic_cast<T*>( &node );
45        if ( result ) _foundNode = result;
46        else traverse( node );
47    }
48   
49    T* _foundNode;
50};
51
52template<class T>
53T* findTopMostNodeOfType( osg::Node* node )
54{
55    if ( !node ) return 0;
56   
57    FindTopMostNodeOfTypeVisitor<T> fnotv;
58    node->accept( fnotv );
59    return fnotv._foundNode;
60}
61
62/* Computing view matrix functions */
63void computeViewMatrix( osg::Camera* camera, const osg::Vec3d& eye, const osg::Vec3d& hpr )
64{
65    osg::Matrixd matrix;
66    matrix.makeTranslate( eye );
67    matrix.preMult( osg::Matrixd::rotate( hpr[0], 0.0, 1.0, 0.0) );
68    matrix.preMult( osg::Matrixd::rotate( hpr[1], 1.0, 0.0, 0.0) );
69    matrix.preMult( osg::Matrixd::rotate( hpr[2], 0.0, 0.0, 1.0) );
70    camera->setViewMatrix( osg::Matrixd::inverse(matrix) );
71}
72
73void computeViewMatrixOnEarth( osg::Camera* camera, osg::Node* scene,
74                               const osg::Vec3d& latLongHeight, const osg::Vec3d& hpr )
75{
76    osg::CoordinateSystemNode* csn = findTopMostNodeOfType<osg::CoordinateSystemNode>(scene);
77    if ( !csn ) return;
78   
79    // Compute eye point in world coordiantes
80    osg::Vec3d eye;
81    csn->getEllipsoidModel()->convertLatLongHeightToXYZ(
82        latLongHeight.x(), latLongHeight.y(), latLongHeight.z(), eye.x(), eye.y(), eye.z() );
83   
84    // Build matrix for computing target vector
85    osg::Matrixd target_matrix =
86        osg::Matrixd::rotate( -hpr.x(), osg::Vec3d(1,0,0),
87                              -latLongHeight.x(), osg::Vec3d(0,1,0),
88                               latLongHeight.y(), osg::Vec3d(0,0,1) );
89   
90    // Compute tangent vector
91    osg::Vec3d tangent = target_matrix.preMult( osg::Vec3d(0,0,1) );
92   
93    // Compute non-inclined, non-rolled up vector
94    osg::Vec3d up( eye );
95    up.normalize();
96   
97    // Incline by rotating the target- and up vector around the tangent/up-vector
98    // cross-product
99    osg::Vec3d up_cross_tangent = up ^ tangent;
100    osg::Matrixd incline_matrix = osg::Matrixd::rotate( hpr.y(), up_cross_tangent );
101    osg::Vec3d target = incline_matrix.preMult( tangent );
102   
103    // Roll by rotating the up vector around the target vector
104    osg::Matrixd roll_matrix = incline_matrix * osg::Matrixd::rotate( hpr.z(), target );
105    up = roll_matrix.preMult( up );
106    camera->setViewMatrixAsLookAt( eye, eye+target, up );
107}
108
109/* CustomRenderer: Do culling only while loading PagedLODs */
110class CustomRenderer : public osgViewer::Renderer
111{
112public:
113    CustomRenderer( osg::Camera* camera )
114    : osgViewer::Renderer(camera), _cullOnly(true)
115    {
116    }
117   
118    void setCullOnly(bool on) { _cullOnly = on; }
119
120    virtual void operator ()( osg::GraphicsContext* )
121    {
122        if ( _graphicsThreadDoesCull )
123        {
124            if (_cullOnly) cull();
125            else cull_draw();
126        }
127    }
128   
129    virtual void cull()
130    {
131        osgUtil::SceneView* sceneView = _sceneView[0].get();
132        if ( !sceneView || _done || _graphicsThreadDoesCull )
133            return;
134       
135        updateSceneView( sceneView );
136       
137        osgViewer::View* view = dynamic_cast<osgViewer::View*>( _camera->getView() );
138        if ( view )
139            sceneView->setFusionDistance( view->getFusionDistanceMode(), view->getFusionDistanceValue() );
140        sceneView->inheritCullSettings( *(sceneView->getCamera()) );
141        sceneView->cull();
142    }
143   
144    bool _cullOnly;
145};
146
147/* PrintPosterHandler: A gui handler for interactive high-res capturing */
148class PrintPosterHandler : public osgGA::GUIEventHandler
149{
150public:
151    PrintPosterHandler( PosterPrinter* printer )
152    : _printer(printer), _started(false) {}
153   
154    bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
155    {
156        osgViewer::View* view = dynamic_cast<osgViewer::View*>( &aa );
157        if ( !view ) return false;
158       
159        switch( ea.getEventType() )
160        {
161        case osgGA::GUIEventAdapter::FRAME:
162            if ( view->getDatabasePager() )
163            {
164                // Wait until all paged nodes are processed
165                if ( view->getDatabasePager()->getRequestsInProgress() )
166                    break;
167            }
168           
169            if ( _printer.valid() )
170            {
171                _printer->frame( view->getFrameStamp(), view->getSceneData() );
172                if ( _started && _printer->done() )
173                {
174                    osg::Switch* root = dynamic_cast<osg::Switch*>( view->getSceneData() );
175                    if ( root )
176                    {
177                        // Assume child 0 is the loaded model and 1 is the poster camera
178                        // Switch them in time to prevent dual traversals of subgraph
179                        root->setValue( 0, true );
180                        root->setValue( 1, false );
181                    }
182                    _started = false;
183                }
184            }
185            break;
186       
187        case osgGA::GUIEventAdapter::KEYDOWN:
188            if ( ea.getKey()=='p' || ea.getKey()=='P' )
189            {
190                if ( _printer.valid() )
191                {
192                    osg::Switch* root = dynamic_cast<osg::Switch*>( view->getSceneData() );
193                    if ( root )
194                    {
195                        // Assume child 0 is the loaded model and 1 is the poster camera
196                        root->setValue( 0, false );
197                        root->setValue( 1, true );
198                    }
199                   
200                    _printer->init( view->getCamera() );
201                    _started = true;
202                }
203                return true;
204            }
205            break;
206       
207        default:
208            break;
209        }
210        return false;
211    }
212
213protected:
214    osg::ref_ptr<PosterPrinter> _printer;
215    bool _started;
216};
217
218/* The main entry */
219int main( int argc, char** argv )
220{
221    osg::ArgumentParser arguments( &argc, argv );
222    osg::ApplicationUsage* usage = arguments.getApplicationUsage();
223    usage->setDescription( arguments.getApplicationName() +
224                           " is the example which demonstrates how to render high-resolution images (posters).");
225    usage->setCommandLineUsage( arguments.getApplicationName() + " [options] scene_file" );
226    usage->addCommandLineOption( "-h or --help", "Display this information." );
227    usage->addCommandLineOption( "--color <r> <g> <b>", "The background color." );
228    usage->addCommandLineOption( "--ext <ext>", "The output tiles' extension (Default: bmp)." );
229    usage->addCommandLineOption( "--poster <filename>", "The output poster's name (Default: poster.bmp)." );
230    usage->addCommandLineOption( "--tilesize <w> <h>", "Size of each image tile (Default: 640 480)." );
231    usage->addCommandLineOption( "--finalsize <w> <h>", "Size of the poster (Default: 6400 4800)." );
232    usage->addCommandLineOption( "--enable-output-poster", "Output the final poster file (Default)." );
233    usage->addCommandLineOption( "--disable-output-poster", "Don't output the final poster file." );
234    //usage->addCommandLineOption( "--enable-output-tiles", "Output all tile files." );
235    //usage->addCommandLineOption( "--disable-output-tiles", "Don't output all tile files (Default)." );
236    usage->addCommandLineOption( "--use-fb", "Use Frame Buffer for rendering tiles (Default, recommended).");
237    usage->addCommandLineOption( "--use-fbo", "Use Frame Buffer Object for rendering tiles.");
238    usage->addCommandLineOption( "--use-pbuffer","Use Pixel Buffer for rendering tiles.");
239    usage->addCommandLineOption( "--use-pbuffer-rtt","Use Pixel Buffer RTT for rendering tiles.");
240    usage->addCommandLineOption( "--inactive", "Inactive capturing mode." );
241    usage->addCommandLineOption( "--camera-eye <x> <y> <z>", "Set eye position in inactive mode." );
242    usage->addCommandLineOption( "--camera-latlongheight <lat> <lon> <h>", "Set eye position on earth in inactive mode." );
243    usage->addCommandLineOption( "--camera-hpr <h> <p> <r>", "Set eye rotation in inactive mode." );
244   
245    if ( arguments.read("-h") || arguments.read("--help") )
246    {
247        usage->write( std::cout );
248        return 1;
249    }
250   
251    // Poster arguments
252    bool activeMode = true;
253    bool outputPoster = true;
254    //bool outputTiles = false;
255    int tileWidth = 640, tileHeight = 480;
256    int posterWidth = 640*2, posterHeight = 480*2;
257    std::string posterName = "poster.bmp", extName = "bmp";
258    osg::Vec4 bgColor(0.2f, 0.2f, 0.6f, 1.0f);
259    osg::Camera::RenderTargetImplementation renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT;
260   
261    while ( arguments.read("--inactive") ) { activeMode = false; }
262    while ( arguments.read("--color", bgColor.r(), bgColor.g(), bgColor.b()) ) {}
263    while ( arguments.read("--tilesize", tileWidth, tileHeight) ) {}
264    while ( arguments.read("--finalsize", posterWidth, posterHeight) ) {}
265    while ( arguments.read("--poster", posterName) ) {}
266    while ( arguments.read("--ext", extName) ) {}
267    while ( arguments.read("--enable-output-poster") ) { outputPoster = true; }
268    while ( arguments.read("--disable-output-poster") ) { outputPoster = false; }
269    //while ( arguments.read("--enable-output-tiles") ) { outputTiles = true; }
270    //while ( arguments.read("--disable-output-tiles") ) { outputTiles = false; }
271    while ( arguments.read("--use-fbo")) { renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT; }
272    while ( arguments.read("--use-pbuffer")) { renderImplementation = osg::Camera::PIXEL_BUFFER; }
273    while ( arguments.read("--use-pbuffer-rtt")) { renderImplementation = osg::Camera::PIXEL_BUFFER_RTT; }
274    while ( arguments.read("--use-fb")) { renderImplementation = osg::Camera::FRAME_BUFFER; }
275   
276    // Camera settings for inactive screenshot
277    bool useLatLongHeight = true;
278    osg::Vec3d eye;
279    osg::Vec3d latLongHeight( 50.0, 10.0, 2000.0 );
280    osg::Vec3d hpr( 0.0, 0.0, 0.0 );
281    if ( arguments.read("--camera-eye", eye.x(), eye.y(), eye.z()) )
282    {
283        useLatLongHeight = false;
284        activeMode = false;
285    }
286    else if ( arguments.read("--camera-latlongheight", latLongHeight.x(), latLongHeight.y(), latLongHeight.z()) )
287    {
288        activeMode = false;
289        latLongHeight.x() = osg::DegreesToRadians( latLongHeight.x() );
290        latLongHeight.y() = osg::DegreesToRadians( latLongHeight.y() );
291    }
292    if ( arguments.read("--camera-hpr", hpr.x(), hpr.y(), hpr.z()) )
293    {
294        activeMode = false;
295        hpr.x() = osg::DegreesToRadians( hpr.x() );
296        hpr.y() = osg::DegreesToRadians( hpr.y() );
297        hpr.z() = osg::DegreesToRadians( hpr.z() );
298    }
299   
300    // Construct scene graph
301    osg::Node* scene = osgDB::readNodeFiles( arguments );
302    if ( !scene ) scene = osgDB::readNodeFile( "cow.osgt" );
303    if ( !scene )
304    {
305        std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
306        return 1;
307    }
308   
309    // Create camera for rendering tiles offscreen. FrameBuffer is recommended because it requires less memory.
310    osg::ref_ptr<osg::Camera> camera = new osg::Camera;
311    camera->setClearColor( bgColor );
312    camera->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
313    camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
314    camera->setRenderOrder( osg::Camera::PRE_RENDER );
315    camera->setRenderTargetImplementation( renderImplementation );
316    camera->setViewport( 0, 0, tileWidth, tileHeight );
317    camera->addChild( scene );
318   
319    // Set the printer
320    osg::ref_ptr<PosterPrinter> printer = new PosterPrinter;
321    printer->setTileSize( tileWidth, tileHeight );
322    printer->setPosterSize( posterWidth, posterHeight );
323    printer->setCamera( camera.get() );
324   
325    osg::ref_ptr<osg::Image> posterImage = 0;
326    if ( outputPoster )
327    {
328        posterImage = new osg::Image;
329        posterImage->allocateImage( posterWidth, posterHeight, 1, GL_RGBA, GL_UNSIGNED_BYTE );
330        printer->setFinalPoster( posterImage.get() );
331        printer->setOutputPosterName( posterName );
332    }
333   
334#if 0
335    // While recording sub-images of the poster, the scene will always be traversed twice, from its two
336    // parent node: root and camera. Sometimes this may not be so comfortable.
337    // To prevent this behaviour, we can use a switch node to enable one parent and disable the other.
338    // However, the solution also needs to be used with care, as the window will go blank while taking
339    // snapshots and recover later.
340    osg::ref_ptr<osg::Switch> root = new osg::Switch;
341    root->addChild( scene, true );
342    root->addChild( camera.get(), false );
343#else
344    osg::ref_ptr<osg::Group> root = new osg::Group;
345    root->addChild( scene );
346    root->addChild( camera.get() );
347#endif
348   
349    osgViewer::Viewer viewer;
350    viewer.setSceneData( root.get() );
351    viewer.getDatabasePager()->setDoPreCompile( false );
352   
353    if ( renderImplementation==osg::Camera::FRAME_BUFFER )
354    {
355        // FRAME_BUFFER requires the window resolution equal or greater than the to-be-copied size
356        viewer.setUpViewInWindow( 100, 100, tileWidth, tileHeight );
357    }
358    else
359    {
360        // We want to see the console output, so just render in a window
361        viewer.setUpViewInWindow( 100, 100, 800, 600 );
362    }
363   
364    if ( activeMode )
365    {
366        viewer.addEventHandler( new PrintPosterHandler(printer.get()) );
367        viewer.addEventHandler( new osgViewer::StatsHandler );
368        viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
369        viewer.setCameraManipulator( new osgGA::TrackballManipulator );
370        viewer.run();
371    }
372    else
373    {
374        osg::Camera* camera = viewer.getCamera();
375        if ( !useLatLongHeight ) computeViewMatrix( camera, eye, hpr );
376        else computeViewMatrixOnEarth( camera, scene, latLongHeight, hpr );
377       
378        osg::ref_ptr<CustomRenderer> renderer = new CustomRenderer( camera );
379        camera->setRenderer( renderer.get() );
380        viewer.setThreadingModel( osgViewer::Viewer::SingleThreaded );
381       
382        // Realize and initiate the first PagedLOD request
383        viewer.realize();
384        viewer.frame();
385       
386        printer->init( camera );
387        while ( !printer->done() )
388        {
389            viewer.advance();
390           
391            // Keep updating and culling until full level of detail is reached
392            renderer->setCullOnly( true );
393            while ( viewer.getDatabasePager()->getRequestsInProgress() )
394            {
395                viewer.updateTraversal();
396                viewer.renderingTraversals();
397            }
398           
399            renderer->setCullOnly( false );
400            printer->frame( viewer.getFrameStamp(), viewer.getSceneData() );
401            viewer.renderingTraversals();
402        }
403    }
404    return 0;
405}
Note: See TracBrowser for help on using the browser.