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

Revision 12597, 26.9 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
  • Property svn:keywords set to Author Date Id Revision
RevLine 
[6941]1/* OpenSceneGraph example, osgdistortion.
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
[2590]19#include <osg/GLExtensions>
20#include <osg/Node>
21#include <osg/Geometry>
22#include <osg/Notify>
23#include <osg/MatrixTransform>
24#include <osg/Texture2D>
25#include <osg/Stencil>
26#include <osg/ColorMask>
27#include <osg/Depth>
28#include <osg/Billboard>
29#include <osg/Material>
30#include <osg/Projection>
[6245]31#include <osg/TextureCubeMap>
32#include <osg/io_utils>
[2590]33
[6252]34
[2590]35#include <osgGA/TrackballManipulator>
36#include <osgGA/FlightManipulator>
37#include <osgGA/DriveManipulator>
[6252]38#include <osgGA/KeySwitchMatrixManipulator>
[6245]39#include <osgGA/StateSetManipulator>
[6252]40#include <osgGA/AnimationPathManipulator>
41#include <osgGA/TerrainManipulator>
[2590]42
43#include <osgUtil/SmoothingVisitor>
44
45#include <osgDB/Registry>
46#include <osgDB/ReadFile>
47
[5923]48#include <osgViewer/Viewer>
[6858]49#include <osgViewer/ViewerEventHandlers>
[2590]50
[6908]51#include <iostream>
52
[2688]53using namespace osg;
54
[4395]55osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearColour)
[2590]56{
[4377]57    osg::Group* distortionNode = new osg::Group;
[2590]58   
[4377]59    unsigned int tex_width = 1024;
60    unsigned int tex_height = 1024;
[2590]61   
[4377]62    osg::Texture2D* texture = new osg::Texture2D;
63    texture->setTextureSize(tex_width, tex_height);
64    texture->setInternalFormat(GL_RGBA);
65    texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
66    texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
67   
68    // set up the render to texture camera.
69    {
[5757]70        osg::Camera* camera = new osg::Camera;
[2590]71
[4395]72        // set clear the color and depth buffer
73        camera->setClearColor(clearColour);
74        camera->setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
75
[4377]76        // just inherit the main cameras view
77        camera->setReferenceFrame(osg::Transform::RELATIVE_RF);
78        camera->setProjectionMatrix(osg::Matrixd::identity());
79        camera->setViewMatrix(osg::Matrixd::identity());
[2590]80
[4377]81        // set viewport
82        camera->setViewport(0,0,tex_width,tex_height);
[2590]83
[4377]84        // set the camera to render before the main camera.
[5757]85        camera->setRenderOrder(osg::Camera::PRE_RENDER);
[2590]86
[4377]87        // tell the camera to use OpenGL frame buffer object where supported.
[5757]88        camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
[2590]89
[4377]90        // attach the texture and use it as the color buffer.
[5757]91        camera->attach(osg::Camera::COLOR_BUFFER, texture);
[2590]92
[4377]93        // add subgraph to render
94        camera->addChild(subgraph);
95       
96        distortionNode->addChild(camera);
97   }
[2590]98   
[6245]99    // set up the hud camera
[2590]100    {
[4377]101        // create the quad to visualize.
102        osg::Geometry* polyGeom = new osg::Geometry();
[2590]103
[4377]104        polyGeom->setSupportsDisplayList(false);
[2590]105
[4377]106        osg::Vec3 origin(0.0f,0.0f,0.0f);
107        osg::Vec3 xAxis(1.0f,0.0f,0.0f);
108        osg::Vec3 yAxis(0.0f,1.0f,0.0f);
109        float height = 1024.0f;
110        float width = 1280.0f;
111        int noSteps = 50;
[2590]112
[4377]113        osg::Vec3Array* vertices = new osg::Vec3Array;
114        osg::Vec2Array* texcoords = new osg::Vec2Array;
115        osg::Vec4Array* colors = new osg::Vec4Array;
[2590]116
[4377]117        osg::Vec3 bottom = origin;
118        osg::Vec3 dx = xAxis*(width/((float)(noSteps-1)));
119        osg::Vec3 dy = yAxis*(height/((float)(noSteps-1)));
[2590]120
[4377]121        osg::Vec2 bottom_texcoord(0.0f,0.0f);
122        osg::Vec2 dx_texcoord(1.0f/(float)(noSteps-1),0.0f);
123        osg::Vec2 dy_texcoord(0.0f,1.0f/(float)(noSteps-1));
[2590]124
[4377]125        int i,j;
126        for(i=0;i<noSteps;++i)
127        {
128            osg::Vec3 cursor = bottom+dy*(float)i;
129            osg::Vec2 texcoord = bottom_texcoord+dy_texcoord*(float)i;
130            for(j=0;j<noSteps;++j)
131            {
132                vertices->push_back(cursor);
133                texcoords->push_back(osg::Vec2((sin(texcoord.x()*osg::PI-osg::PI*0.5)+1.0f)*0.5f,(sin(texcoord.y()*osg::PI-osg::PI*0.5)+1.0f)*0.5f));
134                colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
[2590]135
[4377]136                cursor += dx;
137                texcoord += dx_texcoord;
138            }
139        }
[2590]140
[4377]141        // pass the created vertex array to the points geometry object.
142        polyGeom->setVertexArray(vertices);
[2590]143
[4377]144        polyGeom->setColorArray(colors);
145        polyGeom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
[2590]146
[4377]147        polyGeom->setTexCoordArray(0,texcoords);
[2590]148
149
[4377]150        for(i=0;i<noSteps-1;++i)
[2590]151        {
[4377]152            osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::QUAD_STRIP);
153            for(j=0;j<noSteps;++j)
154            {
155                elements->push_back(j+(i+1)*noSteps);
156                elements->push_back(j+(i)*noSteps);
157            }
158            polyGeom->addPrimitiveSet(elements);
[2590]159        }
160
161
[4377]162        // new we need to add the texture to the Drawable, we do so by creating a
163        // StateSet to contain the Texture StateAttribute.
164        osg::StateSet* stateset = polyGeom->getOrCreateStateSet();
165        stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
166        stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
[2590]167
[4377]168        osg::Geode* geode = new osg::Geode();
169        geode->addDrawable(polyGeom);
[2590]170
[4377]171        // set up the camera to render the textured quad
[5757]172        osg::Camera* camera = new osg::Camera;
[2590]173
[4377]174        // just inherit the main cameras view
175        camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
176        camera->setViewMatrix(osg::Matrix::identity());
177        camera->setProjectionMatrixAsOrtho2D(0,1280,0,1024);
[2590]178
[4377]179        // set the camera to render before the main camera.
[5757]180        camera->setRenderOrder(osg::Camera::NESTED_RENDER);
[2590]181
[4377]182        // add subgraph to render
183        camera->addChild(geode);
184       
185        distortionNode->addChild(camera);
[2590]186    }
[4377]187    return distortionNode;
[2590]188}
189
[6385]190void setDomeFaces(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
[6242]191{
192 
193    osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
194    if (!wsi)
195    {
196        osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
197        return;
198    }
[2590]199
[6242]200    unsigned int width, height;
201    wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
202
[6385]203    while (arguments.read("--width",width)) {}
204    while (arguments.read("--height",height)) {}
205
[6242]206    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
207    traits->x = 0;
208    traits->y = 0;
209    traits->width = width;
210    traits->height = height;
211    traits->windowDecoration = true;
212    traits->doubleBuffer = true;
213    traits->sharedContext = 0;
214
215    osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
216    if (!gc)
217    {
218        osg::notify(osg::NOTICE)<<"GraphicsWindow has not been created successfully."<<std::endl;
219        return;
220    }
221
222
223    int center_x = width/2;
224    int center_y = height/2;
225    int camera_width = 256;
226    int camera_height = 256;
227
228    // front face
229    {
230        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
231        camera->setGraphicsContext(gc.get());
232        camera->setViewport(new osg::Viewport(center_x-camera_width/2, center_y, camera_width, camera_height));
[6252]233
[6242]234        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
235        camera->setDrawBuffer(buffer);
236        camera->setReadBuffer(buffer);
237
238        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
239    }
240   
241    // top face
242    {
243        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
244        camera->setGraphicsContext(gc.get());
245        camera->setViewport(new osg::Viewport(center_x-camera_width/2, center_y+camera_height, camera_width, camera_height));
246        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
247        camera->setDrawBuffer(buffer);
248        camera->setReadBuffer(buffer);
249
250        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(-90.0f), 1.0,0.0,0.0));
251    }
252
253    // left face
254    {
255        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
256        camera->setGraphicsContext(gc.get());
257        camera->setViewport(new osg::Viewport(center_x-camera_width*3/2, center_y, camera_width, camera_height));
258        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
259        camera->setDrawBuffer(buffer);
260        camera->setReadBuffer(buffer);
261
262        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(-90.0f), 0.0,1.0,0.0));
263    }
264
265    // right face
266    {
267        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
268        camera->setGraphicsContext(gc.get());
269        camera->setViewport(new osg::Viewport(center_x+camera_width/2, center_y, camera_width, camera_height));
270        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
271        camera->setDrawBuffer(buffer);
272        camera->setReadBuffer(buffer);
273
274        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(90.0f), 0.0,1.0,0.0));
275    }
276
277    // bottom face
278    {
279        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
280        camera->setGraphicsContext(gc.get());
281        camera->setViewport(new osg::Viewport(center_x-camera_width/2, center_y-camera_height, camera_width, camera_height));
282        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
283        camera->setDrawBuffer(buffer);
284        camera->setReadBuffer(buffer);
285
286        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(90.0f), 1.0,0.0,0.0));
287    }
288
289    // back face
290    {
291        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
292        camera->setGraphicsContext(gc.get());
293        camera->setViewport(new osg::Viewport(center_x-camera_width/2, center_y-2*camera_height, camera_width, camera_height));
294        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
295        camera->setDrawBuffer(buffer);
296        camera->setReadBuffer(buffer);
297
298        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(-180.0f), 1.0,0.0,0.0));
299    }
300   
301    viewer.getCamera()->setProjectionMatrixAsPerspective(90.0f, 1.0, 1, 1000.0);
302
303    viewer.assignSceneDataToCameras();
304}
305
[6261]306osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector,
307                                        osg::ArgumentParser& arguments)
[6245]308{
[6261]309    double sphere_radius = 1.0;
[6301]310    if (arguments.read("--radius", sphere_radius)) {}
311
[6261]312    double collar_radius = 0.45;
[6301]313    if (arguments.read("--collar", collar_radius)) {}
314
[6261]315    osg::Vec3d center(0.0,0.0,0.0);
316    osg::Vec3d eye(0.0,0.0,0.0);
317   
318    double distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius);
[6301]319    if (arguments.read("--distance", distance)) {}
320   
321    bool centerProjection = false;
322
[6261]323    osg::Vec3d projector = eye - osg::Vec3d(0.0,0.0, distance);
324   
[6301]325   
[6261]326    osg::notify(osg::NOTICE)<<"Projector position = "<<projector<<std::endl;
[6301]327    osg::notify(osg::NOTICE)<<"distance = "<<distance<<std::endl;
[6261]328
329
[6260]330    // create the quad to visualize.
331    osg::Geometry* geometry = new osg::Geometry();
332
333    geometry->setSupportsDisplayList(false);
334
335    osg::Vec3 xAxis(widthVector);
336    float width = widthVector.length();
337    xAxis /= width;
338
339    osg::Vec3 yAxis(heightVector);
340    float height = heightVector.length();
341    yAxis /= height;
342   
[6301]343    int noSteps = 50;
[6260]344
345    osg::Vec3Array* vertices = new osg::Vec3Array;
346    osg::Vec3Array* texcoords = new osg::Vec3Array;
347    osg::Vec4Array* colors = new osg::Vec4Array;
348
349    osg::Vec3 bottom = origin;
350    osg::Vec3 dx = xAxis*(width/((float)(noSteps-1)));
351    osg::Vec3 dy = yAxis*(height/((float)(noSteps-1)));
[6261]352   
353    osg::Vec3d screenCenter = origin + widthVector*0.5f + heightVector*0.5f;
354    float screenRadius = heightVector.length() * 0.5f;
[6260]355
356    int i,j;
[6301]357    if (centerProjection)
[6260]358    {
[6301]359        for(i=0;i<noSteps;++i)
[6260]360        {
[6301]361            osg::Vec3 cursor = bottom+dy*(float)i;
362            for(j=0;j<noSteps;++j)
363            {
364                osg::Vec2 delta(cursor.x() - screenCenter.x(), cursor.y() - screenCenter.y());
365                double theta = atan2(-delta.y(), delta.x());
366                double phi = osg::PI_2 * delta.length() / screenRadius;
367                if (phi > osg::PI_2) phi = osg::PI_2;
368
369                phi *= 2.0;
370
371                // osg::notify(osg::NOTICE)<<"theta = "<<theta<< "phi="<<phi<<std::endl;
372
373                osg::Vec3 texcoord(sin(phi) * cos(theta),
374                                   sin(phi) * sin(theta),
375                                   cos(phi));
376
377                vertices->push_back(cursor);
378                colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
379                texcoords->push_back(texcoord);
380
381                cursor += dx;
382            }
383            // osg::notify(osg::NOTICE)<<std::endl;
[6260]384        }
385    }
[6301]386    else
387    {
388        for(i=0;i<noSteps;++i)
389        {
390            osg::Vec3 cursor = bottom+dy*(float)i;
391            for(j=0;j<noSteps;++j)
392            {
393                osg::Vec2 delta(cursor.x() - screenCenter.x(), cursor.y() - screenCenter.y());
394                double theta = atan2(-delta.y(), delta.x());
395                double phi = osg::PI_2 * delta.length() / screenRadius;
396                if (phi > osg::PI_2) phi = osg::PI_2;
[6260]397
[6301]398                // osg::notify(osg::NOTICE)<<"theta = "<<theta<< "phi="<<phi<<std::endl;
399               
400                double f = distance * sin(phi);
401                double e = distance * cos(phi) + sqrt( sphere_radius*sphere_radius - f*f);
402                double l = e * cos(phi);
403                double h = e * sin(phi);
404                double z = l - distance;
405               
406                osg::Vec3 texcoord(h * cos(theta) / sphere_radius,
407                                   h * sin(theta) / sphere_radius,
408                                   z / sphere_radius);
409
410                vertices->push_back(cursor);
411                colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
412                texcoords->push_back(texcoord);
413
414                cursor += dx;
415            }
416            // osg::notify(osg::NOTICE)<<std::endl;
417        }
418    }
419   
[6260]420    // pass the created vertex array to the points geometry object.
421    geometry->setVertexArray(vertices);
422
423    geometry->setColorArray(colors);
424    geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
425
426    geometry->setTexCoordArray(0,texcoords);
427
428    for(i=0;i<noSteps-1;++i)
429    {
430        osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::QUAD_STRIP);
431        for(j=0;j<noSteps;++j)
432        {
433            elements->push_back(j+(i+1)*noSteps);
434            elements->push_back(j+(i)*noSteps);
435        }
436        geometry->addPrimitiveSet(elements);
437    }
438   
439    return geometry;
[6461]440}
[6260]441
442void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
443{
[6245]444 
445    osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
446    if (!wsi)
447    {
448        osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
449        return;
450    }
451
452    unsigned int width, height;
453    wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
454
[6385]455    while (arguments.read("--width",width)) {}
456    while (arguments.read("--height",height)) {}
457
[6245]458    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
459    traits->x = 0;
460    traits->y = 0;
461    traits->width = width;
462    traits->height = height;
463    traits->windowDecoration = false;
464    traits->doubleBuffer = true;
465    traits->sharedContext = 0;
[6385]466   
467   
[6245]468
469    osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
470    if (!gc)
471    {
472        osg::notify(osg::NOTICE)<<"GraphicsWindow has not been created successfully."<<std::endl;
473        return;
474    }
475
[6252]476    int tex_width = 512;
477    int tex_height = 512;
478
[6260]479    int camera_width = tex_width;
480    int camera_height = tex_height;
481
[6245]482    osg::TextureCubeMap* texture = new osg::TextureCubeMap;
[6260]483
[6245]484    texture->setTextureSize(tex_width, tex_height);
485    texture->setInternalFormat(GL_RGB);
[6252]486    texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
487    texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
488   
489#if 0   
490    osg::Camera::RenderTargetImplementation renderTargetImplementation = osg::Camera::SEPERATE_WINDOW;
491    GLenum buffer = GL_FRONT;
492#else
493    osg::Camera::RenderTargetImplementation renderTargetImplementation = osg::Camera::FRAME_BUFFER_OBJECT;
494    GLenum buffer = GL_FRONT;
495#endif
[6245]496
497    // front face
498    {
499        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
500        camera->setName("Front face camera");
501        camera->setGraphicsContext(gc.get());
[6252]502        camera->setViewport(new osg::Viewport(0,0,camera_width, camera_height));
[6245]503        camera->setDrawBuffer(buffer);
504        camera->setReadBuffer(buffer);
[6252]505        camera->setAllowEventFocus(false);
506        // tell the camera to use OpenGL frame buffer object where supported.
507        camera->setRenderTargetImplementation(renderTargetImplementation);
508
[6245]509        // attach the texture and use it as the color buffer.
[6261]510        camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, osg::TextureCubeMap::POSITIVE_Y);
[6260]511
[6245]512        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
513    }
[6252]514
[6245]515   
516    // top face
517    {
518        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
519        camera->setName("Top face camera");
520        camera->setGraphicsContext(gc.get());
[6252]521        camera->setViewport(new osg::Viewport(0,0,camera_width, camera_height));
[6245]522        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
523        camera->setDrawBuffer(buffer);
524        camera->setReadBuffer(buffer);
[6252]525        camera->setAllowEventFocus(false);
[6245]526
[6252]527        // tell the camera to use OpenGL frame buffer object where supported.
528        camera->setRenderTargetImplementation(renderTargetImplementation);
529
[6245]530        // attach the texture and use it as the color buffer.
[6261]531        camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, osg::TextureCubeMap::POSITIVE_Z);
[6245]532
533        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(-90.0f), 1.0,0.0,0.0));
534    }
535
536    // left face
537    {
538        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
539        camera->setName("Left face camera");
540        camera->setGraphicsContext(gc.get());
[6252]541        camera->setViewport(new osg::Viewport(0,0,camera_width, camera_height));
[6245]542        camera->setDrawBuffer(buffer);
543        camera->setReadBuffer(buffer);
[6252]544        camera->setAllowEventFocus(false);
[6245]545
[6252]546        // tell the camera to use OpenGL frame buffer object where supported.
547        camera->setRenderTargetImplementation(renderTargetImplementation);
548
[6245]549        // attach the texture and use it as the color buffer.
550        camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, osg::TextureCubeMap::NEGATIVE_X);
551
[6261]552        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(-90.0f), 0.0,1.0,0.0) * osg::Matrixd::rotate(osg::inDegrees(-90.0f), 0.0,0.0,1.0));
[6245]553    }
554
555    // right face
556    {
557        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
558        camera->setName("Right face camera");
559        camera->setGraphicsContext(gc.get());
[6252]560        camera->setViewport(new osg::Viewport(0,0,camera_width, camera_height));
[6245]561        camera->setDrawBuffer(buffer);
562        camera->setReadBuffer(buffer);
[6252]563        camera->setAllowEventFocus(false);
[6245]564
[6252]565        // tell the camera to use OpenGL frame buffer object where supported.
566        camera->setRenderTargetImplementation(renderTargetImplementation);
567
[6245]568        // attach the texture and use it as the color buffer.
[6261]569        camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, osg::TextureCubeMap::POSITIVE_X);
[6245]570
[6261]571        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(90.0f), 0.0,1.0,0.0 ) * osg::Matrixd::rotate(osg::inDegrees(90.0f), 0.0,0.0,1.0));
[6245]572    }
573
574    // bottom face
575    {
576        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
577        camera->setGraphicsContext(gc.get());
578        camera->setName("Bottom face camera");
[6252]579        camera->setViewport(new osg::Viewport(0,0,camera_width, camera_height));
[6245]580        camera->setDrawBuffer(buffer);
581        camera->setReadBuffer(buffer);
[6252]582        camera->setAllowEventFocus(false);
[6245]583
[6252]584        // tell the camera to use OpenGL frame buffer object where supported.
585        camera->setRenderTargetImplementation(renderTargetImplementation);
586
[6245]587        // attach the texture and use it as the color buffer.
[6261]588        camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, osg::TextureCubeMap::NEGATIVE_Z);
[6245]589
[6261]590        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(90.0f), 1.0,0.0,0.0) * osg::Matrixd::rotate(osg::inDegrees(180.0f), 0.0,0.0,1.0));
[6245]591    }
592
593    // back face
594    {
595        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
596        camera->setName("Back face camera");
597        camera->setGraphicsContext(gc.get());
[6252]598        camera->setViewport(new osg::Viewport(0,0,camera_width, camera_height));
[6245]599        camera->setDrawBuffer(buffer);
600        camera->setReadBuffer(buffer);
[6252]601        camera->setAllowEventFocus(false);
[6245]602
[6252]603        // tell the camera to use OpenGL frame buffer object where supported.
604        camera->setRenderTargetImplementation(renderTargetImplementation);
605
[6245]606        // attach the texture and use it as the color buffer.
[6261]607        camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, osg::TextureCubeMap::NEGATIVE_Y);
[6245]608
[6261]609        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(180.0f), 1.0,0.0,0.0));
[6245]610    }
611   
612    viewer.getCamera()->setProjectionMatrixAsPerspective(90.0f, 1.0, 1, 1000.0);
613
614
615
616    // distortion correction set up.
617    {
[6260]618        osg::Geode* geode = new osg::Geode();
619        geode->addDrawable(createDomeDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), arguments));
[6245]620
[6260]621        // new we need to add the texture to the mesh, we do so by creating a
[6245]622        // StateSet to contain the Texture StateAttribute.
[6260]623        osg::StateSet* stateset = geode->getOrCreateStateSet();
[6245]624        stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
625        stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
626
627        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
628        camera->setGraphicsContext(gc.get());
629        camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
630        camera->setClearColor( osg::Vec4(0.1,0.1,1.0,1.0) );
[6252]631        camera->setViewport(new osg::Viewport(0, 0, width, height));
[6245]632        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
633        camera->setDrawBuffer(buffer);
634        camera->setReadBuffer(buffer);
635        camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
[6252]636        camera->setAllowEventFocus(false);
[6245]637        //camera->setInheritanceMask(camera->getInheritanceMask() & ~osg::CullSettings::CLEAR_COLOR & ~osg::CullSettings::COMPUTE_NEAR_FAR_MODE);
638        //camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
639       
[6260]640        camera->setProjectionMatrixAsOrtho2D(0,width,0,height);
[6245]641        camera->setViewMatrix(osg::Matrix::identity());
642
643        // add subgraph to render
644        camera->addChild(geode);
645       
646        camera->setName("DistortionCorrectionCamera");
647
[6264]648        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), false);
[6245]649    }
[6261]650   
651    viewer.getCamera()->setNearFarRatio(0.0001f);
[6245]652}
653
654
[5923]655int main(int argc, char** argv)
[2590]656{
657    // use an ArgumentParser object to manage the program arguments.
658    osg::ArgumentParser arguments(&argc,argv);
659
660    // construct the viewer.
[5923]661    osgViewer::Viewer viewer;
[6908]662
663    // load the nodes from the commandline arguments.
664    osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
665
666    // if not loaded assume no arguments passed in, try use default mode instead.
[12529]667    if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osgt");
[6908]668 
669    if (!loadedModel)
670    {
671        std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
672        return 1;
673    }
[2590]674   
[6242]675
[6301]676    if (arguments.read("--dome") || arguments.read("--puffer") )
[6242]677    {   
678
679        setDomeCorrection(viewer, arguments);
[2590]680   
[6908]681        viewer.setSceneData( loadedModel );
[6242]682    }
[6245]683    else if (arguments.read("--faces"))
684    {   
685
686        setDomeFaces(viewer, arguments);
[6301]687
[6908]688        viewer.setSceneData( loadedModel );
[6245]689    }
[6242]690    else
691    {
[6908]692        osg::Node* distortionNode = createDistortionSubgraph( loadedModel, viewer.getCamera()->getClearColor());
[6385]693        viewer.setSceneData( distortionNode );
[6301]694    }
[2590]695
[7098]696    while (arguments.read("--sky-light"))
697    {
698        viewer.setLightingMode(osg::View::SKY_LIGHT);
699    }
700   
701    if (viewer.getLightingMode()==osg::View::HEADLIGHT)
702    {
703        viewer.getLight()->setPosition(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
704    }
[6301]705
[7098]706
[6301]707    // load the nodes from the commandline arguments.
708    if (!viewer.getSceneData())
709    {
710        osg::notify(osg::NOTICE)<<"Please specify a model filename on the command line."<<std::endl;
711        return 1;
[6242]712    }
713
[6264]714
[6252]715    // set up the camera manipulators.
716    {
717        osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
718
719        keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
720        keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
721        keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
722        keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
723
724        std::string pathfile;
725        char keyForAnimationPath = '5';
726        while (arguments.read("-p",pathfile))
727        {
728            osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
729            if (apm || !apm->valid())
730            {
731                unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
732                keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
733                keyswitchManipulator->selectMatrixManipulator(num);
734                ++keyForAnimationPath;
735            }
736        }
737
738        viewer.setCameraManipulator( keyswitchManipulator.get() );
739    }
740
[6301]741    viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
[6245]742
743    // add the state manipulator
744    viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
745   
746    // add the stats handler
747    viewer.addEventHandler(new osgViewer::StatsHandler);
748
[5923]749    return viewer.run();
[2590]750}
Note: See TracBrowser for help on using the browser.