diff --git a/Make/makedirdefs b/Make/makedirdefs index 0474c6053..aceb0b312 100644 --- a/Make/makedirdefs +++ b/Make/makedirdefs @@ -93,6 +93,7 @@ DEMOS_DIRS = \ osgparticle\ osgprerender\ osgshadowtexture\ + osgtxp\ osgreflect\ osgscribe\ osgsequence\ diff --git a/Make/makerpms b/Make/makerpms index 49fb1199e..af6b64a2a 100644 --- a/Make/makerpms +++ b/Make/makerpms @@ -119,7 +119,7 @@ make_osg() print_attr $INST_PLUGINS 755 >> $TOPDIR/dist/RPM/OpenSceneGraph.spec print_attr $INST_DEMOS 755 >> $TOPDIR/dist/RPM/OpenSceneGraph.spec - rpm -bb --clean $TOPDIR/dist/RPM/OpenSceneGraph.spec + rpmbuild -bb --clean $TOPDIR/dist/RPM/OpenSceneGraph.spec mv /usr/src/redhat/RPMS/i386/OpenSceneGraph-$REV-$REL.i386.rpm dist/RPM } diff --git a/dist/RPM/OpenSceneGraph.spec b/dist/RPM/OpenSceneGraph.spec index 02ad69e16..23f08afae 100644 --- a/dist/RPM/OpenSceneGraph.spec +++ b/dist/RPM/OpenSceneGraph.spec @@ -1,11 +1,11 @@ Summary: A C++ scene graph API on OpenGL for real time graphics Name: OpenSceneGraph -Version: 0.9.1 +Version: 0.9.2 Release: 1 Copyright: LGPL Group: Graphics -Source: OpenSceneGraph-0.9.1.tar.gz +Source: OpenSceneGraph-0.9.2.tar.gz URL: http://www.openscenegraph.org Packager: Don Burns @@ -26,7 +26,7 @@ graphics rendering, protability, and extensibility %install -cd /usr/src/redhat/BUILD/OpenSceneGraph-0.9.1 +cd /usr/src/redhat/BUILD/OpenSceneGraph-0.9.2 tar cvf - . | tar xvfC - / # --------------------- @@ -37,14 +37,17 @@ tar cvf - . | tar xvfC - / %attr(755, root, root) /usr/local/lib/libosgGA.so %attr(755, root, root) /usr/local/lib/libosgGLUT.so %attr(755, root, root) /usr/local/lib/libosgParticle.so +%attr(755, root, root) /usr/local/lib/libosgSim.so %attr(755, root, root) /usr/local/lib/libosg.so %attr(755, root, root) /usr/local/lib/libosgText.so %attr(755, root, root) /usr/local/lib/libosgUtil.so %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_3ds.so +%attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_ac.so %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_bmp.so %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_dw.so %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_dx.so %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_flt.so +%attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_geo.so %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_gif.so %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_iv.so %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_jpeg.so @@ -64,6 +67,8 @@ tar cvf - . | tar xvfC - / %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_tiff.so %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_txp.so %attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_zip.so +%attr(755, root, root) /usr/share/OpenSceneGraph/bin/memleaks.log +%attr(755, root, root) /usr/share/OpenSceneGraph/bin/osganimate %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgbillboard %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgcallback %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgclip @@ -71,11 +76,14 @@ tar cvf - . | tar xvfC - / %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgconv %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgcopy %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgcube +%attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgcubemap +%attr(755, root, root) /usr/share/OpenSceneGraph/bin/osggeodemo %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osggeometry %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osghangglide %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osghud %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgimpostor %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osglight +%attr(755, root, root) /usr/share/OpenSceneGraph/bin/osglightpoint %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgmultitexture %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgoccluder %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgparticle @@ -83,7 +91,10 @@ tar cvf - . | tar xvfC - / %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgreflect %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgscribe %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgsequence +%attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgshadowtexture +%attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgshape %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgstereoimage +%attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgteapot %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgtext %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgtexture %attr(755, root, root) /usr/share/OpenSceneGraph/bin/osgtexture1D diff --git a/dist/RPM/OpenSceneGraph_dev.spec b/dist/RPM/OpenSceneGraph_dev.spec index 69f7043f8..9e3f7a2ae 100644 --- a/dist/RPM/OpenSceneGraph_dev.spec +++ b/dist/RPM/OpenSceneGraph_dev.spec @@ -1,11 +1,11 @@ Summary: A C++ scene graph API on OpenGL for real time graphics Name: OpenSceneGraph_dev -Version: 0.9.1 +Version: 0.9.2 Release: 1 Copyright: LGPL Group: Graphics -Source: OpenSceneGraph_dev-0.9.1.tar.gz +Source: OpenSceneGraph_dev-0.9.2.tar.gz URL: http://www.openscenegraph.org Packager: Don Burns @@ -26,7 +26,7 @@ graphics rendering, protability, and extensibility %install -cd /usr/src/redhat/BUILD/OpenSceneGraph_dev-0.9.1 +cd /usr/src/redhat/BUILD/OpenSceneGraph_dev-0.9.2 tar cvf - . | tar xvfC - / # --------------------- @@ -41,6 +41,7 @@ tar cvf - . | tar xvfC - / %attr(755, root, root) /usr/local/include/osg/BoundingBox %attr(755, root, root) /usr/local/include/osg/BoundingSphere %attr(755, root, root) /usr/local/include/osg/BoundsChecking +%attr(755, root, root) /usr/local/include/osg/buffered_value %attr(755, root, root) /usr/local/include/osg/Camera %attr(755, root, root) /usr/local/include/osg/ClearNode %attr(755, root, root) /usr/local/include/osg/ClipNode @@ -96,9 +97,10 @@ tar cvf - . | tar xvfC - / %attr(755, root, root) /usr/local/include/osg/Point %attr(755, root, root) /usr/local/include/osg/PolygonMode %attr(755, root, root) /usr/local/include/osg/PolygonOffset +%attr(755, root, root) /usr/local/include/osg/PolygonStipple %attr(755, root, root) /usr/local/include/osg/Polytope %attr(755, root, root) /usr/local/include/osg/PositionAttitudeTransform -%attr(755, root, root) /usr/local/include/osg/Primitive +%attr(755, root, root) /usr/local/include/osg/PrimitiveSet %attr(755, root, root) /usr/local/include/osg/Projection %attr(755, root, root) /usr/local/include/osg/Quat %attr(755, root, root) /usr/local/include/osg/Referenced @@ -106,6 +108,8 @@ tar cvf - . | tar xvfC - / %attr(755, root, root) /usr/local/include/osg/Sequence %attr(755, root, root) /usr/local/include/osg/ShadeModel %attr(755, root, root) /usr/local/include/osg/ShadowVolumeOccluder +%attr(755, root, root) /usr/local/include/osg/Shape +%attr(755, root, root) /usr/local/include/osg/ShapeDrawable %attr(755, root, root) /usr/local/include/osg/State %attr(755, root, root) /usr/local/include/osg/StateAttribute %attr(755, root, root) /usr/local/include/osg/StateSet @@ -146,6 +150,7 @@ tar cvf - . | tar xvfC - / %attr(755, root, root) /usr/local/include/osgDB/Registry %attr(755, root, root) /usr/local/include/osgDB/Version %attr(755, root, root) /usr/local/include/osgDB/WriteFile +%attr(755, root, root) /usr/local/include/osgGA/AnimationPathManipulator %attr(755, root, root) /usr/local/include/osgGA/CameraManipulator %attr(755, root, root) /usr/local/include/osgGA/DriveManipulator %attr(755, root, root) /usr/local/include/osgGA/Export @@ -193,20 +198,30 @@ tar cvf - . | tar xvfC - / %attr(755, root, root) /usr/local/include/osgParticle/Shooter %attr(755, root, root) /usr/local/include/osgParticle/VariableRateCounter %attr(755, root, root) /usr/local/include/osgParticle/Version +%attr(755, root, root) /usr/local/include/osgSim/BlinkSequence +%attr(755, root, root) /usr/local/include/osgSim/Export +%attr(755, root, root) /usr/local/include/osgSim/LightPoint +%attr(755, root, root) /usr/local/include/osgSim/LightPointDrawable +%attr(755, root, root) /usr/local/include/osgSim/LightPointNode +%attr(755, root, root) /usr/local/include/osgSim/Sector +%attr(755, root, root) /usr/local/include/osgSim/Version %attr(755, root, root) /usr/local/include/osgText/Export %attr(755, root, root) /usr/local/include/osgText/Font %attr(755, root, root) /usr/local/include/osgText/Paragraph %attr(755, root, root) /usr/local/include/osgText/Text %attr(755, root, root) /usr/local/include/osgText/Version %attr(755, root, root) /usr/local/include/osgUtil/AppVisitor +%attr(755, root, root) /usr/local/include/osgUtil/CubeMapGenerator %attr(755, root, root) /usr/local/include/osgUtil/CullVisitor -%attr(755, root, root) /usr/local/include/osgUtil/DepthSortedBin %attr(755, root, root) /usr/local/include/osgUtil/DisplayListVisitor %attr(755, root, root) /usr/local/include/osgUtil/DisplayRequirementsVisitor %attr(755, root, root) /usr/local/include/osgUtil/Export +%attr(755, root, root) /usr/local/include/osgUtil/HalfWayMapGenerator +%attr(755, root, root) /usr/local/include/osgUtil/HighlightMapGenerator %attr(755, root, root) /usr/local/include/osgUtil/InsertImpostorsVisitor %attr(755, root, root) /usr/local/include/osgUtil/IntersectVisitor %attr(755, root, root) /usr/local/include/osgUtil/Optimizer +%attr(755, root, root) /usr/local/include/osgUtil/ReflectionMapGenerator %attr(755, root, root) /usr/local/include/osgUtil/RenderBin %attr(755, root, root) /usr/local/include/osgUtil/RenderGraph %attr(755, root, root) /usr/local/include/osgUtil/RenderLeaf @@ -219,80 +234,5 @@ tar cvf - . | tar xvfC - / %attr(755, root, root) /usr/local/include/osgUtil/TransformCallback %attr(755, root, root) /usr/local/include/osgUtil/TriStripVisitor %attr(755, root, root) /usr/local/include/osgUtil/Version -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgbillboard/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgbillboard/osgbillboard.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcallback/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcallback/osgcallback.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgclip/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgclip/osgclip.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcluster/broadcaster.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcluster/broadcaster.h -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcluster/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcluster/osgcluster.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcluster/receiver.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcluster/receiver.h -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgconv/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgconv/OrientationConverter.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgconv/OrientationConverter.h -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgconv/osgconv.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcopy/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcopy/osgcopy.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcube/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgcube/osgcube.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osggeometry/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osggeometry/osggeometry.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/base.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/GliderManipulator.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/GliderManipulator.h -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/hat.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/hat.h -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/osghangglide.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/ReaderWriterFLY.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/sky.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/tank.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/terrain_coords.h -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/terrain.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/terrain_normals.h -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/terrain_texcoords.h -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghangglide/trees.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghud/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osghud/osghud.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgimpostor/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgimpostor/osgimpostor.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osglight/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osglight/osglight.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgmultitexture/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgmultitexture/osgmultitexture.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgoccluder/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgoccluder/osgoccluder.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgparticle/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgparticle/osgparticle.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgprerender/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgprerender/osgprerender.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgreflect/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgreflect/osgreflect.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgscribe/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgscribe/osgscribe.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgsequence/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgsequence/osgsequence.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgstereoimage/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgstereoimage/osgstereoimage.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgtext/main.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgtext/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgtexture1D/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgtexture1D/osgtexture1D.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgtexture2D/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgtexture2D/osgtexture2D.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgtexture3D/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgtexture3D/osgtexture3D.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgunittests/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgunittests/osgunittests.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgversion/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgversion/osgversion.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgviews/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/osgviews/osgviews.cpp -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/sgv/Makefile -%attr(755, root, root) /usr/share/OpenSceneGraph/src/demos/sgv/sgv.cpp %attr(755, root, root) /usr/share/OpenSceneGraph/src/Make/makedefs %attr(755, root, root) /usr/share/OpenSceneGraph/src/Make/makerules diff --git a/include/osgTXP/Export.h b/include/osgTXP/Export.h new file mode 100644 index 000000000..9ed7a45c2 --- /dev/null +++ b/include/osgTXP/Export.h @@ -0,0 +1,29 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. + +#ifndef OSGTXP_EXPORT_ +#define OSGTXP_EXPORT_ 1 + +#if defined(_MSC_VER) + #pragma warning( disable : 4244 ) + #pragma warning( disable : 4251 ) + #pragma warning( disable : 4267 ) + #pragma warning( disable : 4275 ) + #pragma warning( disable : 4290 ) + #pragma warning( disable : 4786 ) +#endif + +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__) + # ifdef OSGTXP_LIBRARY + # define OSGTXP_EXPORT __declspec(dllexport) + # else + # define OSGTXP_EXPORT __declspec(dllimport) + # endif /* OSGTXP_LIBRARY */ +#else + # define OSGTXP_EXPORT +#endif + +#include + +#endif diff --git a/src/osgPlugins/txp/TrPageArchive.h b/include/osgTXP/TrPageArchive.h similarity index 78% rename from src/osgPlugins/txp/TrPageArchive.h rename to include/osgTXP/TrPageArchive.h index 641ea94e5..382652d84 100644 --- a/src/osgPlugins/txp/TrPageArchive.h +++ b/include/osgTXP/TrPageArchive.h @@ -25,10 +25,13 @@ -#include "trpage_sys.h" -#include "trpage_read.h" +#include +#include +#include -#include "TrPageParser.h" +#include + +#include #include #include @@ -37,7 +40,7 @@ namespace txp { /// main class for loading terrapage archives - class TrPageArchive : public trpgr_Archive + class OSGTXP_EXPORT TrPageArchive : public trpgr_Archive { public: TrPageArchive(); @@ -67,12 +70,26 @@ namespace txp */ osg::Group *LoadTile(int x,int y,int lod,int &parent); + + /* This version is used during the paging and takes a Managed Tile + instead of location. These are used to keep track of what to + page in and out. + */ + osg::Group *LoadTile(osg::Group *rootNode,trpgPageManager *,trpgManagedTile *,osg::Group **parentNode=NULL); + + /* Unload Tile + This is called to get rid of a tile from the scenegraph + */ + bool UnLoadTile(trpgPageManager *,trpgManagedTile *); /** Load all the tiles . No paging. @return The parent of the complete scene graph. */ osg::Group *LoadAllTiles(); + // Calculate the center + void GetCenter(osg::Vec3 ¢er); + protected: /// This class does most of the actual parsing. std::auto_ptr parse; @@ -81,6 +98,7 @@ namespace txp std::vector< osg::ref_ptr > m_gstates; std::vector< osg::ref_ptr > m_models; std::string m_alternate_path; + trpgMemReadBuffer buf; }; }; // end namespace diff --git a/src/osgPlugins/txp/TrPageParser.h b/include/osgTXP/TrPageParser.h similarity index 91% rename from src/osgPlugins/txp/TrPageParser.h rename to include/osgTXP/TrPageParser.h index 7456e4761..0a32eb771 100644 --- a/src/osgPlugins/txp/TrPageParser.h +++ b/include/osgTXP/TrPageParser.h @@ -31,13 +31,22 @@ #include #include #include -#include "trpage_read.h" +#include + +#include namespace txp { class TrPageArchive; - class TrPageParser : public trpgSceneParser + // Group ID Info + // Used to keep track of which groups are which IDs for parents + typedef struct { + osg::Group *group; + int id; + } GroupIDInfo; + + class OSGTXP_EXPORT TrPageParser : public trpgSceneParser { public: TrPageParser(TrPageArchive* parent); @@ -62,18 +71,17 @@ namespace txp std::vector >* GetLocalMaterials() { return &local_materials; } std::vector >* GetModels() { return models; } - // Add the Group to the group list + // Add the Group to the current group list bool AddToGroupList(int id,osg::Group *); // Return the group list - std::vector< osg::Group* > *GetGroupList() { return &groupList; } + std::vector< osg::Group *> *GetGroupList() { return &groupList; } - // Set the maximum number of groups (once per archive) - void SetMaxGroupID(int); - /// TXP 2.0 - local materials void LoadLocalMaterials(); - + + void SetMaxGroupID(int maxGroupID); + protected: bool StartChildren(void *); bool EndChildren(void *); @@ -88,7 +96,7 @@ namespace txp int parentID; std::vector >* materials; std::vector > local_materials; - std::vector groupList; + std::vector groupList; std::vector >* models; }; diff --git a/include/osgTXP/TrPageViewer.h b/include/osgTXP/TrPageViewer.h new file mode 100644 index 000000000..86ba05c3d --- /dev/null +++ b/include/osgTXP/TrPageViewer.h @@ -0,0 +1,59 @@ +/* ************************************************************************** + * OpenSceneGraph loader for Terrapage format database + * + * That loader is redistributed under the terms listed on Terrain Experts + * website (www.terrex.com/www/pages/technology/technologypage.htm) + * + * "TerraPage is provided as an Open Source format for use by anyone... + * We supply the TerraPage C++ source code free of charge. Anyone + * can use it and redistribute it as needed (including our competitors). + * We do, however, ask that you keep the TERREX copyrights intact." + * + * Copyright Terrain Experts Inc. 1999. + * All Rights Reserved. + * + *****************************************************************************/ + +#ifndef _TRPAGEVIEWER_H_ +#define _TRPAGEVIEWER_H_ + +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include + +#include + +#include + +namespace txp +{ + /* Paging Viewer + Variant of the regular viewer which knows to call + the Page Manager at the beginning of each app() phase. + */ + class OSGTXP_EXPORT PagingViewer : public osgGLUT::Viewer { + public: + PagingViewer(); + bool Init(OSGPageManager *,txp::OSGPageManager::ThreadMode = txp::OSGPageManager::ThreadNone); + + // called on each frame redraw..return the time in ms for each operation. + virtual float app(unsigned int viewport); + // The default Viewer resets the cameras at the beginning of the run() + // This is annoying. + bool run(); + protected: + OSGPageManager *pageManage; + }; +}; + +#endif diff --git a/include/osgTXP/WaitBlock.h b/include/osgTXP/WaitBlock.h new file mode 100644 index 000000000..62b1d39f0 --- /dev/null +++ b/include/osgTXP/WaitBlock.h @@ -0,0 +1,35 @@ +#ifndef WAIT_BLOCK_H +#define WAIT_BLOCK_H +#ifndef WIN32 +#include + +namespace osgTXP { + +struct WaitBlock{ + pthread_mutex_t mut; + pthread_cond_t cond; + + WaitBlock() + { + pthread_mutex_init( &mut, 0L ); + pthread_cond_init( &cond, 0L ); + } + + void wait() + { + pthread_mutex_lock( &mut ); + pthread_cond_wait( &cond, &mut); + pthread_mutex_unlock(&mut); + } + + void release() + { + pthread_mutex_lock( &mut ); + pthread_cond_broadcast( &cond ); + pthread_mutex_unlock( &mut ); + } +}; +} +#endif +#endif + diff --git a/include/osgTXP/trPagePageManager.h b/include/osgTXP/trPagePageManager.h new file mode 100644 index 000000000..bb23e5163 --- /dev/null +++ b/include/osgTXP/trPagePageManager.h @@ -0,0 +1,154 @@ +/* ************************************************************************** + * OpenSceneGraph loader for Terrapage format database + * + * That loader is redistributed under the terms listed on Terrain Experts + * website (www.terrex.com/www/pages/technology/technologypage.htm) + * + * "TerraPage is provided as an Open Source format for use by anyone... + * We supply the TerraPage C++ source code free of charge. Anyone + * can use it and redistribute it as needed (including our competitors). + * We do, however, ask that you keep the TERREX copyrights intact." + * + * Copyright Terrain Experts Inc. 1999. + * All Rights Reserved. + * + *****************************************************************************/ + +#ifndef _TRPAGEMANAGER_H_ +#define _TRPAGEMANAGER_H_ + +#include + +#ifndef WIN32 +#include +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace txp +{ + /* Thread Identifier + Fill this in for your specific platform. + Should be water ID you use for threads. + */ +#if defined(_WIN32) + typedef HANDLE ThreadID; + typedef HANDLE ThreadMutex; + typedef HANDLE ThreadEvent; +#endif + +#if !defined(ThreadID) + /* + // Stubs to make it compile + typedef int ThreadID; + typedef int ThreadMutex; + typedef int ThreadEvent; + */ + + typedef pthread_t ThreadID; + typedef pthread_mutex_t ThreadMutex; + typedef osgTXP::WaitBlock ThreadEvent; + +#endif + + /* OSG Page Manager + This class handles the paging into + */ + class OSGTXP_EXPORT OSGPageManager { + public: + /* Need a group to put things under and the archive to page. + Also, optionally, a Page Manager (if you've made changes + to the default one). + */ + OSGPageManager(TrPageArchive *,trpgPageManager *pageManage = NULL); + ~OSGPageManager(); + + /* Unthreaded update + Update viewer position and load a maximum of numTile before + returning. + Also unloads everything that needs it. + Don't call this in threaded mode. + */ + bool UpdateNoThread(osg::Group *,double locX,double locY,int numTile=-1); + + /* Thread routines + The thread will run in and around this object. It can + run in one of two modes: + ThreadFree - + ThreadSync - + */ + typedef enum {ThreadNone,ThreadFree,ThreadSync} ThreadMode; + + // Retrieve the current threading mode + ThreadMode GetThreadMode() { return threadMode; } + + // ----- Main thread routines ----- + // ----- Only call these from the main thread ---- + // Create a new thread in the given mode. + bool StartThread(ThreadMode,ThreadID &newThread); + + /* If we're in ThreadFree mode, merge everything the paging + thread has read in up to this point into the main scenegraph. + */ + bool MergeUpdateThread(osg::Group *); + + // Shut down the current paging thread. + bool EndThread(); + + // Update the viewer position + void UpdatePositionThread(double locX,double locY); + + // ----- Paging Thread Routines ---- + // ----- Only call these from the paging thread ---- + + // Called by the thread start function + // Don't call this yourself + bool ThreadLoop(); + + protected: + // Page Manager we'll use is ours (i.e. delete it at the end) + bool pageManageOurs; + trpgPageManager *pageManage; + // Archive to page from + TrPageArchive *archive; + // Database origin + double originX,originY; + + /* Thread specific data. + */ + + // ID of created thread and whether it's valid + ThreadMode threadMode; + ThreadID threadID; + + // Used to notify the paging thread when the location changes + ThreadEvent locationChangeEvent; + + // Lock for the location and location itself + ThreadMutex locationMutex; + bool positionValid; + double locX,locY; + + // Lock for the change lists (merge, unhook, delete) + ThreadMutex changeListMutex; + // Merge list is filled in by the paging thread. + std::vector toMerge; + std::vector toMergeParent; + // Unhook list is filled in by the paging thread + std::vector toUnhook; + // Main thread moves groups to the delete list as soon as they are unhooked + std::vector toDelete; + }; +}; + +#endif diff --git a/src/osgPlugins/txp/trdll.h b/include/osgTXP/trdll.h similarity index 100% rename from src/osgPlugins/txp/trdll.h rename to include/osgTXP/trdll.h diff --git a/src/osgPlugins/txp/trpage_compat.h b/include/osgTXP/trpage_compat.h similarity index 100% rename from src/osgPlugins/txp/trpage_compat.h rename to include/osgTXP/trpage_compat.h diff --git a/src/osgPlugins/txp/trpage_geom.h b/include/osgTXP/trpage_geom.h similarity index 99% rename from src/osgPlugins/txp/trpage_geom.h rename to include/osgTXP/trpage_geom.h index 952dd744a..f88b2c526 100644 --- a/src/osgPlugins/txp/trpage_geom.h +++ b/include/osgTXP/trpage_geom.h @@ -21,10 +21,10 @@ These are the objects that get read from and written to archives. */ -#include "trpage_sys.h" +#include -#include "trpage_io.h" -#include "trpage_swap.h" +#include +#include // Forward declarations diff --git a/src/osgPlugins/txp/trpage_ident.h b/include/osgTXP/trpage_ident.h similarity index 100% rename from src/osgPlugins/txp/trpage_ident.h rename to include/osgTXP/trpage_ident.h diff --git a/src/osgPlugins/txp/trpage_io.h b/include/osgTXP/trpage_io.h similarity index 99% rename from src/osgPlugins/txp/trpage_io.h rename to include/osgTXP/trpage_io.h index 31eef9725..0758c46dd 100644 --- a/src/osgPlugins/txp/trpage_io.h +++ b/include/osgTXP/trpage_io.h @@ -20,7 +20,7 @@ Token definitions and basic classes. */ -#include "trpage_sys.h" +#include // Macros we may need #ifndef MIN diff --git a/include/osgTXP/trpage_managers.h b/include/osgTXP/trpage_managers.h new file mode 100644 index 000000000..5a69b1b68 --- /dev/null +++ b/include/osgTXP/trpage_managers.h @@ -0,0 +1,378 @@ +/* ************************ + Copyright Terrain Experts Inc. + Terrain Experts Inc (TERREX) reserves all rights to this source code + unless otherwise specified in writing by the President of TERREX. + This copyright may be updated in the future, in which case that version + supercedes this one. + ------------------- + Terrex Experts Inc. + 4400 East Broadway #314 + Tucson, AZ 85711 + info@terrex.com + Tel: (520) 323-7990 + ************************ + */ + +#ifndef _trpage_managers_h_ +#define _trpage_managers_h_ + +#include + +/* This file contains class definitions for managers + that help you keep track of data related to + paging. For instance, which tiles to load + in at any given time and what textures you need + to read for a given tile. + */ + +class trpgPageManager; + +/* Managed Tiles are used by the trpgPageManager to keep + track of which tiles are loaded and what textures (and + models) they need loaded into memory with them. + */ +TX_EXDECL class TX_CLDECL trpgManagedTile { +friend class trpgPageManager; +public: + trpgManagedTile(void); + + // Called to clear any info out of this tile + void Reset(void); + + /* Call this when you hit a tile header in your own + Scene parser callback. The managed tile + can then keep track of which textures and models + go with this tile. + */ + bool ParseTileHeader(trpgReadBuffer &); + + // Check if the tile is loaded (e.g. the header read in) + bool IsLoaded(void); + + /* Set the tile location. This resets any internal + state we may be keeping. + */ + bool SetTileLoc(int x,int y,int lod); + + // Get the tile location + bool GetTileLoc(int &x,int &y,int &lod); + + // Return a pointer to the tile header + const trpgTileHeader *GetTileHead(void); + + /* Return a pointer to the list of locally defined + materials. As soon as the tile header is read by + ParseTileHeader (which you call) you'll want to get + this list and load the pageable textures. You can + use SetMatData to keep track of our internal texture + structures. + */ + const std::vector *GetLocMatList(void) const; + + /* Returns a pointer to a single local material, if within + the valid range of local materials for this tile. + */ + const trpgLocalMaterial *GetLocMaterial(int id) const; + + /* Set Local Data for managed tile. The local data would + probably be a pointer to the top of the scene graph you're + using to represent just this tile. + */ + void SetLocalData(void *); + + /* Returns the local data you set with SetLocalData. + */ + void *GetLocalData(void) const; + + /* Associates a void * with one of the materials referenced + within this tile. The idea here is that you'll want + to load the texture for a given local material and then + pass your own internal texture structure into here as + a void *. That way, the trpgPageManager will keep track + of which textures you should unload when this tile goes + out of range. + */ + bool SetMatData(int id,void *); + + /* Gets the void * data you associated with a given local + material index. See SetMatData for more information. + */ + void *GetMatData(int id) const; + + /* Add Group ID to this tile. This is called by the page + manager to keep track of which group IDs belong to this tile. + We use this information to NULL out the appropriate positions + in the group map help by the page manager. + */ + void AddGroupID(int id); + + /* Retrieve the list of group IDs for this tile. + */ + const std::vector *GetGroupIDs(void) const; + + /* Print the current status and information about this managed + Tile. + */ + void Print(trpgPrintBuffer &); +protected: + // Set if a tile is currently loaded + bool isLoaded; + // Tile location info + int x,y,lod; + // Tile Header associated with this tile + trpgTileHeader tileHead; + // Data to keep associated with each individual local material index + std::vector localMatData; + // Used to keep track of group IDs in this tile + std::vector groupIDs; + // Local data (probably the top of the local scene graph) + void *localData; + + // Note: Should do models too if anyone wanted them. +}; + +/* The Page Manager is a helper class that can be used + to keep track of: (1) which tiles need to be loaded + into memory for a given viewer position, (2) which tiles + are currently loaded and (3) which tiles need to be unloaded + when the viewer position moves. The tile list this + class generates is guaranteed to be in the right order + for loading. You would use this class if you're implementing + a TerraPage reader for your visual run-time system. + */ +TX_EXDECL class TX_CLDECL trpgPageManager { +public: + trpgPageManager(void); + virtual ~trpgPageManager(void); + + // Initialize with an archive + virtual void Init(trpgr_Archive *); + + /* Set Paging Distance + This is the extra distance outside the visible range + we want to page. The defaults will be valid. You would + set this if you want to pull tiles in earlier. Be sure + to call it before you call Init(), however. + */ + virtual bool SetPageDistFactor(double); + + /* Updates the current location for paging purposes. + Returns true if any load or unloads need to happen. + */ + virtual bool SetLocation(trpg2dPoint &); + + /* Get next tile to load. + The paging manager is keeping track of which tiles + need to be loaded and in what order. This method + returns a pointer to the next one. The user is + expected to call AckLoad() after the tile is loaded. + */ + virtual trpgManagedTile *GetNextLoad(void); + /* Acknowledge Tile Load. + This method should be called when a tile has been + loaded by the caller. This method is used in conjunction + with GetNextLoad(). + */ + virtual void AckLoad(void); + + /* Add Group ID to map. + This should be called when the user encounters a group-like + object while processing the scene graph data from a tile. + The groupId is given by TerraPage and the data should be + the corresponding group object that the user creates in + their own scenegraph toolkit. This information can then + be retrieved later by GetGroupData(). + */ + virtual void AddGroupID(trpgManagedTile *,int groupID,void *data); + + /* Get Group Data fetches the data cached by the user and + associated with the given groupID. This would be used in + conjunction with trpgAttach nodes to implement geometry paging. + */ + virtual void *GetGroupData(int groupID); + + /* Get next tile to unload. + The paging manager keeps track of which tiles need + to be unloaded based on a change of location. It's + best if you unload tiles before loading them, but + that's really up to you. + */ + virtual trpgManagedTile *GetNextUnload(void); + /* Acknowledge a tile unload. + You should call this after you've "unloaded" a tile + and all its associated textures. + */ + virtual void AckUnload(void); + + /* Stop paging entirely. Call this right before you want to + shut down paging. Everything active will wind up on the + unload lists. Then you can unload those tiles and move on. + */ + virtual bool Stop(void); + + // Print current status and content information + virtual void Print(trpgPrintBuffer &); + +protected: + trpgr_Archive *archive; + + // Center of paging + trpg2dPoint pagePt; + + /* Information associated with each terrain level of + detail as related to paging. + */ + class LodPageInfo { + friend class trpgPageManager; + public: + LodPageInfo(void); + virtual ~LodPageInfo(void); + + /* Initializes the class with its current LOD. + It figures out all the rest. + */ + virtual bool Init(trpgr_Archive *, int myLod, double scale); + + /* Reset the location. This forces a recalculation + of what to load and unload if the cell has changed + or if this is the first SetLocation. + The location passed in must be relative to the southwest + corner of the TerraPage archive. + */ + virtual bool SetLocation(trpg2dPoint &); + + // Return the next tile to load for this terrain lod + virtual trpgManagedTile *GetNextLoad(void); + // Acknowledge the load. Move the active tile to the + // loaded list. + virtual void AckLoad(void); + // Return the next tile to unload for this terrain lod + virtual trpgManagedTile *GetNextUnload(void); + // Acknowledge the unload. Move the active tile to the + // free list. + virtual void AckUnload(void); + // Called to stop paging. Everything active is dumped on + // the unload list. + virtual bool Stop(void); + // Print current status and content information + virtual void Print(trpgPrintBuffer &); + protected: + virtual void Clean(void); + virtual void Update(void); + + // Check if the given tile is within the area we care about + bool isWithin(trpgManagedTile *,trpg2iPoint &sw,trpg2iPoint &ne); + + bool valid; + + // Terrain LOD we're responsible for + int lod; + + /* Adjusted (e.g. paranoid) distance outward from + which to page this terrain LOD. This takes into + account the distance in the header as well as + any factor the user may have added. + */ + double pageDist; + + /* Max tiles we could have loaded in at any given time. + This is just a guess because it's up to the user + to load (and, more importantly) unload. + */ + int maxNumTiles; + + // Size of a single cell. Copied from the archive. + trpg2dPoint cellSize; + + // Number of tiles (cells) in each direction + trpg2iPoint lodSize; + + /* Area of interest size in cells + This is a linear distance "ahead" of the center cell. + */ + trpg2iPoint aoiSize; + + /* Our effective paging location sits at the middle + of this cell. We don't recalculate unless the + cell changes. */ + trpg2iPoint cell; + + // List of tiles to load + std::deque load; + // List of tiles to unload + std::deque unload; + // List of currently loaded tiles + std::deque current; + + // Used by Update. Here because we want to avoid memory allocs, if possible. + std::vector tmpCurrent; + + // Set if a load is in progress + // Load w/o ACK + bool activeLoad; + // Set if an unload is in progress + // Unload w/o ACK + bool activeUnload; + + // List of tile pointers we can reuse + std::deque freeList; + }; + + // Per terrain lod paging information + std::vector pageInfo; + + // Enumerated type for lastLoad + typedef enum {Load,Unload,None} LoadType; + /* Information about what the pending load/unload operation + is. It's up to the user to complete and acknowledge it. + */ + LoadType lastLoad; + // LOD for the pending load/unload requested operation + int lastLod; + // Tile to be loaded/unloaded + trpgManagedTile *lastTile; + + // Optional scaling factor + double scale; + + // Mapping from group IDs to user defined data + typedef std::map ManageGroupMap; + ManageGroupMap groupMap; + + bool valid; +}; + +/* Page Manager Tester. This class tests a given paging manager + by applying likely + */ +TX_EXDECL class TX_CLDECL trpgPageManageTester { +public: + trpgPageManageTester(); + virtual ~trpgPageManageTester(); + + /* Initialize the tester with a paging manager + and an archive. + */ + void Init(trpgPrintBuffer *,trpgPageManager *,trpgr_Archive *); + + /* Feeds the paging manager coordinates starting from + the lower left to upper right of the database in the + given increment. + */ + void Fly_LL_to_UR(double dist=100.0); + + /* Jumps around randomly within the archive loading and + unloading as needed. + */ + void RandomTest(int no=100,int seed=-1); + +protected: + // Does the work of "load" and "unloading" + void ProcessChanges(); + + trpgPageManager *manager; + trpgr_Archive *archive; + trpgPrintBuffer *printBuf; +}; + +#endif diff --git a/src/osgPlugins/txp/trpage_print.h b/include/osgTXP/trpage_print.h similarity index 99% rename from src/osgPlugins/txp/trpage_print.h rename to include/osgTXP/trpage_print.h index 4f93645b7..9d37e0add 100644 --- a/src/osgPlugins/txp/trpage_print.h +++ b/include/osgTXP/trpage_print.h @@ -16,7 +16,7 @@ #ifndef trpage_print_h_ #define trpage_print_h_ -#include "trpage_read.h" +#include /* Print Buffer for TerraPage. Subclasses of this object are used to print out to stdout or disk (or whatever). diff --git a/src/osgPlugins/txp/trpage_read.h b/include/osgTXP/trpage_read.h similarity index 99% rename from src/osgPlugins/txp/trpage_read.h rename to include/osgTXP/trpage_read.h index 8231d0ac0..2a71dd71a 100644 --- a/src/osgPlugins/txp/trpage_read.h +++ b/include/osgTXP/trpage_read.h @@ -21,9 +21,9 @@ Classes used to represent read objects for paging files. */ -#include "trpage_sys.h" +#include -#include "trpage_geom.h" +#include /* Callback base class Called when a given token is found. diff --git a/src/osgPlugins/txp/trpage_scene.h b/include/osgTXP/trpage_scene.h similarity index 99% rename from src/osgPlugins/txp/trpage_scene.h rename to include/osgTXP/trpage_scene.h index 6d2e9b598..605d8e886 100644 --- a/src/osgPlugins/txp/trpage_scene.h +++ b/include/osgTXP/trpage_scene.h @@ -26,7 +26,7 @@ for how to read TerraPage format into your own scene graph. */ -#include "trpage_geom.h" +#include /* {group:Demonstration Scene Graph} diff --git a/src/osgPlugins/txp/trpage_swap.h b/include/osgTXP/trpage_swap.h similarity index 97% rename from src/osgPlugins/txp/trpage_swap.h rename to include/osgTXP/trpage_swap.h index a42e84aaf..6b79eb9ee 100644 --- a/src/osgPlugins/txp/trpage_swap.h +++ b/include/osgTXP/trpage_swap.h @@ -20,9 +20,9 @@ Byte swapping utility functions. */ -#include "trpage_sys.h" +#include -#include "trpage_io.h" +#include // Byte swap and return a short // {group:Byte Ordering Utilities} diff --git a/src/osgPlugins/txp/trpage_sys.h b/include/osgTXP/trpage_sys.h similarity index 97% rename from src/osgPlugins/txp/trpage_sys.h rename to include/osgTXP/trpage_sys.h index bd0ac2a18..e97fec616 100644 --- a/src/osgPlugins/txp/trpage_sys.h +++ b/include/osgTXP/trpage_sys.h @@ -101,7 +101,7 @@ typedef int64 trpgllong; // These are used to export classes from a DLL // Definitely Windows specific -#include "trpage_ident.h" -#include "trdll.h" +#include +#include #endif diff --git a/include/osgTXP/trpage_util.h b/include/osgTXP/trpage_util.h new file mode 100644 index 000000000..13a7bd31e --- /dev/null +++ b/include/osgTXP/trpage_util.h @@ -0,0 +1,33 @@ +/* ************************ + Copyright Terrain Experts Inc. + Terrain Experts Inc (TERREX) reserves all rights to this source code + unless otherwise specified in writing by the President of TERREX. + This copyright may be updated in the future, in which case that version + supercedes this one. + ------------------- + Terrex Experts Inc. + 4400 East Broadway #314 + Tucson, AZ 85711 + info@terrex.com + Tel: (520) 323-7990 + ************************ + */ + +/* trpage_sys.h + System specific declarations. + */ + +#ifndef trpage_util_h_ +#define trpage_util_h_ +#include +#include +#include +#include + +TX_EXDECL class TX_CLDECL trpgUtil { +public: + enum {DoReport = 1<<0,DoCopy = 1<<1, DoTileOpt = 1<<2}; + int merge(trpgr_Archive &inArch1,trpgr_Archive &inArch2,trpgwArchive &outArch, int flags = 0); +}; +#endif + diff --git a/src/osgPlugins/txp/trpage_write.h b/include/osgTXP/trpage_write.h similarity index 99% rename from src/osgPlugins/txp/trpage_write.h rename to include/osgTXP/trpage_write.h index 9e3c1e9a5..642924747 100644 --- a/src/osgPlugins/txp/trpage_write.h +++ b/include/osgTXP/trpage_write.h @@ -21,9 +21,9 @@ Classes that are used to write paging archives. */ -#include "trpage_sys.h" -#include "trpage_io.h" -#include "trpage_swap.h" +#include +#include +#include /* Geometry Stats Used with a Geometry Helper to keep track of what go built. diff --git a/src/Demos/osgtxp/Makefile b/src/Demos/osgtxp/Makefile new file mode 100644 index 000000000..31c676a1c --- /dev/null +++ b/src/Demos/osgtxp/Makefile @@ -0,0 +1,18 @@ +TOPDIR = ../../.. +include $(TOPDIR)/Make/makedefs + +CXXFILES =\ + osgtxp.cpp\ + +LIBS += $(OSG_LIBS) $(GLUT_LIB) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) + +LIBS += -losgTXP + +INSTFILES = \ + $(CXXFILES)\ + Makefile.inst=Makefile + +EXEC = osgtxp + +include $(TOPDIR)/Make/makerules + diff --git a/src/Demos/osgtxp/osgtxp.cpp b/src/Demos/osgtxp/osgtxp.cpp new file mode 100644 index 000000000..8171a83cc --- /dev/null +++ b/src/Demos/osgtxp/osgtxp.cpp @@ -0,0 +1,170 @@ +#include +#include +#include + +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include + + +void write_usage(std::ostream& out,const std::string& name) +{ + out << std::endl; + out <<"usage:"<< std::endl; + out <<" "< commandLine; + for(int i=1;isetWindowTitle(argv[0]); + + // configure the viewer from the commandline arguments, and eat any + // parameters that have been matched. + viewer->readCommandLine(commandLine); + + // configure the plugin registry from the commandline arguments, and + // eat any parameters that have been matched. + osgDB::readCommandLine(commandLine); + + // Initialize the TXP database + bool loadAll = false; + bool threadIt = false; + std::string fileName; + for(std::vector::iterator itr=commandLine.begin(); + itr!=commandLine.end(); + ++itr) + { + if ((*itr)[0]!='-') + { + fileName = (*itr); + } else { + // Look for switches we want + if (!strcasecmp((*itr).c_str(),"-loadall")) { + loadAll = true; + continue; + } + if (!strcasecmp((*itr).c_str(),"-thread")) { + threadIt = true; + continue; + } + } + } + if (fileName.empty()) { + fprintf(stderr,"No TerraPage file specified on command line.\n"); + return 1; + } + // Open the TXP database + TrPageArchive *txpArchive = new TrPageArchive(); + if (!txpArchive->OpenFile(fileName.c_str())) { + fprintf(stderr,"Couldn't load TerraPage archive %s.\n",fileName.c_str()); + return 1; + } + // Note: Should be checking the return values + txpArchive->LoadMaterials(); +// txpArchive->LoadModels(); + + // Might need a page manager if we're paging + OSGPageManager *pageManager = new OSGPageManager(txpArchive); + osg::Group *rootNode=NULL; + if (loadAll) { + // Load the whole scenegraph + rootNode = txpArchive->LoadAllTiles(); + if (!rootNode) { + fprintf(stderr,"Couldn't load whole TerraPage archive %s.\n",fileName.c_str()); + return 1; + } + // add a viewport to the viewer and attach the scene graph. + viewer->addViewport( rootNode ); + } else { + viewer->Init(pageManager,(threadIt ? txp::OSGPageManager::ThreadFree : txp::OSGPageManager::ThreadNone)); + rootNode = new osg::Group(); + viewer->addViewport(rootNode); + } + + // run optimization over the scene graph +// osgUtil::Optimizer optimzer; +// optimzer.optimize(rootnode); + + + // register trackball, flight and drive. + viewer->registerCameraManipulator(new osgGA::TrackballManipulator); + viewer->registerCameraManipulator(new osgGA::FlightManipulator); + viewer->registerCameraManipulator(new osgGA::DriveManipulator); + + // Recenter the camera to the middle of the database + osg::Vec3 center; + txpArchive->GetCenter(center); center[2] += 200; + osgUtil::SceneView *sceneView = viewer->getViewportSceneView(0); + osg::Camera *camera = sceneView->getCamera(); + osg::Vec3 eyePt = center; + eyePt[0] -= 1000; + osg::Vec3 upVec( 0, 0, 1 ); + camera->setLookAt(eyePt,center,upVec); + + // open the viewer window. + viewer->open(); + + // fire up the event loop. + viewer->run(); + + // Close things down + delete pageManager; + delete txpArchive; + delete viewer; + + return 0; +} diff --git a/src/osgPlugins/txp/Makefile b/src/osgPlugins/txp/Makefile index d60c3b7e3..652756c49 100644 --- a/src/osgPlugins/txp/Makefile +++ b/src/osgPlugins/txp/Makefile @@ -23,15 +23,24 @@ CXXFILES =\ trpage_compat.cpp\ trpage_light.cpp\ trpage_pparse.cpp\ - trpage_print.cpp + trpage_print.cpp\ + trpage_managers.cpp\ + trPagePageManager.cpp\ + trpage_print_parse.cpp\ + trpage_util.cpp\ + TrPageViewer.cpp\ -INC += -I$(THISDIR) + +INC += -I$(THISDIR) LIBS += $(OSG_LIBS) $(OTHER_LIBS) -TARGET_BASENAME = txp +PLUGIN_TARGET_BASENAME = txp include $(TOPDIR)/Make/cygwin_plugin_def -PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT) +PLUGIN = $(PLUGIN_PREFIX)$(PLUGIN_TARGET_BASENAME).$(PLUGIN_EXT) + +LIB_TARGET_BASENAME=osgTXP +LIB = $(LIB_PREFIX)$(LIB_TARGET_BASENAME).$(LIB_EXT) include $(TOPDIR)/Make/makerules diff --git a/src/osgPlugins/txp/ReaderWriterTXP.cpp b/src/osgPlugins/txp/ReaderWriterTXP.cpp index 8fa77791b..b0611e437 100644 --- a/src/osgPlugins/txp/ReaderWriterTXP.cpp +++ b/src/osgPlugins/txp/ReaderWriterTXP.cpp @@ -1,5 +1,5 @@ #include "ReaderWriterTXP.h" -#include "TrPageArchive.h" +#include #include #include diff --git a/src/osgPlugins/txp/ReaderWriterTXP.h b/src/osgPlugins/txp/ReaderWriterTXP.h index ec533db5e..4eb0ff3eb 100644 --- a/src/osgPlugins/txp/ReaderWriterTXP.h +++ b/src/osgPlugins/txp/ReaderWriterTXP.h @@ -26,7 +26,7 @@ #ifndef READER_WRITER_TXP_H #define READER_WRITER_TXP_H -#include "trpage_sys.h" +#include #include #include diff --git a/src/osgPlugins/txp/TrPageArchive.cpp b/src/osgPlugins/txp/TrPageArchive.cpp index 0e8bcc534..1dfba053a 100644 --- a/src/osgPlugins/txp/TrPageArchive.cpp +++ b/src/osgPlugins/txp/TrPageArchive.cpp @@ -1,5 +1,9 @@ -#include "TrPageArchive.h" -#include "TrPageParser.h" +#include +#include +#include + +#include +#include #include #include @@ -19,14 +23,12 @@ #include #include -#include "trpage_geom.h" -#include "trpage_read.h" -#include "trpage_write.h" -#include "trpage_scene.h" +#include +#include +#include +#include +#include -#include -#include -#include using namespace txp; using namespace osg; @@ -39,7 +41,8 @@ using namespace osg; TrPageArchive::TrPageArchive() : trpgr_Archive() -, parse(new TrPageParser(this)) +, parse(new TrPageParser(this)) +, buf(GetEndian()) { } @@ -85,6 +88,29 @@ bool TrPageArchive::OpenFile(const char* file) return true; } +/* Calculate the center of the database (including Z) + */ +void TrPageArchive::GetCenter(Vec3 ¢er) +{ + trpg2dPoint sw,ne; + const trpgHeader *head = GetHeader(); + const trpgTileTable *tileTable = GetTileTable(); + head->GetExtents(sw,ne); + trpg2dPoint tileSize; + head->GetTileSize(0,tileSize); + + center[0] = (ne.x+sw.x)/2.0; + center[1] = (ne.y+sw.y)/2.0; + + trpg2iPoint loc; + loc.x = int((center[0]-sw.x)/tileSize.x); + loc.y = int((center[1]-sw.y)/tileSize.y); + trpgwAppAddress foo; + float zmin,zmax; + tileTable->GetTile(loc.x, loc.y,0,foo,zmin,zmax); + center[2] = (zmin+zmax)/2.0; +} + // load textures and materials // TODO : multitexturing void TrPageArchive::LoadMaterials() @@ -174,6 +200,8 @@ void TrPageArchive::LoadMaterials() // TODO : multitextuting // also note that multitexturing in terrapage can came from two sides // - multiple textures per material, and multiple materials per geometry + // Note: Only in theory. The only type you'll encounter is multiple + // materials per polygon. if( numMatTex ) { Material *osg_material = new Material; @@ -337,6 +365,7 @@ bool TrPageArchive::LoadModels() return true; } +// Group* TrPageArchive::LoadTile(int x,int y,int lod,int &parentID,vector **groupList) Group* TrPageArchive::LoadTile(int x,int y,int lod,int &parentID) { trpgMemReadBuffer buf(GetEndian()); @@ -352,10 +381,71 @@ Group* TrPageArchive::LoadTile(int x,int y,int lod,int &parentID) // This is where you would page in textures and models } + // Also return the list of IDs and their groups we read in for this tile +// *groupList = parse->GetGroupList(); + // That's it return tile; } +// Group* TrPageArchive::LoadTile(Group *rootNode,trpgPageManager *pageManage,trpgManagedTile *tile,vector<) +Group* TrPageArchive::LoadTile(Group *rootNode, + trpgPageManager * /*pageManage*/, + trpgManagedTile *tile,osg::Group **parentNode) +{ + int x,y,lod; + tile->GetTileLoc(x,y,lod); + std::vector *groupList = parse->GetGroupList(); + + // Fetch the tile data (but don't parse it) + if (!ReadTile(x,y,lod,buf)) + return NULL; + + // Now parse it + Group *gTile = parse->ParseScene(buf, m_gstates, m_models); + if (gTile && rootNode) { + // Hook it into its parent + int parentID = parse->GetParentID(); + if (parentID >= 0) { + (*groupList)[parentID]->addChild(gTile); + } else + rootNode->addChild(gTile); + + // Note: Need to page in the textures + // They're being forced in during the parse right now + } + if (parentNode) { + int parentID = parse->GetParentID(); + if (parentID >= 0) + *parentNode = (*groupList)[parentID]; + else + *parentNode = rootNode; + } + + // Add the tile to the local data in the managed tile + tile->SetLocalData(gTile); + + return gTile; +} + +bool TrPageArchive::UnLoadTile(trpgPageManager * /*pageManage*/, + trpgManagedTile *tile) +{ + // The local tile data will have the group we need + Group *gTile = (Group *)tile->GetLocalData(); + if (gTile) { + // Remove it from the parent list + // We're only expecting on parent + const Group::ParentList &pList = gTile->getParents(); + if (pList.size() != 1) + return false; + pList[0]->removeChild(gTile); + } else + return false; + + return true; +} + //---------------------------------------------------------------------------- Group* TrPageArchive::LoadAllTiles() { @@ -372,6 +462,7 @@ Group* TrPageArchive::LoadAllTiles() trpg2iPoint tileSize; // The group list is used to map parent IDs to pfGroup nodes + //std::vector groupList; std::vector *groupList = parse->GetGroupList(); for (int nl=0;nladdChild(tile); + (*groupList)[parentID]->addChild(tile); } } } diff --git a/src/osgPlugins/txp/TrPageParser.cpp b/src/osgPlugins/txp/TrPageParser.cpp index a43abfebb..ba1fde1f0 100644 --- a/src/osgPlugins/txp/TrPageParser.cpp +++ b/src/osgPlugins/txp/TrPageParser.cpp @@ -19,7 +19,7 @@ * All Rights Reserved. * *****************************************************************************/ -#include "trpage_sys.h" +#include #include #include #include @@ -35,8 +35,8 @@ #include -#include "TrPageParser.h" -#include "TrPageArchive.h" +#include +#include /* #include #include @@ -121,6 +121,7 @@ Texture2D* txp::GetLocalTexture(trpgrImageHelper& image_helper, trpgLocalMateria if(gltype!=(GLenum)-1) { osg_texture = new Texture2D(); + osg_texture->setInternalFormatMode(internalFormat); Image* image = new Image; @@ -132,7 +133,7 @@ Texture2D* txp::GetLocalTexture(trpgrImageHelper& image_helper, trpgLocalMateria { int32 size = s.x*s.y*depth; // int32 size = const_cast(tex)->MipLevelSize(1) ; - data = (char*)::malloc(size); + data = (char *)::malloc(size); if(locmat) image_helper.GetImageForLocalMat(locmat,data,size); @@ -148,7 +149,7 @@ Texture2D* txp::GetLocalTexture(trpgrImageHelper& image_helper, trpgLocalMateria int32 size = tex->CalcTotalSize(); trpgTexture* tmp_tex = const_cast(tex); - data = (char*)::malloc(size); + data = (char *)::malloc(size); if(locmat) image_helper.GetImageForLocalMat(locmat,data,size); @@ -172,6 +173,8 @@ Texture2D* txp::GetLocalTexture(trpgrImageHelper& image_helper, trpgLocalMateria image->setMipmapData(mipmaps); } +// delete [] data; +// image->unref(); // AAAARRRGH! TOOK ME 2 DAYS TO FIGURE IT OUT // EVERY IMAGE HAS TO HAVE UNIQUE NAME FOR OPTIMIZER NOT TO OPTIMIZE IT OFF // @@ -216,7 +219,7 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf) Vec3Array* vertices = new Vec3Array(numVert); // Get vertices - geom.GetVertices(&(vertices->front())); + geom.GetVertices((float *)&(vertices->front())); // Turn the trpgGeometry into something Performer can understand Geometry *geometry = 0L; @@ -431,6 +434,7 @@ void* billboardRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf) Group* osg_Group = new Group; int type; bill.GetType(type); +// Note: Must deal with the billboard type here if( type == trpgBillboard::Group ) { // Create a new Performer group @@ -489,7 +493,8 @@ void* lodRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf) Vec3 osg_Center; osg_Center[0] = center.x; osg_Center[1] = center.y; osg_Center[2] = center.z; osg_Lod->setCenter(osg_Center); - osg_Lod->setRange(0,minRange,maxRange); + osg_Lod->setRange(0,0.0, minRange); + osg_Lod->setRange(1,minRange, maxRange ); // Our LODs are binary so we need to add a group under this LOD and attach stuff // to that instead of the LOD @@ -535,7 +540,12 @@ void *modelRefRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf) ); // Note: Array check before you do this - Node *osg_Model = (*parse->GetModels())[modelID].get(); + Node *osg_Model = NULL; + std::vector >*modelList = parse->GetModels(); + if( modelList->size() > size_t(modelID) ) + { + //(*parse->GetModels())[modelID].get(); + osg_Model = (*modelList)[modelID].get(); // Create the SCS and position the model if (osg_Model) { MatrixTransform *scs = new MatrixTransform(); @@ -546,6 +556,7 @@ void *modelRefRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf) if (top) top->addChild(scs); } + } return (void *) 1; } diff --git a/src/osgPlugins/txp/TrPageViewer.cpp b/src/osgPlugins/txp/TrPageViewer.cpp new file mode 100644 index 000000000..d38915502 --- /dev/null +++ b/src/osgPlugins/txp/TrPageViewer.cpp @@ -0,0 +1,188 @@ +#if defined(_MSC_VER) + #pragma warning( disable : 4786 ) +#endif + +#include +#include + +#include +#if (!defined(WIN32) && !defined(macintosh)) || defined(__CYGWIN__) +#include +#include +#endif +#include + +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#ifdef WIN32 +#define USE_FLTK +#define USE_GLUT +#endif + +#include +#include + +/* +#if defined(WIN32) && !defined(__CYGWIN__) +#include +#else +#endif +*/ + +using namespace osg; +using namespace osgUtil; +using namespace osgGLUT; +using namespace osgGA; + +using namespace std; +using namespace txp; + +PagingViewer::PagingViewer() : Viewer() +{ + pageManage = NULL; +} + +bool PagingViewer::Init(OSGPageManager *in_manage,OSGPageManager::ThreadMode threadMode) +{ + pageManage = in_manage; + + // Start up the thread if needed + if (threadMode != OSGPageManager::ThreadNone) { + ThreadID newThread; + pageManage->StartThread(threadMode,newThread); + } + + return true; +} + +/* App call + This replaces the app() call for the base viewer. + In this one, we ask the page manager to load stuff in. + */ +float PagingViewer::app(unsigned int viewport) +{ + osg::Timer_t beforeApp = _timer.tick(); + + + // update the camera manipulator. + osg::ref_ptr ea = osgNew GLUTEventAdapter; + ea->adaptFrame(_frameStamp->getReferenceTime()); + +#if 0 // This is the old way... + if (_viewportList[viewport]._eventHandler.valid() && _viewportList[viewport]._eventHandler->handle(*ea,*this)) + { + // event handler handle this call. + } + else if (_viewportList[viewport]._cameraManipulator->handle(*ea,*this)) + { + // osg::notify(osg::INFO) << "Handled update frame"<< std::endl; + } +#else // this is the new way + + bool handled = false; + for (EventHandlerList::iterator eh = _viewportList[viewport]._eventHandlerList.begin(); eh != _viewportList[viewport]._eventHandlerList.end(); + eh++ ) + { + if ( eh->valid() ) + { + if ( (*eh)->handle(*ea,*this) ) + { + handled = true; + break; + } + } + } +// if ( !handled ) { + _viewportList[viewport]._cameraManipulator->handle(*ea,*this); +// } + +#endif + + // Update the paging + if (pageManage) { + int numTile = 1; + osgUtil::SceneView *sceneView = getViewportSceneView(viewport); + osg::Camera *camera = sceneView->getCamera(); + const Vec3 &eyePt = camera->getEyePoint(); + double eyeX = eyePt[0]; + double eyeY = eyePt[1]; + + /* If we're in ThreadFree mode, merge in whatever may be ready. + If we're in non-thread mode, load in the given number of tiles (maximum). + */ + if (pageManage->GetThreadMode() == OSGPageManager::ThreadFree) { + pageManage->MergeUpdateThread((osg::Group *)sceneView->getSceneData()); + pageManage->UpdatePositionThread(eyeX,eyeY); + } else { + pageManage->UpdateNoThread((osg::Group *)sceneView->getSceneData(),eyeX,eyeY,numTile); + } + } + + // do app traversal. + + getViewportSceneView(viewport)->setFrameStamp(_frameStamp.get()); + getViewportSceneView(viewport)->app(); + + osg::Timer_t beforeCull = _timer.tick(); + +#if 0 +// We're going for 66ms per frame +float targetFrameTime = 30; + + static osg::Timer_t lastCull = 0; + if (lastCull > 0) { + float deltaT = _timer.delta_m(lastCull,beforeCull); + int extraTime = targetFrameTime - deltaT; + if (extraTime > 0) + Sleep(extraTime); + } + lastCull = beforeCull; +#endif + + return _timer.delta_m(beforeApp,beforeCull); +} + +bool PagingViewer::run() +{ + updateFrameTick(); + return Window::run(); +} diff --git a/src/osgPlugins/txp/trPagePageManager.cpp b/src/osgPlugins/txp/trPagePageManager.cpp new file mode 100644 index 000000000..2fb2b6870 --- /dev/null +++ b/src/osgPlugins/txp/trPagePageManager.cpp @@ -0,0 +1,413 @@ +#include +#include + +#if defined(_WIN32) +#include +#include +#else +#include +#include +#endif + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include + +using namespace txp; +using namespace osg; + +OSGPageManager::OSGPageManager(TrPageArchive *in_arch,trpgPageManager *in_pageManage) +{ + archive = in_arch; + pageManage = in_pageManage; + + if (!in_arch) + throw 1; + + if (pageManage) + pageManageOurs = false; + else { + pageManage = new trpgPageManager(); + pageManage->SetPageDistFactor(1.2); + pageManage->Init(archive); + pageManageOurs = true; + } + + // Location info we'll need later + const trpgHeader *head = archive->GetHeader(); + trpg2dPoint sw,ne; + head->GetExtents(sw,ne); + originX = sw.x; + originY = sw.y; + + threadMode = ThreadNone; +} + +OSGPageManager::~OSGPageManager() +{ + if (threadMode != ThreadNone) + EndThread(); + if (pageManageOurs) + delete pageManage; + pageManage = NULL; +} + +/* Update + Bring the paging up to date based on the given location. + The location is in TerraPage's coordinate system, but must + still be adjusted to the SW corner. + */ +bool OSGPageManager::UpdateNoThread(osg::Group *rootNode,double locX,double locY,int numTile) +{ + // Adjust to TerraPage coordinates + double lx = locX-originX; + double ly = locY-originY; + + /* Do that paging thing: + - Tell the manager the new location + - Iterate over the unloads + - Iterate over the loads + */ + trpg2dPoint loc; + loc.x = lx; + loc.y = ly; + if (pageManage->SetLocation(loc)) { +// printf("Location (%f,%f) resulted in changes.",loc.x,loc.y); +// trpgFilePrintBuffer printBuf(stdout); +// pageManage->Print(printBuf); + } + + // Do the unloads + trpgManagedTile *tile=NULL; + while ((tile = pageManage->GetNextUnload())) { + archive->UnLoadTile(pageManage,tile); + pageManage->AckUnload(); + }; + + // Decide how many loads to do per frame + int loadCount=0; + + // Do the loads + while ((tile = pageManage->GetNextLoad())) { + archive->LoadTile(rootNode,pageManage,tile); + pageManage->AckLoad(); + loadCount++; + if (numTile > 0 && loadCount >= numTile) + break; + }; + + return true; +} + +// Mutex lock function +// --- Either thread --- +void osgLockMutex(ThreadMutex &mtx) +{ +#if defined (_WIN32) + WaitForSingleObject( mtx, INFINITE); +#else + pthread_mutex_lock( &mtx ); +#endif +} + +// Mutex unlock function +// --- Either thread --- +void osgUnLockMutex(ThreadMutex &mtx) +{ +#if defined (_WIN32) + ReleaseMutex(mtx); +#else + pthread_mutex_unlock( &mtx ); +#endif +} + +// Wait for Event +// --- Either thread (only used in paging thread) --- +void osgWaitEvent(ThreadEvent &ev) +{ +#if defined (_WIN32) + WaitForSingleObject( ev, INFINITE); +#else + ev.wait(); +#endif +} + +// Set Event (i.e. notify the other thread something's up) +// --- Either thread (only used in main thread) --- +void osgSetEvent(ThreadEvent &ev) +{ +#if defined (_WIN32) + SetEvent(ev); +#else + ev.release(); +#endif +} + +// Windows specific thread function. +// This just fires up our own loop +// --- Paging Thread --- +#if defined (_WIN32) +DWORD WINAPI ThreadFunc( LPVOID lpParam ) +{ + OSGPageManager *myPager = (OSGPageManager *)lpParam; + myPager->ThreadLoop(); + + return 0; +} +#else // Pthreads, cause Pthreads is a POSIX standard and is EVERYWHERE else + +void *ThreadFunc( void *data ) +{ + OSGPageManager *myPager = static_cast(data); + myPager->ThreadLoop(); + return 0L; +} +#endif + +/* Start Thread + This initialized + --- Main Thread --- + */ +bool OSGPageManager::StartThread(ThreadMode mode,ThreadID &newThread) +{ + positionValid = false; + +#if defined(_WIN32) + // Create the event we'll use to wake up the pager thread when the location changes + locationChangeEvent = CreateEvent(NULL,false,false,"Location Change Event"); + + // Create the mutexes we'll need later + changeListMutex = CreateMutex(NULL,false,"Change List Mutex"); + locationMutex = CreateMutex(NULL,false,"Location Mutex"); + + { + // Create the thread + DWORD dwThreadId=0; + LPVOID dwThrdParam = (LPVOID) this; + + newThread = CreateThread( + NULL, // default security attributes + 0, // use default stack size + ThreadFunc, // thread function + dwThrdParam, // argument to thread function + 0, // use default creation flags + &dwThreadId); // returns the thread identifier + } + + // Note: Should be optional + // Set the priority low so this is only called when the other thread is idle +// if (!SetThreadPriority(newThread,THREAD_PRIORITY_IDLE)) +// fprintf(stderr,"Couldn't set paging thread priority.\n"); + + // Was successfull + if (newThread != NULL) + threadMode = mode; +#endif + //locationChangeEvent is self-initialized. + pthread_mutex_init( &changeListMutex, 0L ); + pthread_mutex_init( &locationMutex, 0L ); + if( pthread_create( &newThread, 0L, ThreadFunc, (void *)this ) == 0 ) + threadMode = mode; + return threadMode != ThreadNone; +} + +/* End Thread + Note: Do this + */ +bool OSGPageManager::EndThread() +{ +#ifdef WIN32 +#else + // Need a handle to the thread ID here. + //pthread_cancel( ?newThread? ); +#endif + return true; +} + +/* Thread Loop + This method is the main loop for the pager when it's + working in its own thread. + --- Paging Thread --- + */ +bool OSGPageManager::ThreadLoop() +{ + // Note: Only works for free running thread + if (threadMode != ThreadFree) + throw 1; + + bool done = false; + bool pagingActive = false; + while (!done) { + /* Here's how we do it: + Wait for position change + Update manager w/ position + Form delete list + Load tile (if needed) + Add tile to merge list + */ + // Position has already changed or we'll wait for it to do so + osgWaitEvent(locationChangeEvent); + double myLocX,myLocY; + { + osgLockMutex(locationMutex); + myLocX = locX; + myLocY = locY; + osgUnLockMutex(locationMutex); + } + + // Pass the new location on to page manager + trpg2dPoint loc; + loc.x = myLocX; + loc.y = myLocY; + if (pageManage->SetLocation(loc) || pagingActive) { + // If there were changes, process them + // Form the delete list first + trpgManagedTile *tile=NULL; + std::vector unhook; + while (tile = pageManage->GetNextUnload()) { + unhook.push_back((Group *)tile->GetLocalData()); + pageManage->AckUnload(); + } + + // Tell the main thread to unhook tiles + // and get the groups to delete as well. + std::vector nextDelete; + { + osgLockMutex(changeListMutex); + // Add to the unhook list + for (unsigned int ti=0;tiunref(); + + // Now do a single load + tile = pageManage->GetNextLoad(); + osg::Group *tileGroup=NULL; + pagingActive = false; + if (tile) { + osg::Group *parentNode = NULL; + tileGroup = archive->LoadTile(NULL,pageManage,tile,&parentNode); + pageManage->AckLoad(); + if (tileGroup) { + // Make an extra reference to it because we want it back for deletion + tileGroup->ref(); + } else { + int x,y,lod; + tile->GetTileLoc(x,y,lod); + fprintf(stderr,"Failed to load tile (%d,%d,%d)\n",x,y,lod); + } + + // Now add this tile to the merge list + if (tileGroup) { + osgLockMutex(changeListMutex); + toMerge.push_back(tileGroup); + toMergeParent.push_back(parentNode); + osgUnLockMutex(changeListMutex); + } + // We're not necessarily done paging, we're just handing control back + // It's likely we'll be back here + pagingActive = true; + } + } + } + + + return true; +} + +/* Update Position Thread + This method updates the location for the paging thread to use. + --- Main Thread --- + */ +void OSGPageManager::UpdatePositionThread(double inLocX,double inLocY) +{ + // Update the position + { + // Get the location mutex + osgLockMutex(locationMutex); + positionValid = true; + locX = inLocX-originX; + locY = inLocY-originY; + osgUnLockMutex(locationMutex); + } + + // Notify the paging thread there's been a position update + osgSetEvent(locationChangeEvent); +} + +/* Merge Updates + Merge in the new tiles and unhook the ones we'll be deleting. + Actually, we'll hand these back to the paging thread for deletion. + --- Main Thread --- + */ +bool OSGPageManager::MergeUpdateThread(osg::Group *rootNode) +{ + std::vector mergeList; + std::vector mergeParentList; + std::vector unhookList; + + // Make local copies of the merge and unhook lists + { + osgLockMutex(changeListMutex); + mergeList = toMerge; + mergeParentList = toMergeParent; + unhookList = toUnhook; + + toMerge.clear(); + toMergeParent.clear(); + toUnhook.clear(); + osgUnLockMutex(changeListMutex); + } + + // Do the unhooking first + for (unsigned int ui=0;uigetParents(); + for (unsigned int pi=0;piremoveChild(unhookMe); + } + } + + // Put the unhooked things on the list to delete + { + osgLockMutex(changeListMutex); + for (unsigned int di=0;diaddChild(mergeMe); + else + rootNode->addChild(mergeMe); + } + } + + return true; +} diff --git a/src/osgPlugins/txp/trpage_basic.cpp b/src/osgPlugins/txp/trpage_basic.cpp index dee17e4c5..3e166f637 100644 --- a/src/osgPlugins/txp/trpage_basic.cpp +++ b/src/osgPlugins/txp/trpage_basic.cpp @@ -20,7 +20,7 @@ #include #include -#include "trpage_io.h" +#include /* Checkable This is just a class that checks validity. diff --git a/src/osgPlugins/txp/trpage_compat.cpp b/src/osgPlugins/txp/trpage_compat.cpp index ff1161553..9fff51cf7 100644 --- a/src/osgPlugins/txp/trpage_compat.cpp +++ b/src/osgPlugins/txp/trpage_compat.cpp @@ -24,9 +24,9 @@ */ -#include "trpage_geom.h" -#include "trpage_read.h" -#include "trpage_compat.h" +#include +#include +#include /* Old short Material definition from 1.0. {secret} diff --git a/src/osgPlugins/txp/trpage_geom.cpp b/src/osgPlugins/txp/trpage_geom.cpp index 37faa7bda..2d2e067aa 100644 --- a/src/osgPlugins/txp/trpage_geom.cpp +++ b/src/osgPlugins/txp/trpage_geom.cpp @@ -24,8 +24,8 @@ #include #include -#include "trpage_geom.h" -#include "trpage_read.h" +#include +#include #include diff --git a/src/osgPlugins/txp/trpage_header.cpp b/src/osgPlugins/txp/trpage_header.cpp index 9382f591b..120658ed8 100644 --- a/src/osgPlugins/txp/trpage_header.cpp +++ b/src/osgPlugins/txp/trpage_header.cpp @@ -23,8 +23,8 @@ to the header definition. */ -#include "trpage_geom.h" -#include "trpage_read.h" +#include +#include /* Write Header class Fill it in and write it out. diff --git a/src/osgPlugins/txp/trpage_light.cpp b/src/osgPlugins/txp/trpage_light.cpp index b360e331d..d5f8c5cfd 100644 --- a/src/osgPlugins/txp/trpage_light.cpp +++ b/src/osgPlugins/txp/trpage_light.cpp @@ -24,8 +24,8 @@ #include #include -#include "trpage_geom.h" -#include "trpage_read.h" +#include +#include #if defined(_WIN32) #define ALIGNMENT_WORKAROUND false diff --git a/src/osgPlugins/txp/trpage_main.cpp b/src/osgPlugins/txp/trpage_main.cpp index a139b3257..7dc7d6308 100644 --- a/src/osgPlugins/txp/trpage_main.cpp +++ b/src/osgPlugins/txp/trpage_main.cpp @@ -26,6 +26,6 @@ #include #include -#include "trdll.h" +#include TXDUMMY_DLL_MAIN diff --git a/src/osgPlugins/txp/trpage_managers.cpp b/src/osgPlugins/txp/trpage_managers.cpp new file mode 100644 index 000000000..1aaa4031b --- /dev/null +++ b/src/osgPlugins/txp/trpage_managers.cpp @@ -0,0 +1,810 @@ +/* ************************ + Copyright Terrain Experts Inc. + Terrain Experts Inc (TERREX) reserves all rights to this source code + unless otherwise specified in writing by the President of TERREX. + This copyright may be updated in the future, in which case that version + supercedes this one. + ------------------- + Terrex Experts Inc. + 4400 East Broadway #314 + Tucson, AZ 85711 + info@terrex.com + Tel: (520) 323-7990 + ************************ + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +/* Managed Tile class. + Check the header file for details. + */ + +trpgManagedTile::trpgManagedTile() +{ + isLoaded = false; + x = y = -1; + lod = -1; + localData = NULL; +} + +void trpgManagedTile::Reset() +{ + // Null out the local material data + for (int i=0;i *trpgManagedTile::GetLocMatList() const +{ + return tileHead.GetLocalMaterialList(); +} + +const trpgLocalMaterial *trpgManagedTile::GetLocMaterial(int id) const +{ + const std::vector *matList; + matList = tileHead.GetLocalMaterialList(); + + if (id <0 || id >= int(matList->size())) + return NULL; + + return &(*matList)[id]; +} + +void trpgManagedTile::SetLocalData(void *inData) +{ + localData = inData; +} + +void *trpgManagedTile::GetLocalData() const +{ + return localData; +} + +bool trpgManagedTile::SetMatData(int id,void *info) +{ + if (id < 0 || id >= int(localMatData.size())) + return false; + + localMatData[id] = info; + + return true; +} + +void *trpgManagedTile::GetMatData(int id) const +{ + if (id < 0 || id >= int(localMatData.size())) + return NULL; + + return localMatData[id]; +} + +void trpgManagedTile::AddGroupID(int id) +{ + groupIDs.push_back(id); +} + +const std::vector *trpgManagedTile::GetGroupIDs() const +{ + return &groupIDs; +} + +void trpgManagedTile::Print(trpgPrintBuffer &buf) +{ + char line[1024]; + sprintf(line,"x = %d, y = %d, lod = %d",x,y,lod); buf.prnLine(line); + // Note: Should print the rest too, probably. +} + +/* Page Manager LOD Page Info class. + Used by the page manager to keep track of paging information + for a single terrain LOD. See the header file for details. + */ + +trpgPageManager::LodPageInfo::LodPageInfo() +{ + valid = false; + pageDist = 0.0; + cell.x = cell.y = -100; +} + +trpgPageManager::LodPageInfo::~LodPageInfo() +{ + Clean(); +} + +void trpgPageManager::LodPageInfo::Clean() +{ + // Clean up managed tile structures + int i; + for (i=0;iGetHeader(); + head->GetTileSize(lod,cellSize); + head->GetLodRange(lod,pageDist); + head->GetLodSize(lod,lodSize); + pageDist *= scale; + + // Area of interest size (in cells) + aoiSize.x = (int)(pageDist/cellSize.x); + aoiSize.y = (int)(pageDist/cellSize.y); + + /* Make a guess as to how many tiles we might have loaded + in at any given time. Give ourselves 15% extra room. + From the area of interest in cells, we can guess the max + number of tiles (aka cells) we'll have loaded in at once. + Note that the AOI size is only ahead, so it must be doubled. + */ + maxNumTiles = (int)(1.15*(2*aoiSize.x+1)*(2*aoiSize.y+1)); + + // Allocate 'em + for (int i=0;i= lodSize.x) newCell.x = lodSize.x-1; + if (newCell.y >= lodSize.y) newCell.y = lodSize.y-1; + + // Nothing to page. Done. + if (newCell.x == cell.x && newCell.y == cell.y) + return false; + + // Cell has changed. Update. + cell = newCell; + + Update(); + + return true; +} + +trpgManagedTile *trpgPageManager::LodPageInfo::GetNextLoad() +{ + // Can only load one tile at a time + if (activeLoad) + return NULL; + + // Clear any NULLs at the beginning + while (load.size() && !load[0]) + load.pop_front(); + + if (load.size() > 0) { + activeLoad = true; + return load[0]; + } + + return NULL; +} + +void trpgPageManager::LodPageInfo::AckLoad() +{ + if (activeLoad) { + current.push_back(load[0]); + load.pop_front(); + } + activeLoad = false; +} + +trpgManagedTile *trpgPageManager::LodPageInfo::GetNextUnload() +{ + // Can only unload one tile at a time + if (activeUnload) + return NULL; + + // Clear any NULLs at the beginning + while (unload.size() && !unload[0]) + unload.pop_front(); + + if (unload.size() > 0) { + activeUnload = true; + return unload[0]; + } + + return NULL; +} + +void trpgPageManager::LodPageInfo::AckUnload() +{ + if (activeUnload) { + trpgManagedTile *tile = unload[0]; + tile->Reset(); + freeList.push_back(tile); + unload.pop_front(); + } + activeUnload = false; +} + +bool trpgPageManager::LodPageInfo::isWithin(trpgManagedTile *tile,trpg2iPoint &sw,trpg2iPoint &ne) +{ + int tileX,tileY,tileLod; + tile->GetTileLoc(tileX,tileY,tileLod); + if (tileX >= sw.x && tileX <= ne.x && + tileY >= sw.y && tileY <= ne.y) + return true; + + return false; +} + +bool trpgPageManager::LodPageInfo::Stop() +{ + // Empty the load list + int i; + for (i=0;i 0); +} + +/* Update does the major work of figuring out what to load and + what to unload. + */ + +void trpgPageManager::LodPageInfo::Update() +{ + trpg2iPoint sw,ne; + + // Figure out the lower left and upper right corners + // in cell coordinates + sw.x = cell.x - aoiSize.x; sw.y = cell.y - aoiSize.y; + ne.x = cell.x + aoiSize.x; ne.y = cell.y + aoiSize.y; + sw.x = MAX(0,sw.x); sw.y = MAX(0,sw.y); + ne.x = MIN(lodSize.x-1,ne.x); ne.y = MIN(lodSize.y-1,ne.y); + + /* Load list - + Some of the tiles we're supposed to load may now be + out of range. Take them off the load list. + */ + int i; + for (i=0;iGetTileLoc(tileX,tileY,tileLod); + tmpCurrent[(tileY-sw.y)*dx + (tileX-sw.x)] = true; + } + } + + // Now figure out which ones are missing and add them + // to the load list + for (int x=0;x 0) { + tile = freeList[0]; + freeList.pop_front(); + } else + tile = new trpgManagedTile(); + tile->SetTileLoc(x+sw.x,y+sw.y,lod); + load.push_back(tile); + } + } + } + + // That's it. All the rest is handled by the caller + // iterating through the tiles to load and unload. +} + +void trpgPageManager::LodPageInfo::Print(trpgPrintBuffer &buf) +{ + char line[1024]; + int i; + + sprintf(line,"lod = %d, valid = %s",lod,(valid ? "yes" : "no")); buf.prnLine(line); + sprintf(line,"pageDist = %f, maxNumTiles = %d",pageDist,maxNumTiles); buf.prnLine(line); + sprintf(line,"cellSize = (%f,%f)",cellSize.x,cellSize.y); buf.prnLine(line); + sprintf(line,"cell = (%d,%d), aoiSize = (%d,%d), lodSize = (%d,%d)",cell.x,cell.y,aoiSize.x,aoiSize.y,lodSize.x,lodSize.y); buf.prnLine(line); + + sprintf(line,"Loads: (activeLoad = %s)",(activeLoad ? "yes" : "no")); buf.prnLine(line); + buf.IncreaseIndent(); + for (i=0;iPrint(buf); + buf.DecreaseIndent(); + + sprintf(line,"Unloads: (activeUnload = %s)",(activeUnload ? "yes" : "no")); buf.prnLine(line); + buf.IncreaseIndent(); + for (i=0;iPrint(buf); + buf.DecreaseIndent(); + + buf.prnLine("Currently loaded:"); + buf.IncreaseIndent(); + for (i=0;iPrint(buf); + buf.DecreaseIndent(); + + sprintf(line,"Free list size = %d",freeList.size()); buf.prnLine(line); +} + +/* Page Manager methods + These are methods of the main trpgPageManager. Check the header + file for more detailed information. + */ + +trpgPageManager::trpgPageManager() +{ + scale = 1.0; + valid = false; + // This should be sufficiently unlikely + pagePt.x = -1e20; pagePt.y = -1e20; +} + +trpgPageManager::~trpgPageManager() +{ +} + +void trpgPageManager::Init(trpgr_Archive *inArch) +{ + archive = inArch; + + // We're resetting everything. In general, Init should only + // be called once, but it'll work fine if you call it more than once. + lastLoad = None; + lastTile = NULL; + lastLod = -1; + + // Need to know the number of terrain LODs + const trpgHeader *head = archive->GetHeader(); + int numLod; + head->GetNumLods(numLod); + + // Reset the terrain LOD paging classes. + valid = true; + pageInfo.resize(numLod); + for (int i=0;ilod; + } + + return tile; +} + +void trpgPageManager::AckLoad() +{ + // If we're not in the middle of a load, register our displeasure + if (lastLoad != Load) + throw 1; + + LodPageInfo &info = pageInfo[lastLod]; + info.AckLoad(); + lastLoad = None; + lastTile = NULL; +} + +void trpgPageManager::AddGroupID(trpgManagedTile *tile,int groupID,void *data) +{ + groupMap[groupID] = data; + tile->AddGroupID(groupID); +} + +void *trpgPageManager::GetGroupData(int groupID) +{ + ManageGroupMap::const_iterator p = groupMap.find(groupID); + if (p != groupMap.end()) + return (*p).second; + + return NULL; +} + +trpgManagedTile *trpgPageManager::GetNextUnload() +{ + // If we're already doing something, let them know about it + if (lastLoad != None) + throw 1; + + // Look for anything that needs unloaded + // Start with highest LOD, work down to lowest + trpgManagedTile *tile = NULL; + for (int i=pageInfo.size()-1;i>=0;i--) { + LodPageInfo &info = pageInfo[i]; + if ((tile = info.GetNextUnload())) + break; + } + + // Found one. Now the user has to unload it. + if (tile) { + lastLoad = Unload; + lastTile = tile; + lastLod = tile->lod; + } + + return tile; +} + +void trpgPageManager::AckUnload() +{ + // If we're not in the middle of an unload, let 'em know. + if (lastLoad != Unload) + throw 1; + + // Remove this tile's group IDs from the map + const std::vector *groupIDs = lastTile->GetGroupIDs(); + int i; + for (i=0;isize());i++) { + ManageGroupMap::iterator p = groupMap.find((*groupIDs)[i]); + if (p != groupMap.end()) + groupMap.erase(p); + } + + LodPageInfo &info = pageInfo[lastLod]; + info.AckUnload(); + lastLoad = None; + lastTile = NULL; +} + +bool trpgPageManager::Stop() +{ + bool res=false; + int i; + for (i=0;iisValid()) + throw 1; + + // Start up the paging manager + manager->Init(archive); +} + +void trpgPageManageTester::RandomTest(int num,int seed) +{ + if (!manager || !archive || !printBuf) + throw 1; + + // Seed the random number generator so we can replicate runs + if (seed != -1) + srand(seed); + + // Need the extents + trpg2dPoint ll,ur,lod0Size; + const trpgHeader *head = archive->GetHeader(); + head->GetExtents(ll,ur); + head->GetTileSize(0,lod0Size); + + // Give ourselves some space around the extents + ll.x -= lod0Size.x/2.0; ll.y -= lod0Size.y/2.0; + ur.x += lod0Size.x/2.0; ur.y += lod0Size.y/2.0; + + // Jump around + int i; + char line[1024]; + for (i=0;iSetLocation(pt); + sprintf(line,"Jumped to (%f,%f). Tiles to load/unload = %s",pt.x,pt.y, + (changes ? "yes" : "no")); printBuf->prnLine(line); + + // Process the results + ProcessChanges(); + } + + // Ask the page manager for its final status + manager->Print(*printBuf); + + manager->Stop(); +} + +void trpgPageManageTester::Fly_LL_to_UR(double dist) +{ + char line[1024]; + + if (!manager || !archive || !printBuf) + throw 1; + + // Need the extents + trpg2dPoint ll,ur,lod0Size; + const trpgHeader *head = archive->GetHeader(); + head->GetExtents(ll,ur); + head->GetTileSize(0,lod0Size); + + // Give ourselves some space around the extents + ll.x -= lod0Size.x/2.0; ll.y -= lod0Size.y/2.0; + ur.x += lod0Size.x/2.0; ur.y += lod0Size.y/2.0; + + + // Fly the path + trpg2dPoint loc; loc = ll; + do { + loc.x += dist; loc.y += dist; + + // Jump to next point + bool changes = manager->SetLocation(loc); + sprintf(line,"Moved to (%f,%f). Tiles to load/unload = %s",loc.x,loc.y, + (changes ? "yes" : "no")); printBuf->prnLine(line); + + // Process new location + ProcessChanges(); + } while (loc.x < ur.x && loc.y < ur.y); + + // Ask the page manager for its final status + manager->Print(*printBuf); + + manager->Stop(); +} + +void trpgPageManageTester::ProcessChanges() +{ + char line[1024]; + int x,y,lod; + + // Look for unloads to process + trpgManagedTile *unloadTile; + printBuf->prnLine("Tiles to unload:"); + printBuf->IncreaseIndent(); + while ((unloadTile = manager->GetNextUnload())) { + unloadTile->GetTileLoc(x,y,lod); + sprintf(line,"x = %d, y = %d, lod = %d",x,y,lod); printBuf->prnLine(line); + manager->AckUnload(); + } + printBuf->DecreaseIndent(); + + // Look for loads to process + trpgManagedTile *loadTile; + printBuf->prnLine("Tiles to load:"); + printBuf->IncreaseIndent(); + while ((loadTile = manager->GetNextLoad())) { + loadTile->GetTileLoc(x,y,lod); + sprintf(line,"x = %d, y = %d, lod = %d",x,y,lod); printBuf->prnLine(line); + manager->AckLoad(); + } + printBuf->DecreaseIndent(); +} diff --git a/src/osgPlugins/txp/trpage_material.cpp b/src/osgPlugins/txp/trpage_material.cpp index 10091eaf4..da1d5b51a 100644 --- a/src/osgPlugins/txp/trpage_material.cpp +++ b/src/osgPlugins/txp/trpage_material.cpp @@ -23,8 +23,8 @@ You should only modify this code if you want to add data to these classes. */ -#include "trpage_geom.h" -#include "trpage_read.h" +#include +#include /* Write Material Table class Keeps track of the materials that have been added. diff --git a/src/osgPlugins/txp/trpage_model.cpp b/src/osgPlugins/txp/trpage_model.cpp index 3b1d9fe35..0ecae88e8 100644 --- a/src/osgPlugins/txp/trpage_model.cpp +++ b/src/osgPlugins/txp/trpage_model.cpp @@ -22,8 +22,8 @@ You should only modify this code if you want to add data to these classes. */ -#include "trpage_geom.h" -#include "trpage_read.h" +#include +#include /* Write Model class Represents a model reference. diff --git a/src/osgPlugins/txp/trpage_nodes.cpp b/src/osgPlugins/txp/trpage_nodes.cpp index 0a34ea001..387b1c5af 100644 --- a/src/osgPlugins/txp/trpage_nodes.cpp +++ b/src/osgPlugins/txp/trpage_nodes.cpp @@ -24,8 +24,8 @@ of these classes. */ -#include "trpage_geom.h" -#include "trpage_read.h" +#include +#include /* Write Group Basic group. diff --git a/src/osgPlugins/txp/trpage_parse.cpp b/src/osgPlugins/txp/trpage_parse.cpp index 91fec2661..f478ac60b 100644 --- a/src/osgPlugins/txp/trpage_parse.cpp +++ b/src/osgPlugins/txp/trpage_parse.cpp @@ -30,7 +30,7 @@ for the rest of the tokens that you want. */ -#include "trpage_read.h" +#include /* *************************** Paging token callback structure diff --git a/src/osgPlugins/txp/trpage_pparse.cpp b/src/osgPlugins/txp/trpage_pparse.cpp index 7ac09fbb7..055097c83 100644 --- a/src/osgPlugins/txp/trpage_pparse.cpp +++ b/src/osgPlugins/txp/trpage_pparse.cpp @@ -22,8 +22,8 @@ archive for the purpose of printing it out. */ -#include "trpage_print.h" -#include "trpage_scene.h" +#include +#include /* Set up the callbacks for the scene graph parser. In our case this is just one read helper with diff --git a/src/osgPlugins/txp/trpage_print.cpp b/src/osgPlugins/txp/trpage_print.cpp index 45f204d9b..a487185dd 100644 --- a/src/osgPlugins/txp/trpage_print.cpp +++ b/src/osgPlugins/txp/trpage_print.cpp @@ -23,7 +23,7 @@ within a TerraPage archive. */ -#include "trpage_print.h" +#include /* ****************************************** Print Buffer implementation diff --git a/src/osgPlugins/txp/trpage_print_parse.cpp b/src/osgPlugins/txp/trpage_print_parse.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/osgPlugins/txp/trpage_range.cpp b/src/osgPlugins/txp/trpage_range.cpp index 9ee86a58d..b33f8e716 100644 --- a/src/osgPlugins/txp/trpage_range.cpp +++ b/src/osgPlugins/txp/trpage_range.cpp @@ -22,8 +22,8 @@ #include #include -#include "trpage_geom.h" -#include "trpage_read.h" +#include +#include /* ******************* Range Methods diff --git a/src/osgPlugins/txp/trpage_rarchive.cpp b/src/osgPlugins/txp/trpage_rarchive.cpp index e4c70da5f..a0a27f302 100644 --- a/src/osgPlugins/txp/trpage_rarchive.cpp +++ b/src/osgPlugins/txp/trpage_rarchive.cpp @@ -22,8 +22,8 @@ The Read Archive is used to read a paging archive from disk. */ -#include "trpage_read.h" -#include "trpage_compat.h" +#include +#include // Constructor trpgr_Archive::trpgr_Archive() diff --git a/src/osgPlugins/txp/trpage_readbuf.cpp b/src/osgPlugins/txp/trpage_readbuf.cpp index 0308c6a03..b6b3574c6 100644 --- a/src/osgPlugins/txp/trpage_readbuf.cpp +++ b/src/osgPlugins/txp/trpage_readbuf.cpp @@ -28,8 +28,8 @@ implement a trpgDiskReadBuffer as a subclass of trpgReadBuffer. */ -#include "trpage_io.h" -#include "trpage_swap.h" +#include +#include /* ********************** Read buffer base class functions diff --git a/src/osgPlugins/txp/trpage_scene.cpp b/src/osgPlugins/txp/trpage_scene.cpp index cd22c70fa..d6fd08358 100644 --- a/src/osgPlugins/txp/trpage_scene.cpp +++ b/src/osgPlugins/txp/trpage_scene.cpp @@ -34,8 +34,8 @@ to read into a scene graph. You'll need to replace the helpers, primarily. */ -#include "trpage_read.h" -#include "trpage_scene.h" +#include +#include /* **************** MBR Calculation and handling diff --git a/src/osgPlugins/txp/trpage_swap.cpp b/src/osgPlugins/txp/trpage_swap.cpp index 3c25dd8f4..5f43ae66b 100644 --- a/src/osgPlugins/txp/trpage_swap.cpp +++ b/src/osgPlugins/txp/trpage_swap.cpp @@ -20,7 +20,7 @@ Byte swapping utility functions. */ -#include "trpage_swap.h" +#include /* ** func: swap_two( in, out ) diff --git a/src/osgPlugins/txp/trpage_tile.cpp b/src/osgPlugins/txp/trpage_tile.cpp index a4533aac8..5210e7984 100644 --- a/src/osgPlugins/txp/trpage_tile.cpp +++ b/src/osgPlugins/txp/trpage_tile.cpp @@ -23,8 +23,8 @@ the front of an archive) or the Tile Header (at the beginning of each tile). */ -#include "trpage_geom.h" -#include "trpage_read.h" +#include +#include /* Write Tile Table Keeps track of tiles written to disk. diff --git a/src/osgPlugins/txp/trpage_util.cpp b/src/osgPlugins/txp/trpage_util.cpp new file mode 100644 index 000000000..17911d229 --- /dev/null +++ b/src/osgPlugins/txp/trpage_util.cpp @@ -0,0 +1,27 @@ +/* ************************ + Copyright Terrain Experts Inc. + Terrain Experts Inc (TERREX) reserves all rights to this source code + unless otherwise specified in writing by the President of TERREX. + This copyright may be updated in the future, in which case that version + supercedes this one. + ------------------- + Terrex Experts Inc. + 4400 East Broadway #314 + Tucson, AZ 85711 + info@terrex.com + Tel: (520) 323-7990 + ************************ + */ + +#include + +/* trpage_util.cpp + This source file implements various utility routines for paging archive + */ + +/* The merge routine used to be in here. + However, merge isn't actually general enough to be part of the library. + Only portable code should be in the TerraPage API. + Instead, there's a Windows specific program that merges TerraPage archives in + the merge/ directory of this distribution. + */ diff --git a/src/osgPlugins/txp/trpage_warchive.cpp b/src/osgPlugins/txp/trpage_warchive.cpp index f24563587..bb4dc1d15 100644 --- a/src/osgPlugins/txp/trpage_warchive.cpp +++ b/src/osgPlugins/txp/trpage_warchive.cpp @@ -28,10 +28,10 @@ again, subclass and override if you need to change them. */ -#include "trpage_geom.h" -#include "trpage_write.h" -#include "trpage_compat.h" -#include "trpage_read.h" +#include +#include +#include +#include // Constructor trpgwArchive::trpgwArchive(trpgEndian inNess,TileMode inTileMode,int inVersion) diff --git a/src/osgPlugins/txp/trpage_writebuf.cpp b/src/osgPlugins/txp/trpage_writebuf.cpp index 33cf5eb11..9f7bbad12 100644 --- a/src/osgPlugins/txp/trpage_writebuf.cpp +++ b/src/osgPlugins/txp/trpage_writebuf.cpp @@ -29,8 +29,8 @@ is required. */ -#include "trpage_io.h" -#include "trpage_swap.h" +#include +#include /* ********************** Memory Write Buffer functions