Compare commits

..

60 Commits

Author SHA1 Message Date
Robert Osfield
b50d199ded Release OpenSceneGraph-3.0.0 2011-06-28 09:27:02 +00:00
Robert Osfield
806993f3e0 Updated ChangeLog and add fix for typo of name 2011-06-28 07:52:55 +00:00
Robert Osfield
8f4c026a85 Fixed typo and added entry about osgParticle. 2011-06-28 07:37:19 +00:00
Robert Osfield
373687b72f From Wang Rui, merged from changeset 12674. "I've found a small problem which causes crashes in the 3ds plugin
while trying to load a model. The fix here will ensure that the
texture map is valid and everything could work well then."
2011-06-28 07:28:10 +00:00
Robert Osfield
73026ea973 Merged from svn/trunk changeset 12675, "Added #if lib curl version check around #include <curl/types.h> as this header was deprecated and now
removed entirely from libcurl-7.21.7."
2011-06-28 07:25:43 +00:00
Robert Osfield
55ff7019a1 Updated dates in prep for release. 2011-06-27 22:04:22 +00:00
Robert Osfield
efa37bd4c4 From Jean-Sebestien Guay, merged from svn/trunk changeset 12669/12670 - fix for windows bug when reading ascii files with unix file endings. 2011-06-27 21:36:21 +00:00
Robert Osfield
b4a32f6cab Updated NEWS 2011-06-27 13:42:56 +00:00
Robert Osfield
9ffd6d1dc0 Updated NEWS for 3.0.0 2011-06-27 13:16:22 +00:00
Robert Osfield
701c976495 Update AUTHORS file for 3.0.0. 2011-06-27 12:59:45 +00:00
Robert Osfield
3f7406e903 Updated ChangeLOG, NEWS and READE for 3.0.0 release 2011-06-27 12:08:05 +00:00
Robert Osfield
0079c132a7 Updated Version number to final 3.0.0 configuration. 2011-06-27 10:45:36 +00:00
Robert Osfield
3254630625 Merged doxygen comment improvement from svn/trunk. 2011-06-27 10:22:03 +00:00
Robert Osfield
125fa6d05d Merged from svn/trunk changeset 12656. From Andreas Eskland, "I found that a binary PNM file couldn't be read by the PNM plugin in the 3.0 branch. Attached is a small fix in ReaderWriterPNM.cpp, simply opening the file in binary mode." 2011-06-25 20:55:01 +00:00
Robert Osfield
a92241d40d Merged from svn/trunk changset 12654. Fixed memory growth issue when using Texture2D::SubloadCallbacks that don't set the TextureObjects sizes. 2011-06-25 11:02:09 +00:00
Robert Osfield
8ea9d68c9c Merged from svn/trunk changeset 12652, Tighten up float usage 2011-06-25 07:07:58 +00:00
Robert Osfield
1e94ed9fa8 Updated ChangeLog and AUTHORS file for 3.0.0-rc5 2011-06-24 19:45:21 +00:00
Robert Osfield
cd7dc0f161 Merged from svn/trunk changeset 12648, tightened up float/double usage 2011-06-24 19:18:53 +00:00
Robert Osfield
6779944c0e Updated ChangeLog, NEWS and READE for 3.0.0-rc5 2011-06-24 16:27:42 +00:00
Robert Osfield
d5f476a822 Merged from svn/trunk changeset 12645. Removed redundent assert and associated variables to fix warnings. 2011-06-24 16:16:04 +00:00
Robert Osfield
b361047aa0 Updated release candidate number to 5 for 3.0.0-rc5 2011-06-24 16:05:23 +00:00
Robert Osfield
bd2ad48c00 Merged from svn/trunk changeset 12642, "Implemented missing writeShader" 2011-06-24 15:05:28 +00:00
Robert Osfield
e306f27e23 Merged from svn/trunk changeset 12640, From Martin Innus, fixed erroneous change of INTEGER to UNKNOWN, reverting back to INTEGER. 2011-06-24 13:36:45 +00:00
Robert Osfield
26ee7e07d3 Merged from svn/trunk changeset 12638:
Implemented missing Archive::readShader/writeShader, and added searching of the archive list in Registr::read() so that files
that are stored in the archives can be found.
2011-06-24 12:52:11 +00:00
Robert Osfield
3660e3a3c3 Merged from svn/trunk changeset 12636, "While we're on osgSim/ShapeAttribute, here's a fix that fixes the 'UNKNOW' typo and some
doxygen"
2011-06-24 08:33:58 +00:00
Robert Osfield
cb627520a7 From Wang Rui, Merged from svn/trunk changeset 12633.
"I've modified the code to handle -1.#IND and other kinds of infinite
values. Please see the attachments for details"
2011-06-24 08:16:59 +00:00
Robert Osfield
c5867e4957 Merged from svn/trunk changeset 12632. Added operator ==, != and < to fix VS build 2011-06-24 08:15:51 +00:00
Robert Osfield
8f20178748 Merged from svn/trunk changeset r12628.
Fixed warnings generated by clang,

src/osgAnimation/Skeleton.cpp:25:87: warning: addition of default argument on redeclaration makes this constructor a copy constructor [-Wdefault-arg-special-member]
Skeleton::UpdateSkeleton::UpdateSkeleton(const UpdateSkeleton& us, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : osg::Object(us, copyop), osg::NodeCallback(us, copyop)

/src/OpenThreads/pthreads/PThread.cpp:1024:15: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
    if (cpunum<0) return -1;

src/osgDB/ExternalFileWriter.cpp:221:122: warning: expression result unused [-Wunused-value]
    _objects.insert(ObjectsSet::value_type(&obj, ObjectData(absoluteDestinationPath, relativeDestinationPath, written))).first;

src/osgManipulator/Dragger.cpp:175:18: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
        if (*itr = constraint) return;

src/osgManipulator/Dragger.cpp:187:18: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
        if (*itr = constraint)
2011-06-23 20:09:26 +00:00
Robert Osfield
c93ef23d2f Updated release candidate number to 4. 2011-06-23 20:03:16 +00:00
Robert Osfield
69659ade08 Merged from svn/trunk changeset r12573, Added catch for window manager doesn't set the window size to full screen. 2011-06-23 18:29:35 +00:00
Robert Osfield
d4e68e5d73 Merged from svn/trunk changeset 12625. Warning fixes for:
OpenSceneGraph/src/osgPlugins/Inventor/ConvertFromInventor.cpp: In member function ?virtual SbBool SoVRMLImageTextureOsg::readInstance(SoInput*, short unsigned int)?:
OpenSceneGraph/src/osgPlugins/Inventor/ConvertFromInventor.cpp:1264:16: warning: variable ?retval? set but not used [-Wunused-but-set-variable]
OpenSceneGraph/src/osgPlugins/ac/Geode.cpp: In member function ?void ac3d::Geode::ProcessGeometry(std::ostream&, unsigned int)?:
OpenSceneGraph/src/osgPlugins/ac/Geode.cpp:806:35: warning: variable ?fRep_s? set but not used [-Wunused-but-set-variable]
OpenSceneGraph/src/osgPlugins/ac/Geode.cpp:806:43: warning: variable ?fRep_t? set but not used [-Wunused-but-set-variable]
OpenSceneGraph/src/osgPlugins/ac/Geode.cpp:807:35: warning: variable ?fOffset_s? set but not used [-Wunused-but-set-variable]
OpenSceneGraph/src/osgPlugins/ac/Geode.cpp:807:46: warning: variable ?fOffset_t? set but not used [-Wunused-but-set-variable]
OpenSceneGraph/src/osgViewer/GraphicsWindowX11.cpp: In member function ?virtual void osgViewer::GraphicsWindowX11::checkEvents()?:
OpenSceneGraph/src/osgViewer/GraphicsWindowX11.cpp:1181:10: warning: variable ?destroyWindowRequested? set but not used [-Wunused-but-set-variable]
2011-06-23 18:26:11 +00:00
Robert Osfield
b29bf3fe06 Merged from svn/trunk changeset 12623.Fixed virtual method mismtaches between subclasses and parent classes. 2011-06-23 16:39:25 +00:00
Robert Osfield
8f23b42ed2 From Ulrich Hertlein, build fix for OSX. 2011-06-23 15:42:44 +00:00
Robert Osfield
17d876f787 Merged from svn/trunk, changeset 12619, "Added better handling of archives in ReaderWriterZip::readNode() so that if there is no master file definition it
loads all the available nodes in the zip archive and returns an osg::Group containing all the nodes if there is more
than one, or just returns the node if there is just one.  Also implemented this functionality for ReaderWriterZip::readImage()."
2011-06-23 15:39:11 +00:00
Robert Osfield
5cb72e06c2 Fixed typo in name 2011-06-23 12:25:52 +00:00
Robert Osfield
68ac058045 Updated ChangeLog and AUTHORS files 2011-06-23 11:32:24 +00:00
Robert Osfield
75fa5c0555 Fixed name typos 2011-06-23 11:32:09 +00:00
Robert Osfield
3159b36acd Merged from svn/trunk changeset r12611.
Fixed warnings.

OpenSceneGraph/src/osgGA/NodeTrackerManipulator.cpp:32:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor
OpenSceneGraph/src/osgGA/TerrainManipulator.cpp:31:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor
OpenSceneGraph/include/osgSim/ShapeAttribute:99:9: warning: base class ?class std::vector<osgSim::ShapeAttribute>? should be explicitly initialized in the copy constructor
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::gi?
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::byte_before_the_zipfile?
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::num_file?
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::pos_in_central_dir?
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::current_file_ok?
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::central_pos?
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::size_central_dir?
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::offset_central_dir?
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::cur_file_info?
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::cur_file_info_internal?
OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::pfile_in_zip_read?
OpenSceneGraph/src/osgViewer/CompositeViewer.cpp:30:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor
OpenSceneGraph/src/osgViewer/View.cpp:159:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor
OpenSceneGraph/src/osgViewer/Viewer.cpp:196:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor
OpenSceneGraph/src/osgViewer/Viewer.cpp:196:1: warning: base class ?class osgViewer::ViewerBase? should be explicitly initialized in the copy constructor
OpenSceneGraph/include/osgManipulator/Dragger:47:9: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor
2011-06-23 11:10:54 +00:00
Robert Osfield
893a6365a4 From Ryan Pavlik, merge from svn/trunk changeset 12608, "I have successfully compiled OpenSceneGraph trunk using the Clang compiler (using a recent trunk build of llvm and clang, haven't tested an older release). The attached files contain the change shown in the diff below, which was required to finish the build with Clang. It fixes an issue with two-phase name lookup - there's more information here http://blog.llvm.org/2009/12/dreaded-two-phase-name-lookup.html" 2011-06-23 09:39:45 +00:00
Robert Osfield
e330051cf3 Converted tabs to four spaces 2011-06-23 09:27:25 +00:00
Robert Osfield
672777189a From Dimi Christopoulos, merged from svn/trunk changeset 12606."I attach a fixed version of mipmap.cpp which produced a lot of warning on my gcc
compiler."
2011-06-23 09:24:38 +00:00
Robert Osfield
1ef313787d Update ChangeLog and AUTHORs file for 3.0.0-rc3 2011-06-22 16:34:46 +00:00
Robert Osfield
35c26bb5aa From Magnus Kessler, "I have recently installed the latest version of collada-dom on Linux, and
found that the include path has changed. By default, collada-dom now installs
its header files under /usr/local/include/collada-dom or/usr/include/collada-
dom. The attached FindCollada.cmake has been updated to look for these
locations in addition to the previous candidate locations."
2011-06-22 16:18:52 +00:00
Robert Osfield
8aee244e64 Updated ChangeLog and AUTHORS file for release 2011-06-22 15:41:57 +00:00
Robert Osfield
12ca59d3e5 Updated RC number for the 3.0.0-rc3 2011-06-22 12:45:35 +00:00
Robert Osfield
93156fd2ce Merged from svn/trunk changeset 12597:
Resolved warnings reported by g++ 4.6's -Wunused-but-set-variable.

Warnings were:

src/osg/ShapeDrawable.cpp: In member function ?void PrimitiveShapeVisitor::createHalfSphere(unsigned int, unsigned int, float, int, float, const Matrix&)?:
src/osg/ShapeDrawable.cpp:1409:11: warning: variable ?nzBase? set but not used [-Wunused-but-set-variable]
src/osg/ShapeDrawable.cpp:1410:11: warning: variable ?nRatioBase? set but not used [-Wunused-but-set-variable]
src/osgUtil/DelaunayTriangulator.cpp: In function ?osgUtil::Triangle_list osgUtil::fillHole(osg::Vec3Array*, std::vector<unsigned int, std::allocator<unsigned int> >)?:
src/osgUtil/DelaunayTriangulator.cpp:569:27: warning: variable ?ptest? set but not used [-Wunused-but-set-variable]
src/osgUtil/DelaunayTriangulator.cpp: In member function ?bool osgUtil::DelaunayTriangulator::triangulate()?:
src/osgUtil/DelaunayTriangulator.cpp:979:45: warning: variable ?curp? set but not used [-Wunused-but-set-variable]
src/osgUtil/RenderStage.cpp: In member function ?void osgUtil::RenderStage::runCameraSetUp(osg::RenderInfo&)?:
src/osgUtil/RenderStage.cpp:631:18: warning: variable ?stencilAttached? set but not used [-Wunused-but-set-variable]
src/osgText/FadeText.cpp: In member function ?void FadeTextPolytopeData::buildPolytope()?:
src/osgText/FadeText.cpp:74:20: warning: variable ?edge23? set but not used [-Wunused-but-set-variable]
src/osgText/FadeText.cpp:75:20: warning: variable ?edge30? set but not used [-Wunused-but-set-variable]
src/osgText/Text.cpp: In member function ?void osgText::Text::computeBackdropPositions(unsigned int) const?:
src/osgText/Text.cpp:747:10: warning: variable ?is_valid_size? set but not used [-Wunused-but-set-variable]
src/osgGA/NodeTrackerManipulator.cpp: In member function ?virtual bool osgGA::NodeTrackerManipulator::performMovementLeftMouseButton(double, double, double)?:
src/osgGA/NodeTrackerManipulator.cpp:257:21: warning: variable ?lookVector? set but not used [-Wunused-but-set-variable]
src/osgGA/NodeTrackerManipulator.cpp:259:21: warning: variable ?upVector? set but not used [-Wunused-but-set-variable]
src/osgGA/TerrainManipulator.cpp: In member function ?virtual bool osgGA::TerrainManipulator::performMovementMiddleMouseButton(double, double, double)?:
src/osgGA/TerrainManipulator.cpp:217:11: warning: variable ?lookVector? set but not used [-Wunused-but-set-variable]
src/osgGA/TerrainManipulator.cpp:219:11: warning: variable ?upVector? set but not used [-Wunused-but-set-variable]
src/osgVolume/FixedFunctionTechnique.cpp: In member function ?virtual void osgVolume::FixedFunctionTechnique::init()?:
src/osgVolume/FixedFunctionTechnique.cpp:124:30: warning: variable ?tf? set but not used [-Wunused-but-set-variable]
src/osgParticle/FluidProgram.cpp: In member function ?virtual void osgParticle::FluidProgram::execute(double)?:
src/osgParticle/FluidProgram.cpp:38:23: warning: variable ?velBefore? set but not used [-Wunused-but-set-variable]
src/osgShadow/ParallelSplitShadowMap.cpp: In member function ?virtual void osgShadow::ParallelSplitShadowMap::cull(osgUtil::CullVisitor&)?:
src/osgShadow/ParallelSplitShadowMap.cpp:593:22: warning: variable ?bb? set but not used [-Wunused-but-set-variable]
src/osgTerrain/GeometryTechnique.cpp: In member function ?virtual void osgTerrain::GeometryTechnique::generateGeometry(osgTerrain::GeometryTechnique::BufferData&, osgTerrain::Locator*, const osg::Vec3d&)?:
src/osgTerrain/GeometryTechnique.cpp:777:12: warning: variable ?i_sampleFactor? set but not used [-Wunused-but-set-variable]
src/osgTerrain/GeometryTechnique.cpp:778:12: warning: variable ?j_sampleFactor? set but not used [-Wunused-but-set-variable]
src/osgPlugins/dds/ReaderWriterDDS.cpp: In function ?osg::Image* ReadDDSFile(std::istream&)?:
src/osgPlugins/dds/ReaderWriterDDS.cpp:314:10: warning: variable ?is3dImage? set but not used [-Wunused-but-set-variable]
src/osgPlugins/dds/ReaderWriterDDS.cpp: In function ?bool WriteDDSFile(const osg::Image*, std::ostream&)?:
src/osgPlugins/dds/ReaderWriterDDS.cpp:721:10: warning: variable ?is3dImage? set but not used [-Wunused-but-set-variable]
src/osgPlugins/hdr/hdrloader.cpp: In static member function ?static bool HDRLoader::load(const char*, bool, HDRLoaderResult&)?:
src/osgPlugins/hdr/hdrloader.cpp:101:10: warning: variable ?cmd? set but not used [-Wunused-but-set-variable]
src/osgPlugins/vtf/ReaderWriterVTF.cpp: In function ?osg::Image* ReadVTFFile(std::istream&)?:
src/osgPlugins/vtf/ReaderWriterVTF.cpp:360:23: warning: variable ?base? set but not used [-Wunused-but-set-variable]
src/osgPlugins/jp2/ReaderWriterJP2.cpp: In function ?int putdata(jas_stream_t*, jas_image_t*, int)?:
src/osgPlugins/jp2/ReaderWriterJP2.cpp:41:13: warning: variable ?linelen? set but not used [-Wunused-but-set-variable]
src/osgPlugins/Inventor/ConvertToInventor.cpp: In member function ?void ConvertToInventor::processGeometry(const osg::Geometry*, ConvertToInventor::InventorState*)?:
src/osgPlugins/Inventor/ConvertToInventor.cpp:1639:10: warning: variable ?ok? set but not used [-Wunused-but-set-variable]
src/osgPlugins/Inventor/ConvertFromInventor.cpp: In member function ?virtual SbBool SoVRMLImageTextureOsg::readInstance(SoInput*, short unsigned int)?:
src/osgPlugins/Inventor/ConvertFromInventor.cpp:1264:16: warning: variable ?retval? set but not used [-Wunused-but-set-variable]
src/osgPlugins/OpenFlight/GeometryRecords.cpp: In member function ?virtual void flt::Face::readRecord(flt::RecordInputStream&, flt::Document&)?:
src/osgPlugins/OpenFlight/GeometryRecords.cpp:369:19: warning: variable ?secondaryPackedColor? set but not used [-Wunused-but-set-variable]
src/osgPlugins/OpenFlight/GeometryRecords.cpp: In member function ?virtual void flt::Mesh::readRecord(flt::RecordInputStream&, flt::Document&)?:
src/osgPlugins/OpenFlight/GeometryRecords.cpp:942:19: warning: variable ?secondaryPackedColor? set but not used [-Wunused-but-set-variable]
src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp: In member function ?virtual osgDB::ReaderWriter::ReadResult FLTReaderWriter::readNode(std::istream&, const Options*) const?:
src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp:427:40: warning: variable ?pos? set but not used [-Wunused-but-set-variable]
src/osgPlugins/ive/ShapeAttributeList.cpp: In member function ?void ive::ShapeAttributeList::write(ive::DataOutputStream*)?:
src/osgPlugins/ive/ShapeAttributeList.cpp:31:48: warning: variable ?it? set but not used [-Wunused-but-set-variable]
src/osgPlugins/ac/Geode.cpp: In member function ?void ac3d::Geode::ProcessGeometry(std::ostream&, unsigned int)?:
src/osgPlugins/ac/Geode.cpp:806:35: warning: variable ?fRep_s? set but not used [-Wunused-but-set-variable]
src/osgPlugins/ac/Geode.cpp:806:43: warning: variable ?fRep_t? set but not used [-Wunused-but-set-variable]
src/osgPlugins/ac/Geode.cpp:807:35: warning: variable ?fOffset_s? set but not used [-Wunused-but-set-variable]
src/osgPlugins/ac/Geode.cpp:807:46: warning: variable ?fOffset_t? set but not used [-Wunused-but-set-variable]
src/osgPlugins/ac/Geode.cpp:932:38: warning: variable ?primLength? set but not used [-Wunused-but-set-variable]
src/osgPlugins/txp/trpage_geom.cpp: In member function ?virtual bool trpgGeometry::Write(trpgWriteBuffer&)?:
src/osgPlugins/txp/trpage_geom.cpp:615:19: warning: variable ?u? set but not used [-Wunused-but-set-variable]
src/osgPlugins/txp/trpage_material.cpp: In member function ?int trpgMatTable::AddMaterial(const trpgMaterial&, bool)?:
src/osgPlugins/txp/trpage_material.cpp:103:10: warning: variable ?spaceInTable? set but not used [-Wunused-but-set-variable]
src/osgPlugins/txp/trpage_rarchive.cpp: In member function ?virtual bool trpgr_Archive::ReadHeader(bool)?:
src/osgPlugins/txp/trpage_rarchive.cpp:261:14: warning: variable ?headerHasTexTable? set but not used [-Wunused-but-set-variable]
src/osgPlugins/zip/unzip.cpp: In member function ?ZRESULT TUnzip::Get(int, ZIPENTRY*)?:
src/osgPlugins/zip/unzip.cpp:4055:8: warning: variable ?hidden? set but not used [-Wunused-but-set-variable]
src/osgPlugins/zip/unzip.cpp:4055:22: warning: variable ?system? set but not used [-Wunused-but-set-variable]
src/osgPlugins/zip/unzip.cpp:4055:36: warning: variable ?archive? set but not used [-Wunused-but-set-variable]
src/osgPlugins/zip/ZipArchive.cpp: In member function ?virtual bool ZipArchive::getFileNames(osgDB::Archive::FileNameList&) const?:
src/osgPlugins/zip/ZipArchive.cpp:91:37: warning: variable ?iterEnd? set but not used [-Wunused-but-set-variable]
src/osgPlugins/pvr/ReaderWriterPVR.cpp: In member function ?osgDB::ReaderWriter::ReadResult ReaderWriterPVR::readPVRStream(std::istream&) const?:
src/osgPlugins/pvr/ReaderWriterPVR.cpp:155:14: warning: variable ?hasAlpha? set but not used [-Wunused-but-set-variable]
src/osgViewer/View.cpp: In function ?osg::Geometry* create3DSphericalDisplayDistortionMesh(const Vec3&, const Vec3&, const Vec3&, double, double, osg::Image*, const Matrix&)?:
src/osgViewer/View.cpp:737:15: warning: variable ?cursor? set but not used [-Wunused-but-set-variable]
src/osgViewer/View.cpp: In function ?osg::Geometry* createParoramicSphericalDisplayDistortionMesh(const Vec3&, const Vec3&, const Vec3&, double, double, osg::Image*, const Matrix&)?:
src/osgViewer/View.cpp:1130:19: warning: variable ?cursor? set but not used [-Wunused-but-set-variable]
src/osgViewer/View.cpp:1118:15: warning: variable ?dx? set but not used [-Wunused-but-set-variable]
src/osgViewer/GraphicsWindowX11.cpp: In member function ?virtual void osgViewer::GraphicsWindowX11::checkEvents()?:
src/osgViewer/GraphicsWindowX11.cpp:1181:10: warning: variable ?destroyWindowRequested? set but not used [-Wunused-but-set-variable]
src/osgPlugins/cfg/ConfigParser.cpp: In member function ?bool osgProducer::CameraConfig::parseFile(const string&)?:
src/osgPlugins/cfg/ConfigParser.cpp:2247:13: warning: variable ?result? set but not used [-Wunused-but-set-variable]
src/osgQt/QGraphicsViewAdapter.cpp: In member function ?bool osgQt::QGraphicsViewAdapter::handlePointerEvent(int, int, int)?:
src/osgQt/QGraphicsViewAdapter.cpp:344:17: warning: variable ?viewportGeometry? set but not used [-Wunused-but-set-variable]
examples/osgdistortion/osgdistortion.cpp: In function ?osg::Node* createDistortionSubgraph(osg::Node*, const Vec4&)?:
examples/osgdistortion/osgdistortion.cpp:125:19: warning: variable ?cursor? set but not used [-Wunused-but-set-variable]
examples/osgdistortion/osgdistortion.cpp:126:19: warning: variable ?texcoord? set but not used [-Wunused-but-set-variable]
examples/osgdistortion/osgdistortion.cpp: In function ?osg::Geometry* createDomeDistortionMesh(const Vec3&, const Vec3&, const Vec3&, osg::ArgumentParser&)?:
examples/osgdistortion/osgdistortion.cpp:358:15: warning: variable ?cursor? set but not used [-Wunused-but-set-variable]
examples/osgposter/osgposter.cpp: In function ?int main(int, char**)?:
examples/osgposter/osgposter.cpp:253:31: warning: variable ?outputTiles? set but not used [-Wunused-but-set-variable]
examples/osgthreadedterrain/osgthreadedterrain.cpp: In function ?int main(int, char**)?:
examples/osgthreadedterrain/osgthreadedterrain.cpp:669:10: warning: variable ?readParameter? set but not used [-Wunused-but-set-variable]
examples/osgtext3D/TextNode.cpp: In member function ?virtual void osgText::Layout::layout(osgText::TextNode&) const?:
examples/osgtext3D/TextNode.cpp:80:11: warning: variable ?characterHeightScale? set but not used [-Wunused-but-set-variable]
examples/osgvolume/osgvolume.cpp: In function ?int main(int, char**)?:
examples/osgvolume/osgvolume.cpp:678:38: warning: variable ?internalFormatMode? set but not used [-Wunused-but-set-variable]
examples/osgwidgetcanvas/osgwidgetcanvas.cpp: In function ?bool windowMouseOver(osgWidget::Event&)?:
examples/osgwidgetcanvas/osgwidgetcanvas.cpp:27:24: warning: variable ?xy? set but not used [-Wunused-but-set-variable]
examples/osgwidgetcanvas/osgwidgetcanvas.cpp: In function ?bool widgetMouseOver(osgWidget::Event&)?:
examples/osgwidgetcanvas/osgwidgetcanvas.cpp:35:24: warning: variable ?xy? set but not used [-Wunused-but-set-variable]
src/osgPlugins/p3d/ReaderWriterP3D.cpp: In member function ?osg::Node* ReaderWriterP3DXML::parseXmlGraph(osgDB::XmlNode*, bool, osgDB::Options*) const?:
src/osgPlugins/p3d/ReaderWriterP3D.cpp:2121:10: warning: variable ?readSlide? set but not used [-Wunused-but-set-variable]
applications/present3D/present3D.cpp: In function ?int main(int, char**)?:
applications/present3D/present3D.cpp:639:10: warning: variable ?sizesSpecified? set but not used [-Wunused-but-set-variable]
2011-06-22 12:38:53 +00:00
Robert Osfield
e9d597b392 Fixed regression in --run-on-demand feature 2011-06-22 09:06:51 +00:00
Robert Osfield
781e4e259d Merged from svn/trunk changeset r12593, Removed assert() that always evaluated to true. 2011-06-21 17:30:07 +00:00
Robert Osfield
46fa819fa1 Merged from svn/trunk, changeset 12591, From Torben Dannhauer, "originally I posted the addendum of 'freetype244MT', but that was wrong.
I updated it to the correct addendum of 'freetype244' yesterday, but supposedly that was not forwarded to you by the forum-to-mail-gateway.

Find attached the corrected CMake module. "
2011-06-21 13:03:24 +00:00
Robert Osfield
80e1adfb6c Updated ChangeLog and AUTHORS file for 3.0.0-rc2 2011-06-21 10:26:30 +00:00
Robert Osfield
ff216c2100 Merged changeset 12581 from svn/trunk to address VisualStudio warning 2011-06-21 10:07:59 +00:00
Robert Osfield
7f6938ebad Merged from svn/trunk warnings fixes provided by Changeset 12582 from Michael Platings, along with addition
of returns at ends of files and changes to tabs to four spaces.
2011-06-21 09:58:31 +00:00
Robert Osfield
1dc91aa355 Updated release candidate number 2011-06-20 19:41:39 +00:00
Robert Osfield
caa9e38d2b Merged from svn/trunk, r12574.
From Farshid Lashkari, BGR write support for BMP, PNG and TGA
2011-06-20 19:37:40 +00:00
Robert Osfield
6402710910 Merged changes to svn/trunk that address cppcheck reported issues:
[examples/osgphotoalbum/PhotoArchive.cpp:56]: (error) Memory leak: fileIndentifier
[examples/osgphotoalbum/PhotoArchive.cpp:257]: (error) Deallocating a deallocated pointer: newData
[examples/osgphotoalbum/PhotoArchive.cpp:318]: (error) Deallocating a deallocated pointer: newData
[src/osg/ImageUtils.cpp:116]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/ImageUtils.cpp:307]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/ImageUtils.cpp:312]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/ImageUtils.cpp:367]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/ImageUtils.cpp:399]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/ImageUtils.cpp:400]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/ImageUtils.cpp:482]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/ImageUtils.cpp:483]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/ImageUtils.cpp:484]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/ImageUtils.cpp:519]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/ImageUtils.cpp:536]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:71]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:74]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:77]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:82]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:102]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:107]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:599]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:600]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:601]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:602]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:603]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:604]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:605]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osg/OcclusionQueryNode.cpp:606]: (portability) Extra qualification 'osg::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:134]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:135]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:136]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:137]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:139]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:177]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:178]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:195]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:198]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:203]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:205]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/ExternalFileWriter.cpp:253]: (portability) Extra qualification 'osgDB::' unnecessary and considered an error by many compilers.
[src/osgDB/InputStream.cpp:553]: (error) Memory leak: data
[src/osgDB/OutputStream.cpp:393]: (error) Memory leak: data
[src/osgPlugins/Inventor/ConvertToInventor.cpp:656]: (error) Mismatching allocation and deallocation: tmpArray
[src/osgPlugins/Inventor/ReaderWriterIV.cpp:237]: (error) Common realloc mistake: 'buf' nulled but not freed upon failure
[src/osgPlugins/OpenFlight/expGeometryRecords.cpp:167]: (portability) Extra qualification 'flt::' unnecessary and considered an error by many compilers.
[src/osgPlugins/OpenFlight/expGeometryRecords.cpp:373]: (portability) Extra qualification 'flt::' unnecessary and considered an error by many compilers.
[src/osgPlugins/cfg/CameraConfig.cpp:635]: (error) Unusual pointer arithmetic
[src/osgPlugins/freetype/FreeTypeLibrary.cpp:122]: (error) Memory leak: buffer
[src/osgPlugins/geo/ReaderWriterGEO.cpp:210]: (error) Possible null pointer dereference: gfd - otherwise it is redundant to check if gfd is null at line 211
[src/osgPlugins/geo/ReaderWriterGEO.cpp:227]: (error) Possible null pointer dereference: gfd - otherwise it is redundant to check if gfd is null at line 228
[src/osgPlugins/geo/ReaderWriterGEO.cpp:903]: (error) Possible null pointer dereference: gfd - otherwise it is redundant to check if gfd is null at line 904
[src/osgPlugins/geo/osgGeoNodes.h:180]: (error) Memory leak: geoHeaderGeo::intVars
[src/osgPlugins/geo/osgGeoNodes.h:181]: (error) Memory leak: geoHeaderGeo::useVars
[src/osgPlugins/geo/osgGeoNodes.h:182]: (error) Memory leak: geoHeaderGeo::extVars
[src/osgPlugins/md2/ReaderWriterMD2.cpp:180]: (error) Memory leak: mapbase
[src/osgPlugins/md2/ReaderWriterMD2.cpp:166]: (error) Resource leak: file_fd
[src/osgPlugins/pic/ReaderWriterPIC.cpp:152]: (error) Mismatching allocation and deallocation: tmpbuf
[src/osgPlugins/pic/ReaderWriterPIC.cpp:153]: (error) Mismatching allocation and deallocation: buffer
[src/osgPlugins/ply/plyfile.cpp:843]: (error) Memory leak: plyfile
[src/osgPlugins/pvr/ReaderWriterPVR.cpp:179]: (error) Memory leak: imageData
[src/osgPlugins/shp/ESRIShapeParser.cpp:29]: (error) Resource leak: fd
[src/osgPlugins/shp/XBaseParser.cpp:96]: (error) Resource leak: fd
[src/osgPlugins/zip/unzip.cpp:3158]: (error) Possible null pointer dereference: s - otherwise it is redundant to check if s is null at line 3159
[src/osgPlugins/zip/unzip.cpp:4155]: (error) Dangerous usage of 'rd' (strncpy doesn't always 0-terminate it)
[src/osgShadow/MinimalCullBoundsShadowMap.cpp:334]: (error) Possible null pointer dereference: rl - otherwise it is redundant to check if rl is null at line 331
[src/osgViewer/ScreenCaptureHandler.cpp:617]: (error) Possible null pointer dereference: camera - otherwise it is redundant to check if camera is null at line 611
[src/osgViewer/ScreenCaptureHandler.cpp:632]: (error) Possible null pointer dereference: camera - otherwise it is redundant to check if camera is null at line 626
[src/osgVolume/Locator.cpp:209]: (error) Dangerous iterator usage after erase()-method.
[src/osgVolume/RayTracedTechnique.cpp:274]: (error) Possible null pointer dereference: imageLayer - otherwise it is redundant to check if imageLayer is null at line 259
[src/osgVolume/RayTracedTechnique.cpp:275]: (error) Possible null pointer dereference: imageLayer - otherwise it is redundant to check if imageLayer is null at line 259
[src/osgWrappers/serializers/osg/ShaderBinary.cpp:28]: (error) Mismatching allocation and deallocation: data
2011-06-20 19:33:47 +00:00
Robert Osfield
b087e0f952 Merged following revisions from svn/trunk which address problems with toggling fullscreen on/off under modern X11 window managers
------------------------------------------------------------------------

r12573 | robert | 2011-06-20 12:25:52 +0100 (Mon, 20 Jun 2011) | 2 lines

Added catch for window manager doesn't set the window size to full screen.

------------------------------------------------------------------------
r12572 | robert | 2011-06-20 10:28:39 +0100 (Mon, 20 Jun 2011) | 4 lines

Added check against Traits::overrideRedirct to prevent the fullscreen workaround being run when overrideRedirect
is on as overrideRedirect switches off the window managers ability to manage the fullscreen so the problem doesn't
need working around.

------------------------------------------------------------------------
r12571 | robert | 2011-06-20 10:22:57 +0100 (Mon, 20 Jun 2011) | 2 lines

Introduced a workaround for fullscreen toggle issues under modern X11 window managers.
2011-06-20 17:54:27 +00:00
Robert Osfield
98a2ec67a6 Merged from svn/trunk. Added sleep before window resizing to make it less likely that the previous frames rendering traversal is still
running when the window(s) is resized, something that creates what looks like a glitch in rendering.
2011-06-20 09:22:05 +00:00
Robert Osfield
d5d9f4c082 From Torben Dannhauer, "Just in time for OSG 3.0 I will present an updated 3rdParty package for VS2008 , which includes some updated libraries (libcurl, freetype, jpeg). It also provides now all debug databases (*.pdb), so all the annoying compile warnings about missing .pdb files are gone.
I extended the CMAKE module to find the new library."
2011-06-19 19:21:21 +00:00
Robert Osfield
a656e402b7 Reset OPENSCENEGRAPH_SVN setting to branches to enable the tags to be created on the branches rather svn/trunk. 2011-06-17 16:37:58 +00:00
Robert Osfield
f173ea4224 First cut of OpenSceneGraph-3.0 branch from svn/trunk. 2011-06-17 13:14:49 +00:00
2008 changed files with 47275 additions and 93006 deletions

View File

@@ -1,6 +1,6 @@
OpenSceneGraph Library 3.2.2
OpenSceneGraph Library 3.0.0
529 Contributors:
464 Contributors:
Firstname Surname
-----------------
@@ -8,113 +8,102 @@ Robert Osfield
Don Burns
Stephan Huber
Paul Martz
Mathias Fr<46>hlich
Farshid Lashkari
Marco Jez
Wang Rui
Jean-S<>bastien Guay
Ulrich Hertlein
Mathias Fr<46>hlich
Mike Weiblen
Sukender
Jean-S<>bastien Guay
Farshid Lashkari
Eric Wing
Ulrich Hertlein
Cedric Pinson
Wang Rui
Brede Johansen
Bob Kuehne
Sukender
Michael Platings
Bob Kuehne
Geoff Michel
Wojciech Lewandowski
Eric Sokolowsky
Wojciech Lewandowski
David Callu
Laurens Voerman
Colin McDonald
Trajce Nikolov
Tim Moore
Martin Lavery
Tree
Colin McDonald
Tree
Luigi Calori
Mike Wittman
Jason Beverage
Chris Hanson
Roland Smeenk
Roger James
Mattias Helsing
Jeremy Moles
Chris Hanson
Mattias Helsing
Jason Beverage
Jan Peciva
Alberto Luaces
J.P. Delport
Magnus Kessler
David Fries
Andy Skinner
Tom Jolley
Paul Melis
Luc Frauciel
J.P. Delport
David Fries
Tom Jolley
Pavel Moloshtan
Brad Christiansen
Olaf Flebbe
Mathieu Marache
Jason Daly
Aurelien Albert
Art Tevs
Philip Lowman
Per Fahlberg
Norman Vine
Lionel Lagarde
Terry Welsh
Art Tevs
Alberto Luaces
Serge Lages
Romano Jos<6F> Magacho da Silva
Pjotr Svetachov
Chris Denham
Magnus Kessler
Laurens Voerman
Alberto Farre
Torben Dannhauer
Terry Welsh
Sherman Wilcox
Robert Michael
Mourad Boufarguine
Robert Milharcic
Olaf Flebbe
Mathieu Marache
Andr<EFBFBD> Garneau
Adrian Egli
Ruben Lopez
Randall Hopper
Jan Ciger
Glenn Waldron
Mourad Boufarguine
Brad Christiansen
Gideon May
Don Tidrow
Chris Denham
Stephane Lamoliatte
Romano Jos<6F> Magacho da Silva
Michael Gronager
Martin Naylor
Joakim Simonsson
David Spilling
Daniel Sj<53>lie
Bryan Thrall
Glenn Waldron
Fabien Lavignotte
Andreas Ekstrand
Riccardo Corsi
Mike Connell
Torben Dannhauer
Melchior Franz
Johannes Baeuerle
Thomas Hogarth
Sebastian Messerschmidt
Lionel Lagarde
Jan Ciger
Rafa Gaitan
Neil Hughes
Mike Connell
Martin Beckett
Joran Jessurun
Gino van den Bergen
Frederic Marmond
David Guthrie
Csaba Halasz
Cory Riddell
Chuck Seberino
Boris Bralo
Andreas Ekstrand
Yefei He
Sondra Iverson
Simon Julier
Rune Schmidt Jensen
Rainer Oder
Nico Kruithof
Martin Naylor
Martin Aumueller
Mario Valle
Lukasz Izdebski
Jorge Izquierdo Ciges
Luc Frauciel
Gordon Tomlinson
Frederic Bouvier
Cory Riddell
Carlo Camporesi
Ben Discoe
Thibault Genessay
@@ -122,23 +111,19 @@ Sasa Bistrovic
Ravi Mathur
Ralf Habacker
Neil Groves
Mikhail Izmestev
Markus Trenkwalder
Loic Dachary
Joseph Steel
Jordi Torres
Jorge Izquierdo
John Shue
Chuck Seberino
Brad Colbert
Bj<EFBFBD>rn Blissing
Alexander Sinditskiy
Vivek Rajan
Uwe Woessner
Tony Horrobin
Thom DeCarlo
Tatsuhiro Nishioka
Tanguy Fautr<74>
Sean Spicer
Ryan Kawicki
Richard Schmidt
Peter Hrenka
Paul de Repentigny
@@ -147,32 +132,31 @@ Neil Salter
Mihai Radu
Michael Hartman
Martins Innus
Marc Helbling
Maciej Krol
Lilin Xiong
Leandro Motta Barros
Johannes Baeuerle
Johan Nouvel
Hartwig Wiesmann
Frederic Bouvier
Donn Mielcarek
Corbin Holtz
Blasius Czink
Alexander Irion
Toshiyuki Takahei
Tony Horrobin
Sebastien Grignard
Rudolf Wiedemann
Robert Milharcic
Ryan Kawicki
Romano Magacho
Riccardo Corsi
Nico Kruithof
Mikhail Izmestev
Maria Ten
Liang Aibin
Kristofer Tingdahl
Konstantin Matveyev
Leandro Motta Barros
Katharina Plugge
John Vidar Larring
John Kelso
John Ivar
Gustav Haapalahti
Erik den Dekker
Emmanuel Roche
Domenico Mangieri
Daniel Larimer
Colin Dunlop
Bruce Clay
@@ -182,42 +166,37 @@ Alok Priyadarshi
Alberto Barbati
Alan Dickinson
Vladimir Shabanov
Vladimir Chebaev
Tugkan Calapoglu
Tim Daoust
Thomas Hogarth
Sohey Yamamoto
Sergey Leontyev
Santosh Gaikwad
Ryan Pavlik
Rudolf Wiedemann
Rene Molenaar
Piotr Domagalski
Phil Atkin
Nathan Monteleone
Miguel Escriva
Mattias Linde
Mark Sciabica
Marcin Prus
Lilin Xiong
Lee Butler
Lars Nilsson
Konstantin Sinitsyn
Ken Sewell
Julian Ortiz
John Kaniarz
Jim Vaughan
Jeremy Bell
Jaromir Vitek
James French
Guillaume Millet
Gary Quinn
Garrett Potts
Gabor Dorka
Fabio Mierlo
Erik den Dekker
Doug McCorkle
Donald Cipperly
Don Leich
Dietmar Funck
Colin Cochran
Christian Buchner
Domenico Mangieri
Charles Cole
Blake Williams
Antoine Hue
@@ -225,32 +204,28 @@ Andrew Bettison
Anders Backman
Ali Botorabi
Alexander Wiebel
Alessandro Terenzi
Alexander Irion
Zach Deedler
Yuzhong Shen
Wee See
Warren Macchi
Vincent Bourdier
Terrex
Terrex
Tassilo Glander
Sylvain Marie
Steve Lunsford
Stephane Simon
Stephan Eilemann
Stanislav Blinov
Sergey Polischuk
Sebastian Messerschmidt
Ryan Pavlik
Raymond de Vries
Ralf Kern
Piotr Gwiazdowski
Pierre Haritchabalet
Perry Miller
Pawel Ksiezopolski
Paul Palumbo
Paul Obermeier
Patrick Neary
Nguyen Van Truong
Nathan Cournia
Morten Haukness
Morn<EFBFBD> Pistorius
Michael Henheffer
Michael Guerrero
@@ -258,28 +233,22 @@ Maya Leonard
Max Bandazian
Mathias Fiedler
Mathew May
Martin von Gargern
Martin Spott
Martin Lambers
Martijn Kragtwijk
Marius Heise
Marcin Hajder
Marcel Pursche
Lukasz Izdebski
Lilith Bryant
Lars Nilsson
Kevin Moiule
Keith Steffen
Julien Valentin
Julen Garcia
Joseph Winston
John Aughey
Johannes Scholz
Joachim Pouderoux
Jean-Christophe Lombardo
Javier Taibo
Jannik Heller
Jan Klimke
James Moliere
Jaap Glas
Igor Kravtchenko
Himar Carmona
He Sicong
@@ -287,8 +256,6 @@ Guy Volckaert
Gustavo Wagner
Guillaume Taze
Guillaume Chouvenc
Giuseppe Donvito
Gill Peacegood
Gerrick Bivins
George Tarantilis
Ferdi Smit
@@ -296,21 +263,17 @@ Eric Buehler
Eduardo Poyart
Edgar Ellis
Dimi Christopoulos
Diane Delall<6C>e
David Longest
Dietmar Funck
David Ergo
Daniel Trstenjak
Craig Bosma
Claus Scheiblauer
Christophe Loustaunau
Christian Ruzicka
Bradley Baker Searles
Brad Anderegg
Bj<EFBFBD>rn Hein
Aric Aumann
Andrew Sampson
Andrew Lorino
Alexandre Amalric
Alessandro Terenzi
Zbigniew Sroczynski
Yuri Vilmanis
Xin Li
@@ -324,20 +287,15 @@ Vincent Vivanloc
Vincent Gadoury
Vasily Radostev
Valery Bickov
Valeriy Dubov
Vaclav Bilek
Tyge L<>vset
Troy Yee
Tomas Hogarth
Tomas Hnilica
Todd Furlong
Tobias Ottenweller
Tino Schwarze
Tim George
Thorsten Brehm
Thomas Weidner
Tan Dunning
Tamer Fahmy
Stewart Andreason
Steven Thomas
Simon Hammett
@@ -346,7 +304,6 @@ Simon Buckley
Sid Byce
Shuxing Xiao
Shane Arnott
Sergey Kurdakov
Sebastien Kuntz
Ruth Lang
Ruben Smelik
@@ -354,14 +311,12 @@ Ross Anderson
Ronny Krueger
Ronald van Maarseveen
Romain Charbit
Rocco Martino
Robert Swain
Rob Smith
Rob Radtke
Rob Bloemkool
Rick Pingry
Rick Appleton
Remo Eichenberger
Reinhard Sainitzer
Rein Kadijk
Ragnar Hammarqvist
@@ -371,11 +326,10 @@ Pierre Bourdin
Philipp Svehla
Philipp Siemoleit
Philipp M<>chler
Philip Lamb
Petr Salinger
Peter Bear
Peter Amstutz
Paul Idstein
Paul Palumbo
Paul Fredrikson
Paul Fotheringham
Pau Garcia
@@ -384,24 +338,17 @@ Parag Chaudhur
Panagiotis Papadakos
Panagiotis Koutsourakis
Orhun Birsoy
Oren Fromberg
Oliver Neumann
Ole-Morten Duesund
Nicolas Brodu
Nick Black
Morten Haukness
Mojtaba Fathi
Mirko Viviani
Mikkel Gj<EFBFBD>l
Mike Krus
Mikkel Gjøl
Mike Garrity
Miha Rav<61>elj
Michael Schanne
Michael Polak
Michael Morrison
Michael Mc Donnell
Michael Logan
Michael Kapelko
Michael Bach Jensen
Max Rhiener
Max Behensky
Mauricio Hofmam
@@ -412,30 +359,29 @@ Matt Burke
Mathias Walker
Mathias Goldau
Mason Menninger
Martin von Gargern
Martin Scheffler
Martin Lambers
Martin Innus
Martin Beck
Marius Kintel
Mario Guimaraes
Marco Sciabica
Marco Lehmann
Marcin Prus
Maik Keller
Lukas Diduch
Louis Hamilton
Lewis Harmon
Leigh Stivers
Laurence Muller
Laura Cerritelli
Kyle Centers
Kristopher Bixler
Konstantin Matveyev
Kim Seokhwan
Kim Bale
Karsten Weiss
Karl Heijdenberg
Jutta Sauer
Julian Scheid
Juergen Rensen
Juan Manuel Alvarez
Juan Hernando
Josh Portway
John Tan
@@ -450,15 +396,14 @@ Jeroen den Dekker
Jay Zuckerman
Jason Howlett
Jason Ballenger
James Turner
Jan Klimke
James Killian
James Athey
J.E. Hoffmann
Holger Helmich
Henrique Bucher
Hautio Jari
Hartmut Seichter
Gunter Huber
Guillaume Millet
Gregory Jaegy
Graeme Harkness
Gian Lorenzetto
@@ -466,13 +411,10 @@ George Papagiannakis
Galen Faidley
Frida Schlaug
Frederic Smith
Frederic Morin
Frank Warmerdam
Frank Midgley
Frank Lindeman
Frank Lichtenheld
Francois Tigeot
Filip Arlet
Ferdinand Cornelissen
Fajran Iman
Fabien Dachicourt
@@ -484,7 +426,6 @@ Duvan Cope
Duncan Cavens
Drew Whitehouse
Douglas A. Pouk
Dmitry Marakasov
Dean Iverson
David Jung
Danny Valente
@@ -492,16 +433,12 @@ Daniel Stien
Dan Minor
C<EFBFBD>sar L. B. Silveira
Cyril Brulebois
Cl<EFBFBD>ment B<>sch
Clay Fowler
Claus Steuer
Chuck Sembroski
Christopher Blaesius
Christopher Baker
Christophe Herreman
Christian Noon
Christian Kaser
Christian Ehrlicher
Christian Buchner
Chris McGlone
Carlos Garcea
Bryce Eldridge
@@ -509,6 +446,7 @@ Bruno Herbelin
Brian Keener
Brandon Hamm
Bora Utka
Bj<EFBFBD>rn Hein
Bill Prendergast
Bernardt Duvenhage
Benoit Laniel
@@ -516,9 +454,7 @@ Benjamin Wasty
Ben van Basten
Bart Gallet
Axel Volley
Arjun Ramamurthy
Anthousis Andreadis
Anish Thomas
Andy Preece
Andrew Reyonolds
Andreas Roth
@@ -526,10 +462,9 @@ Andreas Jochens
Andre Normann
Almalric Alexandre
Allen Bierbaum
Alexander Sinditskiy
Alberto Jaspe
Alan Purvis
Alan Ott
Alan Harris
Adrien Grandemange
Adrian Clark
Adam Richard

View File

@@ -20,43 +20,21 @@ if(COMMAND cmake_policy)
# statements.
cmake_policy(SET CMP0005 NEW)
# tell CMake to prefer CMake's own CMake modules when available
# only available from cmake-2.8.4
if(${CMAKE_MAJOR_VERSION} GREATER 2 OR
(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 8) OR
(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 8 AND ${CMAKE_PATCH_VERSION} GREATER 3))
cmake_policy(SET CMP0017 NEW)
endif()
# cmake-2.6.1 introduces policy cmp0008 decide how to treat full path libraries that do not appear to be valid library file names
# quote from cvslog "Such libraries worked by accident in the VS IDE and Xcode generators in CMake 2.4 and below."
if(${CMAKE_MAJOR_VERSION} GREATER 2 OR
(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 6) OR
(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6 AND ${CMAKE_PATCH_VERSION} GREATER 0))
if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4 AND ${CMAKE_PATCH_VERSION} GREATER 0)
cmake_policy(SET CMP0008 OLD)
endif()
# disable autolinking to qtmain as we have our own main() functions (new in Qt 5.1)
if(${CMAKE_MAJOR_VERSION} GREATER 2 OR
(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 8) OR
(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 8 AND ${CMAKE_PATCH_VERSION} GREATER 10))
cmake_policy(SET CMP0020 OLD)
endif()
# nicer version check - but needs at least CMake 2.6.2? Worth upgrading the requirements?
#if("${CMAKE_VERSION}" VERSION_GREATER 2.8.10)
# or even easier (available in cmake-2.6)
#if(POLICY CMPxyzw)
endif()
PROJECT(OpenSceneGraph)
SET(OPENSCENEGRAPH_MAJOR_VERSION 3)
SET(OPENSCENEGRAPH_MINOR_VERSION 2)
SET(OPENSCENEGRAPH_PATCH_VERSION 2)
SET(OPENSCENEGRAPH_SOVERSION 100)
SET(OPENSCENEGRAPH_MINOR_VERSION 0)
SET(OPENSCENEGRAPH_PATCH_VERSION 0)
SET(OPENSCENEGRAPH_SOVERSION 80)
# set to 0 when not a release candidate, non zero means that any generated
# set to 0 when not a release candidate, non zero means that any generated
# svn tags will be treated as release candidates of given number
SET(OPENSCENEGRAPH_RELEASE_CANDIDATE 0)
@@ -85,13 +63,6 @@ SET(OpenThreads_SOURCE_DIR ${OpenSceneGraph_SOURCE_DIR})
# Maybe this can be used override existing behavior if needed?
SET(CMAKE_MODULE_PATH "${OpenSceneGraph_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
# Change the default build type to Release
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
## Option to enable Android build using AndroidNDK
OPTION(OSG_BUILD_PLATFORM_ANDROID OFF)
IF(OSG_BUILD_PLATFORM_ANDROID)
@@ -100,48 +71,17 @@ IF(OSG_BUILD_PLATFORM_ANDROID)
INCLUDE(OsgAndroidMacroUtils)
SET(ANDROID TRUE)
IF(NOT ANDROID_PLATFORM)
MESSAGE("Warning Android Platform version NOT defined, Default selected version: 5")
SET(ANDROID_PLATFORM 5)
ENDIF()
IF(NOT ANDROID_ABI)
MESSAGE("Warning Android ABI version NOT defined, Default selection: armeabi armeabi-v7a")
SET(ANDROID_ABI "armeabi armeabi-v7a")
ENDIF()
IF(NOT ANDROID_STL)
MESSAGE("Warning Android STL NOT defined, Default selection: gnustl_static")
SET(ANDROID_STL "gnustl_static")
ENDIF()
IF(ANDROID_DEBUG)
MESSAGE("Warning Android Build is in debug mode")
SET(ANDROID_RELEASE_OPTIM "debug")
ELSE()
MESSAGE("Warning Android Build is in release mode")
SET(ANDROID_RELEASE_OPTIM "release")
ENDIF()
IF(ANDROID_NEON)
MESSAGE("Warning Android NEON optimizations enabled, this will not be available on all armeabi-v7a devices ie. Tegra2")
SET(ANDROID_OPTIM_NEON true)
ELSE()
SET(ANDROID_OPTIM_NEON false)
ENDIF()
IF(ANDROID_ARM32)
MESSAGE("Warning ARM 32bit instruction set will be used")
SET(ANDROID_OPTIM_ARM32 true)
ELSE()
SET(ANDROID_OPTIM_ARM32 false)
ENDIF()
FIND_PACKAGE(AndroidNDK REQUIRED)
SET(ANDROID_PLATFORM 5)
FIND_PACKAGE(AndroidNDK REQUIRED)
SET(OSG_ANDROID_TEMPLATES "${CMAKE_SOURCE_DIR}/PlatformSpecifics/Android")
SET(J "4" CACHE STRING "how many processes for make -j <J>")
ADD_CUSTOM_COMMAND(
OUTPUT Android-OpenSceneGraph
DEPENDS ${CMAKE_BINARY_DIR}/Android.mk
COMMAND "${ANDROID_NDK}/ndk-build"
COMMAND "${ANDROID_NDK}/ndk-build"
ARGS --directory=${CMAKE_BINARY_DIR} NDK_APPLICATION_MK=Application.mk -j${J} NDK_LOG=1
)
@@ -194,9 +134,9 @@ IF (OSG_MAINTAINER)
# Provide target for tagging a release
#
SET(SVNCOMMAND svn)
SET(SVNTRUNKDIR http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk)
SET(SVNTAGDIR http://svn.openscenegraph.org/osg/OpenSceneGraph/tags)
SET(SVNBRANCHDIR http://svn.openscenegraph.org/osg/OpenSceneGraph/branches)
SET(SVNTRUNKDIR http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk)
SET(SVNTAGDIR http://www.openscenegraph.org/svn/osg/OpenSceneGraph/tags)
SET(SVNBRANCHDIR http://www.openscenegraph.org/svn/osg/OpenSceneGraph/branches)
IF (OPENSCENEGRAPH_SVN STREQUAL "trunk")
SET(SVNSOURCEDIR ${SVNTRUNKDIR})
@@ -237,22 +177,11 @@ IF (OSG_MAINTAINER)
COMMAND ${SVNCOMMAND} update
COMMAND ${GENERATELOGS} ${SVNSOURCEDIR}
)
ENDIF(OSG_MAINTAINER)
IF(NOT ANDROID)
IF(APPLE)
# Determine the canonical name of the selected Platform SDK
EXECUTE_PROCESS(COMMAND "/usr/bin/sw_vers" "-productVersion"
OUTPUT_VARIABLE OSG_OSX_SDK_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(REPLACE "." ";" MACOS_VERSION_LIST ${OSG_OSX_SDK_NAME})
LIST(GET MACOS_VERSION_LIST 0 MACOS_VERSION_MAJOR)
LIST(GET MACOS_VERSION_LIST 1 MACOS_VERSION_MINOR)
LIST(GET MACOS_VERSION_LIST 2 MACOS_VERSION_PATCH)
SET(OSG_OSX_SDK_NAME "macosx${MACOS_VERSION_MAJOR}.${MACOS_VERSION_MINOR}")
# Trying to get CMake to generate an XCode IPhone project, current efforts are to get iphoneos sdk 3.1 working
# Added option which needs manually setting to select the IPhone SDK for building. We can only have one of the below
# set to true. Should realy have an OSG_BUILD_PLATFORM variable that we set to our desired platform
@@ -262,24 +191,21 @@ IF(APPLE)
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
#you need to manually set the default sdk version here
SET (IPHONE_SDKVER "6.0" CACHE STRING "IOS SDK-Version")
SET (IPHONE_VERSION_MIN "4.2" CACHE STRING "IOS minimum os version, use 7.0 or greater to get 64bit support")
SET (IPHONE_SDKVER "3.2")
#the below is taken from ogre, it states the gcc stuff needs to happen before PROJECT() is called. I've no clue if we even need it
# Force gcc <= 4.2 on iPhone
IF(IPHONE_VERSION_MIN LESS "6.0")
include(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(llvm-gcc-4.2 GNU)
CMAKE_FORCE_CXX_COMPILER(llvm-gcc-4.2 GNU)
SET(GCC_THUMB_SUPPORT NO)
ENDIF()
include(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(gcc-4.2 GNU)
CMAKE_FORCE_CXX_COMPILER(gcc-4.2 GNU)
SET(GCC_THUMB_SUPPORT NO)
#set either the device sdk or the simulator sdk. Can't find away to separate these in the same project
IF(OSG_BUILD_PLATFORM_IPHONE)
SET (IPHONE_DEVROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer")
SET (IPHONE_DEVROOT "/Developer/Platforms/iPhoneOS.platform/Developer")
SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneOS${IPHONE_SDKVER}.sdk")
ELSE()
SET (IPHONE_DEVROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer")
SET (IPHONE_DEVROOT "/Developer/Platforms/iPhoneSimulator.platform/Developer")
SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneSimulator${IPHONE_SDKVER}.sdk")
ENDIF()
@@ -376,13 +302,7 @@ IF(WIN32 AND NOT ANDROID)
STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
ENDIF(MSVC_USE_DEFAULT_STACK_SIZE)
get_filename_component( CMAKE_MAKE_PROGRAM_NAME ${CMAKE_MAKE_PROGRAM} NAME)
IF (CMAKE_MAKE_PROGRAM_NAME STREQUAL "VCExpress.exe")
OPTION(MSVC_BUILD_USE_SOLUTION_FOLDERS "Enable project grouping in VS - VCExpress detected, not supported in VCExpress )" OFF)
ELSE()
OPTION(MSVC_BUILD_USE_SOLUTION_FOLDERS "Enable project grouping in VS" ON)
ENDIF()
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ${MSVC_BUILD_USE_SOLUTION_FOLDERS})
ENDIF()
#needed for net plugin
@@ -465,7 +385,6 @@ MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS)
OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON)
OPTION(OSG_GL1_AVAILABLE "Set to OFF to disable use of OpenGL 1.x functions library." ON)
OPTION(OSG_GL2_AVAILABLE "Set to OFF to disable use of OpenGL 2.x functions library." ON)
OPTION(OSG_GL3_AVAILABLE "Set to OFF to disable use of OpenGL 3.x functions library." OFF)
@@ -484,7 +403,7 @@ SET(OPENGL_egl_LIBRARY CACHE STRING "Set the OpenGL egl library.")
OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." ${OSG_GL1_AVAILABLE})
OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." ${OSG_GL1_AVAILABLE})
OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertexPointer/glColorPointer etc." ${OSG_GL1_AVAILABLE})
OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ${OSG_GL1_AVAILABLE})
OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." ON)
@@ -527,17 +446,11 @@ IF(WIN32 AND NOT ANDROID)
INCLUDE(Find3rdPartyDependencies)
ENDIF()
#
# If you want to prevent CMake from picking up on any of the following optional 3rd Party dependencies in CMake 2.8 onwards
# you can use the following style of command line option when invoking Cmake (here illustrating ignoring PythonLibs) :
# cmake -DCMAKE_DISABLE_FIND_PACKAGE_PythonLibs=1 .
#
IF(ANDROID)
ANDROID_3RD_PARTY()
ELSE()
# Common to all platforms except android:
FIND_PACKAGE(Freetype)
FIND_PACKAGE(FreeType)
FIND_PACKAGE(Inventor)
FIND_PACKAGE(Jasper)
FIND_PACKAGE(OpenEXR)
@@ -548,10 +461,11 @@ ELSE()
FIND_PACKAGE(OpenVRML)
FIND_PACKAGE(Performer)
FIND_PACKAGE(GDAL)
FIND_PACKAGE(GTA)
FIND_PACKAGE(CURL)
FIND_PACKAGE(ITK)
FIND_PACKAGE(LibVNCServer)
FIND_PACKAGE(OurDCMTK)
FIND_PACKAGE(OpenAL)
FIND_PACKAGE(FFmpeg)
FIND_PACKAGE(DirectShow)
FIND_PACKAGE(SDL)
@@ -560,30 +474,17 @@ ELSE()
FIND_PACKAGE(GtkGl)
FIND_PACKAGE(DirectInput)
FIND_PACKAGE(NVTT)
IF (NOT WIN32)
FIND_PACKAGE(Asio)
ENDIF()
FIND_PACKAGE(ZeroConf)
ENDIF()
IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 8)
FIND_PACKAGE(ITK)
ENDIF()
# Include macro utilities here
INCLUDE(OsgMacroUtils)
OPTION(OSG_USE_QT "Enable to use Qt (build Qt-dependent libraries, plugins and examples)" ON)
IF(OSG_USE_QT AND NOT ANDROID)
IF(NOT ANDROID)
# To select a specific version of QT define DESIRED_QT_VERSION
# via cmake -DDESIRED_QT_VERSION=5
# QUIET option disables messages if the package cannot be found.
# via cmake -DDESIRED_QT_VERSION=4
IF (DESIRED_QT_VERSION)
IF (DESIRED_QT_VERSION MATCHES 5)
FIND_PACKAGE(Qt5Widgets)
ELSEIF (DESIRED_QT_VERSION MATCHES 4)
IF (DESIRED_QT_VERSION MATCHES 4)
FIND_PACKAGE(Qt4)
ELSE()
FIND_PACKAGE(Qt3)
@@ -591,44 +492,14 @@ IF(OSG_USE_QT AND NOT ANDROID)
ELSE()
FIND_PACKAGE(Qt5Widgets QUIET)
FIND_PACKAGE(Qt4)
IF ( Qt5Widgets_FOUND )
# CMake 2.8.8 or greater required
BUILDER_VERSION_GREATER(2 8 7)
IF(NOT VALID_BUILDER_VERSION)
MESSAGE(
SEND_ERROR
"Qt5 requires CMake version 2.8.8 or greater!\n"
"Update CMake or set DESIRED_QT_VERSION to less than 5
or disable OSG_USE_QT."
)
ENDIF( )
ENDIF( )
IF ( NOT Qt5Widgets_FOUND )
FIND_PACKAGE(Qt4)
IF (NOT QT4_FOUND)
FIND_PACKAGE(Qt3)
ENDIF()
IF (NOT QT4_FOUND)
FIND_PACKAGE(Qt3)
ENDIF()
ENDIF()
#If we have found Qt5, let's try to top off by getting the webkit as well
IF ( Qt5Widgets_FOUND )
FIND_PACKAGE(Qt5WebKitWidgets QUIET)
IF(COMMAND cmake_policy)
IF(${CMAKE_MAJOR_VERSION} GREATER 2)
# Qt5 qt5_use_modules usage was causing "Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties." warnings
cmake_policy(SET CMP0043 NEW)
ENDIF()
ENDIF()
ENDIF()
ENDIF()
ENDIF(NOT ANDROID)
#optional example related dependencies
IF (BUILD_OSG_EXAMPLES AND NOT ANDROID)
@@ -663,19 +534,16 @@ IF(NOT ANDROID)
FIND_PACKAGE(JPEG)
FIND_PACKAGE(PNG)
FIND_PACKAGE(TIFF)
# QuickTime is required for OS X, but optional for Windows.
IF(WIN32)
FIND_PACKAGE(QuickTime)
ENDIF()
ELSE()
FIND_PACKAGE(TIFF)
FIND_PACKAGE(QuickTime)
FIND_PACKAGE(QTKit)
FIND_PACKAGE(CoreVideo)
FIND_PACKAGE(CoreMedia)
FIND_PACKAGE(QuartzCore)
FIND_PACKAGE(AVFoundation)
ENDIF()
ENDIF()
@@ -824,31 +692,28 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
# returns too many hits.
# FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
# interesting C-specific flag.
SET(OSG_AGGRESSIVE_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused)
# Also, there is a bug in gcc 4.0. Under C++, -pedantic will create
# errors instead of warnings for certain issues, including superfluous
# semicolons and commas, and the use of long long. -fpermissive seems
# to be the workaround.
SET(OSG_AGGRESSIVE_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive)
# Previous included -Wformat=2 in OSG_AGGRESSIVE_WARNING_FLAGS but had to remove it due to standard library errors
ELSEIF(MSVC)
#disable specific warning level 4 warnings:
#C4100 'identifier' : unreferenced formal parameter
#C4127 Error Message conditional expression is constant
#C4706 assignment within conditional expression
ELSE()
IF(MSVC)
# FIXME: What are good aggressive warning flags for Visual Studio?
# And do we need to further subcase this for different versions of VS?
# CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
SET(OSG_AGGRESSIVE_WARNING_FLAGS /W4 /wd4706 /wd4127 /wd4100)
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(OSG_AGGRESSIVE_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -Wno-overloaded-virtual)
ELSE()
# CMake lacks an elseif, so other non-gcc, non-VS compilers need
# to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
# remain unset.
IF (APPLE)
# set standard lib, clang defaults to c++0x
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++98")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -stdlib=libstdc++ -Wno-overloaded-virtual -Wno-conversion")
set(WARNING_CFLAGS "")
ENDIF()
ENDIF()
ENDIF()
# This part is for the CMake menu option to toggle the warnings on/off.
@@ -901,21 +766,15 @@ IF (BUILD_OSG_EXAMPLES)
ENDIF()
IF(APPLE AND NOT ANDROID)
IF(APPLE)
#Here we check if the user specified IPhone SDK
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
#set iphone arch and flags taken from http://sites.google.com/site/michaelsafyan/coding/resources/how-to-guides/cross-compile-for-the-iphone/how-to-cross-compile-for-the-iphone-using-cmake
IF(OSG_BUILD_PLATFORM_IPHONE)
IF(${IPHONE_VERSION_MIN} LESS "7.0")
SET(CMAKE_OSX_ARCHITECTURES "armv6;armv7" CACHE STRING "Build architectures for iOS" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=${IPHONE_VERSION_MIN} -mno-thumb -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ELSE()
SET(CMAKE_OSX_ARCHITECTURES "armv7;armv7s;arm64" CACHE STRING "Build architectures for iOS" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=${IPHONE_VERSION_MIN} -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ENDIF()
SET(CMAKE_OSX_ARCHITECTURES "armv6;armv7" CACHE STRING "Build architectures for iOS" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=3.1 -mno-thumb -arch armv6 -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ELSE()
#simulator uses i386 architectures
SET(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "Build architectures for iOS Simulator" FORCE)
@@ -947,23 +806,18 @@ IF(APPLE AND NOT ANDROID)
# FORCE is used because the options are not reflected in the UI otherwise.
# Seems like a good place to add version specific compiler flags too.
IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.9" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.10")
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
# 64 Bit Works, i386,ppc is not supported any more
SET(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.8 -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7")
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
# 64 Bit Works, PPC is not supported any more
SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.6" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.5")
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
# 64-bit compiles are not supported with Carbon.
# This is really fragile, but CMake doesn't provide the OS system
# version information we need. (Darwin versions can be changed
# independently of OS X versions.)
# It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
IF(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
# 64-bit compiles are not supported with Carbon. We should enable
# 64-bit compilation by default once osgviewer has been
# rewritten with Cocoa.
#SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ELSEIF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.4")
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "quicktime" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
ELSEIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ELSE()
@@ -971,21 +825,21 @@ IF(APPLE AND NOT ANDROID)
# Should break down further to set the -mmacosx-version-min,
# but the SDK detection is too unreliable here.
ENDIF()
ENDIF()
ENDIF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
ENDIF()
ENDIF()
ENDIF(APPLE)
# For Doxygen
INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
OPTION(BUILD_DOCUMENTATION "Build OpenSceneGraph reference documentation using doxygen (use: make doc_openscenegraph doc_openthreads)" OFF)
OPTION(BUILD_DOCUMENTATION "Build OpenSceneGraph reference documentation using doxygen (use: make DoxygenDoc)" OFF)
MARK_AS_ADVANCED(CLEAR BUILD_DOCUMENTATION)
# To build the documention, you will have to enable it
# and then do the equivalent of "make doc_openscenegraph doc_openthreads".
# and then do the equivalent of "make DoxygenDoc".
IF(BUILD_DOCUMENTATION)
OPTION(BUILD_REF_DOCS_SEARCHENGINE "Enable doxygen's search engine (requires that documentation to be installed on a php enabled web server)" OFF)
@@ -1007,19 +861,19 @@ IF(BUILD_DOCUMENTATION)
ELSE()
SET(HAVE_DOT NO)
ENDIF()
# If html help generation was requested. DOCUMENTATION_HTML_HELP is defined by Documentation.cmake
SET(GENERATE_HTMLHELP "NO")
IF(DOCUMENTATION_HTML_HELP)
# on windows Documentation.cmake finds the html help workshop if it exists. On u*ix we might have it with wine but no way to point it out
# on windows Documentation.cmake finds the html help workshop fi it exists. On u*ix we might have it with wine but no way to point it out
IF(NOT WIN32)
SET(HTML_HELP_COMPILER "" CACHE FILEPATH "Enter location of the HTML help compiler to let doxygen compile html")
MARK_AS_ADVANCED(HTML_HELP_COMPILER)
ENDIF()
# this var sets a proper value in .doxygen files when configuring them below
# this var sets a proper value in .doxygen files when coniguring them below
SET(GENERATE_HTMLHELP "YES")
endif()
# This processes our doxyfile.cmake and substitutes paths to generate
# a final Doxyfile
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/doxyfile.cmake
@@ -1055,7 +909,7 @@ IF(BUILD_DOCUMENTATION)
${PROJECT_BINARY_DIR}/doc/auto_Doxyfile)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/doc/Doxyfiles/core_Doxyfile
${PROJECT_BINARY_DIR}/doc/core_Doxyfile)
# This creates a new target to build documentation.
# It runs ${DOXYGEN} which is the full path and executable to
# Doxygen on your system, set by the FindDoxygen.cmake module
@@ -1066,17 +920,17 @@ IF(BUILD_DOCUMENTATION)
${PROJECT_BINARY_DIR}/doc/openscenegraph.doxyfile
)
SET_TARGET_PROPERTIES(doc_openscenegraph PROPERTIES FOLDER "Documentation")
ADD_CUSTOM_TARGET(doc_openthreads ${DOXYGEN}
${PROJECT_BINARY_DIR}/doc/openthreads.doxyfile
)
SET_TARGET_PROPERTIES(doc_openthreads PROPERTIES FOLDER "Documentation")
ENDIF(BUILD_DOCUMENTATION)
OPTION(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of OpenSceneGraph builds here http://cdash.openscenegraph.org/index.php?project=OpenSceneGraph" OFF)
OPTION(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of OpenSceneGraph builds here http://www.cdash.org/CDashPublic/index.php?project=OpenSceneGraph" OFF)
IF(BUILD_DASHBOARD_REPORTS)
# The following are required to uses Dart and the Cdash dashboard
# viewable here : http://cdash.openscenegraph.org/index.php?project=OpenSceneGraph
# viewable here : http://www.cdash.org/CDashPublic/index.php?project=OpenSceneGraph
INCLUDE(Dart)
ENDIF()
@@ -1109,9 +963,9 @@ SET(PKGCONFIG_FILES
openscenegraph-osgVolume
)
IF(QT4_FOUND OR Qt5Widgets_FOUND )
IF(QT4_FOUND)
SET(PKGCONFIG_FILES ${PKGCONFIG_FILES} openscenegraph-osgQt)
ENDIF()
ENDIF(QT4_FOUND)
FOREACH(PKGCONFIG_FILE ${PKGCONFIG_FILES})
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc.in
@@ -1143,7 +997,7 @@ IF(REQUIRES_LIBPATH_MESSAGE)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/ld.so.conf.d/openscenegraph.conf.in
${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf
)
ADD_CUSTOM_TARGET(install_ld_conf ${CMAKE_COMMAND} -E copy_if_different
ADD_CUSTOM_TARGET(install_ld_conf ${CMAKE_COMMAND} -E copy_if_different
${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf
/etc/ld.so.conf.d/openscenegraph.conf
COMMAND ldconfig

View File

@@ -1,4 +1,4 @@
# Check for availability of atomic operations
# Check for availability of atomic operations
# This module defines
# OPENTHREADS_HAVE_ATOMIC_OPS
@@ -15,143 +15,123 @@ IF (OPENTHREADS_ATOMIC_USE_MUTEX)
SET(_OPENTHREADS_ATOMIC_USE_MUTEX 1)
ELSE()
# as the test does not work for IOS hardcode the ATOMIC implementation
IF(OSG_BUILD_PLATFORM_IPHONE_SIMULATOR OR OSG_BUILD_PLATFORM_IPHONE)
SET(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS 0)
SET(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS 0)
SET(_OPENTHREADS_ATOMIC_USE_SUN 0)
SET(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED 0)
SET(_OPENTHREADS_ATOMIC_USE_MUTEX 0)
SET(_OPENTHREADS_ATOMIC_USE_BSD_ATOMIC 1)
INCLUDE(CheckCXXSourceRuns)
ELSE()
INCLUDE(CheckCXXSourceRuns)
# Do step by step checking,
CHECK_CXX_SOURCE_RUNS("
#include <cstdlib>
# Do step by step checking,
CHECK_CXX_SOURCE_RUNS("
#include <cstdlib>
int main()
{
unsigned value = 0;
void* ptr = &value;
__sync_add_and_fetch(&value, 1);
__sync_synchronize();
__sync_sub_and_fetch(&value, 1);
if (!__sync_bool_compare_and_swap(&value, 0, 1))
return EXIT_FAILURE;
int main()
{
unsigned value = 0;
void* ptr = &value;
__sync_add_and_fetch(&value, 1);
__sync_synchronize();
__sync_sub_and_fetch(&value, 1);
if (!__sync_bool_compare_and_swap(&value, 0, 1))
return EXIT_FAILURE;
if (!__sync_bool_compare_and_swap(&ptr, ptr, ptr))
return EXIT_FAILURE;
if (!__sync_bool_compare_and_swap(&ptr, ptr, ptr))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
CHECK_CXX_SOURCE_RUNS("
#include <stdlib.h>
CHECK_CXX_SOURCE_RUNS("
#include <stdlib.h>
int main(int, const char**)
{
unsigned value = 0;
void* ptr = &value;
__add_and_fetch(&value, 1);
__synchronize(value);
__sub_and_fetch(&value, 1);
if (!__compare_and_swap(&value, 0, 1))
return EXIT_FAILURE;
int main(int, const char**)
{
unsigned value = 0;
void* ptr = &value;
__add_and_fetch(&value, 1);
__synchronize(value);
__sub_and_fetch(&value, 1);
if (!__compare_and_swap(&value, 0, 1))
return EXIT_FAILURE;
if (!__compare_and_swap((unsigned long*)&ptr, (unsigned long)ptr, (unsigned long)ptr))
return EXIT_FAILURE;
if (!__compare_and_swap((unsigned long*)&ptr, (unsigned long)ptr, (unsigned long)ptr))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
CHECK_CXX_SOURCE_RUNS("
#include <atomic.h>
#include <cstdlib>
CHECK_CXX_SOURCE_RUNS("
#include <atomic.h>
#include <cstdlib>
int main(int, const char**)
{
uint_t value = 0;
void* ptr = &value;
atomic_inc_uint_nv(&value);
membar_consumer();
atomic_dec_uint_nv(&value);
if (0 != atomic_cas_uint(&value, 0, 1))
return EXIT_FAILURE;
int main(int, const char**)
{
uint_t value = 0;
void* ptr = &value;
atomic_inc_uint_nv(&value);
membar_consumer();
atomic_dec_uint_nv(&value);
if (0 != atomic_cas_uint(&value, 0, 1))
return EXIT_FAILURE;
if (ptr != atomic_cas_ptr(&ptr, ptr, ptr))
return EXIT_FAILURE;
if (ptr != atomic_cas_ptr(&ptr, ptr, ptr))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_SUN)
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_SUN)
CHECK_CXX_SOURCE_RUNS("
#include <windows.h>
#include <intrin.h>
#include <cstdlib>
CHECK_CXX_SOURCE_RUNS("
#include <windows.h>
#include <intrin.h>
#include <cstdlib>
#pragma intrinsic(_InterlockedAnd)
#pragma intrinsic(_InterlockedOr)
#pragma intrinsic(_InterlockedXor)
#pragma intrinsic(_InterlockedAnd)
#pragma intrinsic(_InterlockedOr)
#pragma intrinsic(_InterlockedXor)
int main(int, const char**)
{
volatile long value = 0;
long data = 0;
long* volatile ptr = &data;
int main(int, const char**)
{
volatile long value = 0;
long data = 0;
long* volatile ptr = &data;
InterlockedIncrement(&value);
MemoryBarrier();
InterlockedDecrement(&value);
InterlockedIncrement(&value);
MemoryBarrier();
InterlockedDecrement(&value);
if (0 != InterlockedCompareExchange(&value, 1, 0))
return EXIT_FAILURE;
if (0 != InterlockedCompareExchange(&value, 1, 0))
return EXIT_FAILURE;
if (ptr != InterlockedCompareExchangePointer((PVOID volatile*)&ptr, (PVOID)ptr, (PVOID)ptr))
return EXIT_FAILURE;
if (ptr != InterlockedCompareExchangePointer((PVOID volatile*)&ptr, (PVOID)ptr, (PVOID)ptr))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
CHECK_CXX_SOURCE_RUNS("
#include <libkern/OSAtomic.h>
CHECK_CXX_SOURCE_RUNS("
#include <libkern/OSAtomic.h>
int main()
{
volatile int32_t value = 0;
long data = 0;
long * volatile ptr = &data;
int main()
{
volatile int32_t value = 0;
long data = 0;
long * volatile ptr = &data;
OSAtomicIncrement32(&value);
OSMemoryBarrier();
OSAtomicDecrement32(&value);
OSAtomicCompareAndSwapInt(value, 1, &value);
OSAtomicCompareAndSwapPtr(ptr, ptr, (void * volatile *)&ptr);
}
" _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC)
IF(NOT _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS AND
NOT _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS AND
NOT _OPENTHREADS_ATOMIC_USE_SUN AND
NOT _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED AND
NOT _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC)
SET(_OPENTHREADS_ATOMIC_USE_MUTEX 1)
ENDIF()
# MinGW can set both WIN32_INTERLOCKED and GCC_BUILTINS to true which results in compliation errors
IF (_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS AND _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
# In this case we prefer the GCC_BUILTINS
SET(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS 1)
SET(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED 0)
ENDIF()
OSAtomicIncrement32(&value);
OSMemoryBarrier();
OSAtomicDecrement32(&value);
OSAtomicCompareAndSwapInt(value, 1, &value);
OSAtomicCompareAndSwapPtr(ptr, ptr, (void * volatile *)&ptr);
}
" _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC)
IF(NOT _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS AND
NOT _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS AND
NOT _OPENTHREADS_ATOMIC_USE_SUN AND
NOT _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED AND
NOT _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC)
SET(_OPENTHREADS_ATOMIC_USE_MUTEX 1)
ENDIF()
ENDIF()

View File

@@ -54,12 +54,12 @@ ENDMACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES_BASE SEARCHPATHLIST D
################################################################################################
# this Macro is tailored to Mike and Torbens dependencies
# this Macro is tailored to Mike dependencies
################################################################################################
MACRO(SEARCH_3RDPARTY OSG_3RDPARTY_BIN)
FIND_DEPENDENCY(TIFF tiff.h libtiff ${OSG_3RDPARTY_BIN} "D" "_i")
FIND_DEPENDENCY(FREETYPE ft2build.h "freetype;freetype2311MT;freetype234;freetype234MT;freetype235;freetype237;freetype238;freetype244;freetype250;" ${OSG_3RDPARTY_BIN} "d" "")
FIND_DEPENDENCY(FREETYPE ft2build.h "freetype;freetype2311MT;freetype234;freetype234MT;freetype235;freetype237;freetype238;freetype244;" ${OSG_3RDPARTY_BIN} "d" "")
IF(FREETYPE_FOUND)
#forcing subsequent FindFreeType stuff to not search for other variables.... kind of a hack
SET(FREETYPE_INCLUDE_DIR_ft2build ${FREETYPE_INCLUDE_DIR} CACHE PATH "" FORCE)
@@ -79,21 +79,21 @@ MACRO(SEARCH_3RDPARTY OSG_3RDPARTY_BIN)
FIND_DEPENDENCY(GIFLIB gif_lib.h "ungif;libungif;giflib" ${OSG_3RDPARTY_BIN} "D" "")
FIND_DEPENDENCY(ZLIB zlib.h "z;zlib;zlib1" ${OSG_3RDPARTY_BIN} "D" "")
IF(ZLIB_FOUND)
FIND_DEPENDENCY(PNG png.h "libpng;libpng13;libpng15;libpng16" ${OSG_3RDPARTY_BIN} "D" "")
FIND_DEPENDENCY(PNG png.h "libpng;libpng13;libpng15" ${OSG_3RDPARTY_BIN} "D" "")
IF(PNG_FOUND)
#forcing subsequent FindPNG stuff to not search for other variables.... kind of a hack
SET(PNG_PNG_INCLUDE_DIR ${PNG_INCLUDE_DIR} CACHE FILEPATH "")
MARK_AS_ADVANCED(PNG_PNG_INCLUDE_DIR)
ENDIF(PNG_FOUND)
ENDIF(ZLIB_FOUND)
FIND_DEPENDENCY(LIBXML2 libxml2 "libxml2" ${OSG_3RDPARTY_BIN} "D" "")
FIND_DEPENDENCY(LIBXML2 libxml "libxml2" ${OSG_3RDPARTY_BIN} "D" "")
IF(LIBXML2_FOUND)
# The CMAKE find libxml module uses LIBXML2_LIBRARIES -> fill it.... kind of a hack
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY} CACHE FILEPATH "" FORCE)
SET(LIBXML2_XMLLINT_EXECUTABLE ${OSG_3RDPARTY_BIN}/bin/xmllint.exe CACHE FILEPATH "Path to xmllint executable" FORCE)
ENDIF(LIBXML2_FOUND)
#FIND_DEPENDENCY(DEPNAME INCLUDEFILE LIBRARY_NAMES_BASE SEARCHPATHLIST DEBUGSUFFIX EXSUFFIX)
FIND_Package(NVTT)
FIND_Package(NVTT)
#luigi#INCLUDE(FindOSGDepends.cmake)
ENDMACRO(SEARCH_3RDPARTY OSG_3RDPARTY_BIN)

View File

@@ -1,40 +0,0 @@
# Locate Apple AVFoundation (next-generation QTKit)
# This module defines
# AV_FOUNDATION_LIBRARY
# AV_FOUNDATION_FOUND, if false, do not try to link to gdal
#
# $AV_FOUNDATION_DIR is an environment variable that would
# correspond to the ./configure --prefix=$AV_FOUNDATION_DIR
#
# Created by Stephan Maximilian Huber
IF(APPLE)
FIND_LIBRARY(AV_FOUNDATION_LIBRARY AVFoundation)
ENDIF()
SET(AV_FOUNDATION_FOUND "NO")
IF(AV_FOUNDATION_LIBRARY)
SET(AV_FOUNDATION_FOUND "YES")
ENDIF()
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
# AVFoundation exists ON iOS, too -- good support for SDK 6.0 and greater
IF(${IPHONE_SDKVER} LESS "6.0")
SET(AV_FOUNDATION_FOUND "NO")
ELSE()
SET(AV_FOUNDATION_FOUND "YES")
ENDIF()
ELSE()
IF(APPLE)
# AVFoundation exists since 10.7, but only 10.8 has all features necessary for OSG
# so check the SDK-setting
IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.9" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.10")
# nothing special here ;-)
ELSE()
MESSAGE("AVFoundation disabled for SDK < 10.8")
SET(AV_FOUNDATION_FOUND "NO")
ENDIF()
ENDIF()
ENDIF()

View File

@@ -1,20 +0,0 @@
# Locate ASIO-headers (http://think-async.com/Asio)
# This module defines
# ASIO_FOUND, if false, do not try to link to gdal
# ASIO_INCLUDE_DIR, where to find the headers
#
# Created by Stephan Maximilian Huber
FIND_PATH(ASIO_INCLUDE_DIR
NAMES
asio.hpp
PATHS
/usr/include
/usr/local/include
)
SET(ASIO_FOUND "NO")
FIND_PACKAGE( Boost 1.37 )
IF(Boost_FOUND AND ASIO_INCLUDE_DIR)
SET(ASIO_FOUND "YES")
ENDIF()

View File

@@ -28,12 +28,6 @@ IF(APPLE)
SET(COLLADA_BUILDNAME "mac")
ELSEIF(MINGW)
SET(COLLADA_BUILDNAME "mingw")
ELSEIF(MSVC12)
SET(COLLADA_BUILDNAME "vc12")
ELSEIF(MSVC11)
SET(COLLADA_BUILDNAME "vc11")
ELSEIF(MSVC10)
SET(COLLADA_BUILDNAME "vc10")
ELSEIF(MSVC90)
SET(COLLADA_BUILDNAME "vc9")
ELSEIF(MSVC80)
@@ -53,7 +47,6 @@ FIND_PATH(COLLADA_INCLUDE_DIR dae.h
/usr/local/include
/usr/local/include/colladadom
/usr/local/include/collada-dom
/opt/local/include/collada-dom
/usr/include/
/usr/include/colladadom
/usr/include/collada-dom
@@ -242,7 +235,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_FILESYSTEM_LIBRARY
NAMES libboost_filesystem boost_filesystem boost_filesystem-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_54 libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_55
NAMES libboost_filesystem boost_filesystem libboost_filesystem-vc90-mt libboost_filesystem-vc100-mt
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@@ -250,7 +243,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_FILESYSTEM_LIBRARY_DEBUG
NAMES libboost_filesystem-d boost_filesystem-d boost_filesystem-mt-d libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_54 libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_55
NAMES libboost_filesystem-d boost_filesystem-d libboost_filesystem-vc90-mt-gd libboost_filesystem-vc100-mt-gd
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@@ -258,7 +251,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_SYSTEM_LIBRARY
NAMES libboost_system boost_system boost_system-mt libboost_system-${COLLADA_BUILDNAME}0-mt libboost_system-${COLLADA_BUILDNAME}0-mt-1_54 libboost_system-${COLLADA_BUILDNAME}0-mt-1_55
NAMES libboost_system boost_system libboost_system-vc90-mt libboost_system-vc100-mt
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@@ -266,7 +259,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_SYSTEM_LIBRARY_DEBUG
NAMES libboost_system-d boost_system-d boost_system-mt-d libboost_system-${COLLADA_BUILDNAME}0-mt-gd libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_54 libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_55
NAMES libboost_system-d boost_system-d libboost_system-vc90-mt-gd libboost_system-vc100-mt-gd
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw

View File

@@ -1,23 +0,0 @@
# Locate Apple CoreMedia
# This module defines
# COREMEDIA_LIBRARY
# COREMEDIA_FOUND, if false, do not try to link to gdal
# COREMEDIA_INCLUDE_DIR, where to find the headers
#
# $COREMEDIA_DIR is an environment variable that would
# correspond to the ./configure --prefix=$COREMEDIA_DIR
#
# Created by Stephan Maximilian Huber.
IF(APPLE)
FIND_PATH(COREMEDIA_INCLUDE_DIR CoreMedia/CoreMedia.h)
FIND_LIBRARY(COREMEDIA_LIBRARY CoreMedia)
ENDIF()
SET(COREMEDIA_FOUND "NO")
IF(COREMEDIA_LIBRARY AND COREMEDIA_INCLUDE_DIR)
SET(COREMEDIA_FOUND "YES")
ENDIF()

View File

@@ -16,12 +16,8 @@ ELSEIF(MSVC80)
SET(FBX_LIBDIR "vs2005")
ELSEIF(MSVC90)
SET(FBX_LIBDIR "vs2008")
ELSEIF(MSVC10)
ELSEIF(MSVC100 OR MSVC_VER>1600)
SET(FBX_LIBDIR "vs2010")
ELSEIF(MSVC11)
SET(FBX_LIBDIR "vs2012")
ELSEIF(MSVC12 OR MSVC_VERSION>1800)
SET(FBX_LIBDIR "vs2013")
ENDIF()
IF(APPLE)
@@ -34,29 +30,22 @@ ELSE()
SET(FBX_LIBDIR ${FBX_LIBDIR}/x86)
ENDIF()
#try to use 2015.1 or 2014.2 version
IF(APPLE)
SET(FBX_LIBNAME "libfbxsdk")
SET(FBX_LIBNAME "fbxsdk-2012.1-static")
ELSEIF(CMAKE_COMPILER_IS_GNUCXX)
SET(FBX_LIBNAME "fbxsdk")
SET(FBX_LIBNAME "fbxsdk-2012.1-static")
ELSE()
SET(FBX_LIBNAME "libfbxsdk-md")
SET(FBX_LIBNAME "fbxsdk-2012.1-md")
ENDIF()
SET(FBX_LIBNAME_DEBUG ${FBX_LIBNAME}d)
SET( FBX_SEARCH_PATHS
$ENV{FBX_DIR}
"$ENV{ProgramW6432}/Autodesk/FBX/FBX SDK/2015.1"
"$ENV{PROGRAMFILES}/Autodesk/FBX/FBX SDK/2015.1"
/Applications/Autodesk/FBXSDK20151
"$ENV{ProgramW6432}/Autodesk/FBX/FBX SDK/2014.2"
"$ENV{PROGRAMFILES}/Autodesk/FBX/FBX SDK/2014.2"
/Applications/Autodesk/FBXSDK20142
/Applications/Autodesk/FBXSDK20141
$ENV{ProgramW6432}/Autodesk/FBX/FbxSdk/2012.1
$ENV{PROGRAMFILES}/Autodesk/FBX/FbxSdk/2012.1
/Applications/Autodesk/FBXSDK20121
)
#I think the last line in the search path is an old typo, but let's search for 2014.1 anyway - LV
# search for headers & debug/release libraries
FIND_PATH(FBX_INCLUDE_DIR "fbxsdk.h"
@@ -64,14 +53,7 @@ FIND_PATH(FBX_INCLUDE_DIR "fbxsdk.h"
PATH_SUFFIXES "include")
FIND_LIBRARY( FBX_LIBRARY ${FBX_LIBNAME}
PATHS ${FBX_SEARCH_PATHS}
PATH_SUFFIXES "lib/${FBX_LIBDIR}/release" "lib/${FBX_LIBDIR}")
#Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.
#no debug d suffix, search in debug folder only
FIND_LIBRARY( FBX_LIBRARY_DEBUG ${FBX_LIBNAME}
PATHS ${FBX_SEARCH_PATHS}
PATH_SUFFIXES "lib/${FBX_LIBDIR}/debug")
PATH_SUFFIXES "lib/${FBX_LIBDIR}")
FIND_LIBRARY( FBX_LIBRARY_DEBUG ${FBX_LIBNAME_DEBUG}
PATHS ${FBX_SEARCH_PATHS}
PATH_SUFFIXES "lib/${FBX_LIBDIR}")
@@ -81,79 +63,3 @@ IF(FBX_LIBRARY AND FBX_LIBRARY_DEBUG AND FBX_INCLUDE_DIR)
ELSE()
SET(FBX_FOUND "NO")
ENDIF()
IF(NOT FBX_FOUND)
#try to use 2014.1 version
IF(APPLE)
SET(FBX_LIBNAME "fbxsdk-2014.1")
ELSEIF(CMAKE_COMPILER_IS_GNUCXX)
SET(FBX_LIBNAME "fbxsdk-2014.1")
ELSE()
SET(FBX_LIBNAME "fbxsdk-2014.1")
ENDIF()
SET(FBX_LIBNAME_DEBUG ${FBX_LIBNAME}d)
SET( FBX_SEARCH_PATHS
$ENV{FBX_DIR}
$ENV{ProgramW6432}/Autodesk/FBX/FBX SDK/2014.1
$ENV{PROGRAMFILES}/Autodesk/FBX/FBX SDK/2014.1
/Applications/Autodesk/FBXSDK20141
)
# search for headers & debug/release libraries
FIND_PATH(FBX_INCLUDE_DIR "fbxsdk.h"
PATHS ${FBX_SEARCH_PATHS}
PATH_SUFFIXES "include")
FIND_LIBRARY( FBX_LIBRARY ${FBX_LIBNAME}
PATHS ${FBX_SEARCH_PATHS}
PATH_SUFFIXES "lib/${FBX_LIBDIR}")
FIND_LIBRARY( FBX_LIBRARY_DEBUG ${FBX_LIBNAME_DEBUG}
PATHS ${FBX_SEARCH_PATHS}
PATH_SUFFIXES "lib/${FBX_LIBDIR}")
IF(FBX_LIBRARY AND FBX_LIBRARY_DEBUG AND FBX_INCLUDE_DIR)
SET(FBX_FOUND "YES")
ELSE()
SET(FBX_FOUND "NO")
ENDIF()
ENDIF()
IF(NOT FBX_FOUND)
#try to use 2013.3 version
IF(APPLE)
SET(FBX_LIBNAME "fbxsdk-2013.3-static")
ELSEIF(CMAKE_COMPILER_IS_GNUCXX)
SET(FBX_LIBNAME "fbxsdk-2013.3-static")
ELSE()
SET(FBX_LIBNAME "fbxsdk-2013.3-md")
ENDIF()
SET(FBX_LIBNAME_DEBUG ${FBX_LIBNAME}d)
SET( FBX_SEARCH_PATHS
$ENV{FBX_DIR}
$ENV{ProgramW6432}/Autodesk/FBX/FBX SDK/2013.3
$ENV{PROGRAMFILES}/Autodesk/FBX/FBX SDK/2013.3
/Applications/Autodesk/FBXSDK20133
)
# search for headers & debug/release libraries
FIND_PATH(FBX_INCLUDE_DIR "fbxsdk.h"
PATHS ${FBX_SEARCH_PATHS}
PATH_SUFFIXES "include")
FIND_LIBRARY( FBX_LIBRARY ${FBX_LIBNAME}
PATHS ${FBX_SEARCH_PATHS}
PATH_SUFFIXES "lib/${FBX_LIBDIR}")
FIND_LIBRARY( FBX_LIBRARY_DEBUG ${FBX_LIBNAME_DEBUG}
PATHS ${FBX_SEARCH_PATHS}
PATH_SUFFIXES "lib/${FBX_LIBDIR}")
IF(FBX_LIBRARY AND FBX_LIBRARY_DEBUG AND FBX_INCLUDE_DIR)
SET(FBX_FOUND "YES")
ELSE()
SET(FBX_FOUND "NO")
ENDIF()
ENDIF()

View File

@@ -11,8 +11,7 @@
#In ffmpeg code, old version use "#include <header.h>" and newer use "#include <libname/header.h>"
#In OSG ffmpeg plugin, we used "#include <header.h>" for compatibility with old version of ffmpeg
#With the new version of FFmpeg, a file named "time.h" was added that breaks compatability with the old version of ffmpeg.
#In OSG ffmpeg plugin, we use "#include <header.h>" for compatibility with old version of ffmpeg
#We have to search the path which contain the header.h (usefull for old version)
#and search the path which contain the libname/header.h (usefull for new version)
@@ -132,17 +131,20 @@ IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODE
SET(FFMPEG_FOUND "YES")
SET(FFMPEG_INCLUDE_DIRS
${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}
${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/libavformat
${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS} ${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS}/libavdevice
${FFMPEG_LIBAVCODEC_INCLUDE_DIRS} ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}/libavcodec
${FFMPEG_LIBAVUTIL_INCLUDE_DIRS} ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}/libavutil
)
# Using the new include style for FFmpeg prevents issues with #include <time.h>
IF (FFMPEG_STDINT_INCLUDE_DIR)
SET(FFMPEG_INCLUDE_DIRS
${FFMPEG_INCLUDE_DIRS}
${FFMPEG_STDINT_INCLUDE_DIR}
${FFMPEG_STDINT_INCLUDE_DIR}/libavformat
${FFMPEG_STDINT_INCLUDE_DIR}/libavdevice
${FFMPEG_STDINT_INCLUDE_DIR}/libavcodec
${FFMPEG_STDINT_INCLUDE_DIR}/libavutil
)
ENDIF()

View File

@@ -48,7 +48,7 @@ FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
/opt/csw
/opt
/usr/freeware
PATH_SUFFIXES include include/freetype2
PATH_SUFFIXES include
)
FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h
@@ -74,20 +74,6 @@ FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h
/usr/freeware/include/freetype2
)
FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 config/ftheader.h
/usr/local/include/freetype2
/usr/include/freetype2
/usr/local/X11R6/include/freetype2
/usr/local/X11/include/freetype2
/usr/X11R6/include/freetype2
/usr/X11/include/freetype2
/sw/include/freetype2
/opt/local/include/freetype2
/opt/csw/include/freetype2
/opt/include/freetype2
/usr/freeware/include/freetype2
)
FIND_LIBRARY(FREETYPE_LIBRARY
NAMES freetype libfreetype freetype219
PATHS

View File

@@ -1,56 +0,0 @@
# Locate libgta
# This module defines
# GTA_FOUND, if false, do not try to link to libgta
# GTA_INCLUDE_DIRS, where to find the headers
# GTA_LIBRARIES
#
# $GTA_DIR is an environment variable that would
# correspond to the ./configure --prefix=$GTA_DIR
# used in building libgta.
INCLUDE(FindPkgConfig OPTIONAL)
IF(PKG_CONFIG_FOUND)
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(GTA gta)
ELSE(PKG_CONFIG_FOUND)
FIND_PATH(GTA_INCLUDE_DIRS gta/gta.hpp
$ENV{GTA_DIR}/include
$ENV{GTA_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
)
FIND_LIBRARY(GTA_LIBRARIES
NAMES gta libgta
PATHS
$ENV{GTA_DIR}/lib
$ENV{GTA_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
SET(GTA_FOUND "NO")
IF(GTA_LIBRARIES AND GTA_INCLUDE_DIRS)
SET(GTA_FOUND "YES")
ENDIF(GTA_LIBRARIES AND GTA_INCLUDE_DIRS)
ENDIF(PKG_CONFIG_FOUND)

View File

@@ -15,7 +15,6 @@ FIND_PATH(NVTT_INCLUDE_DIR nvtt/nvtt.h
PATH_SUFFIXES include
)
# NVTT
FIND_LIBRARY(NVTT_LIBRARY
NAMES nvtt
PATHS
@@ -26,17 +25,6 @@ FIND_LIBRARY(NVTT_LIBRARY
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
)
FIND_LIBRARY(NVTT_LIBRARY_DEBUG
NAMES nvtt_d
PATHS
/usr/local
/usr
$ENV{NVTT_DIR}
${3rdPartyRoot}
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
)
# NVIMAGE
FIND_LIBRARY(NVIMAGE_LIBRARY
NAMES nvimage
PATHS
@@ -47,17 +35,6 @@ FIND_LIBRARY(NVIMAGE_LIBRARY
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
)
FIND_LIBRARY(NVIMAGE_LIBRARY_DEBUG
NAMES nvimage_d
PATHS
/usr/local
/usr
$ENV{NVTT_DIR}
${3rdPartyRoot}
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
)
# NVMATH
FIND_LIBRARY(NVMATH_LIBRARY
NAMES nvmath
PATHS
@@ -68,17 +45,6 @@ FIND_LIBRARY(NVMATH_LIBRARY
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
)
FIND_LIBRARY(NVMATH_LIBRARY_DEBUG
NAMES nvmath_d
PATHS
/usr/local
/usr
$ENV{NVTT_DIR}
${3rdPartyRoot}
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
)
# NVCORE
FIND_LIBRARY(NVCORE_LIBRARY
NAMES nvcore
PATHS
@@ -88,18 +54,6 @@ FIND_LIBRARY(NVCORE_LIBRARY
${3rdPartyRoot}
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
)
FIND_LIBRARY(NVCORE_LIBRARY_DEBUG
NAMES nvcore_d
PATHS
/usr/local
/usr
$ENV{NVTT_DIR}
${3rdPartyRoot}
PATH_SUFFIXES lib64 lib lib/shared lib/static lib64/static
)
SET(NVTT_FOUND "NO")
IF(NVTT_LIBRARY AND NVTT_INCLUDE_DIR)

View File

@@ -1,13 +1,13 @@
# Locate gdal
# This module defines
# OSG_LIBRARY
# OSG_FOUND, if false, do not try to link to gdal
# OSG_FOUND, if false, do not try to link to gdal
# OSG_INCLUDE_DIR, where to find the headers
#
# $OSG_DIR is an environment variable that would
# correspond to the ./configure --prefix=$OSG_DIR
#
# Created by Robert Osfield.
# Created by Robert Osfield.
FIND_PATH(OSG_INCLUDE_DIR osg/Node
${OSG_DIR}/include
@@ -59,7 +59,7 @@ MACRO(FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME)
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
/usr/freeware/lib64
)
FIND_LIBRARY(${MYLIBRARY}
NAMES "${MYLIBRARYNAME}${CMAKE_RELEASE_POSTFIX}"
PATHS
@@ -96,18 +96,13 @@ MACRO(FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME)
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
/usr/freeware/lib64
)
IF( NOT ${MYLIBRARY}_DEBUG)
IF(MYLIBRARY)
SET(${MYLIBRARY}_DEBUG ${MYLIBRARY})
ENDIF(MYLIBRARY)
ELSE()
IF( NOT MYLIBRARY )
SET(${MYLIBRARY} ${${MYLIBRARY}_DEBUG} )
ENDIF(NOT MYLIBRARY)
ENDIF( NOT ${MYLIBRARY}_DEBUG )
ENDIF(MYLIBRARY)
ENDIF( NOT ${MYLIBRARY}_DEBUG)
ENDMACRO(FIND_OSG_LIBRARY LIBRARY LIBRARYNAME)
FIND_OSG_LIBRARY(OSG_LIBRARY osg)
@@ -116,20 +111,12 @@ FIND_OSG_LIBRARY(OSGUTIL_LIBRARY osgUtil)
FIND_OSG_LIBRARY(OSGDB_LIBRARY osgDB)
FIND_OSG_LIBRARY(OSGTEXT_LIBRARY osgText)
FIND_OSG_LIBRARY(OSGWIDGET_LIBRARY osgWidget)
FIND_OSG_LIBRARY(OSGQT_LIBRARY osgQt)
FIND_OSG_LIBRARY(OSGTERRAIN_LIBRARY osgTerrain)
FIND_OSG_LIBRARY(OSGFX_LIBRARY osgFX)
FIND_OSG_LIBRARY(OSGVIEWER_LIBRARY osgViewer)
FIND_OSG_LIBRARY(OSGVOLUME_LIBRARY osgVolume)
FIND_OSG_LIBRARY(OSGMANIPULATOR_LIBRARY osgManipulator)
FIND_OSG_LIBRARY(OSGANIMATION_LIBRARY osgAnimation)
FIND_OSG_LIBRARY(OSGPARTICLE_LIBRARY osgParticle)
FIND_OSG_LIBRARY(OSGSHADOW_LIBRARY osgShadow)
FIND_OSG_LIBRARY(OSGPRESENTATION_LIBRARY osgPresentation)
FIND_OSG_LIBRARY(OSGSIM_LIBRARY osgSim)
FIND_OSG_LIBRARY(OPENTHREADS_LIBRARY OpenThreads)
SET(OSG_FOUND "NO")
IF(OSG_LIBRARY AND OSG_INCLUDE_DIR)
SET(OSG_FOUND "YES")

View File

@@ -1,23 +0,0 @@
# Locate Apple QuartzCore
# This module defines
# QUARTZCORE_LIBRARY
# QUARTZCORE_FOUND, if false, do not try to link to QUARTZCORE
# QUARTZCORE_INCLUDE_DIR, where to find the headers
#
# $QUARTZCORE_DIR is an environment variable that would
# correspond to the ./configure --prefix=$QUARTZCORE_DIR
#
# Created by Stephan Maximilian Huber.
IF(APPLE)
FIND_PATH(QUARTZCORE_INCLUDE_DIR QuartzCore/QuartzCore.h)
FIND_LIBRARY(QUARTZCORE_LIBRARY QuartzCore)
ENDIF()
SET(QUARTZCORE_FOUND "NO")
IF(QUARTZCORE_LIBRARY AND QUARTZCORE_INCLUDE_DIR)
SET(QUARTZCORE_FOUND "YES")
ENDIF()

View File

@@ -49,24 +49,18 @@ ENDIF()
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
SET(QUICKTIME_FOUND "NO")
ELSE()
IF(APPLE)
#Quicktime is not supported under 64bit OSX build so we need to detect it and disable it.
#First check to see if we are running with a native 64-bit compiler (10.6 default) and implicit arch
IF(NOT CMAKE_OSX_ARCHITECTURES AND CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(QUICKTIME_FOUND "NO")
ELSE()
#Otherwise check to see if 64-bit is explicitly called for.
LIST(FIND CMAKE_OSX_ARCHITECTURES "x86_64" has64Compile)
IF(NOT has64Compile EQUAL -1)
SET(QUICKTIME_FOUND "NO")
ENDIF()
ENDIF()
# Disable quicktime for >= 10.7, as it's officially deprecated
IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.7" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.8" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.9" OR ${OSG_OSX_SDK_NAME} STREQUAL "macosx10.10")
MESSAGE("disabling quicktime because it's not supported by the selected SDK ${OSG_OSX_SDK_NAME}")
SET(QUICKTIME_FOUND "NO")
ENDIF()
ENDIF()
ENDIF()
IF(APPLE)
#Quicktime is not supported under 64bit OSX build so we need to detect it and disable it.
#First check to see if we are running with a native 64-bit compiler (10.6 default) and implicit arch
IF(NOT CMAKE_OSX_ARCHITECTURES AND CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(QUICKTIME_FOUND "NO")
ELSE()
#Otherwise check to see if 64-bit is explicitly called for.
LIST(FIND CMAKE_OSX_ARCHITECTURES "x86_64" has64Compile)
IF(NOT has64Compile EQUAL -1)
SET(QUICKTIME_FOUND "NO")
ENDIF()
ENDIF()
ENDIF()

View File

@@ -5,9 +5,7 @@ IF(PKG_CONFIG_FOUND)
INCLUDE(FindPkgConfig)
#Version 2.35 introduces the rsvg_cleanup function which is used
PKG_CHECK_MODULES(RSVG librsvg-2.0>=2.35)
PKG_CHECK_MODULES(RSVG librsvg-2.0)
PKG_CHECK_MODULES(CAIRO cairo)
IF (RSVG_FOUND AND NOT CAIRO_FOUND)

View File

@@ -1,47 +0,0 @@
# Locate ZeroConf / Bonjour
# This module defines
# ZEROCONF_LIBRARY
# ZEROCONF_FOUND, if false, do not try to link to gdal
# ZEROCONF_INCLUDE_DIR, where to find the headers
#
# $ZEROCONF_DIR is an environment variable that would
# correspond to the ./configure --prefix=$ZEROCONF_DIR
# Created by Stephan Maximilian Huber
SET(ZEROCONF_FOUND "NO")
IF(APPLE)
# bonjour is part of the system on os x / ios
SET(ZEROCONF_FOUND "YES")
ELSE()
IF(WIN32)
# find the Bonjour SDK
FIND_PATH(ZEROCONF_INCLUDE_DIR dnssd.h
$ENV{ZEROCONF_DIR}/include
$ENV{ZEROCONF_DIR}
NO_DEFAULT_PATH
)
FIND_PATH(ZEROCONF_INCLUDE_DIR dnssd.h
PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
NO_DEFAULT_PATH
PATH_SUFFIXES include
)
FIND_PATH(ZEROCONF_INCLUDE_DIR dnssd.h)
FIND_LIBRARY(ZEROCONF_LIBRARY dnssd
PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
NO_DEFAULT_PATH
PATH_SUFFIXES lib64 lib
)
FIND_LIBRARY(ZEROCONF_LIBRARY dnssd)
SET(ZEROCONF_FOUND "NO")
IF(ZEROCONF_LIBRARY AND ZEROCONF_INCLUDE_DIR)
SET(ZEROCONF_FOUND "YES")
ENDIF()
ELSE()
# TODO find AVAHI on linux
ENDIF()
ENDIF()

View File

@@ -1,15 +1,12 @@
MACRO(SETUP_ANDROID_LIBRARY LIB_NAME)
#foreach(arg ${TARGET_LIBRARIES})
# set(MODULE_LIBS "${MODULE_LIBS} -l${arg}")
#endforeach(arg ${TARGET_LIBRARIES})
foreach(arg ${TARGET_LIBRARIES})
set(MODULE_LIBS "${MODULE_LIBS} -l${arg}")
endforeach(arg ${TARGET_LIBRARIES})
foreach(arg ${TARGET_SRC})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" n_f ${arg})
IF ("${arg}" MATCHES ".*\\.c$" OR "${arg}" MATCHES ".*\\.cpp$")
#We only include source files, not header files, this removes anoying warnings
set(MODULE_SOURCES "${MODULE_SOURCES} ${n_f}")
ENDIF()
set(MODULE_SOURCES "${MODULE_SOURCES} ${n_f}")
endforeach(arg ${TARGET_SRC})
#SET(MODULE_INCLUDES "${CMAKE_SOURCE_DIR}/include include")
@@ -38,8 +35,7 @@ MACRO(SETUP_ANDROID_LIBRARY LIB_NAME)
ELSEIF(OSG_GLES2_AVAILABLE)
SET(OPENGLES_LIBRARY -lGLESv2)
ENDIF()
#${MODULE_LIBS}
set(MODULE_LIBS_FLAGS "${OPENGLES_LIBRARY} -ldl")
set(MODULE_LIBS "${MODULE_LIBS} ${OPENGLES_LIBRARY} -ldl")
if(NOT CPP_EXTENSION)
set(CPP_EXTENSION "cpp")
endif()
@@ -48,12 +44,8 @@ MACRO(SETUP_ANDROID_LIBRARY LIB_NAME)
ENDIF()
IF("MODULE_USER_STATIC_OR_DYNAMIC" MATCHES "STATIC")
SET(MODULE_BUILD_TYPE "\$\(BUILD_STATIC_LIBRARY\)")
SET(MODULE_LIBS_SHARED " ")
SET(MODULE_LIBS_STATIC ${TARGET_LIBRARIES})
ELSE()
SET(MODULE_BUILD_TYPE "\$\(BUILD_SHARED_LIBRARY\)")
SET(MODULE_LIBS_SHARED ${TARGET_LIBRARIES})
SET(MODULE_LIBS_STATIC " ")
SET(MODULE_BUILD_TYPE "\$\(BUILD_DYNAMIC_LIBRARY\)")
ENDIF()
set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} ${LIB_NAME}")
set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${CMAKE_CURRENT_BINARY_DIR}/Android.mk \n")

View File

@@ -5,7 +5,7 @@
# NAME of the variables, so the macro gets as arguments the target name and the following list of parameters
# is intended as a list of variable names each one containing the path of the libraries to link to
# The existance of a variable name with _DEBUG appended is tested and, in case it' s value is used
# for linking to when in debug mode
# for linking to when in debug mode
# the content of this library for linking when in debugging
#######################################################################################################
@@ -87,12 +87,12 @@ MACRO(LINK_CORELIB_DEFAULT CORELIB_NAME)
SET(ALL_GL_LIBRARIES ${ALL_GL_LIBRARIES} ${OPENGL_egl_LIBRARY})
ENDIF()
LINK_EXTERNAL(${CORELIB_NAME} ${ALL_GL_LIBRARIES})
LINK_EXTERNAL(${CORELIB_NAME} ${ALL_GL_LIBRARIES})
LINK_WITH_VARIABLES(${CORELIB_NAME} OPENTHREADS_LIBRARY)
IF(OPENSCENEGRAPH_SONAMES)
SET_TARGET_PROPERTIES(${CORELIB_NAME} PROPERTIES VERSION ${OPENSCENEGRAPH_VERSION} SOVERSION ${OPENSCENEGRAPH_SOVERSION})
ENDIF(OPENSCENEGRAPH_SONAMES)
ENDMACRO(LINK_CORELIB_DEFAULT CORELIB_NAME)
@@ -112,11 +112,11 @@ MACRO(SETUP_LINK_LIBRARIES)
######################################################################
#
# This set up the libraries to link to, it assumes there are two variable: one common for a group of examples or plugins
# kept in the variable TARGET_COMMON_LIBRARIES and an example or plugin specific kept in TARGET_ADDED_LIBRARIES
# they are combined in a single list checked for unicity
# kept in the variable TARGET_COMMON_LIBRARIES and an example or plugin specific kept in TARGET_ADDED_LIBRARIES
# they are combined in a single list checked for unicity
# the suffix ${CMAKE_DEBUG_POSTFIX} is used for differentiating optimized and debug
#
# a second variable TARGET_EXTERNAL_LIBRARIES hold the list of libraries not differentiated between debug and optimized
# a second variable TARGET_EXTERNAL_LIBRARIES hold the list of libraries not differentiated between debug and optimized
##################################################################################
SET(TARGET_LIBRARIES ${TARGET_COMMON_LIBRARIES})
@@ -151,7 +151,7 @@ MACRO(SETUP_LINK_LIBRARIES)
ENDIF(TARGET_LIBRARIES_VARS)
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
#when using full path name to specify linkage, it seems that already linked libs must be specified
LINK_EXTERNAL(${TARGET_TARGETNAME} ${ALL_GL_LIBRARIES})
LINK_EXTERNAL(${TARGET_TARGETNAME} ${ALL_GL_LIBRARIES})
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
ENDMACRO(SETUP_LINK_LIBRARIES)
@@ -213,7 +213,7 @@ ENDMACRO(SET_OUTPUT_DIR_PROPERTY_260 TARGET_TARGETNAME RELATIVE_OUTDIR)
MACRO(SETUP_LIBRARY LIB_NAME)
IF(ANDROID)
SETUP_ANDROID_LIBRARY(${LIB_NAME})
SETUP_ANDROID_LIBRARY(${LIB_NAME})
ELSE()
SET(TARGET_NAME ${LIB_NAME} )
SET(TARGET_TARGETNAME ${LIB_NAME} )
@@ -224,13 +224,10 @@ MACRO(SETUP_LIBRARY LIB_NAME)
${TARGET_SRC}
)
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES FOLDER "OSG Core")
IF(APPLE)
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "")
ENDIF()
IF(TARGET_LABEL)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
ENDIF(TARGET_LABEL)
IF(TARGET_LIBRARIES)
LINK_INTERNAL(${LIB_NAME} ${TARGET_LIBRARIES})
ENDIF()
@@ -241,14 +238,14 @@ MACRO(SETUP_LIBRARY LIB_NAME)
LINK_WITH_VARIABLES(${LIB_NAME} ${TARGET_LIBRARIES_VARS})
ENDIF(TARGET_LIBRARIES_VARS)
LINK_CORELIB_DEFAULT(${LIB_NAME})
ENDIF()
INCLUDE(ModuleInstall OPTIONAL)
ENDMACRO(SETUP_LIBRARY LIB_NAME)
MACRO(SETUP_PLUGIN PLUGIN_NAME)
IF(ANDROID)
SETUP_ANDROID_LIBRARY(${TARGET_DEFAULT_PREFIX}${PLUGIN_NAME})
SETUP_ANDROID_LIBRARY(${TARGET_DEFAULT_PREFIX}${PLUGIN_NAME})
ELSE()
SET(TARGET_NAME ${PLUGIN_NAME} )
@@ -271,33 +268,38 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
SET(PACKAGE_COMPONENT libopenscenegraph)
ENDIF(${ARGC} GREATER 1)
# Add the VisualStudio versioning info
# Add the VisualStudio versioning info
SET(TARGET_SRC ${TARGET_SRC} ${OPENSCENEGRAPH_VERSIONINFO_RC})
# here we use the command to generate the library
# here we use the command to generate the library
IF (DYNAMIC_OPENSCENEGRAPH)
ADD_LIBRARY(${TARGET_TARGETNAME} MODULE ${TARGET_SRC} ${TARGET_H})
ELSE (DYNAMIC_OPENSCENEGRAPH)
ADD_LIBRARY(${TARGET_TARGETNAME} STATIC ${TARGET_SRC} ${TARGET_H})
ENDIF(DYNAMIC_OPENSCENEGRAPH)
IF(MSVC)
#not sure if needed, but for plugins only Msvc need the d suffix
IF(NOT MSVC)
IF(NOT UNIX)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "")
ENDIF(NOT UNIX)
ELSE(NOT MSVC)
IF(NOT CMAKE24)
SET_OUTPUT_DIR_PROPERTY_260(${TARGET_TARGETNAME} "${OSG_PLUGINS}") # Sets the ouput to be /osgPlugin-X.X.X ; also ensures the /Debug /Release are removed
ELSE(NOT CMAKE24)
IF(OSG_MSVC_VERSIONED_DLL)
IF(OSG_MSVC_VERSIONED_DLL)
#this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
#the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
#because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
#it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
#changing bin to something else breaks this hack
#the dll are placed in bin/${OSG_PLUGINS}
#the dll are placed in bin/${OSG_PLUGINS}
IF(NOT MSVC_IDE)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../bin/${OSG_PLUGINS}/")
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../bin/${OSG_PLUGINS}/")
ELSE(NOT MSVC_IDE)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../../bin/${OSG_PLUGINS}/" IMPORT_PREFIX "../")
ENDIF(NOT MSVC_IDE)
@@ -311,18 +313,16 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
ENDIF(OSG_MSVC_VERSIONED_DLL)
ENDIF(NOT CMAKE24)
ENDIF(MSVC)
ENDIF(NOT MSVC)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES FOLDER "Plugins")
IF(APPLE)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "")
ENDIF()
SETUP_LINK_LIBRARIES()
#the installation path are differentiated for win32 that install in bib versus other architecture that install in lib${LIB_POSTFIX}/${OSG_PLUGINS}
IF(WIN32)
INSTALL(TARGETS ${TARGET_TARGETNAME}
INSTALL(TARGETS ${TARGET_TARGETNAME}
RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT}
ARCHIVE DESTINATION lib/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev
LIBRARY DESTINATION bin/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT})
@@ -350,11 +350,11 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP)
ENDIF(NOT TARGET_LABEL)
IF(${IS_COMMANDLINE_APP})
ADD_EXECUTABLE(${TARGET_TARGETNAME} ${TARGET_SRC} ${TARGET_H})
ELSE(${IS_COMMANDLINE_APP})
IF(APPLE)
# SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
# Short Version is the "marketing version". It is the version
@@ -363,8 +363,6 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP)
# Bundle version is the version the OS looks at.
SET(MACOSX_BUNDLE_BUNDLE_VERSION "${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}")
SET(MACOSX_BUNDLE_GUI_IDENTIFIER "org.openscenegraph.${TARGET_TARGETNAME}" )
# replace underscore by hyphen
STRING(REGEX REPLACE "_" "-" MACOSX_BUNDLE_GUI_IDENTIFIER ${MACOSX_BUNDLE_GUI_IDENTIFIER})
SET(MACOSX_BUNDLE_BUNDLE_NAME "${TARGET_NAME}" )
# SET(MACOSX_BUNDLE_ICON_FILE "myicon.icns")
# SET(MACOSX_BUNDLE_COPYRIGHT "")
@@ -384,7 +382,7 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP)
ENDIF(APPLE)
ADD_EXECUTABLE(${TARGET_TARGETNAME} ${PLATFORM_SPECIFIC_CONTROL} ${TARGET_SRC} ${TARGET_H})
ENDIF(${IS_COMMANDLINE_APP})
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
@@ -398,11 +396,7 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP)
SET_OUTPUT_DIR_PROPERTY_260(${TARGET_TARGETNAME} "") # Ensure the /Debug /Release are removed
ENDIF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
IF(APPLE)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "")
ENDIF()
SETUP_LINK_LIBRARIES()
SETUP_LINK_LIBRARIES()
ENDMACRO(SETUP_EXE)
@@ -416,11 +410,11 @@ MACRO(SETUP_APPLICATION APPLICATION_NAME)
ELSE(${ARGC} GREATER 1)
SET(IS_COMMANDLINE_APP 0)
ENDIF(${ARGC} GREATER 1)
SETUP_EXE(${IS_COMMANDLINE_APP})
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES FOLDER "Applications")
IF(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin BUNDLE DESTINATION bin)
ELSE(APPLE)
@@ -445,13 +439,13 @@ MACRO(SETUP_EXAMPLE EXAMPLE_NAME)
ELSE(${ARGC} GREATER 1)
SET(IS_COMMANDLINE_APP 0)
ENDIF(${ARGC} GREATER 1)
SETUP_EXE(${IS_COMMANDLINE_APP})
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES FOLDER "Examples")
IF(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin BUNDLE DESTINATION share/OpenSceneGraph/bin )
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin BUNDLE DESTINATION share/OpenSceneGraph/bin )
ELSE(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin COMPONENT openscenegraph-examples )
ENDIF(APPLE)
@@ -489,7 +483,7 @@ MACRO(HANDLE_MSVC_DLL)
ENDIF(${ARGC} GREATER 1)
SET_OUTPUT_DIR_PROPERTY_260(${LIB_NAME} "") # Ensure the /Debug /Release are removed
IF(NOT MSVC_IDE)
IF(NOT MSVC_IDE)
IF (NOT CMAKE24)
BUILDER_VERSION_GREATER(2 8 0)
IF(NOT VALID_BUILDER_VERSION)
@@ -522,12 +516,8 @@ MACRO(HANDLE_MSVC_DLL)
ELSE (NOT CMAKE24)
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/${LIB_PREFIX}${LIB_SOVERSION}-" IMPORT_PREFIX "../")
ENDIF (NOT CMAKE24)
ENDIF(NOT MSVC_IDE)
ENDIF(NOT MSVC_IDE)
# SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/osg${OPENSCENEGRAPH_SOVERSION}-")
# SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
ENDMACRO(HANDLE_MSVC_DLL)
MACRO(REMOVE_CXX_FLAG flag)
STRING(REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ENDMACRO()

10332
ChangeLog

File diff suppressed because it is too large Load Diff

892
NEWS.txt

File diff suppressed because it is too large Load Diff

View File

@@ -1,36 +1,27 @@
#ANDROID makefile ${MODULE_NAME}
#ANDROID makefile ${MODULE_NAME}
LOCAL_PATH := ${MODULE_DIR}
LOCAL_PATH := ${MODULE_DIR}
include $(CLEAR_VARS)
ifeq (${ANDROID_OPTIM_NEON},true)
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_ARM_NEON := true
endif
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_ARM_NEON := true
endif
ifeq (${ANDROID_OPTIM_ARM32},true)
LOCAL_ARM_MODE := arm
endif
LOCAL_CPP_EXTENSION := ${CPP_EXTENSION}
LOCAL_LDLIBS := ${MODULE_LIBS}
LOCAL_CPP_EXTENSION := ${CPP_EXTENSION}
LOCAL_MODULE := ${MODULE_NAME}
LOCAL_LDLIBS := ${MODULE_LIBS_FLAGS}
LOCAL_SRC_FILES := ${MODULE_SOURCES}
LOCAL_MODULE := ${MODULE_NAME}
LOCAL_C_INCLUDES := ${MODULE_INCLUDES}
LOCAL_SRC_FILES := ${MODULE_SOURCES}
LOCAL_CFLAGS := ${MODULE_FLAGS_C}
LOCAL_C_INCLUDES := ${MODULE_INCLUDES}
LOCAL_CFLAGS := ${MODULE_FLAGS_C}
LOCAL_CPPFLAGS := ${MODULE_FLAGS_CPP}
LOCAL_SHARED_LIBRARIES := ${MODULE_LIBS_SHARED}
LOCAL_STATIC_LIBRARIES := ${MODULE_LIBS_STATIC}
LOCAL_CPPFLAGS := ${MODULE_FLAGS_CPP}
#include $(BUILD_STATIC_LIBRARY)
include ${MODULE_BUILD_TYPE}

View File

@@ -3,5 +3,5 @@
package="com.openscenegraph"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
</manifest>

View File

@@ -2,14 +2,14 @@
APP_BUILD_SCRIPT := $(call my-dir)/Android.mk
APP_PROJECT_PATH := $(call my-dir)
APP_OPTIM := ${ANDROID_RELEASE_OPTIM}
APP_OPTIM := release
APP_PLATFORM := android-${ANDROID_PLATFORM}
APP_STL := ${ANDROID_STL}
APP_PLATFORM := android-5
APP_STL := gnustl_static
APP_CPPFLAGS := -fexceptions -frtti
#APP_CPPFLAGS := -Os -mthumb-interwork -fno-short-enums
#APP_CPPFLAGS := -Wl,--no-undefined
APP_ABI := ${ANDROID_ABI}
APP_ABI := armeabi armeabi-v7a
APP_MODULES := $ENV{AND_OSG_LIB_NAMES}

View File

@@ -1,14 +1,18 @@
Welcome to the OpenSceneGraph (OSG).
For up-to-date information on the project, in-depth details on how to
compile and run libraries and examples, see the documentation on the
For up-to-date information on the project, in-depth details on how to
compile and run libraries and examples, see the documentation on the
OpenSceneGraph website:
http://www.openscenegraph.org/index.php/documentation
http://www.openscenegraph.org
For support subscribe to our public mailing list:
For support subscribe to our public mailing list or forum, details at:
http://www.openscenegraph.org/projects/osg/wiki/MailingLists
http://www.openscenegraph.org/index.php/support
or forum:
http://forum.openscenegraph.org/
For the impatient, we've included quick build instructions below, these
are are broken down is three parts:
@@ -23,41 +27,41 @@ more indepth instructions.
Robert Osfield.
Project Lead.
4th July 2014.
28th June 2011.
--
Section 1. How to build the OpenSceneGraph
==========================================
The OpenSceneGraph uses the CMake build system to generate a
platform-specific build environment. CMake reads the CMakeLists.txt
files that you'll find throughout the OpenSceneGraph directories,
checks for installed dependenciesand then generates the appropriate
The OpenSceneGraph uses the CMake build system to generate a
platform-specific build environment. CMake reads the CMakeLists.txt
files that you'll find throughout the OpenSceneGraph directories,
checks for installed dependenciesand then generates the appropriate
build system.
If you don't already have CMake installed on your system you can grab
it from http://www.cmake.org, use version 2.4.6 or later. Details on the
If you don't already have CMake installed on your system you can grab
it from http://www.cmake.org, use version 2.4.6 or later. Details on the
OpenSceneGraph's CMake build can be found at:
http://www.openscenegraph.org/projects/osg/wiki/Build/CMake
Under unices (i.e. Linux, IRIX, Solaris, Free-BSD, HP-Ux, AIX, OSX)
use the cmake or ccmake command-line utils, or use the included tiny
configure script that'll run cmake for you. The configure script
simply runs 'cmake . -DCMAKE_BUILD_TYPE=Release' to ensure that you
Under unices (i.e. Linux, IRIX, Solaris, Free-BSD, HP-Ux, AIX, OSX)
use the cmake or ccmake command-line utils, or use the included tiny
configure script that'll run cmake for you. The configure script
simply runs 'cmake . -DCMAKE_BUILD_TYPE=Release' to ensure that you
get the best performance from your final libraries/applications.
cd OpenSceneGraph
./configure
make
sudo make install
Alternatively, you can create an out-of-source build directory and run
cmake or ccmake from there. The advantage to this approach is that the
temporary files created by CMake won't clutter the OpenSceneGraph
source directory, and also makes it possible to have multiple
independent build targets by creating multiple build directories. In a
Alternatively, you can create an out-of-source build directory and run
cmake or ccmake from there. The advantage to this approach is that the
temporary files created by CMake won't clutter the OpenSceneGraph
source directory, and also makes it possible to have multiple
independent build targets by creating multiple build directories. In a
directory alongside the OpenSceneGraph use:
mkdir build
@@ -66,22 +70,22 @@ directory alongside the OpenSceneGraph use:
make
sudo make install
Under Windows use the GUI tool CMakeSetup to build your VisualStudio
files. The following page on our wiki dedicated to the CMake build
Under Windows use the GUI tool CMakeSetup to build your VisualStudio
files. The following page on our wiki dedicated to the CMake build
system should help guide you through the process:
http://www.openscenegraph.org/index.php/documentation/platform-specifics/windows
http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/VisualStudio
Under OSX you can either use the CMake build system above, or use the
Xcode projects that you will find in the OpenSceneGraph/Xcode
Under OSX you can either use the CMake build system above, or use the
Xcode projects that you will find in the OpenSceneGraph/Xcode
directory. See release notes on OSX CMake build below.
For further details on compilation, installation and platform-specific
For further details on compilation, installation and platform-specific
information read "Getting Started" guide:
http://www.openscenegraph.org/index.php/documentation/10-getting-started
http://www.openscenegraph.org/projects/osg/wiki/Support/GettingStarted
Section 2. Release notes on OSX build, by Eric Sokolowsky, August 5, 2008
=========================================================================
@@ -165,11 +169,11 @@ Section 3. Release notes on iOS build, by Thomas Hoghart
* Check that CMAKE_OSX_ARCHITECTURE is i386 for the simulator or armv6;armv7 for the device
* Disable DYNAMIC_OPENSCENEGRAPH, DYNAMIC_OPENTHREADS
This will give us the static build we need for iPhone.
* Disable OSG_GL1_AVAILABLE, OSG_GL2_AVAILABLE, OSG_GL3_AVAILABLE,
* Disable OSG_GL1_AVAILABLE, OSG_GL2_AVAILABLE, OSG_GL3_AVAILABLE,
OSG_GL_DISPLAYLISTS_AVAILABLE, OSG_GL_VERTEX_FUNCS_AVAILABLE
* Enable OSG_GLES1_AVAILABLE *OR* OSG_GLES2_AVAILABLE
* Ensure OSG_WINDOWING_SYSTEM is set to IOS
* Change FREETYPE include and library paths to an iPhone version
* Change FREETYPE include and library paths to an iPhone version
(OpenFrameworks has one bundled with its distribution)
* Ensure that CMake_OSX_SYSROOT points to your iOS SDK.
* Generate the Xcode project
@@ -202,9 +206,9 @@ $ cmake -G Xcode \
Known issues:
* When Linking final app against ive plugin, you need to add -lz to
* When Linking final app against ive plugin, you need to add -lz to
the 'Other linker flags' list.
* Apps and exes don't get created
* You can only select Simulator, or Device projects. In the XCode
project you will see both types but the sdk they link will
* You can only select Simulator, or Device projects. In the XCode
project you will see both types but the sdk they link will
be the same.

View File

@@ -29,7 +29,7 @@ int main( int argc, char **argv )
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an application for collecting a set of separate files into a single archive file that can be later read in OSG applications..");
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an application for collecting a set of seperate files into a single archive file that can be later read in OSG applications..");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
// if user request help write it out to cout.
@@ -139,15 +139,7 @@ int main( int argc, char **argv )
if (obj.valid())
{
std::cout<<" write to archive "<<*itr<<std::endl;
osg::Image* image = dynamic_cast<osg::Image*>(obj.get());
osg::HeightField* hf = dynamic_cast<osg::HeightField*>(obj.get());
osg::Node* node = dynamic_cast<osg::Node*>(obj.get());
osg::Shader* shader = dynamic_cast<osg::Shader*>(obj.get());
if (image) archive->writeImage(*image, *itr);
else if (hf) archive->writeHeightField(*hf, *itr);
else if (node) archive->writeNode(*node, *itr);
else if (shader) archive->writeShader(*shader, *itr);
else archive->writeObject(*obj, *itr);
archive->writeObject(*obj, *itr);
}
}
}

View File

@@ -51,12 +51,12 @@ class MyGraphicsContext {
if (!_gc)
{
osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to normal graphics window."<<std::endl;
traits->pbuffer = false;
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
}
if (_gc.valid())
if (_gc.valid())
{
_gc->realize();
_gc->makeCurrent();
@@ -70,9 +70,9 @@ class MyGraphicsContext {
}
}
}
bool valid() const { return _gc.valid() && _gc->isRealized(); }
private:
osg::ref_ptr<osg::GraphicsContext> _gc;
};
@@ -95,7 +95,8 @@ public:
{
osg::ref_ptr< osg::Vec3Array > newnormals = new osg::Vec3Array;
newnormals->push_back( osg::Z_AXIS );
geometry->setNormalArray( newnormals.get(), osg::Array::BIND_OVERALL );
geometry->setNormalArray( newnormals.get() );
geometry->setNormalBinding( osg::Geometry::BIND_OVERALL );
}
}
}
@@ -120,20 +121,20 @@ public:
if (node.getStateSet()) apply(*node.getStateSet());
traverse(node);
}
virtual void apply(osg::Geode& node)
{
if (node.getStateSet()) apply(*node.getStateSet());
for(unsigned int i=0;i<node.getNumDrawables();++i)
{
osg::Drawable* drawable = node.getDrawable(i);
if (drawable && drawable->getStateSet()) apply(*drawable->getStateSet());
}
traverse(node);
}
virtual void apply(osg::StateSet& stateset)
{
// search for the existence of any texture object attributes
@@ -146,7 +147,7 @@ public:
}
}
}
void compress()
{
MyGraphicsContext context;
@@ -163,21 +164,21 @@ public:
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());
osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);
osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);
// need to disable the unref after apply, other the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);
// get OpenGL driver to create texture from image.
texture->apply(*state);
@@ -198,10 +199,10 @@ public:
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());
osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);
osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid())
{
@@ -214,11 +215,11 @@ public:
}
}
}
typedef std::set< osg::ref_ptr<osg::Texture> > TextureSet;
TextureSet _textureSet;
osg::Texture::InternalFormatMode _internalFormatMode;
};
@@ -242,7 +243,7 @@ public:
{
std::cout<<"Running FixTransparencyVisitor..."<<std::endl;
}
~FixTransparencyVisitor()
{
std::cout<<" Number of Transparent StateSet "<<_numTransparent<<std::endl;
@@ -255,20 +256,20 @@ public:
if (node.getStateSet()) isTransparent(*node.getStateSet());
traverse(node);
}
virtual void apply(osg::Geode& node)
{
if (node.getStateSet()) isTransparent(*node.getStateSet());
for(unsigned int i=0;i<node.getNumDrawables();++i)
{
osg::Drawable* drawable = node.getDrawable(i);
if (drawable && drawable->getStateSet()) isTransparent(*drawable->getStateSet());
}
traverse(node);
}
virtual bool isTransparent(osg::StateSet& stateset)
{
bool hasTranslucentTexture = false;
@@ -288,15 +289,15 @@ public:
for (unsigned int im=0;im<texture->getNumImages();++im)
{
osg::Image* image = texture->getImage(im);
if (image && image->isImageTranslucent()) hasTranslucentTexture = true;
if (image && image->isImageTranslucent()) hasTranslucentTexture = true;
}
}
}
if (hasTranslucentTexture || hasBlendFunc || hasTransparentRenderingHint || hasDepthSortBin)
{
++_numTransparent;
bool makeNonTransparent = false;
switch(_mode)
@@ -314,7 +315,7 @@ public:
makeNonTransparent = false;
break;
}
if (makeNonTransparent)
{
stateset.removeAttribute(osg::StateAttribute::BLENDFUNC);
@@ -334,7 +335,7 @@ public:
}
unsigned int _numTransparent;
unsigned int _numOpaque;
unsigned int _numOpaque;
unsigned int _numTransparentMadeOpaque;
FixTransparencyMode _mode;
};
@@ -349,7 +350,7 @@ public:
{
std::cout<<"Running PruneStateSet..."<<std::endl;
}
~PruneStateSetVisitor()
{
std::cout<<" Number of StateState removed "<<_numStateSetRemoved<<std::endl;
@@ -364,7 +365,7 @@ public:
}
traverse(node);
}
virtual void apply(osg::Geode& node)
{
if (node.getStateSet())
@@ -372,7 +373,7 @@ public:
node.setStateSet(0);
++_numStateSetRemoved;
}
for(unsigned int i=0;i<node.getNumDrawables();++i)
{
osg::Drawable* drawable = node.getDrawable(i);
@@ -382,10 +383,10 @@ public:
++_numStateSetRemoved;
}
}
traverse(node);
}
unsigned int _numStateSetRemoved;
};
@@ -407,7 +408,8 @@ public:
{
osg::Vec4Array* colours = new osg::Vec4Array(1);
(*colours)[0].set(1.0f,1.0f,1.0f,1.0f);
geometry->setColorArray(colours, osg::Array::BIND_OVERALL);
geometry->setColorArray(colours);
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
}
}
}
@@ -543,7 +545,7 @@ int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is a utility for converting between various input and output databases formats.");
@@ -556,19 +558,18 @@ int main( int argc, char **argv )
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
osg::setNotifyLevel(osg::NOTICE);
{
usage( arguments.getApplicationName().c_str(), 0 );
//arguments.getApplicationUsage()->write(std::cout);
return 1;
}
if (arguments.read("--help-env"))
{
{
arguments.getApplicationUsage()->write(std::cout, osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE);
return 1;
}
if (arguments.read("--plugins"))
{
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
@@ -579,23 +580,23 @@ int main( int argc, char **argv )
std::cout<<"Plugin "<<*itr<<std::endl;
}
return 0;
}
}
std::string plugin;
if (arguments.read("--plugin", plugin))
{
osgDB::outputPluginDetails(std::cout, plugin);
return 0;
}
}
std::string ext;
if (arguments.read("--format", ext))
{
plugin = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
osgDB::outputPluginDetails(std::cout, plugin);
return 0;
}
}
if (arguments.read("--formats"))
{
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
@@ -606,8 +607,8 @@ int main( int argc, char **argv )
osgDB::outputPluginDetails(std::cout,*itr);
}
return 0;
}
}
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
@@ -636,7 +637,7 @@ int main( int argc, char **argv )
std::string libName = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
osgDB::Registry::instance()->loadLibrary(libName);
}
std::string libName;
while (arguments.read("-l",libName))
{
@@ -671,7 +672,7 @@ int main( int argc, char **argv )
oc.setRotation( from, to );
do_convert = true;
}
}
}
while (arguments.read("-s",str))
{
@@ -716,7 +717,7 @@ int main( int argc, char **argv )
do_convert = true;
}
FixTransparencyVisitor::FixTransparencyMode fixTransparencyMode = FixTransparencyVisitor::NO_TRANSPARANCY_FIXING;
std::string fixString;
while(arguments.read("--fix-transparency")) fixTransparencyMode = FixTransparencyVisitor::MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE;
@@ -725,7 +726,7 @@ int main( int argc, char **argv )
if (fixString=="MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE") fixTransparencyMode = FixTransparencyVisitor::MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE;
if (fixString=="MAKE_ALL_STATESET_OPAQUE") fixTransparencyMode = FixTransparencyVisitor::MAKE_ALL_STATESET_OPAQUE;
};
bool pruneStateSet = false;
while(arguments.read("--prune-StateSet")) pruneStateSet = true;
@@ -738,7 +739,7 @@ int main( int argc, char **argv )
bool smooth = false;
while(arguments.read("--smooth")) { smooth = true; }
bool addMissingColours = false;
while(arguments.read("--addMissingColours") || arguments.read("--addMissingColors")) { addMissingColours = true; }
@@ -804,13 +805,13 @@ int main( int argc, char **argv )
if ( root.valid() )
{
if (smooth)
{
osgUtil::SmoothingVisitor sv;
root->accept(sv);
}
}
if (addMissingColours)
{
AddMissingColoursToGeometryVisitor av;
@@ -820,10 +821,10 @@ int main( int argc, char **argv )
// optimize the scene graph, remove rendundent nodes and state etc.
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());
if( do_convert )
root = oc.convert( root.get() );
if (internalFormatMode != osg::Texture::USE_IMAGE_DATA_FORMAT)
{
std::string ext = osgDB::getFileExtension(fileNameOut);

View File

@@ -130,6 +130,40 @@ struct Extents
osg::Vec2d _max;
};
class CheckValidVisitor : public osg::NodeVisitor
{
public:
CheckValidVisitor():
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
_numInvalidGeometries(0) {}
void apply(osg::Geode& geode)
{
unsigned int local_numInvalidGeometries = 0;
for(unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
osg::Geometry* geometry = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
if (geometry)
{
if (!geometry->verifyArrays(_errorReports)) ++local_numInvalidGeometries;
}
}
if (local_numInvalidGeometries)
{
_errorReports<<"Geode "<<geode.getName()<<" contains problem geometries"<<std::endl;
_numInvalidGeometries += local_numInvalidGeometries;
}
}
bool valid() const { return _numInvalidGeometries==0; }
unsigned int _numInvalidGeometries;
std::stringstream _errorReports;
};
class LoadDataVisitor : public osg::NodeVisitor
{
public:
@@ -275,7 +309,7 @@ public:
osg::Node* readNodeFileAndWriteToCache(const std::string& filename)
{
osg::Node* node = 0;
if (_fileCache.valid() )
if (_fileCache.valid() && osgDB::containsServerAddress(filename))
{
if (_fileCache->existsInCache(filename))
{
@@ -300,6 +334,17 @@ public:
osg::notify(osg::NOTICE)<<"reading : "<<filename<<std::endl;
node = osgDB::readNodeFile(filename);
}
if (node)
{
CheckValidVisitor cvv;
node->accept(cvv);
if (!cvv.valid())
{
OSG_NOTICE<<"Warning, errors in geometry found in file "<<filename<<std::endl;
OSG_NOTICE<<cvv._errorReports.str()<<std::endl;
}
}
return node;
}
@@ -406,7 +451,7 @@ int main( int argc, char **argv )
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an application for collecting a set of separate files into a single archive file that can be later read in OSG applications..");
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an application for collecting a set of seperate files into a single archive file that can be later read in OSG applications..");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-l level","Read down to level across the whole database.");
arguments.getApplicationUsage()->addCommandLineOption("-e level minX minY maxX maxY","Read down to <level> across the extents minX, minY to maxY, maxY. Note, for geocentric datase X and Y are longitude and latitude respectively.");

View File

@@ -122,7 +122,6 @@ const char* invalidNames[] =
"LineStipple",
"Logos",
"LongIDRecord",
"InputIterator",
"Make",
"Makefile",
"Material",
@@ -248,19 +247,7 @@ const char* invalidNames[] =
"UpdateSkeleton",
"Vec3",
"Plugin",
"Get",
"LightSource",
"SlideEventHandler",
"GraphicsContext*",
"Apple",
"GeometryNew",
"FrameBufferObject",
"Lua",
"VolumeTile",
"PushStackValueVisitor",
"RayIntersector",
"OpenSceneGraph-Data",
"Node"
"Get"
};
@@ -272,7 +259,6 @@ struct TypoCorrection
TypoCorrection typoCorrections[] =
{
{"Cheaev", "Chebaev"},
{"Alaxandre", "Alexandre"},
{"Aderian", "Adrian"},
{"Adndre", "Andre"},
@@ -282,7 +268,6 @@ TypoCorrection typoCorrections[] =
{"André", "Andr<EFBFBD>"},
{"Antione", "Antoine"},
{"Antonoine", "Antoine"},
{"Aurelein", "Aurelien"},
{"Atr", "Art"},
{"Baverage", "Beverage"},
{"Bistroviae", "Bistrovic"},
@@ -301,7 +286,6 @@ TypoCorrection typoCorrections[] =
{"Fabian", "Fabien"},
{"Fautre", "Fautr<EFBFBD>"},
{"Frashid", "Farshid"},
{"Farshild", "Farshid"},
{"Fred", "Frederic"},
{"Fredrick", "Frederic"},
{"Fredric", "Frederic"},
@@ -327,8 +311,6 @@ TypoCorrection typoCorrections[] =
{"Happalahti", "Haapalahti"},
{"Hertlien", "Hertlein"},
{"Hatwig", "Hartwig"},
{"Hauknes", "Haukness"},
{"Hunber", "Huber"},
{"Hi", "He"},
{"Hooper", "Hopper"},
{"Inverson", "Iverson"},
@@ -353,7 +335,6 @@ TypoCorrection typoCorrections[] =
{"Krulthof", "Kruithof"},
{"Lagrade", "Lagarde"},
{"Largade", "Lagarde"},
{"Largarde", "Lagarde"},
{"Larshkari", "Lashkari"},
{"Lashakari", "Lashkari"},
{"Lashari", "Lashkari"},
@@ -399,7 +380,6 @@ TypoCorrection typoCorrections[] =
{"Oritz", "Ortiz"},
{"Osfeld", "Osfield"},
{"Osfied", "Osfield"},
{"Paulk", "Paul"},
{"Pail", "Paul"},
{"Perciva", "Peciva"},
{"Pecvia", "Peciva"},
@@ -460,28 +440,7 @@ TypoCorrection typoCorrections[] =
{"Jahannes","Johannes"},
{"Eskland","Ekstrand"},
{"Baeuerele","Baeuerle"},
{"Bauerle","Baeuerle"},
{"Baeurele","Baeuerle"},
{"Nillson","Nilsson"},
{"Bjorn","Bj<EFBFBD>rn"},
{"Björn","Bj<EFBFBD>rn"},
{"Stepan","Stephan"},
{"Kristoger","Kristofer"},
{"Blessing","Blissing"},
{"Dannahuer","Dannhauer"},
{"Chebeav", "Chebaev"},
{"Messershmidt","Messerschmidt"},
{"Auelien","Aurelien"},
{"Aurélien","Aur<EFBFBD>lien"},
{"McDonnel","Mc Donnell"},
{"McDonnell","Mc Donnell"},
{"Delallée","Delall<EFBFBD>e"},
{"Gjøl","Gj<EFBFBD>l"},
{"Ravšelj","Rav<EFBFBD>elj"},
{"Ravsel", "Rav<EFBFBD>elj"},
{"Ravselj", "Rav<EFBFBD>elj"},
{"Janik", "Jannik"},
{"Viganò", "Vigan<EFBFBD>"}
{"Bauerle","Baeuerle"}
};
@@ -495,28 +454,16 @@ struct NameCorrection
NameCorrection nameCorrections[] =
{
{"FrancoisTigeot","",
"Francois", "Tigeot"},
{"Juan","Manuel",
"Juan", "Manuel Alvarez"},
{"Jaap","Gas",
"Jaap", "Glas"},
{"Philip","Lamp",
"Philip", "Lamb"},
{"Dimi","Christop",
"Dimi", "Christopoulos"},
{"Jorge","Ciges",
"Jorge", "Izquierdo Ciges"},
{"Jorge","Izquierdo",
"Jorge", "Izquierdo Ciges"},
"Jorge", "Izquierdo"},
{"Rafa","Gata",
"Rafa", "Gaitan"},
{"Sukender","I",
"Sukender", ""},
{"Sukender","Here",
"Sukender", ""},
{"Sukender","Fix",
"Sukender", ""},
{"Ewe","Woessner",
"Uwe", "Woessner"},
{"Martin","von",
@@ -531,8 +478,6 @@ NameCorrection nameCorrections[] =
"Thomas", "Hogarth"},
{"Marin", "Lavery",
"Martin", "Lavery"},
{"Michael", "Bach",
"Michael", "Bach Jensen"},
{"Nguyen", "Van",
"Nguyen", "Van Truong"},
{"Thom", "Carlo",
@@ -589,8 +534,6 @@ NameCorrection nameCorrections[] =
"Melchior", "Franz"},
{"Glen", "Waldon",
"Glenn", "Waldron"},
{"Glen", "Waldron",
"Glenn", "Waldron"},
{"Ralf", "Karn",
"Ralf", "Kern"},
{"Donny", "Cipperly",
@@ -623,12 +566,8 @@ NameCorrection nameCorrections[] =
"Romano", "Jos<EFBFBD> Magacho da Silva"},
{"Rommano", "Silva",
"Romano", "Jos<EFBFBD> Magacho da Silva"},
{"Romano", "Magacho",
"Romano", "Jos<EFBFBD> Magacho da Silva"},
{"Leandro", "Motta",
"Leandro", "Motta Barros"},
{"Leandro", "Motto",
"Leandro", "Motta Barros"},
{"A", "Botorabi",
"Ali", "Botorabi"},
{"Waltice", "",
@@ -645,24 +584,10 @@ NameCorrection nameCorrections[] =
"Luc", "Frauciel"},
{"Alberto", "Lucas",
"Alberto", "Luaces"},
{"Alberto", "Luacus",
"Alberto", "Luaces"},
{"Tyge", "",
"Tyge", "L<EFBFBD>vset"},
{"Ricard", "Schmidt",
"Richard", "Schmidt"},
{"Matthias", "Helsing",
"Mattias", "Helsing"},
{"Clement", "Boesch",
"Cl<EFBFBD>ment", "B<EFBFBD>sch"},
{"Lauren", "Voerman",
"Laurens", "Voerman"},
{"Pjotr", "Sventachov",
"Pjotr", "Svetachov"},
{"Bradley", "Baker",
"Bradley", "Baker Searles"},
{"PawelKsiezopolski", "",
"Pawel", "Ksiezopolski"}
"Richard", "Schmidt"}
};
@@ -994,9 +919,7 @@ void printContributors(const std::string& changeLog, bool printNumEntries)
cout << "-------------------------" << endl;
for (SortedNameMap::reverse_iterator sitr = sortedNames.rbegin(); sitr != sortedNames.rend(); ++sitr)
{
cout << sitr->first << "\t" << sitr->second.first;
if (!sitr->second.second.empty()) cout << " " << sitr->second.second;
cout << endl;
cout << sitr->first << "\t" << sitr->second.first << " " << sitr->second.second << endl;
}
}
else
@@ -1005,9 +928,7 @@ void printContributors(const std::string& changeLog, bool printNumEntries)
cout << "-----------------" << endl;
for (SortedNameMap::reverse_iterator sitr = sortedNames.rbegin(); sitr != sortedNames.rend(); ++sitr)
{
cout << sitr->second.first;
if (!sitr->second.second.empty()) cout << " " << sitr->second.second;
cout << endl;
cout << sitr->second.first << " " << sitr->second.second << endl;
}
}
}

View File

@@ -28,116 +28,7 @@
#include <osgGA/TerrainManipulator>
#include <osgGA/SphericalManipulator>
#include <osgGA/Device>
#include <iostream>
#include <stdint.h>
#include <osg/GLExtensions>
#ifndef GL_ARB_sync
#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
#define GL_OBJECT_TYPE 0x9112
#define GL_SYNC_CONDITION 0x9113
#define GL_SYNC_STATUS 0x9114
#define GL_SYNC_FLAGS 0x9115
#define GL_SYNC_FENCE 0x9116
#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
#define GL_UNSIGNALED 0x9118
#define GL_SIGNALED 0x9119
#define GL_ALREADY_SIGNALED 0x911A
#define GL_TIMEOUT_EXPIRED 0x911B
#define GL_CONDITION_SATISFIED 0x911C
#define GL_WAIT_FAILED 0x911D
#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
#endif
class MySwapBuffersCallback : public osg::GraphicsContext::SwapCallback
{
public:
MySwapBuffersCallback():
_extensionInitialized(false),
_glFenceSync(0),
_glIsSync(0),
_glDeleteSync(0),
_glClientWaitSync(0),
_glWaitSync(0),
_glGetInteger64v(0),
_glGetSynciv(0),
_previousSync(0)
{
OSG_NOTICE<<"Created Swap callback."<<std::endl;
}
void setUpExtensions()
{
_extensionInitialized = true;
osg::setGLExtensionFuncPtr(_glFenceSync, "glFenceSync");
osg::setGLExtensionFuncPtr(_glIsSync, "glIsSync");
osg::setGLExtensionFuncPtr(_glDeleteSync, "glDeleteSync");
osg::setGLExtensionFuncPtr(_glClientWaitSync, "glClientWaitSync");
osg::setGLExtensionFuncPtr(_glWaitSync, "glWaitSync");
osg::setGLExtensionFuncPtr(_glGetInteger64v, "glGetInteger64v");
osg::setGLExtensionFuncPtr(_glGetSynciv, "glGetSynciv");
}
virtual void swapBuffersImplementation(osg::GraphicsContext* gc)
{
// OSG_NOTICE<<"Before swap - place to do swap ready sync"<<std::endl;
gc->swapBuffersImplementation();
//glFinish();
if (!_extensionInitialized) setUpExtensions();
if (_glClientWaitSync)
{
if (_previousSync)
{
unsigned int num_seconds = 1;
GLuint64 timeout = num_seconds * ((GLuint64)1000 * 1000 * 1000);
_glClientWaitSync(_previousSync, 0, timeout);
_glDeleteSync(_previousSync);
}
_previousSync = _glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
//gc->getState()->checkGLErrors("after glWaitSync");
//OSG_NOTICE<<"After swap"<<std::endl;
}
#ifdef _WIN32
typedef __int64 GLint64;
typedef unsigned __int64 GLuint64;
#else
typedef int64_t GLint64;
typedef uint64_t GLuint64;
#endif
typedef struct __GLsync *GLsync;
typedef GLsync (GL_APIENTRY * PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags);
typedef GLboolean (GL_APIENTRY * PFNGLISSYNCPROC) (GLsync sync);
typedef void (GL_APIENTRY * PFNGLDELETESYNCPROC) (GLsync sync);
typedef GLenum (GL_APIENTRY * PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
typedef void (GL_APIENTRY * PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
typedef void (GL_APIENTRY * PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params);
typedef void (GL_APIENTRY * PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
bool _extensionInitialized;
PFNGLFENCESYNCPROC _glFenceSync;
PFNGLISSYNCPROC _glIsSync;
PFNGLDELETESYNCPROC _glDeleteSync;
PFNGLCLIENTWAITSYNCPROC _glClientWaitSync;
PFNGLWAITSYNCPROC _glWaitSync;
PFNGLGETINTEGER64VPROC _glGetInteger64v;
PFNGLGETSYNCIVPROC _glGetSynciv;
GLsync _previousSync;
};
int main(int argc, char** argv)
{
@@ -150,9 +41,6 @@ int main(int argc, char** argv)
arguments.getApplicationUsage()->addCommandLineOption("--image <filename>","Load an image and render it on a quad");
arguments.getApplicationUsage()->addCommandLineOption("--dem <filename>","Load an image/DEM and render it on a HeightField");
arguments.getApplicationUsage()->addCommandLineOption("--login <url> <username> <password>","Provide authentication information for http file access.");
arguments.getApplicationUsage()->addCommandLineOption("-p <filename>","Play specified camera path animation file, previously saved with 'z' key.");
arguments.getApplicationUsage()->addCommandLineOption("--speed <factor>","Speed factor for animation playing (1 == normal speed).");
arguments.getApplicationUsage()->addCommandLineOption("--device <device-name>","add named device to the viewer");
osgViewer::Viewer viewer(arguments);
@@ -189,16 +77,6 @@ int main(int argc, char** argv)
}
}
std::string device;
while(arguments.read("--device", device))
{
osg::ref_ptr<osgGA::Device> dev = osgDB::readFile<osgGA::Device>(device);
if (dev.valid())
{
viewer.addDevice(dev.get());
}
}
// set up the camera manipulators.
{
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
@@ -232,8 +110,6 @@ int main(int argc, char** argv)
viewer.setCameraManipulator( keyswitchManipulator.get() );
}
bool doArbSync = arguments.read("--sync");
// add the state manipulator
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
@@ -285,18 +161,6 @@ int main(int argc, char** argv)
viewer.realize();
if (doArbSync)
{
osgViewer::ViewerBase::Contexts contexts;
viewer.getContexts(contexts);
for(osgViewer::ViewerBase::Contexts::iterator itr = contexts.begin();
itr != contexts.end();
++itr)
{
(*itr)->setSwapCallback(new MySwapBuffersCallback);
}
}
return viewer.run();
}

View File

@@ -1,12 +1,12 @@
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
*
* This software is open source and may be redistributed and/or modified under
* This software is open source and may be redistributed and/or modified under
* the terms of the GNU General Public License (GPL) version 2.0.
* The full license is in LICENSE.txt file included with this distribution,.
*
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* include LICENSE.txt for more details.
*/
@@ -33,15 +33,15 @@
#if defined(__linux)
#include <unistd.h>
#include <linux/sockios.h>
#elif defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__FreeBSD__)
#include <unistd.h>
#include <sys/sockio.h>
#elif defined(__sgi)
#include <unistd.h>
#include <net/soioctl.h>
#elif defined(__CYGWIN__)
#elif defined(__CYGWIN__)
#include <unistd.h>
#elif defined(__sun)
#elif defined(__sun)
#include <unistd.h>
#include <sys/sockio.h>
#elif defined (__APPLE__)
@@ -240,7 +240,7 @@ void CameraPacket::readEventQueue(osgViewer::Viewer& viewer)
void CameraPacket::writeEventQueue(osgViewer::Viewer& viewer)
{
osg::notify(osg::INFO)<<"received events = "<<_events.size()<<std::endl;
osg::notify(osg::INFO)<<"recieved events = "<<_events.size()<<std::endl;
// copy the events to osgProducer style events.
viewer.getEventQueue()->appendEvents(_events);
@@ -249,7 +249,7 @@ void CameraPacket::writeEventQueue(osgViewer::Viewer& viewer)
//////////////////////////////////////////////////////////////////////////////
//
// Reciever
// Reciever
//
Receiver::Receiver( void )
{
@@ -336,9 +336,8 @@ void Receiver::sync( void )
return;
}
#if defined(__linux) || defined(__FreeBSD__) || defined( __APPLE__ ) || \
defined(__DragonFly__)
socklen_t
#if defined(__linux) || defined(__FreeBSD__) || defined( __APPLE__ )
socklen_t
#else
int
#endif
@@ -381,7 +380,7 @@ void Receiver::sync( void )
//////////////////////////////////////////////////////////////////////////////
//
// Broadcaster
// Broadcaster
//
Broadcaster::Broadcaster( void )
{

View File

@@ -1,12 +1,12 @@
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
*
* This software is open source and may be redistributed and/or modified under
* This software is open source and may be redistributed and/or modified under
* the terms of the GNU General Public License (GPL) version 2.0.
* The full license is in LICENSE.txt file included with this distribution,.
*
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* include LICENSE.txt for more details.
*/
@@ -29,7 +29,7 @@
//
// Class definition for the recipient of a broadcasted message
//
class Receiver
class Receiver
{
public :
@@ -68,7 +68,7 @@ class Receiver
//
// Class definition for broadcasting a buffer to a LAN
//
class Broadcaster
class Broadcaster
{
public :
@@ -84,7 +84,7 @@ class Broadcaster
// Set a recipient host. If this is used, the Broadcaster
// no longer broadcasts, but rather directs UDP packets at
// host.
void setHost( const char *hostname );
void setHost( const char *hostname );
// Sync broadcasts the buffer
void sync( void );
@@ -112,15 +112,15 @@ class Broadcaster
class CameraPacket {
public:
static const unsigned int MAX_NUM_EVENTS;
static const unsigned int SWAP_BYTES_COMPARE;
CameraPacket():_masterKilled(false)
CameraPacket():_masterKilled(false)
{
_byte_order = SWAP_BYTES_COMPARE;
}
void setPacket(const osg::Matrix& matrix,const osg::FrameStamp* frameStamp)
{
_matrix = matrix;
@@ -129,20 +129,20 @@ class CameraPacket {
_frameStamp = *frameStamp;
}
}
void getModelView(osg::Matrix& matrix,float angle_offset=0.0f)
{
matrix = _matrix * osg::Matrix::rotate(osg::DegreesToRadians(angle_offset),0.0f,1.0f,0.0f);
}
void readEventQueue(osgViewer::Viewer& viewer);
void writeEventQueue(osgViewer::Viewer& viewer);
void setMasterKilled(const bool flag) { _masterKilled = flag; }
const bool getMasterKilled() const { return _masterKilled; }
unsigned int _byte_order;
bool _masterKilled;
osg::Matrix _matrix;
@@ -150,11 +150,11 @@ class CameraPacket {
// note don't use a ref_ptr as used elsewhere for FrameStamp
// since we don't want to copy the pointer - but the memory.
// FrameStamp doesn't have a private destructor to allow
// us to do this, even though its a reference counted object.
// us to do this, even though its a reference counted object.
osg::FrameStamp _frameStamp;
osgGA::EventQueue::Events _events;
};
class DataConverter
@@ -186,22 +186,22 @@ class DataConverter
{
if (_currentPtr+1>=_endPtr) return;
*(_currentPtr++) = *(ptr);
*(_currentPtr++) = *(ptr);
}
inline void read1(char* ptr)
{
if (_currentPtr+1>=_endPtr) return;
*(ptr) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
inline void write2(char* ptr)
{
if (_currentPtr+2>=_endPtr) return;
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
}
inline void read2(char* ptr)
@@ -210,13 +210,13 @@ class DataConverter
if (_swapBytes)
{
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
else
{
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
}
@@ -224,10 +224,10 @@ class DataConverter
{
if (_currentPtr+4>=_endPtr) return;
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
}
inline void read4(char* ptr)
@@ -236,17 +236,17 @@ class DataConverter
if (_swapBytes)
{
*(ptr+3) = *(_currentPtr++);
*(ptr+2) = *(_currentPtr++);
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr+3) = *(_currentPtr++);
*(ptr+2) = *(_currentPtr++);
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
else
{
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
}
@@ -254,15 +254,15 @@ class DataConverter
{
if (_currentPtr+8>=_endPtr) return;
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
}
inline void read8(char* ptr)
@@ -272,27 +272,27 @@ class DataConverter
if (_swapBytes)
{
*(ptr+7) = *(_currentPtr++);
*(ptr+6) = *(_currentPtr++);
*(ptr+5) = *(_currentPtr++);
*(ptr+4) = *(_currentPtr++);
*(ptr+7) = *(_currentPtr++);
*(ptr+6) = *(_currentPtr++);
*(ptr+5) = *(_currentPtr++);
*(ptr+4) = *(_currentPtr++);
*(ptr+3) = *(_currentPtr++);
*(ptr+2) = *(_currentPtr++);
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr+3) = *(_currentPtr++);
*(ptr+2) = *(_currentPtr++);
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
else
{
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
}
@@ -305,14 +305,14 @@ class DataConverter
inline void writeFloat(float c) { write4((char*)&c); }
inline void writeDouble(double c) { write8((char*)&c); }
inline char readChar() { char c=0; read1(&c); return c; }
inline unsigned char readUChar() { unsigned char c=0; read1((char*)&c); return c; }
inline short readShort() { short c=0; read2((char*)&c); return c; }
inline unsigned short readUShort() { unsigned short c=0; read2((char*)&c); return c; }
inline int readInt() { int c=0; read4((char*)&c); return c; }
inline unsigned int readUInt() { unsigned int c=0; read4((char*)&c); return c; }
inline float readFloat() { float c=0.0f; read4((char*)&c); return c; }
inline double readDouble() { double c=0.0; read8((char*)&c); return c; }
inline char readChar() { char c; read1(&c); return c; }
inline unsigned char readUChar() { unsigned char c; read1((char*)&c); return c; }
inline short readShort() { short c; read2((char*)&c); return c; }
inline unsigned short readUShort() { unsigned short c; read2((char*)&c); return c; }
inline int readInt() { int c; read4((char*)&c); return c; }
inline unsigned int readUInt() { unsigned int c; read4((char*)&c); return c; }
inline float readFloat() { float c; read4((char*)&c); return c; }
inline double readDouble() { double c; read8((char*)&c); return c; }
void write(const osg::FrameStamp& fs);
void read(osg::FrameStamp& fs);
@@ -322,13 +322,13 @@ class DataConverter
void write(const osgGA::GUIEventAdapter& event);
void read(osgGA::GUIEventAdapter& event);
void write(CameraPacket& cameraPacket);
void read(CameraPacket& cameraPacket);
char* startPtr() { return _startPtr; }
unsigned int numBytes() { return _numBytes; }
protected:
char* _startPtr;
@@ -341,4 +341,4 @@ class DataConverter
#endif
#endif

View File

@@ -251,12 +251,8 @@ osg::ref_ptr<osg::Node> p3d::readShowFiles(osg::ArgumentParser& arguments,const
if(node)
{
if (node->getName().empty()) node->setName( arguments[pos] );
nodeList.push_back(node);
// make sure that this presentation isn't cached
osgDB::Registry::instance()->removeFromObjectCache( arguments[pos] );
}
}
}

View File

@@ -1,12 +1,12 @@
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
*
* This software is open source and may be redistributed and/or modified under
* This software is open source and may be redistributed and/or modified under
* the terms of the GNU General Public License (GPL) version 2.0.
* The full license is in LICENSE.txt file included with this distribution,.
*
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* include LICENSE.txt for more details.
*/
@@ -28,7 +28,6 @@
#include <OpenThreads/Thread>
#include <osgGA/GUIEventHandler>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
@@ -128,64 +127,89 @@ void setViewer(osgViewer::Viewer& viewer, float width, float height, float dista
// double hfov = osg::RadiansToDegrees(atan2(width/2.0f,distance)*2.0);
viewer.getCamera()->setProjectionMatrixAsPerspective( vfov, width/height, 0.1, 1000.0);
OSG_NOTICE<<"setProjectionMatrixAsPerspective( "<<vfov<<", "<<width/height<<", "<<0.1<<", "<<1000.0<<");"<<std::endl;
}
class ForwardToDeviceEventHandler : public osgGA::GUIEventHandler {
public:
ForwardToDeviceEventHandler(osgGA::Device* device) : osgGA::GUIEventHandler(), _device(device) {}
#if 1
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *)
class RayFollowsMouseCallback : public osg::Drawable::EventCallback
{
RayFollowsMouseCallback() {}
/** do customized Event code. */
virtual void event(osg::NodeVisitor* nv, osg::Drawable* drawable)
{
OSG_INFO<<"ForwardToDeviceEventHandler::setEvent("<<ea.getKey()<<")"<<std::endl;
_device->sendEvent(ea);
return false;
osg::Geometry* geometry = drawable->asGeometry();
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
if (!ev || !geometry) return;
osgGA::GUIActionAdapter* aa = ev->getActionAdapter();
osgViewer::View* view = dynamic_cast<osgViewer::View*>(aa);
if (!view) return;
osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geometry->getVertexArray());
if (!vertices) return;
osg::Camera* camera = view->getCamera();
osg::Matrix VP = camera->getViewMatrix() * camera->getProjectionMatrix();
osg::Matrix inverse_VP;
inverse_VP.invert(VP);
osgGA::EventQueue::Events& events = ev->getEvents();
for(osgGA::EventQueue::Events::iterator itr = events.begin();
itr != events.end();
++itr)
{
handle(inverse_VP, *(*itr), vertices);
}
}
private:
osg::ref_ptr<osgGA::Device> _device;
};
void handle(const osg::Matrix& inverse_VP, osgGA::GUIEventAdapter& ea, osg::Vec3Array* vertices)
{
osg::Vec3d start_eye(ea.getXnormalized(), ea.getYnormalized(), 0.0);
osg::Vec3d end_eye(ea.getXnormalized(), ea.getYnormalized(), 1.0);
osg::Vec3d start_world = start_eye * inverse_VP;
osg::Vec3d end_world = start_eye * inverse_VP;
osg::notify(osg::NOTICE)<<"start_world="<<start_world<<std::endl;
osg::notify(osg::NOTICE)<<"end_world="<<end_world<<std::endl;
(*vertices)[0] = start_world;
(*vertices)[1] = end_world;
}
};
class FollowMouseCallback: public osgGA::GUIEventHandler
{
public:
FollowMouseCallback():
_mousePostition(0.5,0.5) {}
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv)
{
osg::AutoTransform* transform = dynamic_cast<osg::AutoTransform*>(object);
if (!transform) return false;
osg::NotifySeverity level = osg::INFO;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::PUSH):
case(osgGA::GUIEventAdapter::RELEASE):
case(osgGA::GUIEventAdapter::MOVE):
case(osgGA::GUIEventAdapter::DRAG):
osg::notify(level)<<std::endl<<"ea.getGraphicsContext()="<<ea.getGraphicsContext()<<std::endl;
osg::notify(level)<<"ea.getWindowWidth()="<<ea.getWindowWidth()<<std::endl;
osg::notify(level)<<"ea.getWindowHeight()="<<ea.getWindowHeight()<<std::endl;
osg::notify(level)<<"ea.getX()="<<ea.getX()<<std::endl;
osg::notify(level)<<"ea.getXin()="<<ea.getXmin()<<std::endl;
osg::notify(level)<<"ea.getXmax()="<<ea.getXmax()<<std::endl;
osg::notify(level)<<"ea.getY()="<<ea.getY()<<std::endl;
osg::notify(level)<<"ea.getYin()="<<ea.getYmin()<<std::endl;
osg::notify(level)<<"ea.getYmax()="<<ea.getYmax()<<std::endl;
_mousePostition.set(ea.getXnormalized(), ea.getYnormalized());
break;
case(osgGA::GUIEventAdapter::FRAME):
//case(osgGA::GUIEventAdapter::MOVE):
//case(osgGA::GUIEventAdapter::DRAG):
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
transform->setNodeMask(0x0);
osg::notify(osg::NOTICE)<<std::endl<<"ea.getGraphicsContext()="<<ea.getGraphicsContext()<<std::endl;
osg::notify(osg::NOTICE)<<"ea.getWindowWidth()="<<ea.getWindowWidth()<<std::endl;
osg::notify(osg::NOTICE)<<"ea.getWindowHeight()="<<ea.getWindowHeight()<<std::endl;
osg::notify(osg::NOTICE)<<"ea.getX()="<<ea.getX()<<std::endl;
osg::notify(osg::NOTICE)<<"ea.getXin()="<<ea.getXmin()<<std::endl;
osg::notify(osg::NOTICE)<<"ea.getXmax()="<<ea.getXmax()<<std::endl;
osg::notify(osg::NOTICE)<<"ea.getY()="<<ea.getY()<<std::endl;
osg::notify(osg::NOTICE)<<"ea.getYin()="<<ea.getYmin()<<std::endl;
osg::notify(osg::NOTICE)<<"ea.getYmax()="<<ea.getYmax()<<std::endl;
osg::Camera* camera = view->getCamera();
osg::Matrix VP = camera->getViewMatrix() * camera->getProjectionMatrix();
@@ -193,20 +217,18 @@ class FollowMouseCallback: public osgGA::GUIEventHandler
osg::Matrix inverse_VP;
inverse_VP.invert(VP);
osg::Vec3d start_eye(_mousePostition.x(), _mousePostition.y(), 0.0);
osg::Vec3d end_eye(_mousePostition.x(), _mousePostition.y(), 1.0);
osg::Vec3d start_eye(ea.getXnormalized(), ea.getYnormalized(), 0.0);
osg::Vec3d end_eye(ea.getXnormalized(), ea.getYnormalized(), 1.0);
osg::Vec3d start_world = start_eye * inverse_VP;
osg::Vec3d end_world = start_eye * inverse_VP;
osg::notify(level)<<"start_world="<<start_world<<std::endl;
osg::notify(level)<<"end_world="<<end_world<<std::endl;
osg::notify(osg::NOTICE)<<"start_world="<<start_world<<std::endl;
osg::notify(osg::NOTICE)<<"end_world="<<end_world<<std::endl;
if (end_world.valid()) transform->setPosition(end_world);
else
{
OSG_NOTICE<<"Ignoring invalid end_world position"<<std::endl;
}
transform->setPosition(end_world);
transform->setNodeMask(0xffffffff);
break;
}
@@ -236,7 +258,6 @@ class FollowMouseCallback: public osgGA::GUIEventHandler
v.visit(*this);
}
osg::Vec2d _mousePostition;
};
osg::Node* createCursorSubgraph(const std::string& filename, float size)
@@ -246,14 +267,13 @@ osg::Node* createCursorSubgraph(const std::string& filename, float size)
size = 20.0f;
osg::Geometry* geom = osg::createTexturedQuadGeometry(osg::Vec3(-size*0.5f,-size*0.5f,0.0f),osg::Vec3(size,0.0f,0.0f),osg::Vec3(0.0f,size,0.0f));
geom->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
osg::Image* image = osgDB::readImageFile(osgDB::findDataFile(filename));
if (image)
{
osg::StateSet* stateset = geom->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, new osg::Texture2D(image),osg::StateAttribute::ON|osg::StateAttribute::PROTECTED);
stateset->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::PROTECTED);
stateset->setTextureAttributeAndModes(0, new osg::Texture2D(image),osg::StateAttribute::ON);
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
// stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
stateset->setRenderBinDetails(1000, "DepthSortedBin");
}
@@ -271,6 +291,101 @@ osg::Node* createCursorSubgraph(const std::string& filename, float size)
return transform;
}
#else
class FollowMouseCallback: public osgGA::GUIEventHandler
{
public:
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&, osg::Object* object, osg::NodeVisitor*)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::MOVE):
case(osgGA::GUIEventAdapter::DRAG):
{
osg::Camera* camera = dynamic_cast<osg::Camera*>(object);
if (camera)
{
double x = ea.getXnormalized();
double y = ea.getYnormalized();
camera->setViewMatrix(osg::Matrixd::translate(x,y,0.0));
}
break;
}
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='c')
{
osg::Camera* camera = dynamic_cast<osg::Camera*>(object);
if (camera)
{
for(unsigned int i=0; i< camera->getNumChildren(); ++i)
{
osg::Node* node = camera->getChild(i);
node->setNodeMask(
node->getNodeMask()!=0 ?
0 :
0xffffff);
}
}
}
break;
}
default:
break;
}
return false;
}
virtual void accept(osgGA::GUIEventHandlerVisitor& v)
{
v.visit(*this);
}
};
osg::Node* createCursorSubgraph(const std::string& filename, float size)
{
osg::Geode* geode = new osg::Geode;
osg::Geometry* geom = osg::createTexturedQuadGeometry(osg::Vec3(-size*0.5f,-size*0.5f,0.0f),osg::Vec3(size,0.0f,0.0f),osg::Vec3(0.0f,size,0.0f));
osg::Image* image = osgDB::readImageFile(osgDB::findDataFile(filename));
if (image)
{
osg::StateSet* stateset = geom->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, new osg::Texture2D(image),osg::StateAttribute::ON);
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
stateset->setRenderBinDetails(1000, "DepthSortedBin");
}
geode->addDrawable(geom);
osg::Camera* camera = new osg::Camera;
// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(-1,1,-1,1));
// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());
// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
// draw subgraph after main camera view.
camera->setRenderOrder(osg::CameraNode::NESTED_RENDER);
camera->addChild(geode);
camera->setEventCallback(new FollowMouseCallback());
return camera;
}
#endif
enum P3DApplicationType
@@ -281,53 +396,12 @@ enum P3DApplicationType
};
void processLoadedModel(osg::ref_ptr<osg::Node>& loadedModel, int optimizer_options, const std::string& cursorFileName)
{
if (!loadedModel) return;
#if !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
// add back in enabling of the GL_ALPHA_TEST to get around the core OSG no longer setting it by default for opaque bins.
// the alpha test is required for the volume rendering alpha clipping to work.
loadedModel->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
#endif
// optimize the scene graph, remove rendundent nodes and state etc.
osgUtil::Optimizer optimizer;
optimizer.optimize(loadedModel.get(), optimizer_options);
if (!cursorFileName.empty())
{
osg::ref_ptr<osg::Group> group = new osg::Group;
group->addChild(loadedModel.get());
group->addChild(createCursorSubgraph(cursorFileName, 0.05f));
loadedModel = group;
}
}
void addDeviceTo(osgViewer::Viewer& viewer, const std::string& device_name)
{
osg::ref_ptr<osgGA::Device> dev = osgDB::readFile<osgGA::Device>(device_name);
if (dev.valid())
{
OSG_INFO << "Adding Device : " << device_name << std::endl;
viewer.addDevice(dev.get());
if (dev->getCapabilities() & osgGA::Device::SEND_EVENTS)
viewer.getEventHandlers().push_front(new ForwardToDeviceEventHandler(dev.get()));
}
else
{
OSG_WARN << "could not open device: " << device_name << std::endl;
}
}
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the application for presenting 3D interactive slide shows.");
@@ -368,28 +442,13 @@ int main( int argc, char **argv )
osg::DisplaySettings::instance()->readEnvironmentalVariables();
}
// set up any logins required for http access
std::string url, username, password;
while(arguments.read("--login",url, username, password))
{
if (!osgDB::Registry::instance()->getAuthenticationMap())
{
osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
url,
new osgDB::AuthenticationDetails(username, password)
);
}
}
#ifdef USE_SDL
SDLIntegration sdlIntegration;
osg::notify(osg::INFO)<<"USE_SDL"<<std::endl;
#endif
#endif
bool doSetViewer = true;
std::string configurationFile;
@@ -402,7 +461,7 @@ int main( int argc, char **argv )
while (arguments.read("-c",configurationFile)) {}
osg::Vec4 clearColor(0.0f,0.0f,0.0f,0.0f);
while (arguments.read("--clear-color",clearColor[0],clearColor[1],clearColor[2],clearColor[3])) {}
std::string filename;
@@ -441,7 +500,7 @@ int main( int argc, char **argv )
// construct the viewer.
osgViewer::Viewer viewer(arguments);
// set clear colour to black by default.
viewer.getCamera()->setClearColor(clearColor);
@@ -450,60 +509,11 @@ int main( int argc, char **argv )
viewer.readConfiguration(configurationFile);
doSetViewer = false;
}
const char* p3dDevice = getenv("P3D_DEVICE");
if (p3dDevice)
{
osgDB::StringList devices;
osgDB::split(p3dDevice, devices);
for(osgDB::StringList::iterator i = devices.begin(); i != devices.end(); ++i)
{
addDeviceTo(viewer, *i);
}
}
std::string device;
while (arguments.read("--device", device))
{
addDeviceTo(viewer, device);
}
if (arguments.read("--http-control"))
{
std::string server_address = "localhost";
std::string server_port = "8080";
std::string document_root = "htdocs";
while (arguments.read("--http-server-address", server_address)) {}
while (arguments.read("--http-server-port", server_port)) {}
while (arguments.read("--http-document-root", document_root)) {}
osg::ref_ptr<osgDB::Options> device_options = new osgDB::Options("documentRegisteredHandlers");
osg::ref_ptr<osgGA::Device> rest_http_device = osgDB::readFile<osgGA::Device>(server_address+":"+server_port+"/"+document_root+".resthttp", device_options.get());
if (rest_http_device.valid())
{
viewer.addDevice(rest_http_device.get());
}
}
// set up stereo masks
viewer.getCamera()->setCullMask(0xffffffff);
viewer.getCamera()->setCullMaskLeft(0x00000001);
viewer.getCamera()->setCullMaskRight(0x00000002);
bool assignLeftCullMaskForMono = true;
if (assignLeftCullMaskForMono)
{
viewer.getCamera()->setCullMask(viewer.getCamera()->getCullMaskLeft());
}
else
{
viewer.getCamera()->setCullMask(0xffffffff);
}
viewer.getCamera()->setCullMaskRight(0x00000002);
// set up the camera manipulators.
{
@@ -519,7 +529,7 @@ int main( int argc, char **argv )
while (arguments.read("-p",pathfile))
{
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
if (apm || !apm->valid())
if (apm || !apm->valid())
{
unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
@@ -532,9 +542,7 @@ int main( int argc, char **argv )
}
// add the state manipulator
osg::ref_ptr<osgGA::StateSetManipulator> ssManipulator = new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet());
ssManipulator->setKeyEventToggleTexturing('e');
viewer.addEventHandler( ssManipulator.get() );
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
// add the state manipulator
viewer.addEventHandler( new osgViewer::StatsHandler() );
@@ -549,20 +557,11 @@ int main( int argc, char **argv )
std::string cursorFileName( p3dCursor ? p3dCursor : "");
while (arguments.read("--cursor",cursorFileName)) {}
const char* p3dShowCursor = getenv("P3D_SHOW_CURSOR");
std::string showCursor( p3dShowCursor ? p3dShowCursor : "YES");
while (arguments.read("--show-cursor")) { showCursor="YES"; }
while (arguments.read("--hide-cursor")) { showCursor="NO"; }
bool hideCursor = (showCursor=="No" || showCursor=="NO" || showCursor=="no");
while (arguments.read("--set-viewer")) { doSetViewer = true; }
while (arguments.read("--no-set-viewer")) { doSetViewer = false; }
// if we want to hide the cursor override the custom cursor.
if (hideCursor) cursorFileName.clear();
// cluster related entries.
int socketNumber=8100;
@@ -590,29 +589,10 @@ int main( int argc, char **argv )
bool loopPresentation = false;
while (arguments.read("--loop")) loopPresentation = true;
{
// set update hte default traversal mode settings for update visitor
// default to osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN.
osg::NodeVisitor::TraversalMode updateTraversalMode = osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN; // viewer.getUpdateVisitor()->getTraversalMode();
const char* p3dUpdateStr = getenv("P3D_UPDATE");
if (p3dUpdateStr)
{
std::string updateStr(p3dUpdateStr);
if (updateStr=="active" || updateStr=="Active" || updateStr=="ACTIVE") updateTraversalMode = osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN;
else if (updateStr=="all" || updateStr=="All" || updateStr=="ALL") updateTraversalMode = osg::NodeVisitor::TRAVERSE_ALL_CHILDREN;
}
while(arguments.read("--update-active")) updateTraversalMode = osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN;
while(arguments.read("--update-all")) updateTraversalMode = osg::NodeVisitor::TRAVERSE_ALL_CHILDREN;
viewer.getUpdateVisitor()->setTraversalMode(updateTraversalMode);
}
// register the slide event handler - which moves the presentation from slide to slide, layer to layer.
osg::ref_ptr<osgPresentation::SlideEventHandler> seh = new osgPresentation::SlideEventHandler(&viewer);
viewer.addEventHandler(seh.get());
osgPresentation::SlideEventHandler* seh = new osgPresentation::SlideEventHandler(&viewer);
viewer.addEventHandler(seh);
seh->setAutoSteppingActive(autoSteppingActive);
seh->setTimeDelayBetweenSlides(timeDelayBetweenSlides);
@@ -630,7 +610,7 @@ int main( int argc, char **argv )
// set up optimizer options
unsigned int optimizer_options = osgUtil::Optimizer::DEFAULT_OPTIMIZATIONS;
bool relase_and_compile = false;
while (arguments.read("--release-and-compile"))
while (arguments.read("--release-and-compile"))
{
relase_and_compile = true;
}
@@ -641,33 +621,22 @@ int main( int argc, char **argv )
viewer.getDatabasePager()->setUnrefImageDataAfterApplyPolicy(true,false);
optimizer_options &= ~osgUtil::Optimizer::OPTIMIZE_TEXTURE_SETTINGS;
}
//
//
// osgDB::Registry::instance()->getOrCreateDatabasePager()->setUnrefImageDataAfterApplyPolicy(true,false);
// optimizer_options &= ~osgUtil::Optimizer::OPTIMIZE_TEXTURE_SETTINGS;
// osg::Texture::getTextureObjectManager()->setExpiryDelay(0.0f);
// osgDB::Registry::instance()->getOrCreateDatabasePager()->setExpiryDelay(1.0f);
// register the handler for modifying the point size
osg::ref_ptr<PointsEventHandler> peh = new PointsEventHandler;
viewer.addEventHandler(peh.get());
// add the screen capture handler
std::string screenCaptureFilename = "screen_shot.jpg";
while(arguments.read("--screenshot", screenCaptureFilename)) {}
osg::ref_ptr<osgViewer::ScreenCaptureHandler::WriteToFile> writeFile = new osgViewer::ScreenCaptureHandler::WriteToFile(
osgDB::getNameLessExtension(screenCaptureFilename),
osgDB::getFileExtension(screenCaptureFilename) );
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler = new osgViewer::ScreenCaptureHandler(writeFile.get());
screenCaptureHandler->setKeyEventTakeScreenShot('m');//osgGA::GUIEventAdapter::KEY_Print);
screenCaptureHandler->setKeyEventToggleContinuousCapture('M');
viewer.addEventHandler(screenCaptureHandler.get());
PointsEventHandler* peh = new PointsEventHandler;
viewer.addEventHandler(peh);
// osg::DisplaySettings::instance()->setSplitStereoAutoAjustAspectRatio(false);
float width = osg::DisplaySettings::instance()->getScreenWidth();
float height = osg::DisplaySettings::instance()->getScreenHeight();
float distance = osg::DisplaySettings::instance()->getScreenDistance();
while (arguments.read("-s", width, height, distance))
while (arguments.read("-s", width, height, distance))
{
osg::DisplaySettings::instance()->setScreenDistance(distance);
osg::DisplaySettings::instance()->setScreenHeight(height);
@@ -697,11 +666,11 @@ int main( int argc, char **argv )
else if (strcmp(str,"master")==0) P3DApplicationType = MASTER;
else if (strcmp(str,"slave")==0) P3DApplicationType = SLAVE;
}
while (arguments.read("--viewer")) { P3DApplicationType = VIEWER; }
while (arguments.read("--master")) { P3DApplicationType = MASTER; }
while (arguments.read("--slave")) { P3DApplicationType = SLAVE; }
while (arguments.read("--version"))
{
std::string appTypeName = "invalid";
@@ -790,7 +759,7 @@ int main( int argc, char **argv )
// if no model has been successfully loaded report failure.
if (!loadedModel)
if (!loadedModel)
{
osg::notify(osg::INFO) << arguments.getApplicationName() <<": No data loaded" << std::endl;
return 1;
@@ -806,12 +775,12 @@ int main( int argc, char **argv )
for(unsigned int i=0; i<loadedModel->getNumDescriptions(); ++i)
{
const std::string& desc = loadedModel->getDescription(i);
if (desc=="loop")
if (desc=="loop")
{
osg::notify(osg::NOTICE)<<"Enabling looping"<<std::endl;
seh->setLoopPresentation(true);
}
else if (desc=="auto")
else if (desc=="auto")
{
osg::notify(osg::NOTICE)<<"Enabling auto run"<<std::endl;
seh->setAutoSteppingActive(true);
@@ -820,7 +789,26 @@ int main( int argc, char **argv )
}
processLoadedModel(loadedModel, optimizer_options, cursorFileName);
#if !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
// add back in enabling of the GL_ALPHA_TEST to get around the core OSG no longer setting it by default for opaque bins.
// the alpha test is required for the volume rendering alpha clipping to work.
loadedModel->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
#endif
// optimize the scene graph, remove rendundent nodes and state etc.
osgUtil::Optimizer optimizer;
optimizer.optimize(loadedModel.get(), optimizer_options);
if (!cursorFileName.empty())
{
osg::ref_ptr<osg::Group> group = new osg::Group;
group->addChild(loadedModel.get());
group->addChild(createCursorSubgraph(cursorFileName, 0.05f));
loadedModel = group.get();
}
// set the scene to render
viewer.setSceneData(loadedModel.get());
@@ -839,23 +827,7 @@ int main( int argc, char **argv )
viewerInitialized = true;
}
// pass the model to the slide event handler so it knows which to manipulate.
seh->set(loadedModel.get());
seh->selectSlide(0);
seh->home();
if (!outputFileName.empty())
{
osgDB::writeNodeFile(*loadedModel,outputFileName);
return 0;
}
if (!cursorFileName.empty() || hideCursor)
if (!cursorFileName.empty())
{
// have to add a frame in here to avoid problems with X11 threading issue on switching off the cursor
// not yet sure why it makes a difference, but it at least fixes the crash that would otherwise occur
@@ -873,9 +845,21 @@ int main( int argc, char **argv )
}
}
// pass the model to the slide event handler so it knows which to manipulate.
seh->set(loadedModel.get());
seh->selectSlide(0);
seh->home();
if (!outputFileName.empty())
{
osgDB::writeNodeFile(*loadedModel,outputFileName);
return 0;
}
osg::Timer_t startOfFrameTick = osg::Timer::instance()->tick();
double targetFrameTime = 1.0/targetFrameRate;
if (exportName.empty())
{
// objects for managing the broadcasting and recieving of camera packets.
@@ -904,7 +888,7 @@ int main( int argc, char **argv )
startOfFrameTick = osg::Timer::instance()->tick();
#if 0
#if 0
if (kmcb)
{
double time = kmcb->getTime();
@@ -920,9 +904,9 @@ int main( int argc, char **argv )
{
// take camera zero as the guide.
osg::Matrix modelview(viewer.getCamera()->getViewMatrix());
cp.setPacket(modelview,viewer.getFrameStamp());
// cp.readEventQueue(viewer);
scratchPad.reset();
@@ -932,7 +916,7 @@ int main( int argc, char **argv )
scratchPad.read(cp);
bc.setBuffer(scratchPad.startPtr(), scratchPad.numBytes());
std::cout << "bc.sync()"<<scratchPad.numBytes()<<std::endl;
bc.sync();
@@ -942,13 +926,13 @@ int main( int argc, char **argv )
rc.setBuffer(scratchPad.startPtr(), scratchPad.numBytes());
rc.sync();
scratchPad.reset();
scratchPad.read(cp);
// cp.writeEventQueue(viewer);
if (cp.getMasterKilled())
if (cp.getMasterKilled())
{
std::cout << "Received master killed."<<std::endl;
// break out of while (!done) loop since we've now want to shut down.
@@ -960,31 +944,6 @@ int main( int argc, char **argv )
// call all node update callbacks and animations.
viewer.eventTraversal();
if (seh->getRequestReload())
{
OSG_INFO<<"Reload requested"<<std::endl;
seh->setRequestReload(false);
int previous_ActiveSlide = seh->getActiveSlide();
int previous_ActiveLayer = seh->getActiveLayer();
// reset time so any event key generate
loadedModel = p3d::readShowFiles(arguments,cacheAllOption.get());
processLoadedModel(loadedModel, optimizer_options, cursorFileName);
if (!loadedModel)
{
return 0;
}
viewer.setSceneData(loadedModel.get());
seh->set(loadedModel.get());
seh->selectSlide(previous_ActiveSlide, previous_ActiveLayer);
continue;
}
// update the scene by traversing it with the the update visitor which will
// call all node update callbacks and animations.
viewer.updateTraversal();
@@ -1004,9 +963,9 @@ int main( int argc, char **argv )
}
else
{
ExportHTML::write(seh.get(), viewer, exportName);
ExportHTML::write(seh, viewer, exportName);
}
return 0;
}

View File

@@ -31,6 +31,7 @@ SHORT_NAMES = YES
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
@@ -75,6 +76,7 @@ GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
@@ -136,6 +138,7 @@ HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER = ${OpenSceneGraph_SOURCE_DIR}/doc/Doxyfiles/custom_Footer.html
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"

View File

@@ -31,6 +31,7 @@ SHORT_NAMES = YES
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
@@ -75,6 +76,7 @@ GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
@@ -149,6 +151,7 @@ HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER = ${OpenSceneGraph_SOURCE_DIR}/doc/Doxyfiles/custom_Footer.html
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"

View File

@@ -128,6 +128,13 @@ JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
# If the DETAILS_AT_TOP tag is set to YES then Doxygen
# will output the detailed description near the top, like JavaDoc.
# If set to NO, the detailed description appears after the member
# documentation.
DETAILS_AT_TOP = NO
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# re-implements.
@@ -564,6 +571,12 @@ HTML_FOOTER =
HTML_STYLESHEET =
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
HTML_ALIGN_MEMBERS = YES
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)

View File

@@ -21,6 +21,7 @@ SHORT_NAMES = YES
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
@@ -65,6 +66,7 @@ GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
@@ -139,6 +141,7 @@ HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER = ${OpenSceneGraph_SOURCE_DIR}/doc/Doxyfiles/custom_Footer.html
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"

View File

@@ -66,6 +66,7 @@ GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
@@ -140,6 +141,7 @@ HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER = "${OpenSceneGraph_SOURCE_DIR}/doc/Doxyfiles/custom_Footer.html"
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
HTML_DYNAMIC_SECTIONS = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"

View File

@@ -66,6 +66,7 @@ GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
@@ -125,6 +126,7 @@ HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER = "${OpenSceneGraph_SOURCE_DIR}/doc/Doxyfiles/custom_Footer.html"
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
HTML_DYNAMIC_SECTIONS = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"

View File

@@ -4,14 +4,14 @@
SET(TARGET_DEFAULT_PREFIX "example_")
SET(TARGET_DEFAULT_LABEL_PREFIX "Examples")
SET(TARGET_COMMON_LIBRARIES
SET(TARGET_COMMON_LIBRARIES
OpenThreads
osg
osgDB
osg
osgDB
osgUtil
osgGA
osgViewer
osgText
osgViewer
osgText
)
IF(ANDROID)
@@ -23,7 +23,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osg2cpp)
ADD_SUBDIRECTORY(osganalysis)
ADD_SUBDIRECTORY(osganimate)
ADD_SUBDIRECTORY(osgatomiccounter)
ADD_SUBDIRECTORY(osgautocapture)
ADD_SUBDIRECTORY(osgautotransform)
ADD_SUBDIRECTORY(osgbillboard)
@@ -46,9 +45,9 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgfont)
ADD_SUBDIRECTORY(osgforest)
ADD_SUBDIRECTORY(osgfxbrowser)
ADD_SUBDIRECTORY(osgframerenderer)
ADD_SUBDIRECTORY(osgoutline)
ADD_SUBDIRECTORY(osggameoflife)
ADD_SUBDIRECTORY(osggeodemo)
ADD_SUBDIRECTORY(osggeometry)
ADD_SUBDIRECTORY(osggeometryshaders)
ADD_SUBDIRECTORY(osghangglide)
@@ -59,7 +58,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgkdtree)
ADD_SUBDIRECTORY(osgkeyboard)
ADD_SUBDIRECTORY(osgkeyboardmouse)
ADD_SUBDIRECTORY(osgkeystone)
ADD_SUBDIRECTORY(osglauncher)
ADD_SUBDIRECTORY(osglight)
ADD_SUBDIRECTORY(osglightpoint)
@@ -69,16 +67,13 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osggraphicscost)
ADD_SUBDIRECTORY(osgmanipulator)
ADD_SUBDIRECTORY(osgmovie)
ADD_SUBDIRECTORY(osgmultiplemovies)
ADD_SUBDIRECTORY(osgmultiplerendertargets)
ADD_SUBDIRECTORY(osgmultitexture)
ADD_SUBDIRECTORY(osgmultitexturecontrol)
ADD_SUBDIRECTORY(osgmultitouch)
ADD_SUBDIRECTORY(osgmultiviewpaging)
ADD_SUBDIRECTORY(osgoccluder)
ADD_SUBDIRECTORY(osgocclusionquery)
ADD_SUBDIRECTORY(osgoit)
ADD_SUBDIRECTORY(osgoscdevice)
ADD_SUBDIRECTORY(osgpackeddepthstencil)
ADD_SUBDIRECTORY(osgpagedlod)
ADD_SUBDIRECTORY(osgparametric)
@@ -106,7 +101,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgshadow)
ADD_SUBDIRECTORY(osgshape)
ADD_SUBDIRECTORY(osgsharedarray)
ADD_SUBDIRECTORY(osgsimpleshaders)
ADD_SUBDIRECTORY(osgsimplifier)
ADD_SUBDIRECTORY(osgsimulation)
ADD_SUBDIRECTORY(osgsidebyside)
@@ -159,9 +153,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgwidgetwindow)
ADD_SUBDIRECTORY(osguserdata)
# GL3/GL4 example
ADD_SUBDIRECTORY(osgsimplegl3)
IF(OSG_CPP_EXCEPTIONS_AVAILABLE)
ADD_SUBDIRECTORY(osgunittests)
ADD_SUBDIRECTORY(osgmemorytest)
@@ -179,8 +170,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgphotoalbum)
ADD_SUBDIRECTORY(osgtessellate)
ADD_SUBDIRECTORY(osgtessellationshaders)
ADD_SUBDIRECTORY(osgcomputeshaders)
ADD_SUBDIRECTORY(osgpdf)
@@ -200,35 +189,34 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgviewerFOX)
ENDIF(FOX_FOUND)
IF (wxWidgets_FOUND AND CMAKE_BUILD_TYPE)
IF (${CMAKE_BUILD_TYPE} STREQUAL "Release")
ADD_SUBDIRECTORY(osgviewerWX)
ENDIF()
ENDIF()
IF (wxWidgets_FOUND)
ADD_SUBDIRECTORY(osgviewerWX)
ENDIF(wxWidgets_FOUND)
IF ( (QT4_FOUND OR Qt5Widgets_FOUND) AND NOT OSG_GLES1_AVAILABLE AND NOT OSG_GLES2_AVAILABLE AND NOT OSG_GL3_AVAILABLE)
IF (QT_FOUND AND NOT OSG_GLES1_AVAILABLE AND NOT OSG_GLES2_AVAILABLE AND NOT OSG_GL3_AVAILABLE)
OPTION(BUILD_QT_EXAMPLES "Enable the build of the examples that depend on Qt" ON)
IF ( QT4_FOUND OR Qt5Widgets_FOUND)
IF (BUILD_QT_EXAMPLES AND QT_QTOPENGL_LIBRARY)
ADD_SUBDIRECTORY(osgviewerQt)
ADD_SUBDIRECTORY(osgqfont)
ENDIF()
IF ( (QT4_FOUND AND QT_QTWEBKIT_FOUND) OR Qt5WebKitWidgets_FOUND )
IF (BUILD_QT_EXAMPLES AND QT4_FOUND AND QT_QTWEBKIT_FOUND)
ADD_SUBDIRECTORY(osgQtWidgets)
ADD_SUBDIRECTORY(osgQtBrowser)
ENDIF()
ENDIF()
IF (FLTK_FOUND AND FLTK_GL_LIBRARY)
IF (FLTK_FOUND)
ADD_SUBDIRECTORY(osgviewerFLTK)
ENDIF()
ENDIF(FLTK_FOUND)
IF (WIN32)
OPTION(BUILD_MFC_EXAMPLE "Enable the build of the MFC Example" OFF)
IF (BUILD_MFC_EXAMPLE)
IF (BUILD_MFC_EXAMPLE)
ADD_SUBDIRECTORY(osgviewerMFC)
ENDIF(BUILD_MFC_EXAMPLE)
@@ -259,7 +247,7 @@ ELSE(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgviewerIPhone)
ENDIF()
# IPHONE_PORT@tom
ENDIF(DYNAMIC_OPENSCENEGRAPH)
ENDIF(ANDROID)

View File

@@ -66,7 +66,7 @@ int main( int argc, char **argv )
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is a utility for converting glsl shader files into char arrays that can be compiled into applications.");
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is a utility for converting between various input and output databases formats.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("--shader <filename>","Shader file to create a .cpp file for.");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters");

View File

@@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_setClearColor(JNIEnv
}
JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv * env, jobject obj, jstring address){
//Import Strings from JNI
const char *nativeAddress = env->GetStringUTFChars(address, JNI_FALSE);
const char *nativeAddress = env->GetStringUTFChars(address, false);
mainApp.loadObject(std::string(nativeAddress));
@@ -84,8 +84,8 @@ JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv *
}
JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv * env, jobject obj, jstring address, jstring name){
//Import Strings from JNI
const char *nativeAddress = env->GetStringUTFChars(address,JNI_FALSE);
const char *nativeName = env->GetStringUTFChars(name, JNI_FALSE);
const char *nativeAddress = env->GetStringUTFChars(address, false);
const char *nativeName = env->GetStringUTFChars(name, false);
mainApp.loadObject(std::string(nativeName),std::string(nativeAddress));

View File

@@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_setClearColor(JNIEnv
}
JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv * env, jobject obj, jstring address){
//Import Strings from JNI
const char *nativeAddress = env->GetStringUTFChars(address, JNI_FALSE);
const char *nativeAddress = env->GetStringUTFChars(address, false);
mainApp.loadObject(std::string(nativeAddress));
@@ -84,8 +84,8 @@ JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv *
}
JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_loadObject(JNIEnv * env, jobject obj, jstring address, jstring name){
//Import Strings from JNI
const char *nativeAddress = env->GetStringUTFChars(address,JNI_FALSE);
const char *nativeName = env->GetStringUTFChars(name, JNI_FALSE);
const char *nativeAddress = env->GetStringUTFChars(address, false);
const char *nativeName = env->GetStringUTFChars(name, false);
mainApp.loadObject(std::string(nativeName),std::string(nativeAddress));

View File

@@ -7,19 +7,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
STRING(REGEX REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ENDIF()
if ( QT4_FOUND )
SET(TARGET_EXTERNAL_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTWEBKIT_LIBRARY})
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTWEBKIT_INCLUDE_DIR} )
endif( QT4_FOUND )
SET(TARGET_EXTERNAL_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTWEBKIT_LIBRARY})
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})
SET(TARGET_ADDED_LIBRARIES osgWidget osgQt)
#### end var setup ###
SET ( EXAMPLE_NAME osgQtBrowser )
SETUP_EXAMPLE(${EXAMPLE_NAME})
IF ( Qt5Widgets_FOUND )
qt5_use_modules( example_${EXAMPLE_NAME} Widgets OpenGL WebKitWidgets )
ENDIF( Qt5Widgets_FOUND )
SETUP_EXAMPLE(osgQtBrowser)

View File

@@ -29,20 +29,14 @@
#include <osgViewer/ViewerEventHandlers>
#include <osgWidget/Browser>
#include <QtGlobal>
#if QT_VERSION >= 0x050000
# include <QtWebKitWidgets>
#else
# include <QtWebKit>
#endif
#include <QWebSettings>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QApplication>
#include <QPainter>
#include <QtEvents>
#include <QtWebKit/QWebSettings>
#include <QtWebKit/QtWebKit>
#include <QtGui/QGraphicsScene>
#include <QtGui/QGraphicsView>
#include <QtGui/QApplication>
#include <QtGui/QPainter>
#include <QtGui/QtEvents>
#include <osgQt/QGraphicsViewAdapter>
#include <osgQt/QWebViewImage>

View File

@@ -7,17 +7,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
STRING(REGEX REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ENDIF()
if ( QT4_FOUND )
SET(TARGET_EXTERNAL_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTWEBKIT_LIBRARY})
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTWEBKIT_INCLUDE_DIR} )
endif( QT4_FOUND )
SET(TARGET_EXTERNAL_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTWEBKIT_LIBRARY})
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})
SET(TARGET_ADDED_LIBRARIES osgWidget osgQt)
#### end var setup ###
SET ( EXAMPLE_NAME osgQtWidgets )
SETUP_EXAMPLE(${EXAMPLE_NAME})
IF ( Qt5Widgets_FOUND )
qt5_use_modules( example_${EXAMPLE_NAME} OpenGL WebKitWidgets )
ENDIF( Qt5Widgets_FOUND )
SETUP_EXAMPLE(osgQtWidgets)

View File

@@ -36,16 +36,17 @@
#include <osgWidget/Browser>
//#include <QWebSettings>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QApplication>
#include <QPainter>
#include <QtEvents>
#include <QDialog>
#include <QVBoxLayout>
#include <QMainWindow>
#include <QtOpenGL>
//#include <QtWebKit/QWebSettings>
//#include <QtWebKit/QtWebKit>
#include <QtGui/QGraphicsScene>
#include <QtGui/QGraphicsView>
#include <QtGui/QApplication>
#include <QtGui/QPainter>
#include <QtGui/QtEvents>
#include <QtGui/QDialog>
#include <QtGui/QVBoxLayout>
#include <QtGui/QMainWindow>
#include <QtOpenGL/QtOpenGL>
#include <osgQt/QGraphicsViewAdapter>
#include <osgQt/QWebViewImage>
@@ -97,11 +98,7 @@ protected:
virtual void mousePressEvent(QMouseEvent* e)
{
bool ok = false;
#if QT_VERSION >= 0x040500
int val = QInputDialog::getInt(this, "Get integer", "Please enter an integer between 0 and pi", 0, 0, 3, 1, &ok);
#else
int val = QInputDialog::getInteger(this, "Get integer", "Please enter an integer between 0 and pi", 0, 0, 3, 1, &ok);
#endif
std::cout << "Ok was " << (ok ? "" : "not") << " pressed, val is " << val << std::endl;
}
};

View File

@@ -134,11 +134,11 @@ public:
if (_imageProcessor.valid())
{
OSG_NOTICE<<"Will be using ImageProcessor to process image "<<image->getFileName()<<std::endl;
OSG_NOTICE<<"Will be using ImageProcessor to proces image "<<image->getFileName()<<std::endl;
}
else
{
OSG_NOTICE<<"No ImageProcessor to process image "<<image->getFileName()<<std::endl;
OSG_NOTICE<<"No ImageProcessor to proces image "<<image->getFileName()<<std::endl;
}
OSG_NOTICE<<" compressImage "<<_compressImages<<std::endl;
OSG_NOTICE<<" generateMipmaps "<<_generateMipmaps<<std::endl;

View File

@@ -38,46 +38,46 @@
osg::AnimationPath* createAnimationPath(const osg::Vec3& center,float radius,double looptime)
{
// set up the animation path
// set up the animation path
osg::AnimationPath* animationPath = new osg::AnimationPath;
animationPath->setLoopMode(osg::AnimationPath::LOOP);
int numSamples = 40;
float yaw = 0.0f;
float yaw_delta = 2.0f*osg::PI/((float)numSamples-1.0f);
float roll = osg::inDegrees(30.0f);
double time=0.0f;
double time_delta = looptime/(double)numSamples;
for(int i=0;i<numSamples;++i)
{
osg::Vec3 position(center+osg::Vec3(sinf(yaw)*radius,cosf(yaw)*radius,0.0f));
osg::Quat rotation(osg::Quat(roll,osg::Vec3(0.0,1.0,0.0))*osg::Quat(-(yaw+osg::inDegrees(90.0f)),osg::Vec3(0.0,0.0,1.0)));
animationPath->insert(time,osg::AnimationPath::ControlPoint(position,rotation));
yaw += yaw_delta;
time += time_delta;
}
return animationPath;
return animationPath;
}
osg::Node* createBase(const osg::Vec3& center,float radius)
{
int numTilesX = 10;
int numTilesY = 10;
float width = 2*radius;
float height = 2*radius;
osg::Vec3 v000(center - osg::Vec3(width*0.5f,height*0.5f,0.0f));
osg::Vec3 dx(osg::Vec3(width/((float)numTilesX),0.0,0.0f));
osg::Vec3 dy(osg::Vec3(0.0f,height/((float)numTilesY),0.0f));
// fill in vertices for grid, note numTilesX+1 * numTilesY+1...
osg::Vec3Array* coords = new osg::Vec3Array;
int iy;
@@ -88,45 +88,54 @@ osg::Node* createBase(const osg::Vec3& center,float radius)
coords->push_back(v000+dx*(float)ix+dy*(float)iy);
}
}
//Just two colours - black and white.
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); // white
colors->push_back(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); // black
osg::ref_ptr<osg::DrawElementsUShort> whitePrimitives = new osg::DrawElementsUShort(GL_QUADS);
osg::ref_ptr<osg::DrawElementsUShort> blackPrimitives = new osg::DrawElementsUShort(GL_QUADS);
int numColors=colors->size();
int numIndicesPerRow=numTilesX+1;
osg::UByteArray* coordIndices = new osg::UByteArray; // assumes we are using less than 256 points...
osg::UByteArray* colorIndices = new osg::UByteArray;
for(iy=0;iy<numTilesY;++iy)
{
for(int ix=0;ix<numTilesX;++ix)
{
osg::DrawElementsUShort* primitives = ((iy+ix)%2==0) ? whitePrimitives.get() : blackPrimitives.get();
primitives->push_back(ix +(iy+1)*numIndicesPerRow);
primitives->push_back(ix +iy*numIndicesPerRow);
primitives->push_back((ix+1)+iy*numIndicesPerRow);
primitives->push_back((ix+1)+(iy+1)*numIndicesPerRow);
// four vertices per quad.
coordIndices->push_back(ix +(iy+1)*numIndicesPerRow);
coordIndices->push_back(ix +iy*numIndicesPerRow);
coordIndices->push_back((ix+1)+iy*numIndicesPerRow);
coordIndices->push_back((ix+1)+(iy+1)*numIndicesPerRow);
// one color per quad
colorIndices->push_back((ix+iy)%numColors);
}
}
// set up a single normal
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
osg::Geometry* geom = new osg::Geometry;
geom->setVertexArray(coords);
geom->setColorArray(colors, osg::Array::BIND_PER_PRIMITIVE_SET);
geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
geom->addPrimitiveSet(whitePrimitives.get());
geom->addPrimitiveSet(blackPrimitives.get());
geom->setVertexIndices(coordIndices);
geom->setColorArray(colors);
geom->setColorIndices(colorIndices);
geom->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
geom->setNormalArray(normals);
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,coordIndices->size()));
osg::Geode* geode = new osg::Geode;
geode->addDrawable(geom);
return geode;
}
@@ -149,16 +158,16 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
positioned->setMatrix(osg::Matrix::translate(-bs.center())*
osg::Matrix::scale(size,size,size)*
osg::Matrix::rotate(osg::inDegrees(-90.0f),0.0f,0.0f,1.0f));
positioned->addChild(glider);
osg::PositionAttitudeTransform* xform = new osg::PositionAttitudeTransform;
osg::PositionAttitudeTransform* xform = new osg::PositionAttitudeTransform;
xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0,1.0));
xform->addChild(positioned);
model->addChild(xform);
}
osg::Node* cessna = osgDB::readNodeFile("cessna.osgt");
if (cessna)
{
@@ -170,16 +179,16 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
positioned->setMatrix(osg::Matrix::translate(-bs.center())*
osg::Matrix::scale(size,size,size)*
osg::Matrix::rotate(osg::inDegrees(180.0f),0.0f,0.0f,1.0f));
positioned->addChild(cessna);
osg::MatrixTransform* xform = new osg::MatrixTransform;
xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0f,2.0));
xform->addChild(positioned);
model->addChild(xform);
}
return model;
}
@@ -205,10 +214,10 @@ osg::Node* createModel(bool overlay, osgSim::OverlayNode::OverlayTechnique techn
}
else
{
root->addChild(baseModel);
}
root->addChild(movingModel);
return root;
@@ -217,16 +226,16 @@ osg::Node* createModel(bool overlay, osgSim::OverlayNode::OverlayTechnique techn
int main( int argc, char **argv )
{
bool overlay = false;
osg::ArgumentParser arguments(&argc,argv);
while (arguments.read("--overlay")) overlay = true;
osgSim::OverlayNode::OverlayTechnique technique = osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY;
while (arguments.read("--object")) { technique = osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY; overlay=true; }
while (arguments.read("--ortho") || arguments.read("--orthographic")) { technique = osgSim::OverlayNode::VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY; overlay=true; }
while (arguments.read("--persp") || arguments.read("--perspective")) { technique = osgSim::OverlayNode::VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY; overlay=true; }
// initialize the viewer.
osgViewer::Viewer viewer;
@@ -237,7 +246,7 @@ int main( int argc, char **argv )
{
return 1;
}
// tilt the scene so the default eye position is looking down on the model.
osg::MatrixTransform* rootnode = new osg::MatrixTransform;
rootnode->setMatrix(osg::Matrix::rotate(osg::inDegrees(30.0f),1.0f,0.0f,0.0f));
@@ -246,7 +255,7 @@ int main( int argc, char **argv )
// run optimization over the scene graph
osgUtil::Optimizer optimzer;
optimzer.optimize(rootnode);
// set the scene to render
viewer.setSceneData(rootnode);
@@ -257,17 +266,17 @@ int main( int argc, char **argv )
#if 0
// use of custom simulation time.
viewer.realize();
double simulationTime = 0.0;
while (!viewer.done())
{
viewer.frame(simulationTime);
simulationTime += 0.001;
}
return 0;
#else

View File

@@ -1,14 +1,14 @@
/* -*-c++-*-
/* -*-c++-*-
* Copyright (C) 2010 Jeremy Moles <cubicool@gmail.com>
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -50,7 +50,8 @@ osg::Geometry* createEaseMotionGeometry(osgAnimation::Motion* motion) {
geom->setUseDisplayList(false);
geom->setVertexArray(v);
geom->setColorArray(cols, osg::Array::BIND_OVERALL);
geom->setColorArray(cols);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP, 0, v->size()));
return geom;
@@ -104,11 +105,11 @@ struct ColorLabel: public osgWidget::Label {
setFont("fonts/VeraMono.ttf");
setFontSize(14);
setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
setColor(0.3f, 0.3f, 0.3f, 1.0f);
setPadding(2.0f);
setCanFill(true);
addSize(150.0f, 25.0f);
setLabel(label);
@@ -117,9 +118,9 @@ struct ColorLabel: public osgWidget::Label {
bool mousePush(double, double, const osgWidget::WindowManager*) {
osgWidget::Table* p = dynamic_cast<osgWidget::Table*>(_parent);
if(!p) return false;
p->hide();
const std::string& name = getName();
@@ -231,7 +232,7 @@ struct ColorLabel: public osgWidget::Label {
else if(!name.compare("InOutExpoMotion"))
EASE_MOTION_SAMPLER->setMotion<osgAnimation::InOutExpoMotion>()
;
else EASE_MOTION_SAMPLER->setMotion<osgAnimation::LinearMotion>();
return true;
@@ -239,13 +240,13 @@ struct ColorLabel: public osgWidget::Label {
bool mouseEnter(double, double, const osgWidget::WindowManager*) {
setColor(0.9f, 0.6f, 0.1f, 1.0f);
return true;
}
bool mouseLeave(double, double, const osgWidget::WindowManager*) {
setColor(0.3f, 0.3f, 0.3f, 1.0f);
return true;
}
};
@@ -285,7 +286,7 @@ public:
_window->addWidget(new ColorLabel("OutCircMotion"), 3, 3);
_window->addWidget(new ColorLabel("InCircMotion"), 4, 3);
_window->addWidget(new ColorLabel("InOutCircMotion"), 5, 3);
_window->addWidget(new ColorLabel("OutExpoMotion"), 0, 4);
_window->addWidget(new ColorLabel("InExpoMotion"), 1, 4);
_window->addWidget(new ColorLabel("InOutExpoMotion"), 2, 4);

View File

@@ -115,7 +115,7 @@ struct MyRigTransformHardware : public osgAnimation::RigTransformHardware
{
std::stringstream ss;
ss << "boneWeight" << i;
geom.setVertexAttribArray(attribIndex + i, getVertexAttrib(i));
geom.setVertexAttribData(attribIndex + i, osg::Geometry::ArrayData(getVertexAttrib(i),osg::Geometry::BIND_PER_VERTEX));
}
osg::ref_ptr<osg::StateSet> ss = new osg::StateSet;

View File

@@ -1,14 +1,14 @@
/* -*-c++-*-
/* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net>
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -27,7 +27,7 @@ class AnimtkUpdateCallback : public osg::NodeCallback
public:
META_Object(osgAnimation, AnimtkUpdateCallback);
AnimtkUpdateCallback()
AnimtkUpdateCallback()
{
_sampler = new osgAnimation::Vec3CubicBezierSampler;
_playing = false;
@@ -46,9 +46,9 @@ public:
/** Callback method called by the NodeVisitor when visiting a node.*/
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
if (nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR &&
nv->getFrameStamp() &&
{
if (nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR &&
nv->getFrameStamp() &&
nv->getFrameStamp()->getFrameNumber() != _lastUpdate) {
_lastUpdate = nv->getFrameStamp()->getFrameNumber();
@@ -89,7 +89,7 @@ class AnimtkStateSetUpdateCallback : public osg::StateSet::Callback
public:
META_Object(osgAnimation, AnimtkStateSetUpdateCallback);
AnimtkStateSetUpdateCallback()
AnimtkStateSetUpdateCallback()
{
_sampler = new osgAnimation::Vec4LinearSampler;
_playing = false;
@@ -109,20 +109,20 @@ public:
/** Callback method called by the NodeVisitor when visiting a node.*/
virtual void operator()(osg::StateSet* state, osg::NodeVisitor* nv)
{
if (state &&
nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR &&
nv->getFrameStamp() &&
nv->getFrameStamp()->getFrameNumber() != _lastUpdate)
{
if (state &&
nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR &&
nv->getFrameStamp() &&
nv->getFrameStamp()->getFrameNumber() != _lastUpdate)
{
_lastUpdate = nv->getFrameStamp()->getFrameNumber();
_currentTime = osg::Timer::instance()->tick();
if (_playing && _sampler.get() && _sampler->getKeyframeContainer())
if (_playing && _sampler.get() && _sampler->getKeyframeContainer())
{
osg::Material* material = dynamic_cast<osg::Material*>(state->getAttribute(osg::StateAttribute::MATERIAL));
if (material)
if (material)
{
osg::Vec4 result;
float t = osg::Timer::instance()->delta_s(_startTime, _currentTime);
@@ -149,7 +149,7 @@ public:
osg::Geode* createAxis()
{
osg::Geode* geode = new osg::Geode;
osg::Geode* geode = new osg::Geode;
osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry());
osg::ref_ptr<osg::Vec3Array> vertices (new osg::Vec3Array());
@@ -168,7 +168,9 @@ osg::Geode* createAxis()
colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
geometry->setColorArray (colors.get(), osg::Array::BIND_PER_VERTEX);
geometry->setColorArray (colors.get());
geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
geode->addDrawable( geometry.get() );
@@ -215,7 +217,7 @@ osg::MatrixTransform* setupAnimtkNode()
osgAnimation::Vec3CubicBezierKeyframeContainer* keys = callback->_sampler->getOrCreateKeyframeContainer();
keys->push_back(osgAnimation::Vec3CubicBezierKeyframe(0, osgAnimation::Vec3CubicBezier(
v[0], // pos
v[0] + (v[0] - v[3]), // p1
v[0] + (v[0] - v[3]), // p1
v[1] - (v[1] - v[0]) // p2
)));
keys->push_back(osgAnimation::Vec3CubicBezierKeyframe(2, osgAnimation::Vec3CubicBezier(
@@ -252,7 +254,7 @@ int main (int argc, char* argv[])
osgGA::TrackballManipulator* manipulator = new osgGA::TrackballManipulator();
viewer.setCameraManipulator(manipulator);
osg::Group* root = new osg::Group;
root->setInitialBound(osg::BoundingSphere(osg::Vec3(10,0,10), 30));
root->addChild(createAxis());
@@ -264,7 +266,7 @@ int main (int argc, char* argv[])
viewer.setSceneData( root );
viewer.realize();
while (!viewer.done())
while (!viewer.done())
{
viewer.frame();
}

View File

@@ -1,14 +1,14 @@
/* -*-c++-*-
/* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -34,7 +34,7 @@
osg::Geode* createAxis()
{
osg::Geode* geode (new osg::Geode());
osg::Geode* geode (new osg::Geode());
osg::Geometry* geometry (new osg::Geometry());
osg::Vec3Array* vertices (new osg::Vec3Array());
@@ -53,7 +53,9 @@ osg::Geode* createAxis()
colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
geometry->setColorArray (colors, osg::Array::BIND_PER_VERTEX);
geometry->setColorArray (colors);
geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
geode->addDrawable( geometry );
@@ -68,11 +70,12 @@ osgAnimation::RigGeometry* createTesselatedBox(int nsplit, float size)
osg::ref_ptr<osg::Vec3Array> vertices (new osg::Vec3Array());
osg::ref_ptr<osg::Vec3Array> colors (new osg::Vec3Array());
geometry->setVertexArray (vertices.get());
geometry->setColorArray (colors.get(), osg::Array::BIND_PER_VERTEX);
geometry->setColorArray (colors.get());
geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
float step = size / static_cast<float>(nsplit);
float s = 0.5f/4.0f;
for (int i = 0; i < nsplit; i++)
for (int i = 0; i < nsplit; i++)
{
float x = -1.0f + static_cast<float>(i) * step;
std::cout << x << std::endl;
@@ -89,7 +92,7 @@ osgAnimation::RigGeometry* createTesselatedBox(int nsplit, float size)
}
osg::ref_ptr<osg::UIntArray> array = new osg::UIntArray;
for (int i = 0; i < nsplit - 1; i++)
for (int i = 0; i < nsplit - 1; i++)
{
int base = i * 4;
array->push_back(base);
@@ -120,7 +123,7 @@ osgAnimation::RigGeometry* createTesselatedBox(int nsplit, float size)
array->push_back(base+2);
array->push_back(base+7);
}
geometry->addPrimitiveSet(new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, array->size(), &array->front()));
geometry->setUseDisplayList( false );
riggeometry->setSourceGeometry(geometry);
@@ -141,7 +144,7 @@ void initVertexMap(osgAnimation::Bone* b0,
(*vim)[b1->getName()].setName(b1->getName());
(*vim)[b2->getName()].setName(b2->getName());
for (int i = 0; i < (int)array->size(); i++)
for (int i = 0; i < (int)array->size(); i++)
{
float val = (*array)[i][0];
std::cout << val << std::endl;
@@ -226,7 +229,7 @@ int main (int argc, char* argv[])
}
manager->registerAnimation(anim);
manager->buildTargetReference();
// let's start !
manager->playAnimation(anim);
@@ -244,7 +247,7 @@ int main (int argc, char* argv[])
trueroot->setDataVariance(osg::Object::DYNAMIC);
rootTransform->addChild(trueroot);
scene->addChild(rootTransform);
osgAnimation::RigGeometry* geom = createTesselatedBox(4, 4.0f);
osg::Geode* geode = new osg::Geode;
geode->addDrawable(geom);

View File

@@ -1,14 +1,14 @@
/* -*-c++-*-
/* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -30,7 +30,7 @@ using namespace osgAnimation;
osg::ref_ptr<osg::Geode> createAxis()
{
osg::ref_ptr<osg::Geode> geode (new osg::Geode());
osg::ref_ptr<osg::Geode> geode (new osg::Geode());
osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry());
osg::ref_ptr<osg::Vec3Array> vertices (new osg::Vec3Array());
@@ -49,7 +49,9 @@ osg::ref_ptr<osg::Geode> createAxis()
colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
geometry->setColorArray (colors.get(), osg::Array::BIND_PER_VERTEX);
geometry->setColorArray (colors.get());
geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
geode->addDrawable( geometry.get() );
@@ -112,7 +114,7 @@ int main (int argc, char* argv[])
channelAnimation1->getOrCreateSampler()->getOrCreateKeyframeContainer()->push_back(osgAnimation::Vec3Keyframe(0, osg::Vec3(0,0,0)));
channelAnimation1->getOrCreateSampler()->getOrCreateKeyframeContainer()->push_back(osgAnimation::Vec3Keyframe(2, osg::Vec3(1,1,0)));
osgAnimation::Animation* anim1 = new osgAnimation::Animation;
anim1->addChannel(channelAnimation1);
anim1->addChannel(channelAnimation1);
anim1->setPlayMode(osgAnimation::Animation::PPONG);
@@ -128,12 +130,12 @@ int main (int argc, char* argv[])
osgAnimation::Animation* anim2 = new osgAnimation::Animation;
anim2->addChannel(channelAnimation2);
anim2->setPlayMode(osgAnimation::Animation::LOOP);
// We register all animation inside the scheduler
mng->registerAnimation(anim1);
mng->registerAnimation(anim2);
//start the animation
mng->playAnimation(anim1);
mng->playAnimation(anim2);

View File

@@ -1,14 +1,14 @@
/* -*-c++-*-
/* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net>
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* Authors:
@@ -37,13 +37,13 @@ const int WIDTH = 1440;
const int HEIGHT = 900;
osg::Geode* createAxis()
osg::Geode* createAxis()
{
osg::Geode* geode = new osg::Geode();
osg::Geode* geode = new osg::Geode();
osg::Geometry* geometry = new osg::Geometry();
osg::Vec3Array* vertices = new osg::Vec3Array();
osg::Vec4Array* colors = new osg::Vec4Array();
vertices->push_back(osg::Vec3(0.0f, 0.0f, 0.0f));
vertices->push_back(osg::Vec3(1.0f, 0.0f, 0.0f));
vertices->push_back(osg::Vec3(0.0f, 0.0f, 0.0f));
@@ -57,9 +57,10 @@ osg::Geode* createAxis()
colors->push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f));
colors->push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
colors->push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
geometry->setVertexArray(vertices);
geometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
geometry->setColorArray(colors);
geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES, 0, 6));
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, false);
@@ -99,7 +100,7 @@ struct AddHelperBone : public osg::NodeVisitor
}
};
int main(int argc, char** argv)
int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc, argv);
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
@@ -152,7 +153,7 @@ int main(int argc, char** argv)
AnimtkViewerGUI* gui = new AnimtkViewerGUI(&viewer, WIDTH, HEIGHT, 0x1234);
osg::Camera* camera = gui->createParentOrthoCamera();
node->setNodeMask(0x0001);
group->addChild(node);

View File

@@ -1,4 +0,0 @@
SET(TARGET_SRC osgatomiccounter.cpp)
#### end var setup ###
SETUP_EXAMPLE(osgatomiccounter)

View File

@@ -1,238 +0,0 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 2012-2012 David Callu
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commercial and non commercial applications,
* as long as this copyright notice is maintained.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <osg/BufferIndexBinding>
#include <osg/BufferObject>
#include <osg/Camera>
#include <osg/Program>
#include <osgDB/ReadFile>
#include <osgUtil/Optimizer>
#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 <osgGA/SphericalManipulator>
#include <iostream>
class AdaptNumPixelUniform : public osg::Camera::DrawCallback
{
public:
AdaptNumPixelUniform()
{
_atomicCounterArray = new osg::UIntArray;
_atomicCounterArray->push_back(0);
}
virtual void operator () (osg::RenderInfo& renderInfo) const
{
_acbb->readData(*renderInfo.getState(), *_atomicCounterArray);
unsigned int numPixel = osg::maximum(1u, _atomicCounterArray->front());
if ((renderInfo.getView()->getFrameStamp()->getFrameNumber() % 10) == 0)
{
OSG_INFO << "osgatomiccounter : draw " << numPixel << " pixels." << std::endl;
}
_invNumPixelUniform->set( 1.0f / static_cast<float>(numPixel) );
}
osg::ref_ptr<osg::Uniform> _invNumPixelUniform;
osg::ref_ptr<osg::UIntArray> _atomicCounterArray;
osg::ref_ptr<osg::AtomicCounterBufferBinding> _acbb;
};
osg::Program * createProgram()
{
std::stringstream vp;
vp << "#version 420 compatibility\n"
<< "\n"
<< "void main(void)\n"
<< "{\n"
<< " gl_Position = ftransform();\n"
<< "}\n";
osg::Shader * vpShader = new osg::Shader( osg::Shader::VERTEX, vp.str() );
std::stringstream fp;
fp << "#version 420 compatibility\n"
<< "\n"
<< "layout(binding = 0) uniform atomic_uint acRed;\n"
<< "layout(binding = 0, offset = 4) uniform atomic_uint acGreen;\n"
<< "layout(binding = 2) uniform atomic_uint acBlue;\n"
<< "\n"
<< "uniform float invNumPixel;\n"
<< "\n"
<< "void main(void)\n"
<< "{\n"
<< " float r = float(atomicCounterIncrement(acRed)) * invNumPixel;\n"
<< " float g = float(atomicCounterIncrement(acGreen)) * invNumPixel;\n"
<< " float b = float(atomicCounterIncrement(acBlue)) * invNumPixel;\n"
<< " gl_FragColor = vec4(r, g, b, 1.0);\n"
<< "}\n"
<< "\n";
osg::Shader * fpShader = new osg::Shader( osg::Shader::FRAGMENT, fp.str() );
osg::Program * program = new osg::Program;
program->addShader(vpShader);
program->addShader(fpShader);
return program;
}
class ResetAtomicCounter : public osg::StateAttributeCallback
{
public:
virtual void operator () (osg::StateAttribute* sa, osg::NodeVisitor*)
{
osg::AtomicCounterBufferBinding * acbb = dynamic_cast<osg::AtomicCounterBufferBinding *>(sa);
if (acbb)
{
osg::AtomicCounterBufferObject * acbo = dynamic_cast<osg::AtomicCounterBufferObject*>(acbb->getBufferObject());
if (acbo && acbo->getBufferData(0))
{
acbo->getBufferData(0)->dirty();
}
}
}
};
int main(int argc, char** argv)
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is a simple example which show draw order of pixel.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
osgViewer::Viewer viewer(arguments);
unsigned int helpType = 0;
if ((helpType = arguments.readHelpType()))
{
arguments.getApplicationUsage()->write(std::cout, helpType);
return 1;
}
// report any errors if they have occurred when parsing the program arguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// set up the camera manipulators.
viewer.setCameraManipulator( new osgGA::TrackballManipulator() );
// add the state manipulator
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
// add the thread model handler
viewer.addEventHandler(new osgViewer::ThreadingHandler);
// add the window size toggle handler
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
// add the stats handler
viewer.addEventHandler(new osgViewer::StatsHandler);
// add the help handler
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));
// add the screen capture handler
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
// load the data
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)
{
osg::Geometry * quad = osg::createTexturedQuadGeometry(osg::Vec3f(-2.0f, 0.0f, -2.0f),
osg::Vec3f(2.0f, 0.0f, 0.0f),
osg::Vec3f(0.0f, 0.0f, 2.0f) );
osg::Geode * geode = new osg::Geode;
geode->addDrawable(quad);
loadedModel = geode;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occurred when parsing the program arguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
osg::StateSet * ss = loadedModel->asGeode()->getDrawable(0)->getOrCreateStateSet();
ss->setAttributeAndModes( createProgram(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED );
ss = loadedModel->getOrCreateStateSet();
osg::ref_ptr<osg::UIntArray> atomicCounterArrayRedAndGreen = new osg::UIntArray;
atomicCounterArrayRedAndGreen->push_back(0);
atomicCounterArrayRedAndGreen->push_back(0);
osg::ref_ptr<osg::UIntArray> atomicCounterArrayBlue = new osg::UIntArray;
atomicCounterArrayBlue->push_back(0);
osg::ref_ptr<osg::AtomicCounterBufferObject> acboRedAndGreen = new osg::AtomicCounterBufferObject;
acboRedAndGreen->setUsage(GL_STREAM_COPY);
atomicCounterArrayRedAndGreen->setBufferObject(acboRedAndGreen.get());
osg::ref_ptr<osg::AtomicCounterBufferObject> acboBlue = new osg::AtomicCounterBufferObject;
acboBlue->setUsage(GL_STREAM_COPY);
atomicCounterArrayBlue->setBufferObject(acboBlue.get());
osg::ref_ptr<osg::AtomicCounterBufferBinding> acbbRedAndGreen = new osg::AtomicCounterBufferBinding(0, acboRedAndGreen.get(), 0, sizeof(GLuint)*3);
ss->setAttributeAndModes(acbbRedAndGreen.get());
osg::ref_ptr<osg::AtomicCounterBufferBinding> acbbBlue = new osg::AtomicCounterBufferBinding(2, acboBlue.get(), 0, sizeof(GLuint));
ss->setAttributeAndModes(acbbBlue.get());
acbbRedAndGreen->setUpdateCallback(new ResetAtomicCounter);
acbbBlue->setUpdateCallback(new ResetAtomicCounter);
osg::ref_ptr<osg::Uniform> invNumPixelUniform = new osg::Uniform("invNumPixel", 1.0f/(800.0f*600.0f));
ss->addUniform( invNumPixelUniform.get() );
AdaptNumPixelUniform * drawCallback = new AdaptNumPixelUniform;
drawCallback->_invNumPixelUniform = invNumPixelUniform;
drawCallback->_acbb = acbbBlue;
viewer.getCamera()->setFinalDrawCallback(drawCallback);
// optimize the scene graph, remove redundant nodes and state etc.
osgUtil::Optimizer optimizer;
optimizer.optimize(loadedModel.get());
viewer.setSceneData( loadedModel.get() );
viewer.realize();
return viewer.run();
}

View File

@@ -348,8 +348,6 @@ int main( int argc, char **argv )
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
viewer.setCameraManipulator( keyswitchManipulator.get() );
}

View File

@@ -37,7 +37,7 @@
osg::Node* createLabel(const osg::Vec3& pos, float size, const std::string& label, osgText::Text::AxisAlignment axisAlignment)
{
osg::Geode* geode = new osg::Geode();
std::string timesFont("fonts/arial.ttf");
{
@@ -50,17 +50,17 @@ osg::Node* createLabel(const osg::Vec3& pos, float size, const std::string& labe
text->setAxisAlignment(axisAlignment);
text->setAlignment(osgText::Text::CENTER_CENTER);
text->setText(label);
}
return geode;
return geode;
}
osg::Node* createLabel3(const osg::Vec3& pos, float size, const std::string& label)
{
osg::Geode* geode = new osg::Geode();
std::string timesFont("fonts/arial.ttf");
{
@@ -75,10 +75,10 @@ osg::Node* createLabel3(const osg::Vec3& pos, float size, const std::string& lab
text->setAutoRotateToScreen(true);
text->setCharacterSizeMode(osgText::Text::OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT);
text->setText(label);
}
return geode;
return geode;
}
osg::Node* createAxis(const osg::Vec3& s, const osg::Vec3& e, int numReps, osg::AutoTransform::AutoRotateMode autoRotateMode, osgText::Text::AxisAlignment axisAlignment, const std::string& str)
@@ -113,7 +113,8 @@ osg::Node* createAxis(const osg::Vec3& s, const osg::Vec3& e, int numReps, osg::
osg::Geometry* geom = new osg::Geometry;
geom->setVertexArray(vertices);
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,vertices->size()));
osg::Geode* geode = new osg::Geode;
@@ -139,7 +140,8 @@ osg::Node* createAxis(const osg::Vec3& s, const osg::Vec3& e, int numReps, osg::
osg::Geometry* geom = new osg::Geometry;
geom->setVertexArray(vertices);
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,vertices->size()));
osg::Geode* geode = new osg::Geode;
@@ -147,7 +149,7 @@ osg::Node* createAxis(const osg::Vec3& s, const osg::Vec3& e, int numReps, osg::
group->addChild(geode);
}
return group;
}
@@ -167,25 +169,25 @@ osg::Node* createAutoScale(const osg::Vec3& position, float characterSize, const
osg::AutoTransform* at = new osg::AutoTransform;
at->addChild(geode);
at->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN);
at->setAutoScaleToScreen(true);
at->setMinimumScale(minScale);
at->setMaximumScale(maxScale);
at->setPosition(position);
return at;
}
osg::Node* createScene()
{
osg::Group* root = new osg::Group;
// int numReps = 3333;
int numReps = 10;
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(1000.0,0.0,0.0),numReps,osg::AutoTransform::ROTATE_TO_CAMERA,osgText::Text::XY_PLANE, "ROTATE_TO_CAMERA"));
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,1000.0,0.0),numReps,osg::AutoTransform::ROTATE_TO_SCREEN,osgText::Text::XY_PLANE, "ROTATE_TO_SCREEN"));
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,0.0,1000.0),numReps,osg::AutoTransform::NO_ROTATION,osgText::Text::XZ_PLANE, "NO_ROTATION"));
root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,0.0,1000.0),numReps,osg::AutoTransform::NO_ROTATION,osgText::Text::XZ_PLANE, "NO_ROTATION"));
root->addChild(createAutoScale(osg::Vec3(500.0,500.0,500.0), 25.0, "AutoScale with no min, max limits"));
root->addChild(createAutoScale(osg::Vec3(500.0,500.0,300.0), 25.0, "AutoScale with minScale = 1, maxScale = 2.0 ", 1, 2.0));
@@ -200,7 +202,7 @@ int main(int, char**)
// set the scene to render
viewer.setSceneData(createScene());
// run the viewers frame loop
return viewer.run();
}

View File

@@ -6,7 +6,7 @@
* 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
@@ -34,7 +34,7 @@
#include <osgViewer/Viewer>
//
// A simple demo demonstrating different texturing modes,
// A simple demo demonstrating different texturing modes,
// including using of texture extensions.
//
@@ -59,8 +59,9 @@ osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const
osg::Vec3Array* norms = new osg::Vec3Array(1);
(*norms)[0] = width^height;
(*norms)[0].normalize();
geom->setNormalArray(norms, osg::Array::BIND_OVERALL);
geom->setNormalArray(norms);
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
osg::Vec2Array* tcoords = new osg::Vec2Array(4);
(*tcoords)[0].set(0.0f,0.0f);
@@ -68,9 +69,9 @@ osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const
(*tcoords)[2].set(1.0f,1.0f);
(*tcoords)[3].set(0.0f,1.0f);
geom->setTexCoordArray(0,tcoords);
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
if (image)
{
osg::StateSet* stateset = new osg::StateSet;
@@ -79,7 +80,7 @@ osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
geom->setStateSet(stateset);
}
return geom;
}
@@ -109,18 +110,19 @@ osg::Drawable* createAxis(const osg::Vec3& corner,const osg::Vec3& xdir,const os
(*color)[3] = y_color;
(*color)[4] = z_color;
(*color)[5] = z_color;
geom->setColorArray(color, osg::Array::BIND_PER_VERTEX);
geom->setColorArray(color);
geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
osg::StateSet* stateset = new osg::StateSet;
osg::LineWidth* linewidth = new osg::LineWidth();
linewidth->setWidth(4.0f);
stateset->setAttributeAndModes(linewidth,osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
geom->setStateSet(stateset);
return geom;
}
@@ -136,7 +138,7 @@ osg::Node* createModel()
center->addDrawable(
createSquare(osg::Vec3(-0.5f,0.0f,-0.5f),osg::Vec3(1.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osgDB::readImageFile("Images/reflect.rgb")),
osg::Vec3(0.0f,0.0f,0.0f));
osg::Billboard* x_arrow = new osg::Billboard();
x_arrow->setMode(osg::Billboard::AXIAL_ROT);
x_arrow->setAxis(osg::Vec3(1.0f,0.0f,0.0f));
@@ -180,7 +182,7 @@ int main(int, char**)
{
// construct the viewer
osgViewer::Viewer viewer;
// set the scene to render
viewer.setSceneData(createModel());

View File

@@ -48,13 +48,13 @@ const unsigned int MAX_NUM_EVENTS = 10;
const unsigned int SWAP_BYTES_COMPARE = 0x12345678;
class CameraPacket {
public:
CameraPacket():_masterKilled(false)
CameraPacket():_masterKilled(false)
{
_byte_order = SWAP_BYTES_COMPARE;
}
void setPacket(const osg::Matrix& matrix,const osg::FrameStamp* frameStamp)
{
_matrix = matrix;
@@ -63,20 +63,20 @@ class CameraPacket {
_frameStamp = *frameStamp;
}
}
void getModelView(osg::Matrix& matrix,float angle_offset=0.0f)
{
matrix = _matrix * osg::Matrix::rotate(osg::DegreesToRadians(angle_offset),0.0f,1.0f,0.0f);
}
void readEventQueue(osgViewer::Viewer& viewer);
void writeEventQueue(osgViewer::Viewer& viewer);
void setMasterKilled(const bool flag) { _masterKilled = flag; }
const bool getMasterKilled() const { return _masterKilled; }
unsigned int _byte_order;
bool _masterKilled;
osg::Matrix _matrix;
@@ -84,11 +84,11 @@ class CameraPacket {
// note don't use a ref_ptr as used elsewhere for FrameStamp
// since we don't want to copy the pointer - but the memory.
// FrameStamp doesn't have a private destructor to allow
// us to do this, even though its a reference counted object.
// us to do this, even though its a reference counted object.
osg::FrameStamp _frameStamp;
osgGA::EventQueue::Events _events;
};
class DataConverter
@@ -112,7 +112,7 @@ class DataConverter
bool _swapBytes;
char* _currentPtr;
void reset()
{
_currentPtr = _startPtr;
@@ -122,22 +122,22 @@ class DataConverter
{
if (_currentPtr+1>=_endPtr) return;
*(_currentPtr++) = *(ptr);
*(_currentPtr++) = *(ptr);
}
inline void read1(char* ptr)
{
if (_currentPtr+1>=_endPtr) return;
*(ptr) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
inline void write2(char* ptr)
{
if (_currentPtr+2>=_endPtr) return;
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
}
inline void read2(char* ptr)
@@ -146,13 +146,13 @@ class DataConverter
if (_swapBytes)
{
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
else
{
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
}
@@ -160,10 +160,10 @@ class DataConverter
{
if (_currentPtr+4>=_endPtr) return;
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
}
inline void read4(char* ptr)
@@ -172,17 +172,17 @@ class DataConverter
if (_swapBytes)
{
*(ptr+3) = *(_currentPtr++);
*(ptr+2) = *(_currentPtr++);
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr+3) = *(_currentPtr++);
*(ptr+2) = *(_currentPtr++);
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
else
{
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
}
@@ -190,15 +190,15 @@ class DataConverter
{
if (_currentPtr+8>=_endPtr) return;
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr++);
*(_currentPtr++) = *(ptr);
}
inline void read8(char* ptr)
@@ -208,27 +208,27 @@ class DataConverter
if (_swapBytes)
{
*(ptr+7) = *(_currentPtr++);
*(ptr+6) = *(_currentPtr++);
*(ptr+5) = *(_currentPtr++);
*(ptr+4) = *(_currentPtr++);
*(ptr+7) = *(_currentPtr++);
*(ptr+6) = *(_currentPtr++);
*(ptr+5) = *(_currentPtr++);
*(ptr+4) = *(_currentPtr++);
*(ptr+3) = *(_currentPtr++);
*(ptr+2) = *(_currentPtr++);
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr+3) = *(_currentPtr++);
*(ptr+2) = *(_currentPtr++);
*(ptr+1) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
else
{
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr++) = *(_currentPtr++);
*(ptr) = *(_currentPtr++);
}
}
@@ -241,14 +241,14 @@ class DataConverter
inline void writeFloat(float c) { write4((char*)&c); }
inline void writeDouble(double c) { write8((char*)&c); }
inline char readChar() { char c=0; read1(&c); return c; }
inline unsigned char readUChar() { unsigned char c=0; read1((char*)&c); return c; }
inline short readShort() { short c=0; read2((char*)&c); return c; }
inline unsigned short readUShort() { unsigned short c=0; read2((char*)&c); return c; }
inline int readInt() { int c=0; read4((char*)&c); return c; }
inline unsigned int readUInt() { unsigned int c=0; read4((char*)&c); return c; }
inline float readFloat() { float c=0.0f; read4((char*)&c); return c; }
inline double readDouble() { double c=0.0; read8((char*)&c); return c; }
inline char readChar() { char c; read1(&c); return c; }
inline unsigned char readUChar() { unsigned char c; read1((char*)&c); return c; }
inline short readShort() { short c; read2((char*)&c); return c; }
inline unsigned short readUShort() { unsigned short c; read2((char*)&c); return c; }
inline int readInt() { int c; read4((char*)&c); return c; }
inline unsigned int readUInt() { unsigned int c; read4((char*)&c); return c; }
inline float readFloat() { float c; read4((char*)&c); return c; }
inline double readDouble() { double c; read8((char*)&c); return c; }
void write(const osg::FrameStamp& fs)
{
@@ -361,16 +361,16 @@ class DataConverter
event.setModKeyMask(readUInt());
event.setTime(readDouble());
}
void write(CameraPacket& cameraPacket)
{
writeUInt(cameraPacket._byte_order);
writeUInt(cameraPacket._masterKilled);
write(cameraPacket._matrix);
write(cameraPacket._frameStamp);
writeUInt(cameraPacket._events.size());
for(osgGA::EventQueue::Events::iterator itr = cameraPacket._events.begin();
itr != cameraPacket._events.end();
@@ -387,12 +387,12 @@ class DataConverter
{
_swapBytes = !_swapBytes;
}
cameraPacket._masterKilled = readUInt()!=0;
read(cameraPacket._matrix);
read(cameraPacket._frameStamp);
cameraPacket._events.clear();
unsigned int numEvents = readUInt();
for(unsigned int i=0;i<numEvents;++i)
@@ -409,7 +409,7 @@ void CameraPacket::readEventQueue(osgViewer::Viewer& viewer)
_events.clear();
osgViewer::ViewerBase::Contexts contexts;
viewer.getContexts(contexts);
viewer.getContexts(contexts);
for(osgViewer::ViewerBase::Contexts::iterator citr =contexts.begin(); citr != contexts.end(); ++citr)
{
@@ -423,7 +423,7 @@ void CameraPacket::readEventQueue(osgViewer::Viewer& viewer)
}
_events.insert(_events.end(), gw_events.begin(), gw_events.end());
}
viewer.getEventQueue()->copyEvents(_events);
osg::notify(osg::INFO)<<"written events = "<<_events.size()<<std::endl;
@@ -449,7 +449,7 @@ int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates how to approach implementation of clustering.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
@@ -459,7 +459,7 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->addCommandLineOption("-n <int>","Socket number to transmit packets");
arguments.getApplicationUsage()->addCommandLineOption("-f <float>","Field of view of camera");
arguments.getApplicationUsage()->addCommandLineOption("-o <float>","Offset angle of camera");
// construct the viewer.
osgViewer::Viewer viewer;
@@ -468,12 +468,12 @@ int main( int argc, char **argv )
ViewerMode viewerMode = STAND_ALONE;
while (arguments.read("-m")) viewerMode = MASTER;
while (arguments.read("-s")) viewerMode = SLAVE;
int socketNumber=8100;
while (arguments.read("-n",socketNumber)) ;
float camera_fov=-1.0f;
while (arguments.read("-f",camera_fov))
while (arguments.read("-f",camera_fov))
{
}
@@ -497,7 +497,7 @@ int main( int argc, char **argv )
arguments.writeErrorMessages(std::cout);
return 1;
}
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
@@ -514,13 +514,13 @@ int main( int argc, char **argv )
{
double fovy, aspectRatio, zNear, zFar;
viewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio,zNear, zFar);
double original_fov = atan(tan(osg::DegreesToRadians(fovy)*0.5)*aspectRatio)*2.0;
std::cout << "setting lens perspective : original "<<original_fov<<" "<<fovy<<std::endl;
fovy = atan(tan(osg::DegreesToRadians(camera_fov)*0.5)/aspectRatio)*2.0;
viewer.getCamera()->setProjectionMatrixAsPerspective(fovy, aspectRatio,zNear, zFar);
viewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio,zNear, zFar);
original_fov = atan(tan(osg::DegreesToRadians(fovy)*0.5)*aspectRatio)*2.0;
std::cout << "setting lens perspective : new "<<original_fov<<" "<<fovy<<std::endl;
@@ -549,13 +549,13 @@ int main( int argc, char **argv )
rc.setPort(static_cast<short int>(socketNumber));
bool masterKilled = false;
DataConverter scratchPad(1024);
while( !viewer.done() && !masterKilled )
{
osg::Timer_t startTick = osg::Timer::instance()->tick();
viewer.advance();
// special handling for working as a cluster.
@@ -563,12 +563,12 @@ int main( int argc, char **argv )
{
case(MASTER):
{
// take camera zero as the guide.
osg::Matrix modelview(viewer.getCamera()->getViewMatrix());
cp->setPacket(modelview,viewer.getFrameStamp());
cp->readEventQueue(viewer);
scratchPad.reset();
@@ -578,11 +578,11 @@ int main( int argc, char **argv )
scratchPad.read(*cp);
bc.setBuffer(scratchPad._startPtr, scratchPad._numBytes);
std::cout << "bc.sync()"<<scratchPad._numBytes<<std::endl;
bc.sync();
}
break;
case(SLAVE):
@@ -591,13 +591,13 @@ int main( int argc, char **argv )
rc.setBuffer(scratchPad._startPtr, scratchPad._numBytes);
rc.sync();
scratchPad.reset();
scratchPad.read(*cp);
cp->writeEventQueue(viewer);
if (cp->getMasterKilled())
if (cp->getMasterKilled())
{
std::cout << "Received master killed."<<std::endl;
// break out of while (!done) loop since we've now want to shut down.
@@ -609,9 +609,9 @@ int main( int argc, char **argv )
// no need to anything here, just a normal interactive viewer.
break;
}
osg::Timer_t endTick = osg::Timer::instance()->tick();
osg::notify(osg::INFO)<<"Time to do cluster sync "<<osg::Timer::instance()->delta_m(startTick,endTick)<<std::endl;
// update the scene by traversing it with the the update visitor which will
@@ -623,14 +623,14 @@ int main( int argc, char **argv )
{
osg::Matrix modelview;
cp->getModelView(modelview,camera_offset);
viewer.getCamera()->setViewMatrix(modelview);
}
// fire off the cull and draw traversals of the scene.
if(!masterKilled)
viewer.renderingTraversals();
}
// if we are master clean up by telling all slaves that we're going down.
@@ -638,7 +638,7 @@ int main( int argc, char **argv )
{
// need to broadcast my death.
cp->setPacket(osg::Matrix::identity(),viewer.getFrameStamp());
cp->setMasterKilled(true);
cp->setMasterKilled(true);
scratchPad.reset();
scratchPad.write(*cp);

View File

@@ -54,7 +54,7 @@ public:
~PickHandler() {}
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (!view) return false;
@@ -71,7 +71,7 @@ public:
{
if (_mx==ea.getX() && _my==ea.getY())
{
pick(view, ea);
pick(view, ea.getX(), ea.getY());
}
break;
}
@@ -81,13 +81,13 @@ public:
return false;
}
void pick(osgViewer::View* view, const osgGA::GUIEventAdapter& event)
void pick(osgViewer::View* view, float x, float y)
{
osg::Node* node = 0;
osg::Group* parent = 0;
osgUtil::LineSegmentIntersector::Intersections intersections;
if (view->computeIntersections(event, intersections))
if (view->computeIntersections(x, y, intersections))
{
osgUtil::LineSegmentIntersector::Intersection intersection = *intersections.begin();
osg::NodePath& nodePath = intersection.nodePath;
@@ -98,6 +98,7 @@ public:
// now we try to decorate the hit node by the osgFX::Scribe to show that its been "picked"
if (parent && node)
{
osgFX::Scribe* parentAsScribe = dynamic_cast<osgFX::Scribe*>(parent);
if (!parentAsScribe)
{

View File

@@ -1,2 +0,0 @@
SET(TARGET_SRC osgcomputeshaders.cpp)
SETUP_EXAMPLE(osgcomputeshaders)

View File

@@ -1,92 +0,0 @@
/* -*-c++-*- OpenSceneGraph example, osgcomputeshaders.
*
* 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.
*/
// Written by Wang Rui
// This example can work only if GL version is 4.3 or greater
#include <osg/Texture2D>
#include <osg/Geometry>
#include <osg/Geode>
#include <osgDB/ReadFile>
#include <osgGA/StateSetManipulator>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
static const char* computeSrc = {
"#version 430\n"
"uniform float osg_FrameTime;\n"
"layout (r32f, binding =0) uniform image2D targetTex;\n"
"layout (local_size_x = 16, local_size_y = 16) in;\n"
"void main() {\n"
" ivec2 storePos = ivec2(gl_GlobalInvocationID.xy);\n"
" float coeffcient = 0.5*sin(float(gl_WorkGroupID.x + gl_WorkGroupID.y)*0.1 + osg_FrameTime);\n"
" coeffcient *= length(vec2(ivec2(gl_LocalInvocationID.xy) - ivec2(8)) / vec2(8.0));\n"
" imageStore(targetTex, storePos, vec4(1.0-coeffcient, 0.0, 0.0, 0.0));\n"
"}\n"
};
int main( int argc, char** argv )
{
osg::ArgumentParser arguments( &argc, argv );
// Create the texture as both the output of compute shader and the input of a normal quad
osg::ref_ptr<osg::Texture2D> tex2D = new osg::Texture2D;
tex2D->setTextureSize( 512, 512 );
tex2D->setFilter( osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR );
tex2D->setFilter( osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR );
tex2D->setInternalFormat( GL_R32F );
tex2D->setSourceFormat( GL_RED );
tex2D->setSourceType( GL_FLOAT );
tex2D->bindToImageUnit( 0, osg::Texture::WRITE_ONLY ); // So we can use 'image2D' in the compute shader
// The compute shader can't work with other kinds of shaders
// It also requires the work group numbers. Setting them to 0 will disable the compute shader
osg::ref_ptr<osg::Program> computeProg = new osg::Program;
computeProg->setComputeGroups( 512/16, 512/16, 1 );
computeProg->addShader( new osg::Shader(osg::Shader::COMPUTE, computeSrc) );
// Create a node for outputting to the texture.
// It is OK to have just an empty node here, but seems inbuilt uniforms like osg_FrameTime won't work then.
// TODO: maybe we can have a custom drawable which also will implement glMemoryBarrier?
osg::Node* sourceNode = osgDB::readNodeFile("axes.osgt");
if ( !sourceNode ) sourceNode = new osg::Node;
sourceNode->setDataVariance( osg::Object::DYNAMIC );
sourceNode->getOrCreateStateSet()->setAttributeAndModes( computeProg.get() );
sourceNode->getOrCreateStateSet()->addUniform( new osg::Uniform("targetTex", (int)0) );
sourceNode->getOrCreateStateSet()->setTextureAttributeAndModes( 0, tex2D.get() );
// Display the texture on a quad. We will also be able to operate on the data if reading back to CPU side
osg::Geometry* geom = osg::createTexturedQuadGeometry(
osg::Vec3(), osg::Vec3(1.0f,0.0f,0.0f), osg::Vec3(0.0f,0.0f,1.0f) );
osg::ref_ptr<osg::Geode> quad = new osg::Geode;
quad->addDrawable( geom );
quad->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
quad->getOrCreateStateSet()->setTextureAttributeAndModes( 0, tex2D.get() );
// Create the scene graph and start the viewer
osg::ref_ptr<osg::Group> scene = new osg::Group;
scene->addChild( sourceNode );
scene->addChild( quad.get() );
osgViewer::Viewer viewer;
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
viewer.addEventHandler( new osgViewer::StatsHandler );
viewer.addEventHandler( new osgViewer::WindowSizeHandler );
viewer.setSceneData( scene.get() );
return viewer.run();
}

View File

@@ -45,21 +45,21 @@
class WallConstraint: public osgUtil::DelaunayConstraint { // forces lines to eb edge
// wall constraint - can generate a wall at the coordinates of the constraint
public:
/** if you derive a class from DelaunayConstraint then you can create
/** if you derive a class from DelaunayConstraint then you can create
* a specific geometry creation routine.
*/
WallConstraint() : height(0), txxrepWall(10), txyrepWall(10) { }
/** or create a wall around the constraint area: */
virtual osg::Geometry * makeWallGeometry(void) const;
/** for basic purposes, you can call these routines to make simple fill in geometries */
virtual osg::DrawArrays* makeWall(void ) const { // build a wall height high around the constraint
const osg::Vec3Array *_line= dynamic_cast<const osg::Vec3Array*>(getVertexArray());
return (new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,2*_line->size()));
}
virtual osg::Vec3Array *getWall(const float height) const;
virtual osg::Vec2Array *getWallTexcoords(const float height) const;
virtual osg::Vec3Array *getWallNormals(void) const {
@@ -67,7 +67,7 @@ public:
const osg::Vec3Array *vertices= dynamic_cast<const osg::Vec3Array*>(getVertexArray());
for (unsigned int ipr=0; ipr<getNumPrimitiveSets(); ipr++) {
const osg::PrimitiveSet* prset=getPrimitiveSet(ipr);
if (prset->getMode()==osg::PrimitiveSet::LINE_LOOP ||
if (prset->getMode()==osg::PrimitiveSet::LINE_LOOP ||
prset->getMode()==osg::PrimitiveSet::LINE_STRIP) { // loops and walls
// start with the last point on the loop
osg::Vec3 prevp=(*vertices)[prset->index (prset->getNumIndices()-1)];
@@ -88,12 +88,12 @@ public:
}
return nrms.release();
}
// geometry creation parameters
void setWallTexrep(const float w,const float h) { txxrepWall=w;txyrepWall=h;}
/** Wall Geometry will return with this texture applied: */
void setTexture(const char *tx) { texture=tx;}
/** fence/wall height */
@@ -106,18 +106,18 @@ protected:
class ArealConstraint: public osgUtil::DelaunayConstraint { // forces edges of an area to fit triangles
// areal constraint - general nonuniform field, forest, lake etc.
public:
/** if you derive a class from DelaunayConstraint then you can create
/** if you derive a class from DelaunayConstraint then you can create
* a specific geometry creation routine.
*/
ArealConstraint() : txxrepArea(10), txyrepArea(10),txxrepWall(10), txyrepWall(10) { }
/** return a geometry that fills the constraint.
*/
virtual deprecated_osg::Geometry * makeAreal( osg::Vec3Array *points);
virtual osg::Geometry * makeAreal( osg::Vec3Array *points);
/** or create a wall around the constraint area: */
virtual deprecated_osg::Geometry * makeWallGeometry( osg::Vec3Array *points) ;
virtual osg::Geometry * makeWallGeometry( osg::Vec3Array *points) ;
/** for basic purposes, you can call these routines to make simple fill in geometries */
virtual osg::DrawArrays* makeWall(void ) const;
virtual osg::Vec3Array *getWall(const float height) const;
@@ -129,7 +129,7 @@ public:
virtual osg::Vec3Array *getCanopy(const osg::Vec3Array *points,const float height) const;
virtual osg::Vec2Array *getCanopyTexcoords(const osg::Vec3Array *points) const;
virtual osg::Vec3Array *getCanopyNormals(const osg::Vec3Array *points) const;
// geometry creation parameters
void setTexrep(const float w,const float h) { txxrepArea=w;txyrepArea=h;}
void setWallTexrep(const float w,const float h) { txxrepWall=w;txyrepWall=h;}
@@ -147,39 +147,39 @@ protected:
float txxrepWall, txyrepWall;
};
class LinearConstraint: public osgUtil::DelaunayConstraint {
class LinearConstraint: public osgUtil::DelaunayConstraint {
/** forces edges of a "road" to fit triangles
* if 2 roads cross, then the overlap will be replaced by a 'cross road'
* and the roads built up to the cross roads with a texture along its length. */
public:
LinearConstraint() : osgUtil::DelaunayConstraint(), txxrepAlong(10), txyrepAcross(10), width(2) { }
/** geometry creation parameters */
/* Width of linear feature (eg road, railway) */
void setWidth(const float w) { width=w;}
/** Texture repeat distance across linear (often equal to width) and along its length */
virtual void setTexrep(const float w,const float h) { txyrepAcross=h;txxrepAlong=w; }
/** generate constant width around line - creates the area to be cut into the terrain. */
virtual void setVertices( osg::Vec3Array *lp, const float width);
/** return a geometry that fills the constraint.
*/
virtual deprecated_osg::Geometry *makeGeometry(const osg::Vec3Array *points) ;
virtual osg::Geometry *makeGeometry(const osg::Vec3Array *points) ;
/** return normals array - flat shaded */
osg::Vec3Array* getNormals(const osg::Vec3Array *points);
/** Roads apply a texture proportional to length along the road line. */
virtual osg::DrawArrays* makeRoad( ) const;
virtual osg::Vec3Array *getRoadVertices() const;
virtual osg::Vec2Array *getRoadTexcoords(const osg::Vec3Array *points) ;
virtual osg::Vec3Array *getRoadNormals(const osg::Vec3Array *points) const;
/** Geometry will return with this texture applied: */
void setTexture(const char *tx) { texture=tx;}
protected:
osg::ref_ptr<osg::Vec2Array> _tcoords;
osg::ref_ptr<osg::Vec3Array> _edgecoords;
@@ -196,19 +196,19 @@ class pyramid : public osgUtil::DelaunayConstraint {
* geometry of an Egyptian pyramid to fit the hole. */
public:
pyramid() : _side(100.) {}
void setpos(const osg::Vec3 p, const float size) { _pos=p;_side=size;}
virtual osg::Geometry * makeGeometry(void) const
{
// create pyramid geometry. Centre plus points around base
const osg::Vec3Array *_line= dynamic_cast<const osg::Vec3Array*>(getVertexArray());
deprecated_osg::Geometry *gm=new deprecated_osg::Geometry;
osg::Geometry *gm=new osg::Geometry;
osg::Vec3Array *pts=new osg::Vec3Array;
osg::Vec3Array *norms=new osg::Vec3Array;
osg::Vec2Array *tcoords=new osg::Vec2Array;
int ip;
pts->push_back(_pos+osg::Vec3(0,0,_side)*0.5);
for (ip=0; ip<4; ip++) {
pts->push_back((*_line)[ip]);
@@ -218,12 +218,12 @@ public:
nrm.normalize( );
norms->push_back(nrm);
}
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
gm->setVertexArray(pts);
osg::StateSet *dstate= gm->getOrCreateStateSet( );
dstate->setMode( GL_LIGHTING, osg::StateAttribute::ON );
osg::Image* image = osgDB::readImageFile("Images/Brick-Std-Orange.TGA");
if (image)
{
@@ -283,66 +283,66 @@ osg::Vec3d getpt(const int np)
osg::Node* createHUD(const int ndcs,std::string what)
{ // add a string reporting the type of winding rule tessellation applied
osg::Geode* geode = new osg::Geode();
std::string timesFont("fonts/arial.ttf");
// turn lighting off for the text and disable depth test to ensure its always ontop.
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
// Disable depth test, and make sure that the hud is drawn after everything
// Disable depth test, and make sure that the hud is drawn after everything
// else so that it always appears ontop.
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
stateset->setRenderBinDetails(11,"RenderBin");
osg::Vec3 position(50.0f,900.0f,0.0f);
osg::Vec3 delta(0.0f,-35.0f,0.0f);
{
osgText::Text* text = new osgText::Text;
geode->addDrawable( text );
std::ostringstream cue;
cue<<"Delaunay triangulation with constraints level "<<ndcs <<"\n"<< what;
text->setFont(timesFont);
text->setPosition(position);
text->setText(cue.str());
text->setColor(osg::Vec4(1.0,1.0,0.8,1.0));
position += delta*(ndcs+2);
#if 0
#if 0
text = new osgText::Text;
geode->addDrawable( text );
text->setFont(timesFont);
text->setPosition(position);
text->setText("(use 'W' wireframe & 'T' texture to visualise mesh)");
text->setColor(osg::Vec4(1.0,1.0,0.8,1.0));
position += delta;
#endif
}
#endif
}
{
osgText::Text* text = new osgText::Text;
geode->addDrawable( text );
text->setFont(timesFont);
text->setPosition(position);
text->setText("Press 'n' to add another constraint.");
}
}
// create the hud.
osg::MatrixTransform* modelview_abs = new osg::MatrixTransform;
modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
modelview_abs->setMatrix(osg::Matrix::identity());
modelview_abs->addChild(geode);
osg::Projection* projection = new osg::Projection;
projection->setMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
projection->addChild(modelview_abs);
return projection;
}
osg::Group *makedelaunay(const int ndcs)
{ // create a terrain tile. This is just an example!
@@ -351,9 +351,9 @@ osg::Group *makedelaunay(const int ndcs)
osg::ref_ptr<osg::Geode> geode=new osg::Geode;
osg::ref_ptr<osgUtil::DelaunayTriangulator> trig=new osgUtil::DelaunayTriangulator();
osg::StateSet *stateset=geode->getOrCreateStateSet();
osg::Vec3Array *points=new osg::Vec3Array;
osg::Image* image = osgDB::readImageFile("Images/blueFlowers.png");
if (image)
{
@@ -363,10 +363,10 @@ osg::Group *makedelaunay(const int ndcs)
texture->setWrap( osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT );
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
}
geode->setStateSet( stateset );
unsigned int i;
int eod=0;
while (eod>=0) {
osg::Vec3d pos=getpt(eod);
@@ -400,7 +400,7 @@ osg::Group *makedelaunay(const int ndcs)
}
dc->setVertexArray(bounds);
dc->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,nmax) );
trig->addInputConstraint(dc.get());
what << nmax << " point simple constraint\n";
}
@@ -426,10 +426,10 @@ osg::Group *makedelaunay(const int ndcs)
}
dc->setVertexArray(bounds);
dc->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,12) );
trig->addInputConstraint(dc.get());
what << 12 << " point closed loop";
if (ndcs>2) {
wc=new WallConstraint; // This example does not remove the interior
// eg to force terrain edges that are on ridges in the terrain etc.
@@ -447,7 +447,7 @@ osg::Group *makedelaunay(const int ndcs)
trig->addInputConstraint(wc.get());
what << " with interior removed\n";
what << 5 << " point wall derived constraint\n";
if (ndcs>3) {
// add a removed area and replace it with a different texture
dc2=new ArealConstraint;
@@ -461,7 +461,7 @@ osg::Group *makedelaunay(const int ndcs)
dc2->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,18) );
trig->addInputConstraint(dc2.get());
what << 18 << " point area replaced\n";
if (ndcs>4) {
dc3=new LinearConstraint;
// a linear feature or 'road'
@@ -495,7 +495,7 @@ osg::Group *makedelaunay(const int ndcs)
forest->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,12) );
if (ndcs==6) trig->addInputConstraint(forest.get());
what << 12 << " point forest constraint\n";
if (ndcs>6) { // add roads that intersect forest
osg::ref_ptr<osgUtil::DelaunayConstraint> forestplus=new osgUtil::DelaunayConstraint;
forestroad=new LinearConstraint;
@@ -605,17 +605,17 @@ osg::Group *makedelaunay(const int ndcs)
}
} // ndcs>0
trig->setInputPointArray(points);
/** NB you need to supply a vec3 array for the triangulator to calculate normals into */
osg::Vec3Array *norms=new osg::Vec3Array;
trig->setOutputNormalArray(norms);
trig->triangulate();
osg::notify(osg::WARN) << " End of trig\n " <<std::endl;
// Calculate the texture coordinates after triangulation as
// Calculate the texture coordinates after triangulation as
//the points may get disordered by the triangulate function
osg::ref_ptr<deprecated_osg::Geometry> gm=new deprecated_osg::Geometry;
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry;
gm->setVertexArray(points); // points may have been modified in order by triangulation.
/** calculate texture coords for terrain points */
if (image) {
@@ -629,17 +629,17 @@ osg::Group *makedelaunay(const int ndcs)
}
gm->addPrimitiveSet(trig->getTriangles());
gm->setNormalArray(trig->getOutputNormalArray());
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
geode->addDrawable(gm.get());
if (ndcs>0) {
for ( std::vector < pyramid* >::iterator itr=pyrlist.begin(); itr!=pyrlist.end(); itr++) {
trig->removeInternalTriangles(*itr);
geode->addDrawable((*itr)->makeGeometry()); // this fills the holes of each pyramid with geometry
}
if (ndcs>2) {
trig->removeInternalTriangles(dc.get());
wc->setTexture("Images/Brick-Norman-Brown.TGA"); // wall looks like brick
geode->addDrawable(wc->makeWallGeometry()); // this creates wall at wc drawarrays
if (ndcs>3) {
@@ -647,13 +647,13 @@ osg::Group *makedelaunay(const int ndcs)
osg::ref_ptr<osg::Vec3Array> arpts=dc2->getPoints(points);
dc2->setTexture("Images/purpleFlowers.png");
geode->addDrawable(dc2->makeAreal(arpts.get())); // this creates fill in geometry
if (ndcs>4) { // a simple "road"
trig->removeInternalTriangles(dc3.get());
dc3->setTexture ("Images/road.png");
dc3->setTexrep(40,9.5); // texture is repeated at this frequency
geode->addDrawable(dc3->makeGeometry(points)); // this creates road geometry
if (ndcs>5) {
if (ndcs>6) { // road & forest overlap - order of removal is important
trig->removeInternalTriangles(forestroad.get());
@@ -661,11 +661,11 @@ osg::Group *makedelaunay(const int ndcs)
trig->removeInternalTriangles(forestroad3.get());
}
trig->removeInternalTriangles(forest.get());
forest->setTexture("Images/forestRoof.png");
forest->setTexture("Images/forestRoof.png");
osg::ref_ptr<osg::Vec3Array> locpts=forest->getPoints(points);
geode->addDrawable(forest->makeAreal(locpts.get()));
forest->setWallTexture("Images/forestWall.png");
forest->setWallTexture("Images/forestWall.png");
geode->addDrawable(forest->makeWallGeometry(locpts.get()) );
for (osg::Vec3Array::iterator vit=(*locpts).begin(); vit!=(*locpts).end(); vit++) {
(*vit)+=osg::Vec3(0,0,30);
@@ -713,10 +713,10 @@ osg::Group *makedelaunay(const int ndcs)
class KeyboardEventHandler : public osgGA::GUIEventHandler
{ // extra event handler traps 'n' key to re-triangulate the basic terrain.
public:
KeyboardEventHandler(osgViewer::Viewer &vr):
viewer(vr), iview(0) {}
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
{
switch(ea.getEventType())
@@ -738,7 +738,7 @@ public:
}
return false;
}
osgViewer::Viewer &viewer;
int iview;
};
@@ -786,11 +786,11 @@ osg::Vec2Array * WallConstraint::getWallTexcoords(const float height) const
}
const osg::Vec3 curp=(*vertices)[prset->index (0)];
circumference+=(curp-prevp).length();
int nround=(int)(circumference/txxrepWall);
if (nround<1) nround=1; // at least one repeat.
texrepRound=circumference/nround;
float ds=0;
prevp=(*vertices)[prset->index (prset->getNumIndices()-1)];
if (tcoords) {
@@ -809,7 +809,7 @@ osg::Vec2Array * WallConstraint::getWallTexcoords(const float height) const
tcoords->push_back(tci);
}
} // per primitiveset
}
return tcoords;
}
@@ -836,8 +836,9 @@ osg::Geometry *WallConstraint::makeWallGeometry() const
gm->setVertexArray(getWall(height));
gm->addPrimitiveSet(makeWall());
gm->setTexCoordArray(0,getWallTexcoords(height));
gm->setNormalArray(getWallNormals(), osg::Array::BIND_PER_VERTEX); // this creates normals to walls
gm->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
gm->setNormalArray(getWallNormals()); // this creates normals to walls
return gm.release();
}
@@ -912,11 +913,11 @@ osg::Vec2Array * ArealConstraint::getWallTexcoords(const float height) const
}
const osg::Vec3 curp=(*vertices)[prset->index (0)];
circumference+=(curp-prevp).length();
int nround=(int)(circumference/txxrepWall);
if (nround<1) nround=1; // at least one repeat.
texrepRound=circumference/nround;
float ds=0;
prevp=(*vertices)[prset->index (prset->getNumIndices()-1)];
if (tcoords) {
@@ -987,23 +988,23 @@ osg::DrawArrays * ArealConstraint::makeWall(void) const
return (new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,2+2*_line->size()));
}
deprecated_osg::Geometry *ArealConstraint::makeWallGeometry( osg::Vec3Array *pt)
osg::Geometry *ArealConstraint::makeWallGeometry( osg::Vec3Array *pt)
{
osg::ref_ptr<deprecated_osg::Geometry> gm=new deprecated_osg::Geometry; // the wall
osg::ref_ptr<deprecated_osg::Geometry> edges=new deprecated_osg::Geometry; // edges of bounds
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry; // the wall
osg::ref_ptr<osg::Geometry> edges=new osg::Geometry; // edges of bounds
edges->setVertexArray(pt);
osg::DrawElementsUInt *trgeom=getTriangles();
edges->addPrimitiveSet(trgeom);
osg::ref_ptr<osgUtil::Tessellator> tscx=new osgUtil::Tessellator; // this assembles all the constraints
tscx->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
tscx->setBoundaryOnly(true);
tscx->setWindingType( osgUtil::Tessellator::TESS_WINDING_NONZERO);
tscx->setWindingType( osgUtil::Tessellator::TESS_WINDING_NONZERO);
// find all edges.
const osg::Vec3Array *points=dynamic_cast<osg::Vec3Array*>(getVertexArray());
tscx->retessellatePolygons(*(edges)); // find all edges
if (walltexture!="") {
osg::Image* image = osgDB::readImageFile(walltexture.c_str());
if (image)
@@ -1046,21 +1047,21 @@ deprecated_osg::Geometry *ArealConstraint::makeWallGeometry( osg::Vec3Array *pt)
nstart+=2+2*pr->getNumIndices();
}
}
return gm.release();
}
deprecated_osg::Geometry * ArealConstraint::makeAreal( osg::Vec3Array *points)
osg::Geometry * ArealConstraint::makeAreal( osg::Vec3Array *points)
{
osg::ref_ptr<deprecated_osg::Geometry> gm; // the fill in area
osg::ref_ptr<osg::Geometry> gm; // the fill in area
if (_interiorTris.size()>0) {
gm =new deprecated_osg::Geometry; // the forest roof
gm =new osg::Geometry; // the forest roof
gm->setVertexArray(points);
osg::DrawElementsUInt *trgeom=getTriangles();
gm->addPrimitiveSet(trgeom);
gm->setNormalArray(getCanopyNormals(points));
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
gm->setTexCoordArray(0,getCanopyTexcoords(points));
osg::Image* image = osgDB::readImageFile(texture);
if (image)
@@ -1093,7 +1094,7 @@ void LinearConstraint::setVertices( osg::Vec3Array *lp, const float w)
for(unsigned int i=0;i<lp->size();i++) {
osg::Vec3 valong;
osg::Vec3 pos[2];
if (i==0) {
valong=(*lp)[i+1]-(*lp)[i];
} else if (i==lp->size()-1) {
@@ -1120,7 +1121,7 @@ void LinearConstraint::setVertices( osg::Vec3Array *lp, const float w)
osg::DrawArrays* LinearConstraint::makeRoad(void ) const
{
return new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,2*_midline->size());
}
osg::Vec3Array *LinearConstraint::getRoadNormals(const osg::Vec3Array* /*points*/) const
@@ -1198,7 +1199,7 @@ osg::Vec2Array *LinearConstraint::getRoadTexcoords(const osg::Vec3Array *points)
ptfound=true;
}
ibm1=ib;
ib++;
ib++;
pminus=(*vit);
}
}
@@ -1218,7 +1219,7 @@ osg::Vec2Array *LinearConstraint::getRoadTexcoords(const osg::Vec3Array *points)
}
return tcoords.release();
}
osg::Vec3Array * LinearConstraint::getNormals(const osg::Vec3Array *points)
osg::Vec3Array * LinearConstraint::getNormals(const osg::Vec3Array *points)
{
osg::ref_ptr<osg::Vec3Array> norms=new osg::Vec3Array;
for (osg::DrawElementsUInt::iterator uiitr=prim_tris_->begin(); uiitr!=prim_tris_->end();uiitr+=3) {
@@ -1232,9 +1233,9 @@ osg::Vec3Array * LinearConstraint::getNormals(const osg::Vec3Array *points)
return norms.release();
}
deprecated_osg::Geometry * LinearConstraint::makeGeometry(const osg::Vec3Array *points)
osg::Geometry * LinearConstraint::makeGeometry(const osg::Vec3Array *points)
{
osg::ref_ptr<deprecated_osg::Geometry> gm=new deprecated_osg::Geometry; // the fill in road/railway
osg::ref_ptr<osg::Geometry> gm=new osg::Geometry; // the fill in road/railway
if (_midline->size()>0) {
osg::ref_ptr<osg::Vec3Array> locpts=getPoints(points);
if (texture!="") {
@@ -1257,19 +1258,19 @@ deprecated_osg::Geometry * LinearConstraint::makeGeometry(const osg::Vec3Array *
}
gm->setVertexArray(locpts.get());
gm->setNormalArray(getNormals(locpts.get()));
gm->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
gm->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
gm->addPrimitiveSet(getTriangles());
}
return gm.release();
}
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
@@ -1278,24 +1279,24 @@ int main( int argc, char **argv )
// create the scene from internal specified terrain/constraints.
osg::ref_ptr<osg::Node> loadedModel = makedelaunay(0);
// if no model has been successfully loaded report failure.
if (!loadedModel)
if (!loadedModel)
{
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
return 1;
}
// optimize the scene graph, remove redundant nodes and state etc.
osgUtil::Optimizer optimizer;
optimizer.optimize(loadedModel.get());
// pass the loaded scene graph to the viewer.
viewer.setSceneData(loadedModel.get());
// copied from osgtessealte.cpp
// add event handler for keyboard 'n' to retriangulate
viewer.addEventHandler(new KeyboardEventHandler(viewer));
return viewer.run();
}

View File

@@ -46,7 +46,7 @@ osg::Node* createScene()
osg::Geode* earth_geode = new osg::Geode;
earth_geode->setName("EarthGeode");
earth_geode->addDrawable(earth_sd);
// Create the Sun, in yellow
osg::ShapeDrawable *sun_sd = new osg::ShapeDrawable;
osg::Sphere* sun_sphere = new osg::Sphere;
@@ -63,12 +63,13 @@ osg::Node* createScene()
osg::PositionAttitudeTransform *pat = new osg::PositionAttitudeTransform;
pat->setPosition(osg::Vec3d(0.0, AU, 0.0));
pat->addChild(sun_geode);
osg::Geometry * unitCircle = new osg::Geometry();
{
osg::Vec4Array * colours = new osg::Vec4Array(1);
(*colours)[0] = osg::Vec4d(1.0,1.0,1.0,1.0);
unitCircle->setColorArray(colours, osg::Array::BIND_OVERALL);
unitCircle->setColorArray(colours);
unitCircle->setColorBinding(osg::Geometry::BIND_OVERALL);
const unsigned int n_points = 1024;
osg::Vec3Array * coords = new osg::Vec3Array(n_points);
const double dx = 2.0*osg::PI/n_points;
@@ -87,7 +88,8 @@ osg::Node* createScene()
{
osg::Vec4Array *colours = new osg::Vec4Array(1);
(*colours)[0] = osg::Vec4d(1.0,0.0,0.0,1.0);
axes->setColorArray(colours, osg::Array::BIND_OVERALL);
axes->setColorArray(colours);
axes->setColorBinding(osg::Geometry::BIND_OVERALL);
osg::Vec3Array *coords = new osg::Vec3Array(6);
(*coords)[0].set(osg::Vec3d(0.0, 0.0, 0.0));
(*coords)[1].set(osg::Vec3d(0.5, 0.0, 0.0));
@@ -99,25 +101,25 @@ osg::Node* createScene()
axes->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
axes->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));
}
// Earth orbit
osg::Geode * earthOrbitGeode = new osg::Geode;
earthOrbitGeode->addDrawable(unitCircle);
earthOrbitGeode->addDrawable(axes);
earthOrbitGeode->setName("EarthOrbitGeode");
osg::PositionAttitudeTransform * earthOrbitPAT = new osg::PositionAttitudeTransform;
earthOrbitPAT->setScale(osg::Vec3d(AU,AU,AU));
earthOrbitPAT->setPosition(osg::Vec3d(0.0, AU, 0.0));
earthOrbitPAT->addChild(earthOrbitGeode);
earthOrbitPAT->setName("EarthOrbitPAT");
osg::Group* scene = new osg::Group;
scene->setName("SceneGroup");
scene->addChild(earth_geode);
scene->addChild(pat);
scene->addChild(earthOrbitPAT);
return scene;
}
@@ -142,9 +144,9 @@ int main( int argc, char **argv )
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
// if one hasn't been loaded create an earth and sun test model.
if (!scene)
if (!scene)
{
scene = createScene();
scene = createScene();
needToSetHomePosition = true;
}
// pass the loaded scene graph to the viewer.
@@ -156,7 +158,7 @@ int main( int argc, char **argv )
{
viewer.getCameraManipulator()->setHomePosition(osg::Vec3d(0.0,-5.0*r_earth,0.0),osg::Vec3d(0.0,0.0,0.0),osg::Vec3d(0.0,0.0,1.0));
}
double zNear=1.0, zMid=10.0, zFar=1000.0;
if (arguments.read("--depth-partition",zNear, zMid, zFar))
{
@@ -173,7 +175,7 @@ int main( int argc, char **argv )
// set up depth partitioning with default settings
viewer.setUpDepthPartition();
}
return viewer.run();
}

View File

@@ -27,48 +27,48 @@
DePee::DePee(osg::Group* parent, osg::Group* subgraph, unsigned width, unsigned height)
{
_renderToFirst = false;
_isSketchy =false;
_isColored = false;
_isEdgy = true;
_isCrayon = false;
_normalDepthMapProgram = Utility::createProgram("shaders/depthpeel_normaldepthmap.vert","shaders/depthpeel_normaldepthmap.frag");
_colorMapProgram = Utility::createProgram("shaders/depthpeel_colormap.vert","shaders/depthpeel_colormap.frag" );
_edgeMapProgram = Utility::createProgram("shaders/depthpeel_edgemap.vert", "shaders/depthpeel_edgemap.frag");
_parent = new osg::Group;
parent->addChild(_parent.get());
_subgraph = subgraph;
_width = width;
_height = height;
_texWidth = width;
_texHeight = height;
assert(parent);
assert(subgraph);
_fps = 0;
_colorCamera = 0;
_sketchy = new osg::Uniform("sketchy", false);
_colored = new osg::Uniform("colored", false);
_edgy = new osg::Uniform("edgy", true);
_sketchiness = new osg::Uniform("sketchiness", (float) 1.0);
_normalDepthMap0 = Utility::newColorTexture2D(_texWidth, _texHeight, 32);
_normalDepthMap1 = Utility::newColorTexture2D(_texWidth, _texHeight, 32);
_edgeMap = Utility::newColorTexture2D(_texWidth, _texHeight, 8);
_colorMap = Utility::newColorTexture2D(_texWidth, _texHeight, 8);
//create a noise map...this doesn't end up in a new rendering pass
(void) createMap(NOISE_MAP);
//the viewport aligned quad
_quadGeode = Utility::getCanvasQuad(_width, _height);
//!!!Getting problems if assigning unit to texture in depth peeling subgraph and removing depth peeling steps!!!
//That's why it is done here
osg::StateSet* stateset = _parent->getOrCreateStateSet();
@@ -77,12 +77,12 @@ DePee::DePee(osg::Group* parent, osg::Group* subgraph, unsigned width, unsigned
stateset->setTextureAttributeAndModes(3, _edgeMap.get(), osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(4, _colorMap.get(), osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(5, _noiseMap.get(), osg::StateAttribute::ON);
// render the final thing
(void) createFinal();
//take one step initially
addDePeePass();
addDePeePass();
//render head up display
(void) createHUD();
@@ -111,7 +111,7 @@ void DePee::setSketchiness(double sketchiness)
{
_sketchiness->set((float)sketchiness);
}
void DePee::setColored(bool colored)
{
if(colored == !_isColored)
@@ -128,20 +128,20 @@ void DePee::setColored(bool colored)
_isColored = colored;
}
}
void DePee::setEdgy(bool edgy)
{
if(edgy != _isEdgy)
{
_isEdgy = edgy;
unsigned int n = 0;
while(remDePeePass())
{
++n;
}
if(edgy)
{
(void) createMap(EDGE_MAP,_dePeePasses.size() == 1);
@@ -150,7 +150,7 @@ void DePee::setEdgy(bool edgy)
{
_dePeePasses.back()->remRenderPass(EDGE_MAP);
}
for(unsigned int i=0; i < n; i++)
{
addDePeePass();
@@ -158,8 +158,8 @@ void DePee::setEdgy(bool edgy)
}
_edgy->set(edgy);
}
void DePee::setFPS(double* fps)
{
@@ -177,29 +177,29 @@ unsigned int DePee::getNumberOfRenderPasses()
bool DePee::addDePeePass()
{
if(_isColored)
{
//remove previous color pass
_dePeePasses.back()->remRenderPass(COLOR_MAP);
}
_dePeePasses.push_back(new DePeePass());
_parent->addChild(_dePeePasses.back()->root.get());
//need to create a depth map in every case
(void) createMap(NORMAL_DEPTH_MAP, _dePeePasses.size() == 1);
if(_isEdgy)
{
(void) createMap(EDGE_MAP,_dePeePasses.size() == 1);
}
if(_isColored)
{
(void) createMap(COLOR_MAP, false);
}
return true;
}
@@ -213,12 +213,12 @@ bool DePee::remDePeePass()
_dePeePasses.pop_back();
_renderToFirst = !_renderToFirst;
if(_isColored)
{
(void) createMap(COLOR_MAP, false);
}
return true;
}
@@ -234,11 +234,11 @@ bool DePee::createNoiseMap()
_noiseMap->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
stateset->setTextureAttributeAndModes(5, _noiseMap.get(), osg::StateAttribute::ON);
}
osg::Image* image = new osg::Image;
unsigned char* data = new unsigned char[_width*_height];
unsigned char* tmpData = new unsigned char[_width*_height];
int random=rand() % 5000;
for(unsigned y=0; y < _height; y++)
for(unsigned x=0; x < _width; x++)
@@ -258,10 +258,10 @@ bool DePee::createNoiseMap()
data[y*_width + x] = (unsigned char)Utility::smoothNoise(_width, _height, x,y, tmpData);
}
}
image->setImage(_width, _height, 1,
1, GL_LUMINANCE, GL_UNSIGNED_BYTE,
data,
image->setImage(_width, _height, 1,
1, GL_LUMINANCE, GL_UNSIGNED_BYTE,
data,
osg::Image::USE_NEW_DELETE);
_noiseMap->setImage(image);
return true;
@@ -270,24 +270,24 @@ bool DePee::createNoiseMap()
bool DePee::createHUD()
{
osg::Geode* geode = new osg::Geode();
std::string timesFont("fonts/arial.ttf");
// turn lighting off for the text and disable depth test to ensure its always ontop.
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
stateset->setTextureAttributeAndModes(1, _normalDepthMap0.get(), osg::StateAttribute::OFF);
stateset->setTextureAttributeAndModes(2, _normalDepthMap1.get(), osg::StateAttribute::OFF);
stateset->setTextureAttributeAndModes(3, _edgeMap.get(), osg::StateAttribute::OFF);
stateset->setTextureAttributeAndModes(4, _colorMap.get(), osg::StateAttribute::OFF);
stateset->setTextureAttributeAndModes(5, _noiseMap.get(), osg::StateAttribute::OFF);
osg::Vec3 position(5.0f,7.0f,0.0f);
osg::Vec3 delta(0.0f,-120.0f,0.0f);
_hudText = new osgText::Text;
{
geode->addDrawable( _hudText );
_hudText->setDataVariance(osg::Object::DYNAMIC);
@@ -298,16 +298,16 @@ bool DePee::createHUD()
_hudText->setCharacterSize(20.0);
position += delta;
}
{
osg::BoundingBox bb;
for(unsigned int i=0;i<geode->getNumDrawables();++i)
{
bb.expandBy(geode->getDrawable(i)->getBound());
}
osg::Geometry* geom = new osg::Geometry;
osg::Vec3Array* vertices = new osg::Vec3Array;
float depth = bb.zMin()-0.1;
vertices->push_back(osg::Vec3(bb.xMin(),bb.yMax(),depth));
@@ -315,22 +315,24 @@ bool DePee::createHUD()
vertices->push_back(osg::Vec3(bb.xMax(),bb.yMin(),depth));
vertices->push_back(osg::Vec3(bb.xMax(),bb.yMax(),depth));
geom->setVertexArray(vertices);
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
geom->setNormalArray(normals);
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(0.0f,0.0,0.0f,0.3f));
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));
osg::StateSet* stateset = geom->getOrCreateStateSet();
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
//geode->addDrawable(geom);
}
@@ -339,7 +341,7 @@ bool DePee::createHUD()
// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
// set the view matrix
// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());
@@ -350,19 +352,19 @@ bool DePee::createHUD()
camera->setRenderOrder(osg::Camera::POST_RENDER);
camera->addChild(geode);
_parent->addChild(camera);
return true;
}
// then create the first camera node to do the render to texture
// render normal and depth map color map
bool DePee::createMap(MapMode mapMode, bool first)
{
{
switch(mapMode)
{
case EDGE_MAP:
@@ -375,13 +377,13 @@ bool DePee::createMap(MapMode mapMode, bool first)
default:
std::cerr << "mapMode not recognized!!!\n";
return false;
}
}
}
bool DePee::createFinal()
{
osg::Projection* screenAlignedProjectionMatrix = new osg::Projection;
screenAlignedProjectionMatrix->setMatrix(osg::Matrix::ortho2D(0,_width,0,_height));
screenAlignedProjectionMatrix->setCullingActive(false);
@@ -391,20 +393,20 @@ bool DePee::createFinal()
// Make sure the model view matrix is not affected by any transforms
// above it in the scene graph:
screenAlignedModelViewMatrix->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
// new we need to add the texture to the Drawable, we do so by creating a
// new we need to add the texture to the Drawable, we do so by creating a
// StateSet to contain the Texture StateAttribute.
osg::StateSet* stateset = new osg::StateSet;
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
_quadGeode->setStateSet(stateset);
_parent->addChild(screenAlignedProjectionMatrix);
screenAlignedProjectionMatrix->addChild(screenAlignedModelViewMatrix);
screenAlignedModelViewMatrix->addChild(_quadGeode.get());
//setup shader
std::string vertSource;
if(!Utility::readFile("shaders/depthpeel_final.vert", vertSource))
@@ -412,82 +414,82 @@ bool DePee::createFinal()
printf("shader source not found\n");
return false;
}
std::string fragSource;
if(!Utility::readFile("shaders/depthpeel_final.frag", fragSource))
{
printf("shader source not found\n");
return false;
}
osg::ref_ptr<osg::Program> program = new osg::Program;
program->addShader( new osg::Shader( osg::Shader::VERTEX, vertSource.c_str() ) );
program->addShader( new osg::Shader( osg::Shader::FRAGMENT, fragSource.c_str() ) );
//choose map to display
stateset->addUniform( new osg::Uniform("normalDepthMap0", 1));
stateset->addUniform( new osg::Uniform("normalDepthMap1", 2));
stateset->addUniform(new osg::Uniform("edgeMap", 3));
stateset->addUniform( new osg::Uniform("colorMap", 4));
stateset->addUniform( new osg::Uniform("noiseMap", 5));
stateset->addUniform(_sketchy);
stateset->addUniform(_colored);
stateset->addUniform(_edgy);
stateset->addUniform(_sketchiness);
stateset->setAttributeAndModes( program.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
//switch lighting off
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
return true;
}
bool DePee::createEdgeMap(bool first)
//create the edge map of the first normal and depth map
{
{
_dePeePasses.back()->newRenderPass(EDGE_MAP);
// set up the background color and clear mask.
_dePeePasses.back()->Cameras[EDGE_MAP]->setClearColor(osg::Vec4(0.3,0.3f,0.3f,1.0f));
_dePeePasses.back()->Cameras[EDGE_MAP]->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
const osg::BoundingSphere& bs = _quadGeode->getBound();
if (!bs.valid())
{
return false;
}
float znear = 1.0f*bs.radius();
float zfar = 3.0f*bs.radius();
znear *= 0.9f;
zfar *= 1.1f;
// set up projection.
//_dePeePasses.back()->Cameras.top()->setProjectionMatrixAsFrustum(-proj_right,proj_right,-proj_top,proj_top,znear,zfar);
_dePeePasses.back()->Cameras[EDGE_MAP]->setProjectionMatrixAsOrtho(0,_width,0,_height,znear,zfar);
//set view
_dePeePasses.back()->Cameras[EDGE_MAP]->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
_dePeePasses.back()->Cameras[EDGE_MAP]->setViewMatrixAsLookAt(osg::Vec3(0.0f,0.0f,2.0f)*bs.radius(), osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0f,1.0f,0.0f));
// set viewport
_dePeePasses.back()->Cameras[EDGE_MAP]->setViewport(0,0,_texWidth,_texHeight);
// set the camera to render before the main camera.
_dePeePasses.back()->Cameras[EDGE_MAP]->setRenderOrder(osg::Camera::PRE_RENDER);
// tell the camera to use OpenGL frame buffer object
_dePeePasses.back()->Cameras[EDGE_MAP]->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER);
//switch lighting off
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
if(_renderToFirst)
{
stateset->addUniform(new osg::Uniform("normalDepthMap", 1));
@@ -499,14 +501,14 @@ bool DePee::createEdgeMap(bool first)
_dePeePasses.back()->Cameras[EDGE_MAP]->attach(osg::Camera::COLOR_BUFFER, _edgeMap.get());
stateset->addUniform( new osg::Uniform("edgeMap", 3));
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
osg::StateAttribute::OFF);
//setup shader
stateset->setAttributeAndModes(_edgeMapProgram.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform("width", (float) _width));
stateset->addUniform(new osg::Uniform("height", (float) _height));
if(first)
{
stateset->addUniform(new osg::Uniform("first", (float)1.0));
@@ -516,12 +518,12 @@ bool DePee::createEdgeMap(bool first)
stateset->addUniform(new osg::Uniform("first", (float)0.0));
}
_dePeePasses.back()->settingNodes[EDGE_MAP]->setStateSet(stateset.get());
// add subgraph to render
assert(_dePeePasses.size() > 0);
_dePeePasses.back()->settingNodes[EDGE_MAP]->addChild(_quadGeode.get());
return true;
}
@@ -529,13 +531,13 @@ bool DePee::createEdgeMap(bool first)
bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
{
DePeePass* pass;
pass = _dePeePasses.back();
pass->newRenderPass(mapMode);
//
// setup camera
// setup camera
//
// set up the background color and clear mask
@@ -547,23 +549,23 @@ bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
{
return false;
}
float znear = 1.0f*bs.radius();
float zfar = 3.0f*bs.radius();
// 2:1 aspect ratio as per flag geometry below.
float projTop = 0.25f*znear;
float projRight = projTop * ((double)_width/(double)_height);
znear *= 0.9f;
zfar *= 1.1f;
// set up projection.
pass->Cameras[mapMode]->setProjectionMatrixAsFrustum(-projRight,projRight,-projTop,projTop, znear,zfar);
// setup view
pass->Cameras[mapMode]->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
pass->Cameras[mapMode]->setViewMatrixAsLookAt(bs.center()-osg::Vec3(0.0f,2.0f,0.0f)*bs.radius(),
bs.center(),
osg::Vec3(0.0f,0.0f,1.0f));
@@ -572,24 +574,24 @@ bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
// set the camera to render before the main camera.
pass->Cameras[mapMode]->setRenderOrder(osg::Camera::PRE_RENDER);
pass->Cameras[mapMode]->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
//
// setup stateset
//
//switch lighting off
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
osg::StateAttribute::OFF);
switch(mapMode)
{
case NORMAL_DEPTH_MAP:
_renderToFirst = !_renderToFirst;
if(_renderToFirst)
{
pass->Cameras[mapMode]->attach(osg::Camera::COLOR_BUFFER, _normalDepthMap0.get());
@@ -600,17 +602,17 @@ bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
pass->Cameras[mapMode]->attach(osg::Camera::COLOR_BUFFER, _normalDepthMap1.get());
stateset->addUniform(new osg::Uniform("normalDepthMap", 1));
}
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
stateset->setAttributeAndModes(_normalDepthMapProgram.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
break;
case COLOR_MAP:
assert(pass == _dePeePasses.back());
pass->Cameras[mapMode]->attach(osg::Camera::COLOR_BUFFER, _colorMap.get());
if(_renderToFirst)
{
stateset->addUniform(new osg::Uniform("normalDepthMap", 1));
@@ -624,26 +626,26 @@ bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
stateset->setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->setAttributeAndModes(_colorMapProgram.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform("tex", 0));
break;
default:
return false;
};
// add subgraph to render
pass->settingNodes[mapMode]->addChild(_subgraph.get());
stateset->addUniform(new osg::Uniform("first", first));
stateset->addUniform(new osg::Uniform("width", (float) _width));
stateset->addUniform(new osg::Uniform("height", (float) _height));
stateset->addUniform(new osg::Uniform("znear", znear));
stateset->addUniform(new osg::Uniform("zfar", zfar));
pass->settingNodes[mapMode]->setStateSet(stateset.get());
return true;
}
@@ -663,7 +665,7 @@ bool DePee::updateHUDText()
+ (_isSketchy ? "+" : "-") + "(S)ketchy " +
+ (_isColored ? "+" : "-") + "(C)olored " +
+ "-> "+Utility::toString(getNumberOfRenderPasses())+ " Rendering Passes "
+ "@ "
+ "@ "
+ tmp + " fps");
return true;
}

View File

@@ -19,7 +19,7 @@ bool Utility::readFile(const char* fName, std::string& s)
{
std::string foundFile = osgDB::findDataFile(fName);
if (foundFile.empty()) return false;
osgDB::ifstream is;//(fName);
is.open(foundFile.c_str());
if (is.fail())
@@ -51,17 +51,17 @@ osg::Program* Utility::createProgram(std::string vs, std::string fs)
if(!readFile((char*)vs.c_str(), vertSource))
{
printf("shader source not found\n");
return 0;
return false;
}
std::string fragSource;
if(!readFile((char*)fs.c_str(), fragSource))
{
printf("shader source not found\n");
return 0;
return false;
}
osg::Program* program = new osg::Program;
program->addShader( new osg::Shader( osg::Shader::VERTEX, vertSource.c_str() ) );
program->addShader( new osg::Shader( osg::Shader::FRAGMENT, fragSource.c_str() ) );
@@ -80,28 +80,28 @@ double Utility::getNoise(unsigned x, unsigned y, unsigned random)
double Utility::smoothNoise(unsigned width, unsigned height, unsigned x, unsigned y, unsigned char* noise)
{
assert(noise);
if(x==0 || x > width -2
if(x==0 || x > width -2
|| y==0 || y > height -2)
return noise[x + y*width];
double corners = (noise[x-1 + (y-1) *width]
+noise[x+1 + (y-1)*width]
+noise[x-1 + (y+1) * width]
+noise[x+1 + (y+1) * width]) / 16.0;
double sides = (noise[x-1 + y*width]
+noise[x+1 + y*width]
+noise[x + (y-1)*width]
double sides = (noise[x-1 + y*width]
+noise[x+1 + y*width]
+noise[x + (y-1)*width]
+noise[x + (y+1)*width]) / 8.0;
double center = noise[x + y*width] / 4.0;
return corners + sides + center;
}
osg::Texture2D* Utility::newColorTexture2D(unsigned width, unsigned height, unsigned accuracy)
{
osg::Texture2D* texture2D = new osg::Texture2D;
texture2D->setTextureSize(width, height);
if(accuracy == 32)
{
@@ -124,29 +124,30 @@ osg::Geode* Utility::getCanvasQuad(unsigned width, unsigned height, double depth
osg::Vec2Array* texCoords = new osg::Vec2Array;
vertices->push_back(osg::Vec3(0,0,depth));
texCoords->push_back(osg::Vec2(0,0));
vertices->push_back(osg::Vec3(width,0,depth));
texCoords->push_back(osg::Vec2(1,0));
vertices->push_back(osg::Vec3(0,height,depth));
texCoords->push_back(osg::Vec2(0,1));
vertices->push_back(osg::Vec3(width,height,depth));
texCoords->push_back(osg::Vec2(1,1));
osg::Geometry* quad = new osg::Geometry;
quad->setVertexArray(vertices);
quad->setTexCoordArray(1,texCoords);
quad->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,vertices->size()));
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
quad->setColorArray(colors, osg::Array::BIND_OVERALL);
quad->setColorArray(colors);
quad->setColorBinding(osg::Geometry::BIND_OVERALL);
osg::Geode* geode = new osg::Geode();
geode->addDrawable(quad);
return geode;
}

View File

@@ -55,16 +55,16 @@ using namespace osg;
osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearColour)
{
osg::Group* distortionNode = new osg::Group;
unsigned int tex_width = 1024;
unsigned int tex_height = 1024;
osg::Texture2D* texture = new osg::Texture2D;
texture->setTextureSize(tex_width, tex_height);
texture->setInternalFormat(GL_RGBA);
texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
// set up the render to texture camera.
{
osg::Camera* camera = new osg::Camera;
@@ -92,10 +92,10 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
// add subgraph to render
camera->addChild(subgraph);
distortionNode->addChild(camera);
}
// set up the hud camera
{
// create the quad to visualize.
@@ -141,7 +141,8 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
// pass the created vertex array to the points geometry object.
polyGeom->setVertexArray(vertices);
polyGeom->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
polyGeom->setColorArray(colors);
polyGeom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
polyGeom->setTexCoordArray(0,texcoords);
@@ -158,7 +159,7 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
}
// new we need to add the texture to the Drawable, we do so by creating a
// new we need to add the texture to the Drawable, we do so by creating a
// StateSet to contain the Texture StateAttribute.
osg::StateSet* stateset = polyGeom->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
@@ -180,7 +181,7 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
// add subgraph to render
camera->addChild(geode);
distortionNode->addChild(camera);
}
return distortionNode;
@@ -188,9 +189,9 @@ osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearC
void setDomeFaces(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
{
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
if (!wsi)
{
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return;
@@ -236,7 +237,7 @@ void setDomeFaces(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
}
// top face
{
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
@@ -296,7 +297,7 @@ void setDomeFaces(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(-180.0f), 1.0,0.0,0.0));
}
viewer.getCamera()->setProjectionMatrixAsPerspective(90.0f, 1.0, 1, 1000.0);
viewer.assignSceneDataToCameras();
@@ -313,15 +314,15 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
osg::Vec3d center(0.0,0.0,0.0);
osg::Vec3d eye(0.0,0.0,0.0);
double distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius);
if (arguments.read("--distance", distance)) {}
bool centerProjection = false;
osg::Vec3d projector = eye - osg::Vec3d(0.0,0.0, distance);
osg::notify(osg::NOTICE)<<"Projector position = "<<projector<<std::endl;
osg::notify(osg::NOTICE)<<"distance = "<<distance<<std::endl;
@@ -338,7 +339,7 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
osg::Vec3 yAxis(heightVector);
float height = heightVector.length();
yAxis /= height;
int noSteps = 50;
osg::Vec3Array* vertices = new osg::Vec3Array;
@@ -348,7 +349,7 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
osg::Vec3 bottom = origin;
osg::Vec3 dx = xAxis*(width/((float)(noSteps-1)));
osg::Vec3 dy = yAxis*(height/((float)(noSteps-1)));
osg::Vec3d screenCenter = origin + widthVector*0.5f + heightVector*0.5f;
float screenRadius = heightVector.length() * 0.5f;
@@ -395,13 +396,13 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
if (phi > osg::PI_2) phi = osg::PI_2;
// osg::notify(osg::NOTICE)<<"theta = "<<theta<< "phi="<<phi<<std::endl;
double f = distance * sin(phi);
double e = distance * cos(phi) + sqrt( sphere_radius*sphere_radius - f*f);
double l = e * cos(phi);
double h = e * sin(phi);
double z = l - distance;
osg::Vec3 texcoord(h * cos(theta) / sphere_radius,
h * sin(theta) / sphere_radius,
z / sphere_radius);
@@ -415,11 +416,12 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
// osg::notify(osg::NOTICE)<<std::endl;
}
}
// pass the created vertex array to the points geometry object.
geometry->setVertexArray(vertices);
geometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
geometry->setColorArray(colors);
geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
geometry->setTexCoordArray(0,texcoords);
@@ -433,15 +435,15 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
}
geometry->addPrimitiveSet(elements);
}
return geometry;
}
void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
{
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
if (!wsi)
{
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return;
@@ -461,8 +463,8 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext = 0;
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc)
@@ -483,8 +485,8 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
texture->setInternalFormat(GL_RGB);
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
#if 0
#if 0
osg::Camera::RenderTargetImplementation renderTargetImplementation = osg::Camera::SEPERATE_WINDOW;
GLenum buffer = GL_FRONT;
#else
@@ -510,7 +512,7 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
}
// top face
{
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
@@ -606,7 +608,7 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate(osg::inDegrees(180.0f), 1.0,0.0,0.0));
}
viewer.getCamera()->setProjectionMatrixAsPerspective(90.0f, 1.0, 1, 1000.0);
@@ -616,7 +618,7 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
osg::Geode* geode = new osg::Geode();
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));
// new we need to add the texture to the mesh, we do so by creating a
// new we need to add the texture to the mesh, we do so by creating a
// StateSet to contain the Texture StateAttribute.
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
@@ -634,18 +636,18 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
camera->setAllowEventFocus(false);
//camera->setInheritanceMask(camera->getInheritanceMask() & ~osg::CullSettings::CLEAR_COLOR & ~osg::CullSettings::COMPUTE_NEAR_FAR_MODE);
//camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
camera->setProjectionMatrixAsOrtho2D(0,width,0,height);
camera->setViewMatrix(osg::Matrix::identity());
// add subgraph to render
camera->addChild(geode);
camera->setName("DistortionCorrectionCamera");
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), false);
}
viewer.getCamera()->setNearFarRatio(0.0001f);
}
@@ -663,23 +665,23 @@ int main(int argc, char** argv)
// if not loaded assume no arguments passed in, try use default mode instead.
if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osgt");
if (!loadedModel)
{
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
return 1;
}
if (arguments.read("--dome") || arguments.read("--puffer") )
{
{
setDomeCorrection(viewer, arguments);
viewer.setSceneData( loadedModel );
}
else if (arguments.read("--faces"))
{
{
setDomeFaces(viewer, arguments);
@@ -695,7 +697,7 @@ int main(int argc, char** argv)
{
viewer.setLightingMode(osg::View::SKY_LIGHT);
}
if (viewer.getLightingMode()==osg::View::HEADLIGHT)
{
viewer.getLight()->setPosition(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
@@ -724,7 +726,7 @@ int main(int argc, char** argv)
while (arguments.read("-p",pathfile))
{
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
if (apm || !apm->valid())
if (apm || !apm->valid())
{
unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
@@ -740,7 +742,7 @@ int main(int argc, char** argv)
// add the state manipulator
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
// add the stats handler
viewer.addEventHandler(new osgViewer::StatsHandler);

View File

@@ -31,8 +31,6 @@
#include <osg/StateSet>
#include <osg/Switch>
#include <osg/Texture2D>
#include <osg/TextureBuffer>
#include <osg/Image>
#include <osg/TexEnv>
#include <osg/VertexProgram>
#include <osg/FragmentProgram>
@@ -87,9 +85,9 @@ public:
float _height;
unsigned int _type;
};
typedef std::vector< osg::ref_ptr<Tree> > TreeList;
class Cell : public osg::Referenced
{
public:
@@ -97,21 +95,21 @@ public:
Cell():_parent(0) {}
Cell(osg::BoundingBox& bb):_parent(0), _bb(bb) {}
void addCell(Cell* cell) { cell->_parent=this; _cells.push_back(cell); }
void addTree(Tree* tree) { _trees.push_back(tree); }
void addTrees(const TreeList& trees) { _trees.insert(_trees.end(),trees.begin(),trees.end()); }
void computeBound();
bool contains(const osg::Vec3& position) const { return _bb.contains(position); }
bool divide(unsigned int maxNumTreesPerCell=10);
bool divide(bool xAxis, bool yAxis, bool zAxis);
void bin();
@@ -119,7 +117,7 @@ public:
osg::BoundingBox _bb;
CellList _cells;
TreeList _trees;
};
float random(float min,float max) { return min + (max-min)*(float)rand()/(float)RAND_MAX; }
@@ -141,17 +139,11 @@ public:
osg::Node* createTransformGraph(Cell* cell,osg::StateSet* stateset);
osg::Node* createShaderGraph(Cell* cell,osg::StateSet* stateset);
osg::Node* createGeometryShaderGraph(Cell* cell, osg::StateSet* stateset);
osg::Node* createTextureBufferGraph(Cell* cell, osg::Geometry* templateGeometry);
void CollectTreePositions(Cell* cell, std::vector< osg::Vec3 >& positions);
osg::Node* createHUDWithText(const std::string& text);
osg::Node* createScene(unsigned int numTreesToCreates, unsigned int maxNumTreesPerCell);
osg::Node* createScene(unsigned int numTreesToCreates);
void advanceToNextTechnique(int delta=1)
{
if (_techniqueSwitch.valid())
@@ -164,10 +156,10 @@ public:
_techniqueSwitch->setSingleChildOn(_currentTechnique);
}
}
osg::ref_ptr<osg::Switch> _techniqueSwitch;
int _currentTechnique;
};
@@ -177,22 +169,22 @@ class TechniqueEventHandler : public osgGA::GUIEventHandler
public:
TechniqueEventHandler(ForestTechniqueManager* ttm=0) { _ForestTechniqueManager = ttm; }
META_Object(osgforestApp,TechniqueEventHandler);
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&, osg::Object*, osg::NodeVisitor*);
virtual void getUsage(osg::ApplicationUsage& usage) const;
protected:
~TechniqueEventHandler() {}
TechniqueEventHandler(const TechniqueEventHandler&,const osg::CopyOp&) {}
osg::ref_ptr<ForestTechniqueManager> _ForestTechniqueManager;
};
bool TechniqueEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&, osg::Object*, osg::NodeVisitor*)
@@ -202,14 +194,14 @@ bool TechniqueEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAc
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='n' ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Right ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Right ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Right)
{
_ForestTechniqueManager->advanceToNextTechnique(1);
return true;
}
else if (ea.getKey()=='p' ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Left ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Left ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Left)
{
_ForestTechniqueManager->advanceToNextTechnique(-1);
@@ -337,7 +329,7 @@ bool ForestTechniqueManager::Cell::divide(bool xAxis, bool yAxis, bool zAxis)
}
void ForestTechniqueManager::Cell::bin()
{
{
// put trees in appropriate cells.
TreeList treesNotAssigned;
for(TreeList::iterator titr=_trees.begin();
@@ -395,9 +387,9 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
texture->setImage(image);
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
}
geode->setStateSet( stateset );
unsigned int numColumns = 38;
unsigned int numRows = 39;
unsigned int r;
@@ -414,7 +406,7 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
max_z = osg::maximum(max_z,vertex[r+c*numRows][2]);
}
}
float scale_z = size.z()/(max_z-min_z);
@@ -435,22 +427,22 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
grid->setHeight(c,r,(vertex[r+c*numRows][2]-min_z)*scale_z);
}
}
geode->addDrawable(new osg::ShapeDrawable(grid));
}
else
{
osg::Geometry* geometry = new osg::Geometry;
osg::Vec3Array& v = *(new osg::Vec3Array(numColumns*numRows));
osg::Vec2Array& t = *(new osg::Vec2Array(numColumns*numRows));
osg::Vec4ubArray& color = *(new osg::Vec4ubArray(1));
color[0].set(255,255,255,255);
float rowCoordDelta = size.y()/(float)(numRows-1);
float columnCoordDelta = size.x()/(float)(numColumns-1);
float rowTexDelta = 1.0f/(float)(numRows-1);
float columnTexDelta = 1.0f/(float)(numColumns-1);
@@ -472,11 +464,12 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
pos.y() += rowCoordDelta;
tex.y() += rowTexDelta;
}
geometry->setVertexArray(&v);
geometry->setColorArray(&color, osg::Array::BIND_OVERALL);
geometry->setColorArray(&color);
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->setTexCoordArray(0,&t);
for(r=0;r<numRows-1;++r)
{
osg::DrawElementsUShort& drawElements = *(new osg::DrawElementsUShort(GL_QUAD_STRIP,2*numColumns));
@@ -488,13 +481,13 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const
drawElements[ei++] = (r)*numColumns+c;
}
}
geode->addDrawable(geometry);
osgUtil::SmoothingVisitor sv;
sv.smooth(*geometry);
}
return geode;
}
@@ -503,7 +496,7 @@ void ForestTechniqueManager::createTreeList(osg::Node* terrain,const osg::Vec3&
float max_TreeHeight = sqrtf(size.length2()/(float)numTreesToCreate);
float max_TreeWidth = max_TreeHeight*0.5f;
float min_TreeHeight = max_TreeHeight*0.3f;
float min_TreeWidth = min_TreeHeight*0.5f;
@@ -518,14 +511,14 @@ void ForestTechniqueManager::createTreeList(osg::Node* terrain,const osg::Vec3&
tree->_width = random(min_TreeWidth,max_TreeWidth);
tree->_height = random(min_TreeHeight,max_TreeHeight);
tree->_type = 0;
if (terrain)
{
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
new osgUtil::LineSegmentIntersector(tree->_position,tree->_position+osg::Vec3(0.0f,0.0f,size.z()));
osgUtil::IntersectionVisitor iv(intersector.get());
terrain->accept(iv);
if (intersector->containsIntersections())
@@ -540,7 +533,7 @@ void ForestTechniqueManager::createTreeList(osg::Node* terrain,const osg::Vec3&
}
}
}
trees.push_back(tree);
}
}
@@ -570,7 +563,8 @@ osg::Geometry* ForestTechniqueManager::createSprite( float w, float h, osg::Vec4
geom->setTexCoordArray( 0, &t );
geom->setColorArray( &c, osg::Array::BIND_OVERALL );
geom->setColorArray( &c );
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
geom->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4) );
@@ -583,7 +577,7 @@ osg::Geometry* ForestTechniqueManager::createOrthogonalQuads( const osg::Vec3& p
osg::Vec3Array& v = *(new osg::Vec3Array(8));
osg::Vec2Array& t = *(new osg::Vec2Array(8));
osg::Vec4ubArray& c = *(new osg::Vec4ubArray(1));
float rotation = random(0.0f,osg::PI/2.0f);
float sw = sinf(rotation)*w*0.5f;
float cw = cosf(rotation)*w*0.5f;
@@ -616,7 +610,8 @@ osg::Geometry* ForestTechniqueManager::createOrthogonalQuads( const osg::Vec3& p
geom->setTexCoordArray( 0, &t );
geom->setColorArray( &c, osg::Array::BIND_OVERALL );
geom->setColorArray( &c );
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
geom->addPrimitiveSet( new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,8) );
@@ -627,10 +622,10 @@ osg::Node* ForestTechniqueManager::createBillboardGraph(Cell* cell,osg::StateSet
{
bool needGroup = !(cell->_cells.empty());
bool needBillboard = !(cell->_trees.empty());
osg::Billboard* billboard = 0;
osg::Group* group = 0;
if (needBillboard)
{
billboard = new osg::Billboard;
@@ -640,10 +635,10 @@ osg::Node* ForestTechniqueManager::createBillboardGraph(Cell* cell,osg::StateSet
++itr)
{
Tree& tree = **itr;
billboard->addDrawable(createSprite(tree._width,tree._height,tree._color),tree._position);
billboard->addDrawable(createSprite(tree._width,tree._height,tree._color),tree._position);
}
}
if (needGroup)
{
group = new osg::Group;
@@ -653,9 +648,9 @@ osg::Node* ForestTechniqueManager::createBillboardGraph(Cell* cell,osg::StateSet
{
group->addChild(createBillboardGraph(itr->get(),stateset));
}
if (billboard) group->addChild(billboard);
}
if (group) return group;
else return billboard;
@@ -665,15 +660,15 @@ osg::Node* ForestTechniqueManager::createXGraph(Cell* cell,osg::StateSet* states
{
bool needGroup = !(cell->_cells.empty());
bool needTrees = !(cell->_trees.empty());
osg::Geode* geode = 0;
osg::Group* group = 0;
if (needTrees)
{
geode = new osg::Geode;
geode->setStateSet(stateset);
for(TreeList::iterator itr=cell->_trees.begin();
itr!=cell->_trees.end();
++itr)
@@ -682,7 +677,7 @@ osg::Node* ForestTechniqueManager::createXGraph(Cell* cell,osg::StateSet* states
geode->addDrawable(createOrthogonalQuads(tree._position,tree._width,tree._height,tree._color));
}
}
if (needGroup)
{
group = new osg::Group;
@@ -692,9 +687,9 @@ osg::Node* ForestTechniqueManager::createXGraph(Cell* cell,osg::StateSet* states
{
group->addChild(createXGraph(itr->get(),stateset));
}
if (geode) group->addChild(geode);
}
if (group) return group;
else return geode;
@@ -704,16 +699,16 @@ osg::Node* ForestTechniqueManager::createTransformGraph(Cell* cell,osg::StateSet
{
bool needGroup = !(cell->_cells.empty());
bool needTrees = !(cell->_trees.empty());
osg::Group* transform_group = 0;
osg::Group* group = 0;
if (needTrees)
{
transform_group = new osg::Group;
osg::Geometry* geometry = createOrthogonalQuads(osg::Vec3(0.0f,0.0f,0.0f),1.0f,1.0f,osg::Vec4ub(255,255,255,255));
for(TreeList::iterator itr=cell->_trees.begin();
itr!=cell->_trees.end();
++itr)
@@ -721,7 +716,7 @@ osg::Node* ForestTechniqueManager::createTransformGraph(Cell* cell,osg::StateSet
Tree& tree = **itr;
osg::MatrixTransform* transform = new osg::MatrixTransform;
transform->setMatrix(osg::Matrix::scale(tree._width,tree._width,tree._height)*osg::Matrix::translate(tree._position));
osg::Geode* geode = new osg::Geode;
geode->setStateSet(stateset);
geode->addDrawable(geometry);
@@ -729,7 +724,7 @@ osg::Node* ForestTechniqueManager::createTransformGraph(Cell* cell,osg::StateSet
transform_group->addChild(transform);
}
}
if (needGroup)
{
group = new osg::Group;
@@ -739,9 +734,9 @@ osg::Node* ForestTechniqueManager::createTransformGraph(Cell* cell,osg::StateSet
{
group->addChild(createTransformGraph(itr->get(),stateset));
}
if (transform_group) group->addChild(transform_group);
}
if (group) return group;
else return transform_group;
@@ -752,7 +747,7 @@ osg::Geometry* ForestTechniqueManager::createOrthogonalQuadsNoColor( const osg::
// set up the coords
osg::Vec3Array& v = *(new osg::Vec3Array(8));
osg::Vec2Array& t = *(new osg::Vec2Array(8));
float rotation = random(0.0f,osg::PI/2.0f);
float sw = sinf(rotation)*w*0.5f;
float cw = cosf(rotation)*w*0.5f;
@@ -800,7 +795,7 @@ class ShaderGeometry : public osg::Drawable
META_Object(osg,ShaderGeometry)
typedef std::vector<osg::Vec4> PositionSizeList;
virtual void drawImplementation(osg::RenderInfo& renderInfo) const
{
for(PositionSizeList::const_iterator itr = _trees.begin();
@@ -827,241 +822,29 @@ class ShaderGeometry : public osg::Drawable
}
return bb;
}
void setGeometry(osg::Geometry* geometry)
{
_geometry = geometry;
}
void addTree(ForestTechniqueManager::Tree& tree)
{
_trees.push_back(osg::Vec4(tree._position.x(), tree._position.y(), tree._position.z(), tree._height));
}
osg::ref_ptr<osg::Geometry> _geometry;
PositionSizeList _trees;
protected:
virtual ~ShaderGeometry() {}
};
osg::Geometry* shared_geometry = 0;
osg::Program* createGeometryShader()
{
static const char* vertSource = {
"#version 120\n"
"#extension GL_EXT_geometry_shader4 : enable\n"
"varying vec2 texcoord;\n"
"void main(void)\n"
"{\n"
" gl_Position = gl_Vertex;\n"
" texcoord = gl_MultiTexCoord0.st;\n"
"}\n"
};
static const char* geomSource = {
"#version 120\n"
"#extension GL_EXT_geometry_shader4 : enable\n"
"varying vec2 texcoord;\n"
"varying float intensity; \n"
"varying float red_intensity; \n"
"void main(void)\n"
"{\n"
" vec4 v = gl_PositionIn[0];\n"
" vec4 info = gl_PositionIn[1];\n"
" intensity = info.y;\n"
" red_intensity = info.z;\n"
"\n"
" float h = info.x;\n"
" float w = h*0.35;\n"
" vec4 e;\n"
" e = v + vec4(-w,0.0,0.0,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(0.0,0.0); EmitVertex();\n"
" e = v + vec4(w,0.0,0.0,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(1.0,0.0); EmitVertex();\n"
" e = v + vec4(-w,0.0,h,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(0.0,1.0); EmitVertex();\n"
" e = v + vec4(w,0.0,h,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(1.0,1.0); EmitVertex();\n"
" EndPrimitive();\n"
" e = v + vec4(0.0,-w,0.0,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(0.0,0.0); EmitVertex();\n"
" e = v + vec4(0.0,w,0.0,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(1.0,0.0); EmitVertex();\n"
" e = v + vec4(0.0,-w,h,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(0.0,1.0); EmitVertex();\n"
" e = v + vec4(0.0,w,h,0.0); gl_Position = gl_ModelViewProjectionMatrix * e; texcoord = vec2(1.0,1.0); EmitVertex();\n"
" EndPrimitive();\n"
"}\n"
};
static const char* fragSource = {
"uniform sampler2D baseTexture; \n"
"varying vec2 texcoord; \n"
"varying float intensity; \n"
"varying float red_intensity; \n"
"\n"
"void main(void) \n"
"{ \n"
" vec4 finalColor = texture2D( baseTexture, texcoord); \n"
" vec4 color = finalColor * intensity;\n"
" color.w = finalColor.w;\n"
" color.x *= red_intensity;\n"
" gl_FragColor = color;\n"
"}\n"
};
osg::Program* pgm = new osg::Program;
pgm->setName( "osgshader2 demo" );
pgm->addShader( new osg::Shader( osg::Shader::VERTEX, vertSource ) );
pgm->addShader( new osg::Shader( osg::Shader::FRAGMENT, fragSource ) );
pgm->addShader( new osg::Shader( osg::Shader::GEOMETRY, geomSource ) );
pgm->setParameter( GL_GEOMETRY_VERTICES_OUT_EXT, 8 );
pgm->setParameter( GL_GEOMETRY_INPUT_TYPE_EXT, GL_LINES );
pgm->setParameter( GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_TRIANGLE_STRIP);
return pgm;
}
void ForestTechniqueManager::CollectTreePositions(Cell* cell, std::vector< osg::Vec3 >& positions)
{
bool needGroup = !(cell->_cells.empty());
bool needTrees = !(cell->_trees.empty());
if (needTrees)
{
for(TreeList::iterator itr=cell->_trees.begin();
itr!=cell->_trees.end();
++itr)
{
Tree& tree = **itr;
positions.push_back(tree._position);
}
}
if (needGroup)
{
for(Cell::CellList::iterator itr=cell->_cells.begin();
itr!=cell->_cells.end();
++itr)
{
CollectTreePositions(itr->get(),positions);
}
}
}
osg::Node* ForestTechniqueManager::createGeometryShaderGraph(Cell* cell, osg::StateSet* dstate)
{
bool needGroup = !(cell->_cells.empty());
bool needTrees = !(cell->_trees.empty());
osg::Geode* geode = 0;
osg::Group* group = 0;
if (needTrees)
{
geode = new osg::Geode;
geode->setStateSet(dstate);
osg::Geometry* geometry = new osg::Geometry;
geode->addDrawable(geometry);
osg::Vec3Array* v = new osg::Vec3Array;
for(TreeList::iterator itr=cell->_trees.begin();
itr!=cell->_trees.end();
++itr)
{
Tree& tree = **itr;
v->push_back(tree._position);
v->push_back(osg::Vec3(/*tree._height*/30.0,(double)random(0.75f,1.15f),(double)random(1.0f,1.250f)));
}
geometry->setVertexArray( v );
geometry->addPrimitiveSet( new osg::DrawArrays( GL_LINES, 0, v->size() ) );
osg::StateSet* sset = geode->getOrCreateStateSet();
sset->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
sset->setAttribute( createGeometryShader() );
osg::Uniform* baseTextureSampler = new osg::Uniform("baseTexture",0);
sset->addUniform(baseTextureSampler);
}
if (needGroup)
{
group = new osg::Group;
for(Cell::CellList::iterator itr=cell->_cells.begin();
itr!=cell->_cells.end();
++itr)
{
group->addChild(createGeometryShaderGraph(itr->get(),dstate));
}
if (geode) group->addChild(geode);
}
if (group) return group;
else return geode;
}
osg::Node* ForestTechniqueManager::createTextureBufferGraph(Cell* cell, osg::Geometry* templateGeometry)
{
bool needGroup = !(cell->_cells.empty());
bool needTrees = !(cell->_trees.empty());
osg::Geode* geode = 0;
osg::Group* group = 0;
if (needTrees)
{
osg::Geometry* geometry = (osg::Geometry*)templateGeometry->clone( osg::CopyOp::DEEP_COPY_PRIMITIVES );
osg::DrawArrays* primSet = dynamic_cast<osg::DrawArrays*>( geometry->getPrimitiveSet(0) );
primSet->setNumInstances( cell->_trees.size() );
geode = new osg::Geode;
geode->addDrawable(geometry);
osg::ref_ptr<osg::Image> treeParamsImage = new osg::Image;
treeParamsImage->allocateImage( 3*cell->_trees.size(), 1, 1, GL_RGBA, GL_FLOAT );
unsigned int i=0;
for(TreeList::iterator itr=cell->_trees.begin();
itr!=cell->_trees.end();
++itr,++i)
{
osg::Vec4f* ptr = (osg::Vec4f*)treeParamsImage->data(3*i);
Tree& tree = **itr;
ptr[0] = osg::Vec4f(tree._position.x(),tree._position.y(),tree._position.z(),1.0);
ptr[1] = osg::Vec4f((float)tree._color.r()/255.0f,(float)tree._color.g()/255.0f, (float)tree._color.b()/255.0f, 1.0);
ptr[2] = osg::Vec4f(tree._width, tree._height, 1.0, 1.0);
}
osg::ref_ptr<osg::TextureBuffer> tbo = new osg::TextureBuffer;
tbo->setImage( treeParamsImage.get() );
tbo->setInternalFormat(GL_RGBA32F_ARB);
geometry->getOrCreateStateSet()->setTextureAttribute(1, tbo.get());
geometry->setInitialBound( cell->_bb );
}
if (needGroup)
{
group = new osg::Group;
for(Cell::CellList::iterator itr=cell->_cells.begin();
itr!=cell->_cells.end();
++itr)
{
group->addChild(createTextureBufferGraph(itr->get(),templateGeometry));
}
if (geode) group->addChild(geode);
}
if (group) return group;
else return geode;
}
osg::Node* ForestTechniqueManager::createShaderGraph(Cell* cell,osg::StateSet* stateset)
{
if (shared_geometry==0)
@@ -1073,18 +856,18 @@ osg::Node* ForestTechniqueManager::createShaderGraph(Cell* cell,osg::StateSet* s
bool needGroup = !(cell->_cells.empty());
bool needTrees = !(cell->_trees.empty());
osg::Geode* geode = 0;
osg::Group* group = 0;
if (needTrees)
{
geode = new osg::Geode;
ShaderGeometry* shader_geometry = new ShaderGeometry;
shader_geometry->setGeometry(shared_geometry);
for(TreeList::iterator itr=cell->_trees.begin();
itr!=cell->_trees.end();
++itr)
@@ -1097,7 +880,7 @@ osg::Node* ForestTechniqueManager::createShaderGraph(Cell* cell,osg::StateSet* s
geode->setStateSet(stateset);
geode->addDrawable(shader_geometry);
}
if (needGroup)
{
group = new osg::Group;
@@ -1107,9 +890,9 @@ osg::Node* ForestTechniqueManager::createShaderGraph(Cell* cell,osg::StateSet* s
{
group->addChild(createShaderGraph(itr->get(),stateset));
}
if (geode) group->addChild(geode);
}
if (group) return group;
else return geode;
@@ -1118,14 +901,14 @@ osg::Node* ForestTechniqueManager::createShaderGraph(Cell* cell,osg::StateSet* s
osg::Node* ForestTechniqueManager::createHUDWithText(const std::string& str)
{
osg::Geode* geode = new osg::Geode();
std::string timesFont("fonts/arial.ttf");
// turn lighting off for the text and disable depth test to ensure its always ontop.
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
// or disable depth test, and make sure that the hud is drawn after everything
// or disable depth test, and make sure that the hud is drawn after everything
// else so that it always appears ontop.
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
stateset->setRenderBinDetails(11,"RenderBin");
@@ -1140,11 +923,11 @@ osg::Node* ForestTechniqueManager::createHUDWithText(const std::string& str)
text->setFont(timesFont);
text->setPosition(position);
text->setText(str);
position += delta;
}
}
// create the hud.
osg::MatrixTransform* modelview_abs = new osg::MatrixTransform;
modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
@@ -1158,7 +941,7 @@ osg::Node* ForestTechniqueManager::createHUDWithText(const std::string& str)
return projection;
}
osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, unsigned int maxNumTreesPerCell)
osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates)
{
osg::Vec3 origin(0.0f,0.0f,0.0f);
osg::Vec3 size(1000.0f,1000.0f,200.0f);
@@ -1166,26 +949,26 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
std::cout<<"Creating terrain...";
osg::ref_ptr<osg::Node> terrain = createTerrain(origin,size);
std::cout<<"done."<<std::endl;
std::cout<<"Creating tree locations...";std::cout.flush();
TreeList trees;
createTreeList(terrain.get(),origin,size,numTreesToCreates,trees);
std::cout<<"done."<<std::endl;
std::cout<<"Creating cell subdivision...";
osg::ref_ptr<Cell> cell = new Cell;
cell->addTrees(trees);
cell->divide(maxNumTreesPerCell);
std::cout<<"done."<<std::endl;
cell->divide();
std::cout<<"done."<<std::endl;
osg::Texture2D *tex = new osg::Texture2D;
tex->setWrap( osg::Texture2D::WRAP_S, osg::Texture2D::CLAMP );
tex->setWrap( osg::Texture2D::WRAP_T, osg::Texture2D::CLAMP );
tex->setImage(osgDB::readImageFile("Images/tree0.rgba"));
osg::StateSet *dstate = new osg::StateSet;
{
{
dstate->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON );
dstate->setTextureAttribute(0, new osg::TexEnv );
@@ -1200,7 +983,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
dstate->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
}
_techniqueSwitch = new osg::Switch;
@@ -1208,11 +991,11 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
std::cout<<"Creating osg::Billboard based forest...";
osg::Group* group = new osg::Group;
group->addChild(createBillboardGraph(cell.get(),dstate));
group->addChild(createHUDWithText("Using osg::Billboard's to create a forest\n\nPress left cursor key to select geometry instancing with Texture Buffer Object\nPress right cursor key to select double quad based forest"));
group->addChild(createHUDWithText("Using osg::Billboard's to create a forest\n\nPress left cursor key to select OpenGL shader based forest\nPress right cursor key to select double quad based forest"));
_techniqueSwitch->addChild(group);
std::cout<<"done."<<std::endl;
}
{
std::cout<<"Creating double quad based forest...";
osg::Group* group = new osg::Group;
@@ -1242,7 +1025,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
std::ostringstream vp_oss;
vp_oss <<
"!!ARBvp1.0\n"
"ATTRIB vpos = vertex.position;\n"
"ATTRIB vcol = vertex.color;\n"
"ATTRIB tc = vertex.texcoord[" << 0 << "];"
@@ -1251,8 +1034,8 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
"PARAM one = { 1.0, 1.0, 1.0, 1.0 };"
"TEMP position;\n"
// vec3 position = gl_Vertex.xyz * gl_Color.w + gl_Color.xyz;
// vec3 position = gl_Vertex.xyz * gl_Color.w + gl_Color.xyz;
"MAD position, vpos, vcol.w, vcol;\n"
// gl_Position = gl_ModelViewProjectionMatrix * vec4(position,1.0);
@@ -1265,7 +1048,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
// gl_FrontColor = vec4(1.0,1.0,1.0,1.0);
"MOV result.color.front.primary, one;\n"
// texcoord = gl_MultiTexCoord0.st;
// texcoord = gl_MultiTexCoord0.st;
"MOV result.texcoord, tc;\n"
"END\n";
@@ -1304,10 +1087,10 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
#if 1
// use inline shaders
///////////////////////////////////////////////////////////////////
// vertex shader using just Vec4 coefficients
char vertexShaderSource[] =
char vertexShaderSource[] =
"varying vec2 texcoord;\n"
"\n"
"void main(void)\n"
@@ -1321,7 +1104,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
//////////////////////////////////////////////////////////////////
// fragment shader
//
char fragmentShaderSource[] =
char fragmentShaderSource[] =
"uniform sampler2D baseTexture; \n"
"varying vec2 texcoord; \n"
"\n"
@@ -1335,7 +1118,7 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource);
program->addShader(fragment_shader);
#else
// get shaders from source
@@ -1349,99 +1132,17 @@ osg::Node* ForestTechniqueManager::createScene(unsigned int numTreesToCreates, u
}
group->addChild(createShaderGraph(cell.get(),stateset));
group->addChild(createHUDWithText("Using OpenGL Shader to create a forest\n\nPress left cursor key to select osg::Vertex/FragmentProgram based forest\nPress right cursor key to select osg::Vertex/Geometry/FragmentProgram based forest"));
group->addChild(createHUDWithText("Using OpenGL Shader to create a forest\n\nPress left cursor key to select osg::Vertex/FragmentProgram based forest\nPress right cursor key to select osg::Billboard based forest"));
_techniqueSwitch->addChild(group);
std::cout<<"done."<<std::endl;
}
{
std::cout<<"Creating Geometry Shader based forest...";
osg::StateSet* stateset = new osg::StateSet(*dstate, osg::CopyOp::DEEP_COPY_ALL);
osg::Group* group = new osg::Group;
group->addChild(createGeometryShaderGraph(cell.get(), stateset));
group->addChild(createHUDWithText("Using osg::Vertex/Geometry/FragmentProgram to create a forest\n\nPress left cursor key to select OpenGL Shader based forest\nPress right cursor key to select geometry instancing with Texture Buffer Object"));
_techniqueSwitch->addChild(group);
std::cout<<"done."<<std::endl;
}
{
std::cout<<"Creating forest using geometry instancing and texture buffer objects ...";
osg::StateSet* stateset = new osg::StateSet(*dstate, osg::CopyOp::DEEP_COPY_ALL);
{
osg::Program* program = new osg::Program;
stateset->setAttribute(program);
char vertexShaderSource[] =
"#version 420 compatibility\n"
"uniform samplerBuffer dataBuffer;\n"
"layout(location = 0) in vec3 VertexPosition;\n"
"layout(location = 8) in vec3 VertexTexCoord;\n"
"out vec2 TexCoord;\n"
"out vec4 Color;\n"
"void main()\n"
"{\n"
" int instanceAddress = gl_InstanceID * 3;\n"
" vec3 position = texelFetch(dataBuffer, instanceAddress).xyz;\n"
" Color = texelFetch(dataBuffer, instanceAddress + 1);\n"
" vec2 size = texelFetch(dataBuffer, instanceAddress + 2).xy;\n"
" mat4 mvpMatrix = gl_ModelViewProjectionMatrix *\n"
" mat4( size.x, 0.0, 0.0, 0.0,\n"
" 0.0, size.x, 0.0, 0.0,\n"
" 0.0, 0.0, size.y, 0.0,\n"
" position.x, position.y, position.z, 1.0);\n"
" gl_Position = mvpMatrix * vec4(VertexPosition,1.0) ;\n"
" TexCoord = VertexTexCoord.xy;\n"
"}\n";
char fragmentShaderSource[] =
"#version 420 core\n"
"uniform sampler2D baseTexture; \n"
"in vec2 TexCoord;\n"
"in vec4 Color;\n"
"layout(location = 0, index = 0) out vec4 FragData0;\n"
"void main(void) \n"
"{\n"
" FragData0 = Color*texture(baseTexture, TexCoord);\n"
"}\n";
osg::Shader* vertex_shader = new osg::Shader(osg::Shader::VERTEX, vertexShaderSource);
program->addShader(vertex_shader);
osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource);
program->addShader(fragment_shader);
osg::Uniform* baseTextureSampler = new osg::Uniform("baseTexture",0);
stateset->addUniform(baseTextureSampler);
osg::Uniform* dataBufferSampler = new osg::Uniform("dataBuffer",1);
stateset->addUniform(dataBufferSampler);
}
osg::ref_ptr<osg::Geometry> templateGeometry = createOrthogonalQuadsNoColor(osg::Vec3(0.0f,0.0f,0.0f),1.0f,1.0f);
templateGeometry->setUseVertexBufferObjects(true);
templateGeometry->setUseDisplayList(false);
osg::Node* textureBufferGraph = createTextureBufferGraph(cell.get(), templateGeometry.get());
textureBufferGraph->setStateSet( stateset );
osg::Group* group = new osg::Group;
group->addChild(textureBufferGraph);
group->addChild(createHUDWithText("Using geometry instancing to create a forest\n\nPress left cursor key to select osg::Vertex/Geometry/FragmentProgram based forest\nPress right cursor key to select osg::Billboard based forest"));
_techniqueSwitch->addChild(group);
std::cout<<"done."<<std::endl;
}
_currentTechnique = 0;
_techniqueSwitch->setSingleChildOn(_currentTechnique);
osg::Group* scene = new osg::Group;
scene->addChild(terrain.get());
scene->addChild(_techniqueSwitch.get());
@@ -1453,19 +1154,15 @@ int main( int argc, char **argv )
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// construct the viewer.
osgViewer::Viewer viewer(arguments);
unsigned int numTreesToCreate = 10000;
arguments.read("--trees",numTreesToCreate);
unsigned int maxNumTreesPerCell = sqrtf(static_cast<float>(numTreesToCreate));
arguments.read("--trees-per-cell",maxNumTreesPerCell);
float numTreesToCreates = 10000;
arguments.read("--trees",numTreesToCreates);
osg::ref_ptr<ForestTechniqueManager> ttm = new ForestTechniqueManager;
// add the stats handler
viewer.addEventHandler(new osgViewer::StatsHandler);
@@ -1473,7 +1170,7 @@ int main( int argc, char **argv )
viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
// add model to viewer.
viewer.setSceneData( ttm->createScene(numTreesToCreate, maxNumTreesPerCell) );
viewer.setSceneData( ttm->createScene((unsigned int)numTreesToCreates) );
return viewer.run();

View File

@@ -1,11 +0,0 @@
SET(TARGET_SRC
CameraPathProperty.cpp
CameraProperty.cpp
CaptureSettings.cpp
EventProperty.cpp
osgframerenderer.cpp
UpdateProperty.cpp
)
#### end var setup ###
SETUP_EXAMPLE(osgframerenderer)

View File

@@ -1,88 +0,0 @@
#include "CameraPathProperty.h"
using namespace gsc;
void CameraPathProperty::update(osgViewer::View* view)
{
osg::Camera* camera = view->getCamera();
osg::FrameStamp* fs = view->getFrameStamp();
if (_animationPath.valid())
{
osg::AnimationPath::ControlPoint cp;
_animationPath->getInterpolatedControlPoint( fs->getSimulationTime(), cp );
OSG_NOTICE<<"CameraPathProperty "<<fs->getFrameNumber()<<" "<<fs->getSimulationTime()<<std::endl;
osg::Matrixd matrix;
cp.getMatrix( matrix );
camera->setViewMatrix( osg::Matrix::inverse(matrix) );
}
}
void CameraPathProperty::loadAnimationPath()
{
_animationPath = new osg::AnimationPath;;
//_animationPath->setLoopMode(osg::AnimationPath::LOOP);
osgDB::ifstream in(_filename.c_str());
if (!in)
{
OSG_WARN << "CameraPathProperty: Cannot open animation path file \"" << _filename << "\".\n";
return;
}
_animationPath->read(in);
}
bool CameraPathProperty::getTimeRange(double& startTime, double& endTime) const
{
if (!_animationPath) return false;
const osg::AnimationPath::TimeControlPointMap& tcpm = _animationPath->getTimeControlPointMap();
if (tcpm.empty()) return false;
startTime = tcpm.begin()->first;
endTime = tcpm.rbegin()->first;
return true;
}
void CameraPathProperty::resetTimeRange(double startTime, double endTime)
{
if (!_animationPath) return;
osg::AnimationPath::TimeControlPointMap& tcpm = _animationPath->getTimeControlPointMap();
if (tcpm.empty()) return;
osg::AnimationPath::TimeControlPointMap copy_tcpm = tcpm;
double offset = tcpm.begin()->first;
double originalLength = tcpm.rbegin()->first - tcpm.begin()->first ;
double scale = originalLength>0.0 ? (endTime-startTime)/originalLength : 1.0;
tcpm.clear();
for(osg::AnimationPath::TimeControlPointMap::iterator itr = copy_tcpm.begin();
itr != copy_tcpm.end();
++itr)
{
tcpm[startTime + (itr->first-offset)*scale] = itr->second;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// Serialization support
//
REGISTER_OBJECT_WRAPPER( gsc_CameraPathProperty,
new gsc::CameraPathProperty,
gsc::CameraPathProperty,
"osg::Object gsc::CameraPathProperty" )
{
ADD_STRING_SERIALIZER( AnimationPathFileName, "" );
}

View File

@@ -1,46 +0,0 @@
#ifndef CAMERAPATHPROPERTY_H
#define CAMERAPATHPROPERTY_H
#include <osg/AnimationPath>
#include "UpdateProperty.h"
namespace gsc
{
class CameraPathProperty : public gsc::UpdateProperty
{
public:
CameraPathProperty() {}
CameraPathProperty(const std::string& filename) { setAnimationPathFileName(filename); }
CameraPathProperty(const CameraPathProperty& cpp, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {}
META_Object(gsc, CameraPathProperty);
void setAnimationPathFileName(const std::string& filename) { _filename = filename; loadAnimationPath(); }
const std::string& getAnimationPathFileName() const { return _filename; }
void setAnimationPath(osg::AnimationPath* ap) { _animationPath = ap; }
osg::AnimationPath* getAnimationPath() { return _animationPath.get(); }
const osg::AnimationPath* getAnimationPath() const { return _animationPath.get(); }
bool getTimeRange(double& startTime, double& endTime) const;
void resetTimeRange(double startTime, double endTime);
virtual void update(osgViewer::View* view);
protected:
virtual ~CameraPathProperty() {}
void loadAnimationPath();
std::string _filename;
osg::ref_ptr<osg::AnimationPath> _animationPath;
};
}
#endif

View File

@@ -1,81 +0,0 @@
#include "CameraProperty.h"
using namespace gsc;
void CameraProperty::setToModel(const osg::Node* node)
{
osg::BoundingSphere bs = node->getBound();
double dist = osg::DisplaySettings::instance()->getScreenDistance();
OSG_NOTICE<<"Node name "<<node->getName()<<std::endl;
#if 1
if (node->getName().find("Presentation")==std::string::npos)
{
double screenWidth = osg::DisplaySettings::instance()->getScreenWidth();
double screenHeight = osg::DisplaySettings::instance()->getScreenHeight();
double screenDistance = osg::DisplaySettings::instance()->getScreenDistance();
double vfov = atan2(screenHeight/2.0,screenDistance)*2.0;
double hfov = atan2(screenWidth/2.0,screenDistance)*2.0;
double viewAngle = vfov<hfov ? vfov : hfov;
dist = bs.radius() / sin(viewAngle*0.5);
}
#endif
_center = bs.center();
_eye = _center - osg::Vec3d(0.0, dist, 0.0);
_up = osg::Vec3d(0.0, 0.0, 1.0);
_rotationCenter = _center;
_rotationAxis = osg::Vec3d(0.0, 0.0, 1.0);
_rotationSpeed = 0.0;
}
void CameraProperty::update(osgViewer::View* view)
{
osg::Camera* camera = view->getCamera();
osg::FrameStamp* fs = view->getFrameStamp();
osg::Matrixd matrix;
matrix.makeLookAt(_eye, _center, _up);
if (_rotationSpeed!=0.0)
{
matrix.preMult(osg::Matrixd::translate(-_rotationCenter) *
osg::Matrix::rotate(osg::DegreesToRadians(_rotationSpeed*fs->getSimulationTime()), _rotationAxis) *
osg::Matrixd::translate(_rotationCenter));
}
camera->setViewMatrix( matrix );
// set the fusion distance up so that the left and right eye images are co-incedent on the image plane at the center of ration.
view->setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE,(_center-_eye).length());
// view->setFusionDistance(osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE, 1.0);
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// Serialization support
//
REGISTER_OBJECT_WRAPPER( gsc_CameraProperty,
new gsc::CameraProperty,
gsc::CameraProperty,
"osg::Object gsc::CameraProperty" )
{
ADD_VEC3D_SERIALIZER( Center, osg::Vec3d(0.0,0.0,0.0) );
ADD_VEC3D_SERIALIZER( EyePoint, osg::Vec3d(0.0,-1.0,0.0) );
ADD_VEC3D_SERIALIZER( UpVector, osg::Vec3d(0.0,0.0,1.0) );
ADD_VEC3D_SERIALIZER( RotationCenter, osg::Vec3d(0.0,0.0,0.0) );
ADD_VEC3D_SERIALIZER( RotationAxis, osg::Vec3d(0.0,0.0,1.0) );
ADD_DOUBLE_SERIALIZER( RotationSpeed, 0.0 );
}

View File

@@ -1,72 +0,0 @@
#ifndef CAMERAPROPERTY_H
#define CAMERAPROPERTY_H
#include <osg/AnimationPath>
#include "UpdateProperty.h"
namespace gsc
{
class CameraProperty : public gsc::UpdateProperty
{
public:
CameraProperty():
_center(0.0,0.0,0.0),
_eye(0.0,-1.0,0.0),
_up(0.0,0.0,1.0),
_rotationCenter(0.0,0.0,0.0),
_rotationAxis(0.0,0.0,1.0),
_rotationSpeed(0.0) {}
CameraProperty(const CameraProperty& cp, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
_center(cp._center),
_eye(cp._eye),
_up(cp._up),
_rotationCenter(cp._rotationCenter),
_rotationAxis(cp._rotationAxis),
_rotationSpeed(cp._rotationSpeed)
{}
META_Object(gsc, CameraProperty);
void setToModel(const osg::Node* node);
void setCenter(const osg::Vec3d& center) { _center = center; }
const osg::Vec3d& getCenter() const { return _center; }
void setEyePoint(const osg::Vec3d& eye) { _eye = eye; }
const osg::Vec3d& getEyePoint() const { return _eye; }
void setUpVector(const osg::Vec3d& up) { _up = up; }
const osg::Vec3d& getUpVector() const { return _up; }
void setRotationCenter(const osg::Vec3d& center) { _rotationCenter = center; }
const osg::Vec3d& getRotationCenter() const { return _rotationCenter; }
void setRotationAxis(const osg::Vec3d& axis) { _rotationAxis = axis; }
const osg::Vec3d& getRotationAxis() const { return _rotationAxis; }
void setRotationSpeed(double speed) { _rotationSpeed = speed; }
double getRotationSpeed() const { return _rotationSpeed; }
virtual void update(osgViewer::View* view);
protected:
virtual ~CameraProperty() {}
osg::Vec3d _center;
osg::Vec3d _eye;
osg::Vec3d _up;
osg::Vec3d _rotationCenter;
osg::Vec3d _rotationAxis;
double _rotationSpeed;
};
}
#endif

View File

@@ -1,187 +0,0 @@
#include "CaptureSettings.h"
using namespace gsc;
CaptureSettings::CaptureSettings():
_stereoMode(OFF),
_offscreen(false),
_outputImageFlip(false),
_width(1024),
_height(512),
_screenWidth(0.0),
_screenHeight(0.0),
_screenDistance(0.0),
_samples(0),
_sampleBuffers(0),
_frameRate(60.0),
_numberOfFrames(0.0)
{
}
CaptureSettings::CaptureSettings(const CaptureSettings& cs, const osg::CopyOp& copyop):
osg::Object(cs, copyop),
_inputFileName(cs._inputFileName),
_outputFileName(cs._outputFileName),
_outputDirectoryName(cs._outputDirectoryName),
_outputBaseFileName(cs._outputBaseFileName),
_outputExtension(cs._outputExtension),
_stereoMode(cs._stereoMode),
_offscreen(cs._offscreen),
_outputImageFlip(cs._outputImageFlip),
_width(cs._width),
_height(cs._height),
_screenWidth(cs._screenWidth),
_screenHeight(cs._screenHeight),
_screenDistance(cs._screenDistance),
_samples(cs._samples),
_sampleBuffers(cs._sampleBuffers),
_frameRate(cs._frameRate),
_numberOfFrames(cs._numberOfFrames),
_eventHandlers(cs._eventHandlers),
_properties(cs._properties)
{
}
void CaptureSettings::setOutputFileName(const std::string& filename)
{
_outputFileName = filename;
_outputDirectoryName = osgDB::getFilePath(filename);
if (!_outputDirectoryName.empty()) _outputDirectoryName += osgDB::getNativePathSeparator();
_outputBaseFileName = osgDB::getStrippedName(filename);
_outputExtension = osgDB::getFileExtensionIncludingDot(filename);
}
const std::string& CaptureSettings::getOutputFileName() const
{
return _outputFileName;
}
std::string CaptureSettings::getOutputFileName(unsigned int frameNumber) const
{
std::stringstream str;
str<<_outputDirectoryName<<_outputBaseFileName<<"_"<<frameNumber<<_outputExtension;
return str.str();
}
std::string CaptureSettings::getOutputFileName(unsigned int cameraNum, unsigned int frameNumber) const
{
std::stringstream str;
str<<_outputDirectoryName<<_outputBaseFileName<<"_"<<cameraNum<<"_"<<frameNumber<<_outputExtension;
return str.str();
}
bool CaptureSettings::valid() const
{
return _numberOfFrames>0 && !_outputBaseFileName.empty() && !_outputExtension.empty() && !_inputFileName.empty();
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// Serialization support
//
static bool checkEventHandlers( const gsc::CaptureSettings& cs )
{
return !cs.getEventHandlers().empty();
}
static bool readEventHandlers( osgDB::InputStream& is, gsc::CaptureSettings& cs )
{
unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
osg::ref_ptr<osg::Object> obj = is.readObject();
gsc::UpdateProperty* up = dynamic_cast<gsc::UpdateProperty*>( obj.get() );
if ( up ) cs.addUpdateProperty( up );
}
is >> is.END_BRACKET;
return true;
}
static bool writeEventHandlers( osgDB::OutputStream& os, const gsc::CaptureSettings& cs )
{
const gsc::CaptureSettings::EventHandlers& pl = cs.getEventHandlers();
unsigned int size = pl.size();
os << size << os.BEGIN_BRACKET << std::endl;
for ( unsigned int i=0; i<size; ++i )
{
os << pl[i].get();
}
os << os.END_BRACKET << std::endl;
return true;
}
static bool checkProperties( const gsc::CaptureSettings& cs )
{
return !cs.getProperties().empty();
}
static bool readProperties( osgDB::InputStream& is, gsc::CaptureSettings& cs )
{
unsigned int size = 0; is >> size >> is.BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
osg::ref_ptr<osg::Object> obj = is.readObject();
gsc::UpdateProperty* up = dynamic_cast<gsc::UpdateProperty*>( obj.get() );
if ( up ) cs.addUpdateProperty( up );
}
is >> is.END_BRACKET;
return true;
}
static bool writeProperties( osgDB::OutputStream& os, const gsc::CaptureSettings& cs )
{
const gsc::CaptureSettings::Properties& pl = cs.getProperties();
unsigned int size = pl.size();
os << size << os.BEGIN_BRACKET << std::endl;
for ( unsigned int i=0; i<size; ++i )
{
os << pl[i].get();
}
os << os.END_BRACKET << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( gsc_CaptureSettings,
new gsc::CaptureSettings,
gsc::CaptureSettings,
"osg::Object gsc::CaptureSettings" )
{
ADD_STRING_SERIALIZER( InputFileName, "" );
ADD_STRING_SERIALIZER( OutputFileName, "" );
ADD_DOUBLE_SERIALIZER( FrameRate, 60.0 );
BEGIN_ENUM_SERIALIZER( StereoMode, OFF );
ADD_ENUM_VALUE( OFF );
ADD_ENUM_VALUE( HORIZONTAL_SPLIT );
ADD_ENUM_VALUE( VERTICAL_SPLIT );
END_ENUM_SERIALIZER();
ADD_BOOL_SERIALIZER( Offscreen, false );
ADD_BOOL_SERIALIZER( OutputImageFlip, false );
ADD_UINT_SERIALIZER( Width, 1024 );
ADD_UINT_SERIALIZER( Height, 512 );
ADD_FLOAT_SERIALIZER( ScreenWidth, 0.0 );
ADD_FLOAT_SERIALIZER( ScreenHeight, 0.0 );
ADD_FLOAT_SERIALIZER( ScreenDistance, 0.0 );
BEGIN_ENUM_SERIALIZER( PixelFormat, RGB );
ADD_ENUM_VALUE( RGB );
ADD_ENUM_VALUE( RGBA );
END_ENUM_SERIALIZER();
ADD_UINT_SERIALIZER( Samples, 0 );
ADD_UINT_SERIALIZER( SampleBuffers, 0 );
ADD_UINT_SERIALIZER( NumberOfFrames, 0 );
ADD_USER_SERIALIZER( EventHandlers );
ADD_USER_SERIALIZER( Properties );
}

View File

@@ -1,148 +0,0 @@
#ifndef CAPTURESETTINGS_H
#define CAPTURESETTINGS_H
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/WriteFile>
#include <osgViewer/Viewer>
#include <osg/AnimationPath>
#include "UpdateProperty.h"
namespace gsc
{
class CaptureSettings : public osg::Object
{
public:
CaptureSettings();
CaptureSettings(const CaptureSettings& cs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(gsc, CaptureSettings);
void setInputFileName(const std::string& filename) { _inputFileName = filename; }
const std::string& getInputFileName() const { return _inputFileName; }
void setOutputFileName(const std::string& filename);
const std::string& getOutputFileName() const;
std::string getOutputFileName(unsigned int frameNumber) const;
std::string getOutputFileName(unsigned int cameraNumber, unsigned int frameNumber) const;
enum StereoMode
{
OFF,
HORIZONTAL_SPLIT,
VERTICAL_SPLIT
};
void setStereoMode(StereoMode mode) { _stereoMode = mode; }
StereoMode getStereoMode() const { return _stereoMode; }
void setOffscreen(bool o) { _offscreen = o; }
bool getOffscreen() const { return _offscreen; }
void setOutputImageFlip(bool flip) { _outputImageFlip = flip; }
bool getOutputImageFlip() const { return _outputImageFlip; }
void setWidth(unsigned int width) { _width = width; }
unsigned int getWidth() const { return _width; }
void setHeight(unsigned int height) { _height = height; }
unsigned int getHeight() const { return _height; }
void setScreenWidth(float width) { _screenWidth = width; }
float getScreenWidth() const { return _screenWidth; }
void setScreenHeight(float height) { _screenHeight = height; }
float getScreenHeight() const { return _screenHeight; }
void setScreenDistance(float distance) { _screenDistance = distance; }
float getScreenDistance() const { return _screenDistance; }
enum PixelFormat
{
RGB,
RGBA
};
void setPixelFormat(PixelFormat format) { _pixelFormat = format; }
PixelFormat getPixelFormat() const { return _pixelFormat; }
void setSamples(unsigned int s) { _samples = s; }
unsigned int getSamples() const { return _samples; }
void setSampleBuffers(unsigned int s) { _sampleBuffers = s; }
unsigned int getSampleBuffers() const { return _sampleBuffers; }
void setFrameRate(double fr) { _frameRate = fr; }
double getFrameRate() const { return _frameRate; }
void setNumberOfFrames(unsigned int nf) { _numberOfFrames = nf; }
unsigned int getNumberOfFrames() const { return _numberOfFrames; }
typedef std::vector< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlers;
void setEventHandlers(const EventHandlers& eh);
EventHandlers& getEventHandlers() { return _eventHandlers; }
const EventHandlers& getEventHandlers() const { return _eventHandlers; }
typedef std::vector< osg::ref_ptr<UpdateProperty> > Properties;
void addUpdateProperty(UpdateProperty* up) { _properties.push_back(up); }
void setProperties(const Properties& pl) { _properties = pl; }
Properties& getProperties() { return _properties; }
const Properties& getProperties() const { return _properties; }
template<typename T>
T* getPropertyOfType()
{
for(Properties::iterator itr = _properties.begin();
itr != _properties.end();
++itr)
{
T* p = dynamic_cast<T*>(itr->get());
if (p) return p;
}
return 0;
}
bool valid() const;
protected:
virtual ~CaptureSettings() {}
std::string _inputFileName;
std::string _outputFileName;
std::string _outputDirectoryName;
std::string _outputBaseFileName;
std::string _outputExtension;
StereoMode _stereoMode;
bool _offscreen;
bool _outputImageFlip;
unsigned int _width;
unsigned int _height;
float _screenWidth;
float _screenHeight;
float _screenDistance;
PixelFormat _pixelFormat;
unsigned int _samples;
unsigned int _sampleBuffers;
double _frameRate;
unsigned int _numberOfFrames;
EventHandlers _eventHandlers;
Properties _properties;
};
}
#endif

View File

@@ -1,41 +0,0 @@
#include "EventProperty.h"
namespace gsc
{
void EventProperty::update(osgViewer::View* view)
{
if (view && view->getEventQueue() && _event.valid())
{
view->getEventQueue()->addEvent(_event.get());
}
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// Serialization support
//
REGISTER_OBJECT_WRAPPER( gsc_EventProperty,
new gsc::EventProperty,
gsc::EventProperty,
"osg::Object gsc::EventProperty" )
{
ADD_OBJECT_SERIALIZER( Event, osgGA::GUIEventAdapter, NULL );
}
}
namespace osgGA
{
namespace B
{
}
}

View File

@@ -1,38 +0,0 @@
#ifndef EVENTPROPERTY_H
#define EVENTPROPERTY_H
#include <osgGA/GUIEventAdapter>
#include "UpdateProperty.h"
namespace gsc
{
class EventProperty : public gsc::UpdateProperty
{
public:
EventProperty() {}
EventProperty(osgGA::GUIEventAdapter* event):_event(event) {}
EventProperty(const EventProperty& cpp, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {}
META_Object(gsc, EventProperty);
void setEvent(osgGA::GUIEventAdapter* ea) { _event = ea; }
osgGA::GUIEventAdapter* getEvent() { return _event.get(); }
const osgGA::GUIEventAdapter* getEvent() const { return _event.get(); }
virtual void update(osgViewer::View* view);
protected:
virtual ~EventProperty() {}
double _previousFrameTime;
osg::ref_ptr<osgGA::GUIEventAdapter> _event;
};
}
#endif

View File

@@ -1,4 +0,0 @@
#include "UpdateProperty.h"
using namespace gsc;

View File

@@ -1,32 +0,0 @@
#ifndef UPDATEPROPERTY_H
#define UPDATEPROPERTY_H
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/WriteFile>
#include <osgViewer/Viewer>
#include <osg/AnimationPath>
namespace gsc
{
class UpdateProperty : public osg::Object
{
public:
UpdateProperty() {}
UpdateProperty(const UpdateProperty& up, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {}
META_Object(gsc, UpdateProperty);
virtual void update(osgViewer::View* view) {}
protected:
virtual ~UpdateProperty() {}
};
}
#endif

View File

@@ -1,559 +0,0 @@
#include <osgDB/ReadFile>
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgDB/WriteFile>
#include <osgViewer/Viewer>
#include <osg/AnimationPath>
#include "UpdateProperty.h"
#include "CameraProperty.h"
#include "CameraPathProperty.h"
#include "EventProperty.h"
#include "CaptureSettings.h"
#include <osgGA/StateSetManipulator>
struct ScreenShot : public osg::Camera::DrawCallback
{
ScreenShot(GLenum pixelFormat, bool flip):
_pixelFormat(pixelFormat),
_flip(flip) {}
virtual void operator () (osg::RenderInfo& renderInfo) const
{
if (!_frameCapture)
{
OSG_NOTICE<<"No FrameCamera assigned"<<std::endl;
return;
}
unsigned int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber();
CameraNumMap::const_iterator itr = _cameraNumMap.find(renderInfo.getCurrentCamera());
std::string outputFileName = (itr!=_cameraNumMap.end()) ?
_frameCapture->getOutputFileName(itr->second, frameNumber) :
_frameCapture->getOutputFileName(frameNumber);
OSG_NOTICE<<"outputFileName="<<outputFileName<<std::endl;
osg::Camera* camera = renderInfo.getCurrentCamera();
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
if (viewport)
{
OSG_NOTICE<<"Doing read of ="<<viewport->x()<<", "<<viewport->y()<<", "<<viewport->width()<<", "<<viewport->height()<<" with pixelFormat=0x"<<std::hex<<_pixelFormat<<std::dec<<std::endl;
glReadBuffer(camera->getDrawBuffer());
osg::ref_ptr<osg::Image> image = new osg::Image;
image->readPixels(viewport->x(),viewport->y(),viewport->width(),viewport->height(),
_pixelFormat, GL_UNSIGNED_BYTE, 1);
if (_flip) image->flipVertical();
osgDB::writeImageFile(*image, outputFileName);
}
}
typedef std::map<const osg::Camera*, unsigned int> CameraNumMap;
GLenum _pixelFormat;
bool _flip;
osg::ref_ptr<gsc::CaptureSettings> _frameCapture;
CameraNumMap _cameraNumMap;
};
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of 3D textures.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options]");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-i <filename>","Input scene (or presentation) filename.");
arguments.getApplicationUsage()->addCommandLineOption("-o <filename>","Base ouput filename of the images, recommended to use something like Images/image.png");
arguments.getApplicationUsage()->addCommandLineOption("--cs <filename>","Load pre-generated configuration file for run.");
arguments.getApplicationUsage()->addCommandLineOption("--ouput-cs <filename>","Output configuration file with settings provided on commandline.");
arguments.getApplicationUsage()->addCommandLineOption("-p <filename>","Use specificied camera path file to control camera position.");
arguments.getApplicationUsage()->addCommandLineOption("--offscreen","Use an pbuffer to render the images offscreen.");
arguments.getApplicationUsage()->addCommandLineOption("--screen","Use an window to render the images.");
arguments.getApplicationUsage()->addCommandLineOption("--width <width>","Window/output image width.");
arguments.getApplicationUsage()->addCommandLineOption("--height <height>","Window/output image height.");
arguments.getApplicationUsage()->addCommandLineOption("--screen-distance <distance>","Set the distance of the viewer from the physical screen.");
arguments.getApplicationUsage()->addCommandLineOption("--screen-width <width>","Set the width of the physical screen.");
arguments.getApplicationUsage()->addCommandLineOption("--screen-height <height>","Set the height of the physical screen.");
arguments.getApplicationUsage()->addCommandLineOption("--ms <s>","Number of multi-samples to use when rendering, an enable a single sample buffer.");
arguments.getApplicationUsage()->addCommandLineOption("--samples <s>","Number of multi-samples to use when rendering.");
arguments.getApplicationUsage()->addCommandLineOption("--sampleBuffers <sb>","Number of sample buffers to use when rendering.");
arguments.getApplicationUsage()->addCommandLineOption("-f <fps>","Number of frames per second in simulation time.");
arguments.getApplicationUsage()->addCommandLineOption("-n <frames>","Number of frames to render/images to create.");
arguments.getApplicationUsage()->addCommandLineOption("-d <time>","Duration of rendering run (duration = frames/fps).");
arguments.getApplicationUsage()->addCommandLineOption("--center <x> <y> <z>","View center.");
arguments.getApplicationUsage()->addCommandLineOption("--eye <x> <y> <z>","Camera eye point.");
arguments.getApplicationUsage()->addCommandLineOption("--up <x> <y> <z>","Camera up vector.");
arguments.getApplicationUsage()->addCommandLineOption("--rotation-center <x> <y> <z>","Position to rotatate around.");
arguments.getApplicationUsage()->addCommandLineOption("--rotation-axis <x> <y> <z>","Axis to rotate around.");
arguments.getApplicationUsage()->addCommandLineOption("--rotation-speed <v>","Degrees per second.");
arguments.getApplicationUsage()->addCommandLineOption("--stereo <mode>","OFF | HORIZONTAL_SPLIT | VERTICAL_SPLIT");
unsigned int helpType = 0;
if ((helpType = arguments.readHelpType()))
{
arguments.getApplicationUsage()->write(std::cout, helpType);
return 1;
}
osgViewer::Viewer viewer;
typedef std::list< osg::ref_ptr<gsc::CaptureSettings> > CaptureSettingsList;
CaptureSettingsList frameCaptureList;
osg::ref_ptr<gsc::CaptureSettings> fc = new gsc::CaptureSettings;
double duration = 0.0;
double fps = 0.0f;
unsigned int nframes = 0;
bool readCaptureSettings = false;
std::string filename;
if (arguments.read("--cs",filename))
{
osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(filename);
gsc::CaptureSettings* input_cs = dynamic_cast<gsc::CaptureSettings*>(object.get());
if (input_cs) { fc = input_cs; readCaptureSettings = true; }
else
{
OSG_NOTICE<<"Unable to read CaptureSettings from file: "<<filename<<std::endl;
if (object.valid()) OSG_NOTICE<<"Object read, "<<object.get()<<", className()="<<object->className()<<std::endl;
return 1;
}
}
float screenWidth = fc->getScreenWidth()!=0.0 ? fc->getScreenWidth() : osg::DisplaySettings::instance()->getScreenWidth();
if (arguments.read("--screen-width",screenWidth)) {}
float screenHeight = fc->getScreenHeight()!=0.0 ? fc->getScreenHeight() : osg::DisplaySettings::instance()->getScreenHeight();
if (arguments.read("--screen-height",screenHeight)) {}
float screenDistance = fc->getScreenDistance()!=0.0 ? fc->getScreenDistance() : osg::DisplaySettings::instance()->getScreenDistance();
if (arguments.read("--screen-distance",screenDistance)) {}
fc->setScreenWidth(screenWidth);
osg::DisplaySettings::instance()->setScreenWidth(screenWidth);
fc->setScreenHeight(screenHeight);
osg::DisplaySettings::instance()->setScreenHeight(screenHeight);
fc->setScreenDistance(screenDistance);
osg::DisplaySettings::instance()->setScreenDistance(screenDistance);
bool useScreenSizeForProjectionMatrix = true;
if (arguments.read("-i",filename)) fc->setInputFileName(filename);
if (arguments.read("-o",filename)) fc->setOutputFileName(filename);
if (arguments.read("-p",filename))
{
osg::ref_ptr<gsc::CameraPathProperty> cpp = new gsc::CameraPathProperty;
cpp->setAnimationPathFileName(filename);
double startTime = 0, endTime = 1.0f;
if (cpp->getTimeRange(startTime, endTime))
{
OSG_NOTICE<<"Camera path time range "<<startTime<<", "<<endTime<<std::endl;
if (startTime!=0.0)
{
cpp->resetTimeRange(0.0, endTime-startTime);
if (cpp->getTimeRange(startTime, endTime))
{
OSG_NOTICE<<" new time range "<<startTime<<", "<<endTime<<std::endl;
}
else
{
OSG_NOTICE<<" failed to set new time range "<<startTime<<", "<<endTime<<std::endl;
}
}
duration = endTime;
}
else
{
OSG_NOTICE<<"Camera path time range "<<startTime<<", "<<endTime<<std::endl;
}
fc->addUpdateProperty(cpp.get());
}
else
{
osg::ref_ptr<gsc::CameraProperty> cp = fc->getPropertyOfType<gsc::CameraProperty>();
bool newCameraProperty = false;
bool valueSet = false;
if (!cp)
{
newCameraProperty = true;
cp = new gsc::CameraProperty;
osg::ref_ptr<osg::Node> node = fc->getInputFileName().empty() ? 0 : osgDB::readNodeFile(fc->getInputFileName());
if (node.valid())
{
cp->setToModel(node.get());
valueSet = true;
}
}
osg::Vec3d vec;
while (arguments.read("--center",vec.x(), vec.y(), vec.z())) { cp->setCenter(vec); valueSet = true; }
while (arguments.read("--eye",vec.x(), vec.y(), vec.z())) { cp->setEyePoint(vec); valueSet = true; }
while (arguments.read("--up",vec.x(), vec.y(), vec.z())) { cp->setUpVector(vec); valueSet = true; }
while (arguments.read("--rotation-center",vec.x(), vec.y(), vec.z())) { cp->setRotationCenter(vec); valueSet = true; }
while (arguments.read("--rotation-axis",vec.x(), vec.y(), vec.z())) { cp->setRotationAxis(vec); valueSet = true; }
double speed;
while (arguments.read("--rotation-speed",speed)) { cp->setRotationSpeed(speed); valueSet = true; }
if (newCameraProperty && valueSet)
{
fc->addUpdateProperty(cp.get());
}
}
std::string stereoMode;
if (arguments.read("--stereo", stereoMode))
{
if (stereoMode=="HORIZONTAL_SPLIT") fc->setStereoMode(gsc::CaptureSettings::HORIZONTAL_SPLIT);
else if (stereoMode=="VERTICAL_SPLIT") fc->setStereoMode(gsc::CaptureSettings::VERTICAL_SPLIT);
else if (stereoMode=="OFF") fc->setStereoMode(gsc::CaptureSettings::OFF);
}
if (arguments.read("--offscreen")) fc->setOffscreen(true);
if (arguments.read("--screen")) fc->setOffscreen(false);
if (arguments.read("--flip")) fc->setOutputImageFlip(true);
if (arguments.read("--no-flip")) fc->setOutputImageFlip(false);
unsigned int width = 1024;
if (arguments.read("--width",width)) fc->setWidth(width);
unsigned int height = 512;
if (arguments.read("--height",height)) fc->setHeight(height);
if (arguments.read("--rgb")) fc->setPixelFormat(gsc::CaptureSettings::RGB);
if (arguments.read("--rgba")) fc->setPixelFormat(gsc::CaptureSettings::RGBA);
osg::Vec4 clearColor(0.0f,0.0f,0.0f,0.0f);
while (arguments.read("--clear-color",clearColor[0],clearColor[1],clearColor[2],clearColor[3])) {}
unsigned int samples = 0;
if (arguments.read("--samples",samples)) fc->setSamples(samples);
unsigned int sampleBuffers = 0;
if (arguments.read("--sampleBuffers",sampleBuffers)) fc->setSampleBuffers(sampleBuffers);
unsigned int ms = 0;
if (arguments.read("--ms",ms))
{
fc->setSamples(ms);
fc->setSampleBuffers(1);
}
if (arguments.read("-f",fps)) fc->setFrameRate(fps);
if (arguments.read("-n",nframes)) fc->setNumberOfFrames(nframes);
if (arguments.read("-d",duration)) {}
std::string key;
double time;
while(arguments.read("--key-down",time, key) && key.size()>=1)
{
OSG_NOTICE<<"keydown "<<key<<", "<<time<<std::endl;
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter;
event->setTime(time);
event->setEventType(osgGA::GUIEventAdapter::KEYDOWN);
event->setKey(key[0]);
fc->addUpdateProperty(new gsc::EventProperty(event.get()));
}
while(arguments.read("--key-up",time, key) && key.size()>=1)
{
OSG_NOTICE<<"keyup "<<key<<", "<<time<<std::endl;
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter;
event->setTime(time);
event->setEventType(osgGA::GUIEventAdapter::KEYUP);
event->setKey(key[0]);
fc->addUpdateProperty(new gsc::EventProperty(event.get()));
}
double mouse_x, mouse_y;
while(arguments.read("--mouse-move",time, mouse_x, mouse_y))
{
OSG_NOTICE<<"mouse move "<<time<<", "<<mouse_x<<", "<<mouse_y<<std::endl;
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter;
event->setTime(time);
event->setEventType(osgGA::GUIEventAdapter::MOVE);
event->setX(mouse_x);
event->setY(mouse_y);
fc->addUpdateProperty(new gsc::EventProperty(event.get()));
}
while(arguments.read("--mouse-drag",time, mouse_x, mouse_y))
{
OSG_NOTICE<<"mouse drag "<<time<<", "<<mouse_x<<", "<<mouse_y<<std::endl;
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter;
event->setTime(time);
event->setEventType(osgGA::GUIEventAdapter::DRAG);
event->setX(mouse_x);
event->setY(mouse_y);
fc->addUpdateProperty(new gsc::EventProperty(event.get()));
}
if (!readCaptureSettings)
{
if (duration!=0.0)
{
if (fps!=0.0) nframes = static_cast<unsigned int>(ceil(duration*fps));
else if (nframes!=0) fps = duration/static_cast<double>(nframes);
else
{
fps = 60.0;
nframes = static_cast<unsigned int>(ceil(duration/fps));
}
}
else // duration == 0.0
{
if (fps==0.0) fps=60.0;
if (nframes==0) nframes=1;
duration = static_cast<double>(nframes)/fps;
}
fc->setNumberOfFrames(nframes);
fc->setFrameRate(fps);
OSG_NOTICE<<"Duration="<<duration<<", FPS="<<fps<<", Number of Frames="<<nframes<<std::endl;
}
if (arguments.read("--output-cs",filename))
{
osgDB::writeObjectFile(*fc, filename);
return 1;
}
if (fc.valid())
{
frameCaptureList.push_back(fc);
}
if (frameCaptureList.empty())
{
OSG_NOTICE<<"No settings provided"<<std::endl;
return 1;
}
// setup viewer
{
osg::ref_ptr<osg::DisplaySettings> ds = new osg::DisplaySettings;
bool stereo = fc->getStereoMode()!=gsc::CaptureSettings::OFF;
osg::DisplaySettings::StereoMode stereoMode = fc->getStereoMode()==gsc::CaptureSettings::VERTICAL_SPLIT ? osg::DisplaySettings::VERTICAL_SPLIT : osg::DisplaySettings::HORIZONTAL_SPLIT;
double fovx_multiple = fc->getStereoMode()==gsc::CaptureSettings::HORIZONTAL_SPLIT ? 2.0 : 1;
double fovy_multiple = fc->getStereoMode()==gsc::CaptureSettings::VERTICAL_SPLIT ? 2.0 : 1;
ds->setStereoMode(stereoMode);
ds->setStereo(stereo);
if (fc->getScreenWidth()!=0.0) ds->setScreenWidth(fc->getScreenWidth());
if (fc->getScreenHeight()!=0.0) ds->setScreenHeight(fc->getScreenHeight());
if (fc->getScreenDistance()!=0.0) ds->setScreenDistance(fc->getScreenDistance());
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds.get());
traits->readDISPLAY();
if (traits->displayNum<0) traits->displayNum = 0;
traits->x = 0;
traits->y = 0;
traits->width = fc->getWidth();
traits->height = fc->getHeight();
traits->alpha = (fc->getPixelFormat() == gsc::CaptureSettings::RGBA) ? 8 : 0;
traits->samples = fc->getSamples();
traits->sampleBuffers = fc->getSampleBuffers();
traits->windowDecoration = !(fc->getOffscreen());
traits->doubleBuffer = true;
traits->sharedContext = 0;
traits->pbuffer = fc->getOffscreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc)
{
OSG_NOTICE<<"Failed to created requested graphics context"<<std::endl;
return 1;
}
viewer.getCamera()->setClearColor(clearColor);
viewer.getCamera()->setGraphicsContext(gc.get());
viewer.getCamera()->setDisplaySettings(ds.get());
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get());
if (gw)
{
OSG_INFO<<"GraphicsWindow has been created successfully."<<std::endl;
gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, fc->getWidth(), fc->getHeight());
}
else
{
OSG_NOTICE<<"PixelBuffer has been created succseffully "<<traits->width<<", "<<traits->height<<std::endl;
}
if (useScreenSizeForProjectionMatrix)
{
OSG_NOTICE<<"Setting projection matrix"<<std::endl;
double vfov = osg::RadiansToDegrees(atan2(screenHeight/2.0f,screenDistance)*2.0);
// double hfov = osg::RadiansToDegrees(atan2(width/2.0f,distance)*2.0);
viewer.getCamera()->setProjectionMatrixAsPerspective( vfov*fovy_multiple, (screenWidth/screenHeight)*fovx_multiple, 0.1, 1000.0);
OSG_NOTICE<<"setProjectionMatrixAsPerspective( "<<vfov*fovy_multiple<<", "<<(screenWidth/screenHeight)*fovx_multiple<<", "<<0.1<<", "<<1000.0<<");"<<std::endl;
}
else
{
double fovy, aspectRatio, zNear, zFar;
viewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar);
double newAspectRatio = double(traits->width) / double(traits->height);
double aspectRatioChange = newAspectRatio / aspectRatio;
if (aspectRatioChange != 1.0)
{
viewer.getCamera()->getProjectionMatrix() *= osg::Matrix::scale(fovx_multiple/aspectRatioChange,fovy_multiple,1.0);
}
}
// set up stereo masks
viewer.getCamera()->setCullMask(0xffffffff);
viewer.getCamera()->setCullMaskLeft(0x00000001);
viewer.getCamera()->setCullMaskRight(0x00000002);
viewer.getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
viewer.getCamera()->setDrawBuffer(buffer);
viewer.getCamera()->setReadBuffer(buffer);
}
std::string outputPath = osgDB::getFilePath(fc->getOutputFileName());
if (!outputPath.empty())
{
osgDB::FileType type = osgDB::fileType(outputPath);
switch(type)
{
case(osgDB::FILE_NOT_FOUND):
if (!osgDB::makeDirectory(outputPath))
{
OSG_NOTICE<<"Error: could not create directory ["<<outputPath<<"]."<<std::endl;
return 1;
}
OSG_NOTICE<<"Created directory ["<<outputPath<<"]."<<std::endl;
break;
case(osgDB::REGULAR_FILE):
OSG_NOTICE<<"Error: filepath for output files is regular file, not a directory as required."<<std::endl;
return 1;
case(osgDB::DIRECTORY):
OSG_NOTICE<<"Valid path["<<outputPath<<"] provided for output files."<<std::endl;
break;
}
}
GLenum pixelFormat = (fc->getPixelFormat()==gsc::CaptureSettings::RGBA) ? GL_RGBA : GL_RGB;
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
viewer.realize();
// set up screen shot
osg::ref_ptr<ScreenShot> screenShot = new ScreenShot(pixelFormat, fc->getOutputImageFlip());;
{
osgViewer::Viewer::Cameras cameras;
viewer.getCameras(cameras);
if (cameras.size()>1)
{
unsigned int cameraNum = 0;
for(osgViewer::Viewer::Cameras::iterator itr = cameras.begin();
itr != cameras.end();
++itr, ++cameraNum)
{
osg::Camera* camera = *itr;
camera->setFinalDrawCallback(screenShot.get());
screenShot->_cameraNumMap[camera] = cameraNum;
}
}
else if (cameras.size()==1)
{
osg::Camera* camera = cameras.front();
camera->setFinalDrawCallback(screenShot.get());
}
else
{
OSG_NOTICE<<"No usable Cameras created."<<std::endl;
return 1;
}
}
for(CaptureSettingsList::iterator itr = frameCaptureList.begin();
itr != frameCaptureList.end();
++itr)
{
gsc::CaptureSettings* fc = itr->get();
screenShot->_frameCapture = fc;
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(fc->getInputFileName());
if (!model) break;
viewer.setSceneData(model.get());
double simulationTime = 0.0;
for(unsigned int i=0; i<fc->getNumberOfFrames(); ++i)
{
OSG_NOTICE<<"fc.getOutputFileName("<<i<<")="<<fc->getOutputFileName(i)<<std::endl;
viewer.advance(simulationTime);
gsc::CaptureSettings::Properties& pl = fc->getProperties();
for(gsc::CaptureSettings::Properties::iterator plitr = pl.begin();
plitr != pl.end();
++plitr)
{
(*plitr)->update(&viewer);
}
viewer.eventTraversal();
viewer.updateTraversal();
viewer.renderingTraversals();
// advance simulationTime and number of frames rendered
simulationTime += 1.0/fc->getFrameRate();
}
}
osg::ref_ptr<osg::Object> object = new osgGA::StateSetManipulator;
osg::ref_ptr<osgGA::StateSetManipulator> ss = dynamic_cast<osgGA::StateSetManipulator*>(object.get());
return 0;
}

View File

@@ -23,7 +23,7 @@
namespace osgfxbrowser {
Frame::Frame()
: osg::Geode(),
: osg::Geode(),
bgcolor_(0.5f, 0.5f, 0.5f, 1.0f),
rect_(0, 0, 100, 100),
caption_("Frame")
@@ -108,7 +108,8 @@ osg::Geometry *Frame::build_quad(const Rect &rect, const osg::Vec4 &color, bool
clr->push_back(osg::Vec4(black, 0));
}
geo->setColorArray(clr.get(), osg::Array::BIND_PER_VERTEX);
geo->setColorArray(clr.get());
geo->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
geo->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, shadow? 12: 4));

View File

@@ -27,10 +27,10 @@ ProcessPass::ProcessPass(osg::TextureRectangle *in_tex,
_TextureHeight(height)
{
_RootGroup = new osg::Group;
_InTexture = in_tex;
_OutTexture = out_tex;
_Camera = new osg::Camera;
setupCamera();
_Camera->addChild(createTexturedQuad().get());
@@ -47,7 +47,7 @@ ProcessPass::~ProcessPass()
osg::ref_ptr<osg::Group> ProcessPass::createTexturedQuad()
{
osg::ref_ptr<osg::Group> top_group = new osg::Group;
osg::ref_ptr<osg::Geode> quad_geode = new osg::Geode;
osg::ref_ptr<osg::Vec3Array> quad_coords = new osg::Vec3Array; // vertex coords
@@ -72,18 +72,19 @@ osg::ref_ptr<osg::Group> ProcessPass::createTexturedQuad()
quad_geom->setVertexArray(quad_coords.get());
quad_geom->setTexCoordArray(0, quad_tcoords.get());
quad_geom->addPrimitiveSet(quad_da.get());
quad_geom->setColorArray(quad_colors.get(), osg::Array::BIND_OVERALL);
quad_geom->setColorArray(quad_colors.get());
quad_geom->setColorBinding(osg::Geometry::BIND_OVERALL);
_StateSet = quad_geom->getOrCreateStateSet();
_StateSet->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
_StateSet->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
_StateSet->setTextureAttributeAndModes(0, _InTexture.get(), osg::StateAttribute::ON);
_StateSet->addUniform(new osg::Uniform("textureIn", 0));
quad_geode->addDrawable(quad_geom.get());
top_group->addChild(quad_geode.get());
return top_group;
@@ -93,7 +94,7 @@ void ProcessPass::setupCamera()
{
// clearing
_Camera->setClearMask(GL_DEPTH_BUFFER_BIT);
// projection and view
_Camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));
_Camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
@@ -117,7 +118,7 @@ void ProcessPass::setShader(std::string filename)
return;
}
osg::ref_ptr<osg::Shader> fshader = new osg::Shader( osg::Shader::FRAGMENT );
osg::ref_ptr<osg::Shader> fshader = new osg::Shader( osg::Shader::FRAGMENT );
fshader->loadShaderSourceFromFile(foundFile);
_FragmentProgram = 0;
@@ -134,7 +135,7 @@ GameOfLifePass::GameOfLifePass(osg::Image *in_image)
{
_TextureWidth = in_image->s();
_TextureHeight = in_image->t();
_RootGroup = new osg::Group;
_BranchSwith[0] = new osg::Switch;
@@ -148,11 +149,11 @@ GameOfLifePass::GameOfLifePass(osg::Image *in_image)
createOutputTextures();
_InOutTextureLife[0]->setImage(in_image);
_ProcessPass[0] = new ProcessPass(_InOutTextureLife[0].get(),
_InOutTextureLife[1].get(),
_TextureWidth, _TextureHeight);
// For the other pass, the input/output textures are flipped
_ProcessPass[1] = new ProcessPass(_InOutTextureLife[1].get(),
_InOutTextureLife[0].get(),
@@ -193,7 +194,7 @@ void GameOfLifePass::createOutputTextures()
{
for (int i=0; i<2; i++) {
_InOutTextureLife[i] = new osg::TextureRectangle;
_InOutTextureLife[i]->setTextureSize(_TextureWidth, _TextureHeight);
_InOutTextureLife[i]->setInternalFormat(GL_RGBA);
_InOutTextureLife[i]->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST);

View File

@@ -46,10 +46,10 @@ osg::Node* createScene(osg::Image *start_im)
// create quad to display image on
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
// each geom will contain a quad
osg::ref_ptr<osg::DrawArrays> da = new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4);
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
@@ -58,7 +58,7 @@ osg::Node* createScene(osg::Image *start_im)
tcoords->push_back(osg::Vec2(width, 0));
tcoords->push_back(osg::Vec2(width, height));
tcoords->push_back(osg::Vec2(0, height));
osg::ref_ptr<osg::Vec3Array> vcoords = new osg::Vec3Array; // vertex coords
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
@@ -67,24 +67,25 @@ osg::Node* createScene(osg::Image *start_im)
vcoords->push_back(osg::Vec3d(width, 0, 0));
vcoords->push_back(osg::Vec3d(width, 0, height));
vcoords->push_back(osg::Vec3d(0, 0, height));
geom->setVertexArray(vcoords.get());
geom->setTexCoordArray(0,tcoords.get());
geom->addPrimitiveSet(da.get());
geom->setColorArray(colors.get(), osg::Array::BIND_OVERALL);
geom->setColorArray(colors.get());
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geomss = geom->getOrCreateStateSet();
geomss->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
geode->addDrawable(geom.get());
topnode->addChild(geode.get());
// create the ping pong processing passes
golpass = new GameOfLifePass(start_im);
topnode->addChild(golpass->getRoot().get());
// attach the output of the processing to the geom
geomss->setTextureAttributeAndModes(0,
geomss->setTextureAttributeAndModes(0,
golpass->getOutputTexture().get(),
osg::StateAttribute::ON);
return topnode;
@@ -118,14 +119,14 @@ int main(int argc, char *argv[])
// load the image
osg::ref_ptr<osg::Image> startIm = osgDB::readImageFile(startName);
if (!startIm) {
std::cout << "Could not load start image.\n";
return(1);
}
osg::Node* scene = createScene(startIm.get());
// construct the viewer.
osgViewer::Viewer viewer;
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
@@ -144,7 +145,7 @@ int main(int argc, char *argv[])
// flip the textures after we've completed a frame
golpass->flip();
// attach the proper output to view
geomss->setTextureAttributeAndModes(0,
geomss->setTextureAttributeAndModes(0,
golpass->getOutputTexture().get(),
osg::StateAttribute::ON);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osggeodemo.cpp )
SET(TARGET_ADDED_LIBRARIES osgGA )
#### end var setup ###
SETUP_EXAMPLE(osggeodemo)

View File

@@ -0,0 +1,152 @@
// Geo demo written by Geoff Michel, November 2002.
/* OpenSceneGraph example, osggeodemo.
*
* 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 <stdio.h>
#include <osgViewer/Viewer>
#include <osg/Node>
#include <osg/Notify>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgDB/WriteFile>
#include <osgDB/FileUtils>
#include <osgDB/FileNameUtils>
#include <osgUtil/Optimizer>
#include <iostream>
// currently not a satisfactory solution, but this is early days for the
// geo loader and having direct links with it.
#include "../../src/osgPlugins/geo/osgGeoAnimation.h"
//== event trapper gets events
class geodemoEventHandler : public osgGA::GUIEventHandler
{
public:
geodemoEventHandler( ) { mouse_x=mouse_y=0;}
virtual ~geodemoEventHandler( ) {}
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
{
mouse_x=ea.getX();
mouse_y=ea.getY();
return false;
}
inline float getMouseX(void) {return mouse_x;};
inline float getMouseY(void) {return mouse_y;};
private:
float mouse_x, mouse_y;
};
static geodemoEventHandler *ghand=NULL;
inline double DEG2RAD(const double val) { return val*0.0174532925199432957692369076848861;}
inline double RAD2DEG(const double val) { return val*57.2957795130823208767981548141052;}
double dodynamics(const double /*time*/, const double val, const std::string name)
{ // Each local variable named 'name' declared in the geo modeller is passed into here.
// its current value is val; returns new value. Time - elapsed time
static double heading,speed; // these are only required for my 'dynamics'
if (name == "xpos") {
return (val+speed*sin(heading));
// std::cout << " nx " << (*itr->getValue()) ;
} else if (name == "ypos") {
return (val+speed*cos(heading));
// std::cout << " ny " << (*itr->getValue()) ;
} else if (name == "sped") {
speed=(0.00025*(ghand->getMouseY()-300)); // (*itr->getValue());
return (speed);
} else if (name == "heading") {
heading-= 0.01*DEG2RAD(ghand->getMouseX()-400); // =DEG2RAD(*itr->getValue());
return (RAD2DEG(heading));
} else if (name == "conerot") {
return ((ghand->getMouseX()-400));
} else if (name == "planrot") {
return ((ghand->getMouseY()-300)/200.0);
} else if (name == "secint" || name == "minutehand"|| name == "hourhand") {
// std::cout << " updating " << name << " " << val << std::endl;
}
return val;
}
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// construct the viewer.
osgViewer::Viewer viewer;
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode)
{
osg::notify(osg::NOTICE)<<"Please specify a geo model filename on the command line."<<std::endl;
return 1;
}
// run optimization over the scene graph
osgUtil::Optimizer optimzer;
optimzer.optimize(rootnode);
// add a viewport to the viewer and attach the scene graph.
viewer.setSceneData( rootnode );
geoHeader *gh = dynamic_cast<geoHeader *>(rootnode);
if (gh)
{ // it is a geo file, so set function to update its animation variables.
ghand=new geodemoEventHandler();
gh->setUserUpdate(dodynamics);
viewer.addEventHandler(ghand);
}
else
{ // maybe a group with geo models below.
osg::Group *gpall=dynamic_cast<osg::Group *>(rootnode);
if (gpall)
{
int nchild=gpall->getNumChildren();
for (int i=0; i<nchild; i++)
{
osg::Node *nod=gpall->getChild(i);
gh = dynamic_cast<geoHeader *>(nod);
if (gh)
{
ghand=new geodemoEventHandler();
gh->setUserUpdate(dodynamics);
viewer.addEventHandler(ghand);
}
}
}
}
return viewer.run();
}

View File

@@ -37,11 +37,10 @@
#include <iostream>
// This demo illustrates how to create the various different types of geometry that
// the osg::Geometry class can represent. This demo uses the OpenGL red book diagram of different
// OpenGL Primitives as a template for all the equivalent OpenSceneGraph Primitives. The OpenSceneGraph
// wraps OpenGL very thinly and therefore uses all the same enum and naming conventions. The coordinate data is also
// the osg::Geometry class can represent. This demo uses the OpenGL red book diagram of different
// OpenGL Primitives as a template for all the equivalent OpenSceneGraph Primitives. The OpenSceneGraph
// wraps OpenGL very thinly and therefore uses all the same enum and naming conventions. The coordinate data is also
// wrapped around OpenGL's vertex arrays and draw arrays/elements calls. Familiarity with
// OpenGL will help you understand the osg::Geometry class which encapsulate all this, or if you
// havn't learned OpenGL yet, learning osg::Geometry will help you understand how OpenGL
@@ -51,7 +50,7 @@
// a draw method for drawing objects in the scene. osg::Geometry contains all the vertex, normal
// color and texture coordinate arrays required to specify the coordinates of your objects, and the
// primitives join these coordinates together as the points, lines or surfaces that you will see
// rendered on your screen.
// rendered on your screen.
//
// This demo is split into two functions, the createScene() function which creates the scene graph
// with the various primitives in it, and the main() which sets up a basic viewer window and
@@ -60,7 +59,7 @@
struct NormalPrint
{
void operator() (const osg::Vec3& v1,const osg::Vec3& v2,const osg::Vec3& v3, bool) const
void operator() (const osg::Vec3& v1,const osg::Vec3& v2,const osg::Vec3& v3, bool) const
{
osg::Vec3 normal = (v2-v1)^(v3-v2);
normal.normalize();
@@ -72,10 +71,10 @@ struct NormalPrint
void printTriangles(const std::string& name, osg::Drawable& drawable)
{
std::cout<<name<<std::endl;
osg::TriangleFunctor<NormalPrint> tf;
drawable.accept(tf);
std::cout<<std::endl;
}
@@ -94,9 +93,9 @@ osg::Node* createScene()
{
// create Geometry object to store all the vertices and points primitive.
osg::Geometry* pointsGeom = new osg::Geometry();
// create a Vec3Array and add to it all my coordinates.
// Like all the *Array variants (see include/osg/Array) , Vec3Array is derived from both osg::Array
// Like all the *Array variants (see include/osg/Array) , Vec3Array is derived from both osg::Array
// and std::vector<>. osg::Array's are reference counted and hence sharable,
// which std::vector<> provides all the convenience, flexibility and robustness
// of the most popular of all STL containers.
@@ -106,28 +105,30 @@ osg::Node* createScene()
vertices->push_back(osg::Vec3(-0.873376, 9.18133e-09, 0.832179));
vertices->push_back(osg::Vec3(-0.836299, -2.15188e-09, 0.885735));
vertices->push_back(osg::Vec3(-0.790982, 9.18133e-09, 0.959889));
// pass the created vertex array to the points geometry object.
pointsGeom->setVertexArray(vertices);
// create the color of the geometry, one single for the whole geometry.
// for consistency of design even one single color must added as an element
// in a color array.
osg::Vec4Array* colors = new osg::Vec4Array;
// add a white color, colors take the form r,g,b,a with 0.0 off, 1.0 full on.
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
// pass the color array to points geometry, note the binding to tell the geometry
// that only use one color for the whole object.
pointsGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
pointsGeom->setColorArray(colors);
pointsGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// set the normal in the same way color.
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
pointsGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
pointsGeom->setNormalArray(normals);
pointsGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
// create and add a DrawArray Primitive (see include/osg/Primitive). The first
@@ -136,8 +137,8 @@ osg::Node* createScene()
// parameter is the index position into the vertex array of the first point
// to draw, and the third parameter is the number of points to draw.
pointsGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS,0,vertices->size()));
// add the points geometry to the geode.
geode->addDrawable(pointsGeom);
}
@@ -146,7 +147,7 @@ osg::Node* createScene()
{
// create Geometry object to store all the vertices and lines primitive.
osg::Geometry* linesGeom = new osg::Geometry();
// this time we'll preallocate the vertex array to the size we
// need and then simple set them as array elements, 8 points
// makes 4 line segments.
@@ -160,37 +161,39 @@ osg::Node* createScene()
(*vertices)[6].set(-1.07936, 9.18133e-09, 0.317217);
(*vertices)[7].set(-0.700348, 9.18133e-09, 0.362533);
// pass the created vertex array to the points geometry object.
linesGeom->setVertexArray(vertices);
// set the colors as before, plus using the above
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
linesGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
linesGeom->setColorArray(colors);
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// set the normal in the same way color.
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
linesGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
linesGeom->setNormalArray(normals);
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
// This time we simply use primitive, and hardwire the number of coords to use
// This time we simply use primitive, and hardwire the number of coords to use
// since we know up front,
linesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,8));
// add the points geometry to the geode.
geode->addDrawable(linesGeom);
}
// create LINE_STRIP
{
// create Geometry object to store all the vertices and lines primitive.
osg::Geometry* linesGeom = new osg::Geometry();
// this time we'll preallocate the vertex array to the size
// this time we'll preallocate the vertex array to the size
// and then use an iterator to fill in the values, a bit perverse
// but does demonstrate that we have just a standard std::vector underneath.
osg::Vec3Array* vertices = new osg::Vec3Array(5);
@@ -200,27 +203,29 @@ osg::Node* createScene()
(vitr++)->set(0.164788, -2.15188e-09, 0.366653);
(vitr++)->set(-0.0288379, -2.15188e-09, 0.333695);
(vitr++)->set(-0.0453167, -2.15188e-09, 0.280139);
// pass the created vertex array to the points geometry object.
linesGeom->setVertexArray(vertices);
// set the colors as before, plus using the above
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
linesGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
linesGeom->setColorArray(colors);
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// set the normal in the same way color.
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
linesGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
linesGeom->setNormalArray(normals);
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
// This time we simply use primitive, and hardwire the number of coords to use
// This time we simply use primitive, and hardwire the number of coords to use
// since we know up front,
linesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,5));
// add the points geometry to the geode.
geode->addDrawable(linesGeom);
}
@@ -229,9 +234,9 @@ osg::Node* createScene()
{
// create Geometry object to store all the vertices and lines primitive.
osg::Geometry* linesGeom = new osg::Geometry();
// this time we'll a C arrays to initialize the vertices.
osg::Vec3 myCoords[] =
{
osg::Vec3(0.741546, -2.15188e-09, 0.453167),
@@ -241,31 +246,33 @@ osg::Node* createScene()
osg::Vec3(0.968129, -2.15188e-09, 0.337815),
osg::Vec3(0.869256, -2.15188e-09, 0.531441)
};
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
// pass the created vertex array to the points geometry object.
linesGeom->setVertexArray(vertices);
// set the colors as before, plus using the above
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
linesGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
linesGeom->setColorArray(colors);
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// set the normal in the same way color.
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
linesGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
linesGeom->setNormalArray(normals);
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
// This time we simply use primitive, and hardwire the number of coords to use
// This time we simply use primitive, and hardwire the number of coords to use
// since we know up front,
linesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,numCoords));
// add the points geometry to the geode.
geode->addDrawable(linesGeom);
}
@@ -293,17 +300,17 @@ osg::Node* createScene()
// According to the OpenGL diagram vertices should be specified in a clockwise direction.
// In reality you need to specify coords for polygons in a anticlockwise direction
// for their front face to be pointing towards you; get this wrong and you could
// find back face culling removing the wrong faces of your models. The OpenGL diagram
// find back face culling removing the wrong faces of your models. The OpenGL diagram
// is just plain wrong, but it's a nice diagram so we'll keep it for now!
// create POLYGON
{
// create Geometry object to store all the vertices and lines primitive.
osg::Geometry* polyGeom = new osg::Geometry();
// this time we'll use C arrays to initialize the vertices.
// note, anticlockwise ordering.
// note II, OpenGL polygons must be convex, planar polygons, otherwise
// note II, OpenGL polygons must be convex, planar polygons, otherwise
// undefined results will occur. If you have concave polygons or ones
// that cross over themselves then use the osgUtil::Tessellator to fix
// the polygons into a set of valid polygons.
@@ -315,28 +322,30 @@ osg::Node* createScene()
osg::Vec3(-0.766264, 0.0f, -0.0576758),
osg::Vec3(-0.980488, 0.0f, -0.094753)
};
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
// pass the created vertex array to the points geometry object.
polyGeom->setVertexArray(vertices);
// use the shared color array.
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
polyGeom->setColorArray(shared_colors.get());
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// use the shared normal array.
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
polyGeom->setNormalArray(shared_normals.get());
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
// This time we simply use primitive, and hardwire the number of coords to use
// This time we simply use primitive, and hardwire the number of coords to use
// since we know up front,
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,numCoords));
printTriangles("Polygon",*polyGeom);
// add the points geometry to the geode.
geode->addDrawable(polyGeom);
}
@@ -346,7 +355,7 @@ osg::Node* createScene()
{
// create Geometry object to store all the vertices and lines primitive.
osg::Geometry* polyGeom = new osg::Geometry();
// note, anticlockwise ordering.
osg::Vec3 myCoords[] =
{
@@ -360,27 +369,29 @@ osg::Node* createScene()
osg::Vec3(0.164788, 0.0f, -0.0453167),
osg::Vec3(0.13595, 0.0f, -0.255421)
};
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
// pass the created vertex array to the points geometry object.
polyGeom->setVertexArray(vertices);
// use the shared color array.
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
polyGeom->setColorArray(shared_colors.get());
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// use the shared normal array.
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
polyGeom->setNormalArray(shared_normals.get());
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
// This time we simply use primitive, and hardwire the number of coords to use
// This time we simply use primitive, and hardwire the number of coords to use
// since we know up front,
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,numCoords));
printTriangles("Quads",*polyGeom);
// add the points geometry to the geode.
@@ -391,7 +402,7 @@ osg::Node* createScene()
{
// create Geometry object to store all the vertices and lines primitive.
osg::Geometry* polyGeom = new osg::Geometry();
// note, first coord at top, second at bottom, reverse to that buggy OpenGL image..
osg::Vec3 myCoords[] =
{
@@ -407,27 +418,29 @@ osg::Node* createScene()
osg::Vec3(1.11232, -2.15188e-09, 0.0123591),
osg::Vec3(1.12468, 9.18133e-09, -0.164788),
};
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
// pass the created vertex array to the points geometry object.
polyGeom->setVertexArray(vertices);
// use the shared color array.
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
polyGeom->setColorArray(shared_colors.get());
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// use the shared normal array.
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
polyGeom->setNormalArray(shared_normals.get());
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
// This time we simply use primitive, and hardwire the number of coords to use
// This time we simply use primitive, and hardwire the number of coords to use
// since we know up front,
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,numCoords));
printTriangles("Quads strip",*polyGeom);
// add the points geometry to the geode.
@@ -438,7 +451,7 @@ osg::Node* createScene()
{
// create Geometry object to store all the vertices and lines primitive.
osg::Geometry* polyGeom = new osg::Geometry();
// note, first coord at top, second at bottom, reverse to that buggy OpenGL image..
osg::Vec3 myCoords[] =
{
@@ -454,7 +467,7 @@ osg::Node* createScene()
osg::Vec3(-1.067, 9.18133e-09, -0.609715),
// TRIANGLE STRIP 6 vertices, v6..v11
// note defined top point first,
// note defined top point first,
// then anticlockwise for the next two points,
// then alternating to bottom there after.
osg::Vec3(-0.160668, -2.15188e-09, -0.531441),
@@ -473,44 +486,46 @@ osg::Node* createScene()
osg::Vec3(0.840418, -2.15188e-09, -0.506723),
};
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
// pass the created vertex array to the points geometry object.
polyGeom->setVertexArray(vertices);
// use the shared color array.
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
polyGeom->setColorArray(shared_colors.get());
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// use the shared normal array.
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
polyGeom->setNormalArray(shared_normals.get());
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
// This time we simply use primitive, and hardwire the number of coords to use
// This time we simply use primitive, and hardwire the number of coords to use
// since we know up front,
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,6));
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,6,6));
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_FAN,12,5));
// polygon stipple
osg::StateSet* stateSet = new osg::StateSet();
polyGeom->setStateSet(stateSet);
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
osg::PolygonStipple* polygonStipple = new osg::PolygonStipple;
stateSet->setAttributeAndModes(polygonStipple,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
#endif
printTriangles("Triangles/Strip/Fan",*polyGeom);
// add the points geometry to the geode.
geode->addDrawable(polyGeom);
}
return geode;
return geode;
}
@@ -527,33 +542,33 @@ class MyTransformCallback : public osg::NodeCallback
virtual void operator() (osg::Node* node, osg::NodeVisitor* nv)
{
osg::MatrixTransform* transform = dynamic_cast<osg::MatrixTransform*>(node);
osg::MatrixTransform* transform = dynamic_cast<osg::MatrixTransform*>(node);
if (nv && transform && nv->getFrameStamp())
{
double time = nv->getFrameStamp()->getSimulationTime();
transform->setMatrix(osg::Matrix::translate(0.0f,1.0f+cosf(time*_angular_velocity),0.0f));
}
// must continue subgraph traversal.
traverse(node,nv);
traverse(node,nv);
}
protected:
float _angular_velocity;
};
osg::Node* createBackground()
{
{
// we'll create a texture mapped quad to sit behind the Geometry
// we'll create a texture mapped quad to sit behind the Geometry
osg::Image* image = osgDB::readImageFile("Images/primitives.gif");
if (!image) return NULL;
// create Geometry object to store all the vertices and lines primitive.
osg::Geometry* polyGeom = new osg::Geometry();
@@ -573,13 +588,15 @@ osg::Node* createBackground()
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
polyGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
polyGeom->setColorArray(colors);
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// set the normal in the same way color.
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
polyGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
polyGeom->setNormalArray(normals);
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
osg::Vec2 myTexCoords[] =
{
@@ -608,11 +625,11 @@ osg::Node* createBackground()
// There are three variants of the DrawElements osg::Primitive, UByteDrawElements which
// contains unsigned char indices, UShortDrawElements which contains unsigned short indices,
// and UIntDrawElements which contains ... unsigned int indices.
// The first parameter to DrawElements is
// and UIntDrawElements which contains ... unsigned int indices.
// The first parameter to DrawElements is
polyGeom->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP,numIndices,myIndices));
// new we need to add the texture to the Drawable, we do so by creating a
// new we need to add the texture to the Drawable, we do so by creating a
// StateSet to contain the Texture2D StateAttribute.
osg::StateSet* stateset = new osg::StateSet;
@@ -624,7 +641,7 @@ osg::Node* createBackground()
polyGeom->setStateSet(stateset);
// create the Geode (Geometry Node) to contain all our osg::Geometry objects.
osg::Geode* geode = new osg::Geode();
@@ -634,7 +651,7 @@ osg::Node* createBackground()
//return geode;
// create a transform to move the background back and forward with.
osg::MatrixTransform* transform = new osg::MatrixTransform();
transform->setUpdateCallback(new MyTransformCallback(1.0f));
transform->addChild(geode);

View File

@@ -141,7 +141,8 @@ public:
SomePoints()
{
osg::Vec4Array* cAry = new osg::Vec4Array;
setColorArray( cAry, osg::Array::BIND_OVERALL );
setColorArray( cAry );
setColorBinding( osg::Geometry::BIND_OVERALL );
cAry->push_back( osg::Vec4(1,1,1,1) );
osg::Vec3Array* vAry = new osg::Vec3Array;

View File

@@ -395,7 +395,8 @@ osg::Node* createTrackModel(Track* track, const osg::Vec4& colour)
osg::ref_ptr<osg::Vec4Array> colours = new osg::Vec4Array;
colours->push_back(colour);
geometry->setColorArray(colours.get(), osg::Array::BIND_OVERALL);
geometry->setColorArray(colours.get());
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP, 0, points.size()));

View File

@@ -44,7 +44,7 @@ Node *makeBase( void )
c = 0;
(*coords)[c].set(0.0f,0.0f,0.0f);
(*tcoords)[c].set(0.0f,0.0f);
for( i = 0; i <= 18; i++ )
{
theta = osg::DegreesToRadians((float)i * 20.0);
@@ -61,7 +61,8 @@ Node *makeBase( void )
geom->setTexCoordArray( 0, tcoords );
geom->setColorArray( colors, Array::BIND_OVERALL );
geom->setColorArray( colors );
geom->setColorBinding( Geometry::BIND_OVERALL );
geom->addPrimitiveSet( new DrawArrays(PrimitiveSet::TRIANGLE_FAN,0,19) );
@@ -80,7 +81,7 @@ Node *makeBase( void )
// clear the depth to the far plane.
osg::Depth* depth = new osg::Depth;
depth->setFunction(osg::Depth::ALWAYS);
depth->setRange(1.0,1.0);
depth->setRange(1.0,1.0);
dstate->setAttributeAndModes(depth,StateAttribute::ON );
dstate->setRenderBinDetails(-1,"RenderBin");

View File

@@ -58,8 +58,8 @@ Node *makeSky( void )
Vec3Array& coords = *(new Vec3Array(19*nlev));
Vec4Array& colors = *(new Vec4Array(19*nlev));
Vec2Array& tcoords = *(new Vec2Array(19*nlev));
int ci = 0;
for( i = 0; i < nlev; i++ )
@@ -104,11 +104,12 @@ Node *makeSky( void )
geom->addPrimitiveSet(drawElements);
}
geom->setVertexArray( &coords );
geom->setTexCoordArray( 0, &tcoords );
geom->setColorArray( &colors, Array::BIND_PER_VERTEX );
geom->setColorArray( &colors );
geom->setColorBinding( Geometry::BIND_PER_VERTEX );
Texture2D *tex = new Texture2D;
@@ -120,12 +121,12 @@ Node *makeSky( void )
dstate->setTextureAttribute(0, new TexEnv );
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
dstate->setMode( GL_CULL_FACE, StateAttribute::ON );
// clear the depth to the far plane.
osg::Depth* depth = new osg::Depth;
depth->setFunction(osg::Depth::ALWAYS);
depth->setRange(1.0,1.0);
depth->setRange(1.0,1.0);
dstate->setAttributeAndModes(depth,StateAttribute::ON );
dstate->setRenderBinDetails(-2,"RenderBin");

View File

@@ -94,19 +94,17 @@ Node *makeTerrain( void )
Vec3Array& v = *(new Vec3Array(m*n));
Vec2Array& t = *(new Vec2Array(m*n));
Vec4Array& col = *(new Vec4Array(1));
col[0][0] = col[0][1] = col[0][2] = col[0][3] = 1.0f;
for( i = 0; i < m * n; i++ )
{
float* vc = vertex[i];
v[i][0] = vc[0] - dbcenter[0];
v[i][1] = vc[1] - dbcenter[1];
v[i][2] = vc[2];
v[i][0] = vertex[i][0] - dbcenter[0];
v[i][1] = vertex[i][1] - dbcenter[1];
v[i][2] = vertex[i][2];
float* tc = texcoord[i];
t[i][0] = tc[0];
t[i][1] = tc[1];
t[i][0] = texcoord[i][0] + 0.025;
t[i][1] = texcoord[i][1];
}
Geometry *geom = new Geometry;
@@ -114,7 +112,8 @@ Node *makeTerrain( void )
geom->setVertexArray( &v );
geom->setTexCoordArray( 0, &t );
geom->setColorArray( &col, Array::BIND_OVERALL );
geom->setColorArray( &col );
geom->setColorBinding( Geometry::BIND_OVERALL );
for( i = 0; i < m-2; i++ )
{

View File

@@ -166,10 +166,10 @@ static Geometry *makeTree( _tree *tree, StateSet *dstate )
{
float vv[][3] =
{
{ -tree->w/2.0f, 0.0f, 0.0f },
{ tree->w/2.0f, 0.0f, 0.0f },
{ tree->w/2.0f, 0.0f, 2.0f * tree->h },
{ -tree->w/2.0f, 0.0f, 2.0f * tree->h },
{ -tree->w/2.0, 0.0, 0.0 },
{ tree->w/2.0, 0.0, 0.0 },
{ tree->w/2.0, 0.0, 2 * tree->h },
{ -tree->w/2.0, 0.0, 2 * tree->h },
};
Vec3Array& v = *(new Vec3Array(4));
@@ -198,7 +198,8 @@ static Geometry *makeTree( _tree *tree, StateSet *dstate )
geom->setTexCoordArray( 0, &t );
geom->setColorArray( &l, Array::BIND_OVERALL );
geom->setColorArray( &l );
geom->setColorBinding( Geometry::BIND_OVERALL );
geom->addPrimitiveSet( new DrawArrays(PrimitiveSet::QUADS,0,4) );
@@ -237,7 +238,7 @@ Node *makeTrees( void )
tex->setImage(osgDB::readImageFile("Images/tree0.rgba"));
StateSet *dstate = new StateSet;
dstate->setTextureAttributeAndModes(0, tex, StateAttribute::ON );
dstate->setTextureAttribute(0, new TexEnv );
@@ -248,7 +249,7 @@ Node *makeTrees( void )
dstate->setAttributeAndModes( alphaFunc, StateAttribute::ON );
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
dstate->setRenderingHint( StateSet::TRANSPARENT_BIN );
int tt[] = { 15, 30, 45, 58, 72, 75, 93, 96, 105, -1 };

View File

@@ -46,7 +46,7 @@ osg::Camera* createHUD()
// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
// set the view matrix
// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());
@@ -58,7 +58,7 @@ osg::Camera* createHUD()
// we don't want the camera to grab event focus from the viewers main camera(s).
camera->setAllowEventFocus(false);
// add to this camera a subgraph to render
@@ -84,7 +84,7 @@ osg::Camera* createHUD()
text->setText("Head Up Displays are simple :-)");
position += delta;
}
}
{
@@ -96,7 +96,7 @@ osg::Camera* createHUD()
text->setText("All you need to do is create your text in a subgraph.");
position += delta;
}
}
{
@@ -109,7 +109,7 @@ osg::Camera* createHUD()
"to create an orthographic projection.\n");
position += delta;
}
}
{
osgText::Text* text = new osgText::Text;
@@ -121,7 +121,7 @@ osg::Camera* createHUD()
"it remains independent from any external model view matrices.");
position += delta;
}
}
{
osgText::Text* text = new osgText::Text;
@@ -132,7 +132,7 @@ osg::Camera* createHUD()
text->setText("And set the Camera's clear mask to just clear the depth buffer.");
position += delta;
}
}
{
osgText::Text* text = new osgText::Text;
@@ -144,7 +144,7 @@ osg::Camera* createHUD()
"to make sure it's drawn last.");
position += delta;
}
}
{
@@ -166,11 +166,13 @@ osg::Camera* createHUD()
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
geom->setNormalArray(normals);
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0,0.8f,0.2f));
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));
@@ -194,14 +196,14 @@ struct SnapImage : public osg::Camera::DrawCallback
_filename(filename),
_snapImage(false)
{
_image = new osg::Image;
_image = new osg::Image;
}
virtual void operator () (osg::RenderInfo& renderInfo) const
{
if (!_snapImage) return;
osg::notify(osg::NOTICE)<<"Camera callback"<<std::endl;
osg::Camera* camera = renderInfo.getCurrentCamera();
@@ -215,10 +217,10 @@ struct SnapImage : public osg::Camera::DrawCallback
GL_RGBA,
GL_UNSIGNED_BYTE);
osgDB::writeImageFile(*_image, _filename);
osg::notify(osg::NOTICE)<<"Taken screenshot, and written to '"<<_filename<<"'"<<std::endl;
osg::notify(osg::NOTICE)<<"Taken screenshot, and written to '"<<_filename<<"'"<<std::endl;
}
_snapImage = false;
}
@@ -257,7 +259,7 @@ struct SnapeImageHandler : public osgGA::GUIEventHandler
return false;
}
int _key;
osg::ref_ptr<SnapImage> _snapImage;
};
@@ -271,11 +273,11 @@ int main( int argc, char **argv )
// read the scene from the list of file specified commandline args.
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
// if not loaded assume no arguments passed in, try use default model instead.
if (!scene) scene = osgDB::readNodeFile("dumptruck.osgt");
if (!scene)
{
osg::notify(osg::NOTICE)<<"No model loaded"<<std::endl;
@@ -289,16 +291,16 @@ int main( int argc, char **argv )
osgViewer::Viewer viewer;
// create a HUD as slave camera attached to the master view.
viewer.setUpViewAcrossAllScreens();
osgViewer::Viewer::Windows windows;
viewer.getWindows(windows);
if (windows.empty()) return 1;
osg::Camera* hudCamera = createHUD();
// set up cameras to render on the first window available.
hudCamera->setGraphicsContext(windows[0]);
hudCamera->setViewport(0,0,windows[0]->getTraits()->width, windows[0]->getTraits()->height);
@@ -325,21 +327,21 @@ int main( int argc, char **argv )
view->setCameraManipulator(new osgGA::TrackballManipulator);
// now create the HUD camera's view
osgViewer::Viewer::Windows windows;
viewer.getWindows(windows);
if (windows.empty()) return 1;
osg::Camera* hudCamera = createHUD();
// set up cameras to render on the first window available.
hudCamera->setGraphicsContext(windows[0]);
hudCamera->setViewport(0,0,windows[0]->getTraits()->width, windows[0]->getTraits()->height);
osgViewer::View* hudView = new osgViewer::View;
hudView->setCamera(hudCamera);
viewer.addView(hudView);
return viewer.run();
@@ -349,18 +351,18 @@ int main( int argc, char **argv )
{
// construct the viewer.
osgViewer::Viewer viewer;
SnapImage* postDrawCallback = new SnapImage("PostDrawCallback.png");
viewer.getCamera()->setPostDrawCallback(postDrawCallback);
viewer.getCamera()->setPostDrawCallback(postDrawCallback);
viewer.addEventHandler(new SnapeImageHandler('p',postDrawCallback));
SnapImage* finalDrawCallback = new SnapImage("FinalDrawCallback.png");
viewer.getCamera()->setFinalDrawCallback(finalDrawCallback);
viewer.getCamera()->setFinalDrawCallback(finalDrawCallback);
viewer.addEventHandler(new SnapeImageHandler('f',finalDrawCallback));
osg::ref_ptr<osg::Group> group = new osg::Group;
// add the HUD subgraph.
// add the HUD subgraph.
if (scene.valid()) group->addChild(scene.get());
group->addChild(createHUD());
@@ -369,5 +371,5 @@ int main( int argc, char **argv )
return viewer.run();
}
}

View File

@@ -29,9 +29,6 @@
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
@@ -39,32 +36,6 @@
#include <iostream>
static osgDB::DirectoryContents getSuitableFiles(osg::ArgumentParser& arguments)
{
osgDB::DirectoryContents files;
for(int i=1; i<arguments.argc(); ++i)
{
if (osgDB::fileType(arguments[i]) == osgDB::DIRECTORY)
{
const std::string& directory = arguments[i];
osgDB::DirectoryContents dc = osgDB::getSortedDirectoryContents(directory);
for(osgDB::DirectoryContents::iterator itr = dc.begin(); itr != dc.end(); ++itr)
{
std::string full_file_name = directory + "/" + (*itr);
std::string ext = osgDB::getLowerCaseFileExtension(full_file_name);
if ((ext == "jpg") || (ext == "png") || (ext == "gif") || (ext == "rgb") || (ext == "dds") )
{
files.push_back(full_file_name);
}
}
}
else {
files.push_back(arguments[i]);
}
}
return files;
}
//
@@ -98,20 +69,13 @@ osg::StateSet* createState(osg::ArgumentParser& arguments)
double length = -1.0;
while (arguments.read("--length",length)) {}
double fps = 30.0;
while (arguments.read("--fps",fps)) {}
osgDB::DirectoryContents files = getSuitableFiles(arguments);
if (!files.empty())
if (arguments.argc()>1)
{
for(osgDB::DirectoryContents::iterator itr = files.begin();
itr != files.end();
++itr)
for(int i=1; i<arguments.argc(); ++i)
{
const std::string& filename = *itr;
if (preLoad)
{
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(filename);
osg::ref_ptr<osg::Image> image = osgDB::readImageFile(arguments[i]);
if (image.valid())
{
imageSequence->addImage(image.get());
@@ -119,9 +83,8 @@ osg::StateSet* createState(osg::ArgumentParser& arguments)
}
else
{
imageSequence->addImageFile(filename);
imageSequence->addImageFile(arguments[i]);
}
}
if (length>0.0)
@@ -130,8 +93,10 @@ osg::StateSet* createState(osg::ArgumentParser& arguments)
}
else
{
unsigned int maxNum = imageSequence->getNumImageData();
imageSequence->setLength(double(maxNum)*(1.0/fps));
unsigned int maxNum = osg::maximum(imageSequence->getFileNames().size(),
imageSequence->getImages().size());
imageSequence->setLength(float(maxNum)*0.1f);
}
}
else
@@ -206,48 +171,11 @@ public:
void set(osg::Node* node);
void setTrackMouse(bool tm)
{
if (tm==_trackMouse) return;
_trackMouse = tm;
std::cout << "tracking mouse: " << (_trackMouse ? "ON" : "OFF") << std::endl;
for(ImageStreamList::iterator itr=_imageStreamList.begin();
itr!=_imageStreamList.end();
++itr)
{
if ((*itr)->getStatus()==osg::ImageStream::PLAYING)
{
(*itr)->pause();
}
else
{
(*itr)->play();
}
}
}
bool getTrackMouse() const { return _trackMouse; }
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv);
virtual void getUsage(osg::ApplicationUsage& usage) const;
typedef std::vector< osg::observer_ptr<osg::ImageStream> > ImageStreamList;
struct ImageStreamPlaybackSpeedData {
double fps;
unsigned char* lastData;
double timeStamp, lastOutput;
ImageStreamPlaybackSpeedData() : fps(0), lastData(NULL), timeStamp(0), lastOutput(0) {}
};
typedef std::vector< ImageStreamPlaybackSpeedData > ImageStreamPlayBackSpeedList;
protected:
@@ -312,7 +240,6 @@ protected:
bool _playToggle;
bool _trackMouse;
ImageStreamList _imageStreamList;
ImageStreamPlayBackSpeedList _imageStreamPlayBackSpeedList;
};
@@ -326,7 +253,6 @@ void MovieEventHandler::set(osg::Node* node)
FindImageStreamsVisitor fisv(_imageStreamList);
node->accept(fisv);
}
_imageStreamPlayBackSpeedList.resize(_imageStreamList.size());
}
@@ -334,53 +260,6 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::FRAME):
{
double t = ea.getTime();
bool printed(false);
ImageStreamPlayBackSpeedList::iterator fps_itr = _imageStreamPlayBackSpeedList.begin();
for(ImageStreamList::iterator itr=_imageStreamList.begin();
itr!=_imageStreamList.end();
++itr, ++fps_itr)
{
if (((*itr)->getStatus()==osg::ImageStream::PLAYING) && ((*itr)->data() != (*fps_itr).lastData))
{
ImageStreamPlaybackSpeedData& data(*fps_itr);
double dt = (data.timeStamp > 0) ? t - data.timeStamp : 1/60.0;
data.lastData = (*itr)->data();
data.fps = (*fps_itr).fps * 0.8 + 0.2 * (1/dt);
data.timeStamp = t;
if (t-data.lastOutput > 1)
{
std::cout << data.fps << " ";
data.lastOutput = t;
printed = true;
}
}
}
if (printed)
std::cout << std::endl;
}
break;
case(osgGA::GUIEventAdapter::MOVE):
{
if (_trackMouse)
{
for(ImageStreamList::iterator itr=_imageStreamList.begin();
itr!=_imageStreamList.end();
++itr)
{
double dt = (*itr)->getLength() * ((1.0+ea.getXnormalized()) / 2.0);
(*itr)->seek(dt);
std::cout << "seeking to " << dt << " length: " <<(*itr)->getLength() << std::endl;
}
}
return false;
}
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='p')
@@ -433,12 +312,6 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
}
}
return true;
}
else if (ea.getKey() == 'i')
{
setTrackMouse(!_trackMouse);
}
return false;
}
@@ -446,13 +319,10 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
default:
return false;
}
return false;
}
void MovieEventHandler::getUsage(osg::ApplicationUsage& usage) const
{
usage.addKeyboardMouseBinding("i","toggle interactive mode, scrub via mouse-move");
usage.addKeyboardMouseBinding("p","Play/Pause movie");
usage.addKeyboardMouseBinding("r","Restart movie");
usage.addKeyboardMouseBinding("l","Toggle looping of movie");
@@ -477,9 +347,6 @@ int main(int argc, char **argv)
// pass the model to the MovieEventHandler so it can pick out ImageStream's to manipulate.
MovieEventHandler* meh = new MovieEventHandler();
meh->set( viewer.getSceneData() );
if (arguments.read("--track-mouse")) meh->setTrackMouse(true);
viewer.addEventHandler( meh );
viewer.addEventHandler( new osgViewer::StatsHandler());

View File

@@ -43,7 +43,7 @@ typedef NodeContainer::iterator NodeIterator;
NodeContainer nodes;
//
osg::ref_ptr<osg::Group> Root = 0;
osg::Group * Root = 0;
const int HOUSES_SIZE = 25000; // total number of houses
double XDim = 5000.0f; // area dimension +/- XDim
@@ -81,11 +81,11 @@ void CreateHouses()
};
// use the same color, normal and indices for all houses.
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(1);
osg::Vec4Array* colors = new osg::Vec4Array(1);
(*colors)[0] = osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f);
// normals
osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array(16);
osg::Vec3Array * normals = new osg::Vec3Array(16);
(*normals)[0] = osg::Vec3( 0.0f, -0.0f, -1.0f);
(*normals)[1] = osg::Vec3( 0.0f, -0.0f, -1.0f);
(*normals)[2] = osg::Vec3( 0.0f, -1.0f, 0.0f);
@@ -104,10 +104,10 @@ void CreateHouses()
(*normals)[15] = osg::Vec3(-0.707107f, 0.0f, 0.707107f);
// coordIndices
osg::ref_ptr<osg::UByteArray> coordIndices = new osg::UByteArray(48,indices);
osg::UByteArray* coordIndices = new osg::UByteArray(48,indices);
// share the primitive set.
osg::PrimitiveSet* primitives = new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,48);
// share the primitive set.
osg::PrimitiveSet* primitives = new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,48);
for (int q = 0; q < HOUSES_SIZE; q++)
{
@@ -120,11 +120,11 @@ void CreateHouses()
* 2 * ZDim) - ZDim;
float scale = 10.0f;
osg::Vec3 offset(xPos,yPos,0.0f);
osg::Vec3 offset(xPos,yPos,0.0f);
// coords
osg::ref_ptr<osg::Vec3Array> coords = new osg::Vec3Array(10);
osg::Vec3Array* coords = new osg::Vec3Array(10);
(*coords)[0] = osg::Vec3( 0.5f, -0.7f, 0.0f);
(*coords)[1] = osg::Vec3( 0.5f, 0.7f, 0.0f);
(*coords)[2] = osg::Vec3(-0.5f, 0.7f, 0.0f);
@@ -143,23 +143,23 @@ void CreateHouses()
// create geometry
osg::ref_ptr<deprecated_osg::Geometry> geometry = new deprecated_osg::Geometry();
osg::Geometry * geometry = new osg::Geometry();
geometry->addPrimitiveSet(primitives);
geometry->setVertexArray(coords);
geometry->setVertexIndices(coordIndices);
geometry->setColorArray(colors);
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->setNormalArray(normals);
geometry->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
geometry->setVertexArray(coords.get());
geometry->setVertexIndices(coordIndices.get());
geometry->setColorArray(colors.get());
geometry->setColorBinding(deprecated_osg::Geometry::BIND_OVERALL);
geometry->setNormalArray(normals.get());
geometry->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
geode->addDrawable(geometry.get());
nodes.push_back(geode.get());
osg::Geode * geode = new osg::Geode();
geode->addDrawable(geometry);
nodes.push_back(geode);
}
}
@@ -187,14 +187,14 @@ void LayoutAsGrid()
{
osg::Node * node = nodeIter->get();
osg::Vec3 center = node->getBound().center();
int x = (int)floor((center.x() - xGridStart) / xGridSize);
int z = (int)floor((center.y() - yGridStart) / yGridSize);
groups[z * GridX + x]->addChild(node);
}
// add nodes to building root
// add nodes to building root
for (i = 0; i < GridX * GridY; i++)
{
osg::StateSet * stateset = new osg::StateSet();
@@ -205,7 +205,7 @@ void LayoutAsGrid()
0.5f + (static_cast<double> (rand()) / (2.0*static_cast<double> (RAND_MAX))),
0.5f + (static_cast<double> (rand()) / ( 2.0*static_cast<double>(RAND_MAX))),
1.0f);
material->setAmbient(osg::Material::FRONT_AND_BACK, color);
material->setDiffuse(osg::Material::FRONT_AND_BACK, color);
stateset->setAttributeAndModes(material, osg::StateAttribute::ON);
@@ -244,14 +244,14 @@ int main( int argc, char **argv )
// load the nodes from the commandline arguments.
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
osg::Node* model = osgDB::readNodeFiles(arguments);
if (model)
{
// the osgSim::InsertImpostorsVisitor used lower down to insert impostors
// only operators on subclass of Group's, if the model top node is not
// a group then it won't be able to insert an impostor. We therefore
// manually insert an impostor above the model.
if (dynamic_cast<osg::Group*>(model.get())==0)
if (dynamic_cast<osg::Group*>(model)==0)
{
const osg::BoundingSphere& bs = model->getBound();
if (bs.valid())
@@ -260,7 +260,7 @@ int main( int argc, char **argv )
osgSim::Impostor* impostor = new osgSim::Impostor;
// standard LOD settings
impostor->addChild(model.get());
impostor->addChild(model);
impostor->setRange(0,0.0f,1e7f);
impostor->setCenter(bs.center());
@@ -278,9 +278,9 @@ int main( int argc, char **argv )
// we would know about it, other than by following the parent path
// up from model. This is really what should be done, but I'll pass
// on it right now as it requires a getRoots() method to be added to
// osg::Node, and we're about to make a release so no new features!
osg::ref_ptr<osg::Group> rootnode = new osg::Group;
rootnode->addChild(model.get());
// osg::Node, and we're about to make a release so no new features!
osg::Group* rootnode = new osg::Group;
rootnode->addChild(model);
// now insert impostors in the model using the InsertImpostorsVisitor.
@@ -304,7 +304,7 @@ int main( int argc, char **argv )
}
// add model to viewer.
viewer.setSceneData(model.get());
viewer.setSceneData(model);
return viewer.run();
}

View File

@@ -1,5 +0,0 @@
SET(TARGET_SRC
osgkeystone.cpp )
#### end var setup ###
SETUP_EXAMPLE(osgkeystone)

Some files were not shown because too many files have changed in this diff Show More