From 03232ec6674b2c62e068056c05e70962a890440f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 1 May 2005 19:48:49 +0000 Subject: [PATCH] Moved osg::Impostor to osgSim::Impostor, as Impostor isn't a core feature. --- VisualStudio/VisualStudio.dsw | 3 + .../examples/osgfxbrowser/osgfxbrowser.dsp | 2 - VisualStudio/osg/osg.dsp | 16 - VisualStudio/osgPlugins/osg/dot_osg.dsp | 4 - VisualStudio/osgPlugins/osgSim/dot_osgSim.dsp | 4 + VisualStudio/osgSim/osgSim.dsp | 24 + VisualStudio/osgUtil/osgUtil.dsp | 8 - VisualStudio/osgWrappers/osg/wrapper_osg.dsp | 8 - examples/osgimpostor/GNUmakefile | 2 +- examples/osgimpostor/GNUmakefile.inst | 2 +- examples/osgimpostor/osgimpostor.cpp | 12 +- .../osgvertexprogram/osgvertexprogram.cpp | 1 + examples/osgvolume/osgvolume.cpp | 1 + include/osg/NodeVisitor | 2 - include/osgGA/EventVisitor | 2 - include/{osg => osgSim}/Impostor | 24 +- include/{osg => osgSim}/ImpostorSprite | 79 +-- .../InsertImpostorsVisitor | 14 +- include/osgUtil/CullVisitor | 9 - include/osgUtil/DisplayRequirementsVisitor | 2 - include/osgUtil/UpdateVisitor | 2 - src/osg/GNUmakefile | 2 - src/osg/Impostor.cpp | 80 --- src/osgPlugins/ive/DataInputStream.cpp | 2 +- src/osgPlugins/ive/DataOutputStream.cpp | 2 +- src/osgPlugins/ive/Impostor.h | 4 +- src/osgPlugins/lib3ds/ReaderWriter3DS.cpp | 1 - src/osgPlugins/osg/GNUmakefile | 1 - src/osgPlugins/osgSim/GNUmakefile | 1 + src/osgSim/GNUmakefile | 29 +- src/osgSim/Impostor.cpp | 536 ++++++++++++++++++ src/{osg => osgSim}/ImpostorSprite.cpp | 49 +- .../InsertImpostorsVisitor.cpp | 22 +- src/osgUtil/CullVisitor.cpp | 429 -------------- src/osgUtil/DisplayRequirementsVisitor.cpp | 26 +- src/osgUtil/GNUmakefile | 1 - src/osgUtil/Optimizer.cpp | 1 - src/osgUtil/RenderBin.cpp | 3 - src/osgWrappers/osg/GNUmakefile | 2 - src/osgWrappers/osg/Impostor.cpp | 55 -- src/osgWrappers/osg/ImpostorSprite.cpp | 80 --- 41 files changed, 702 insertions(+), 845 deletions(-) rename include/{osg => osgSim}/Impostor (88%) rename include/{osg => osgSim}/ImpostorSprite (73%) rename include/{osgUtil => osgSim}/InsertImpostorsVisitor (87%) delete mode 100644 src/osg/Impostor.cpp create mode 100644 src/osgSim/Impostor.cpp rename src/{osg => osgSim}/ImpostorSprite.cpp (81%) rename src/{osgUtil => osgSim}/InsertImpostorsVisitor.cpp (92%) delete mode 100644 src/osgWrappers/osg/Impostor.cpp delete mode 100644 src/osgWrappers/osg/ImpostorSprite.cpp diff --git a/VisualStudio/VisualStudio.dsw b/VisualStudio/VisualStudio.dsw index 41d596f65..f4e923a75 100644 --- a/VisualStudio/VisualStudio.dsw +++ b/VisualStudio/VisualStudio.dsw @@ -848,6 +848,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name Core osgUtil End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgSim + End Project Dependency }}} ############################################################################### diff --git a/VisualStudio/examples/osgfxbrowser/osgfxbrowser.dsp b/VisualStudio/examples/osgfxbrowser/osgfxbrowser.dsp index 3d077898e..170327236 100644 --- a/VisualStudio/examples/osgfxbrowser/osgfxbrowser.dsp +++ b/VisualStudio/examples/osgfxbrowser/osgfxbrowser.dsp @@ -171,8 +171,6 @@ DEP_CPP_OSGFX=\ "..\..\..\Include\Osg\Gl"\ "..\..\..\Include\Osg\Group"\ "..\..\..\Include\Osg\Image"\ - "..\..\..\Include\Osg\Impostor"\ - "..\..\..\Include\Osg\ImpostorSprite"\ "..\..\..\Include\Osg\Light"\ "..\..\..\Include\Osg\LightSource"\ "..\..\..\Include\Osg\LineSegment"\ diff --git a/VisualStudio/osg/osg.dsp b/VisualStudio/osg/osg.dsp index fb38d00ca..850c776b3 100755 --- a/VisualStudio/osg/osg.dsp +++ b/VisualStudio/osg/osg.dsp @@ -268,14 +268,6 @@ SOURCE=..\..\src\osg\ImageStream.cpp # End Source File # Begin Source File -SOURCE=..\..\src\osg\Impostor.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\src\osg\ImpostorSprite.cpp -# End Source File -# Begin Source File - SOURCE=..\..\src\osg\Light.cpp # End Source File # Begin Source File @@ -724,14 +716,6 @@ SOURCE=..\..\Include\Osg\ImageStream # End Source File # Begin Source File -SOURCE=..\..\Include\Osg\Impostor -# End Source File -# Begin Source File - -SOURCE=..\..\Include\Osg\ImpostorSprite -# End Source File -# Begin Source File - SOURCE=..\..\Include\Osg\IndexedGeometry # End Source File # Begin Source File diff --git a/VisualStudio/osgPlugins/osg/dot_osg.dsp b/VisualStudio/osgPlugins/osg/dot_osg.dsp index 829d2dd5c..c302ec237 100755 --- a/VisualStudio/osgPlugins/osg/dot_osg.dsp +++ b/VisualStudio/osgPlugins/osg/dot_osg.dsp @@ -188,10 +188,6 @@ SOURCE=..\..\..\src\osgPlugins\osg\Image.cpp # End Source File # Begin Source File -SOURCE=..\..\..\src\osgPlugins\osg\Impostor.cpp -# End Source File -# Begin Source File - SOURCE=..\..\..\src\osgPlugins\osg\Light.cpp # End Source File # Begin Source File diff --git a/VisualStudio/osgPlugins/osgSim/dot_osgSim.dsp b/VisualStudio/osgPlugins/osgSim/dot_osgSim.dsp index b16a05cf8..174ca13b5 100644 --- a/VisualStudio/osgPlugins/osgSim/dot_osgSim.dsp +++ b/VisualStudio/osgPlugins/osgSim/dot_osgSim.dsp @@ -104,6 +104,10 @@ SOURCE=..\..\..\src\osgPlugins\osgSim\IO_DOFTransform.cpp # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\osgSim\IO_Impostor.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\osgSim\IO_LightPoint.cpp # End Source File # Begin Source File diff --git a/VisualStudio/osgSim/osgSim.dsp b/VisualStudio/osgSim/osgSim.dsp index cc6431910..18f58550b 100644 --- a/VisualStudio/osgSim/osgSim.dsp +++ b/VisualStudio/osgSim/osgSim.dsp @@ -107,6 +107,18 @@ SOURCE=..\..\src\osgSim\DOFTransform.cpp # End Source File # Begin Source File +SOURCE=..\..\src\osgSim\Impostor.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\src\osgSim\ImpostorSprite.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\src\osgSim\InsertImpostorsVisitor.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\osgSim\LightPoint.cpp # End Source File # Begin Source File @@ -167,6 +179,18 @@ SOURCE=..\..\include\osgSim\Export # End Source File # Begin Source File +SOURCE=..\..\Include\osgSim\Impostor +# End Source File +# Begin Source File + +SOURCE=..\..\Include\osgSim\ImpostorSprite +# End Source File +# Begin Source File + +SOURCE=..\..\Include\osgSim\InsertImpostorsVisitor +# End Source File +# Begin Source File + SOURCE=..\..\include\osgSim\LightPoint # End Source File # Begin Source File diff --git a/VisualStudio/osgUtil/osgUtil.dsp b/VisualStudio/osgUtil/osgUtil.dsp index c58abf5ac..0846054fa 100755 --- a/VisualStudio/osgUtil/osgUtil.dsp +++ b/VisualStudio/osgUtil/osgUtil.dsp @@ -123,10 +123,6 @@ SOURCE=..\..\src\osgUtil\HighlightMapGenerator.cpp # End Source File # Begin Source File -SOURCE=..\..\src\osgUtil\InsertImpostorsVisitor.cpp -# End Source File -# Begin Source File - SOURCE=..\..\src\osgUtil\IntersectVisitor.cpp # End Source File # Begin Source File @@ -239,10 +235,6 @@ SOURCE=..\..\include\osgUtil\HighlightMapGenerator # End Source File # Begin Source File -SOURCE=..\..\Include\osgUtil\InsertImpostorsVisitor -# End Source File -# Begin Source File - SOURCE=..\..\Include\osgUtil\IntersectVisitor # End Source File # Begin Source File diff --git a/VisualStudio/osgWrappers/osg/wrapper_osg.dsp b/VisualStudio/osgWrappers/osg/wrapper_osg.dsp index 230ef5e78..bcb73f50c 100644 --- a/VisualStudio/osgWrappers/osg/wrapper_osg.dsp +++ b/VisualStudio/osgWrappers/osg/wrapper_osg.dsp @@ -258,14 +258,6 @@ SOURCE=..\..\..\src\osgWrappers\osg\Image.cpp SOURCE=..\..\..\src\osgWrappers\osg\ImageStream.cpp # End Source File -# Begin Source File -SOURCE=..\..\..\src\osgWrappers\osg\Impostor.cpp -# End Source File - -# Begin Source File -SOURCE=..\..\..\src\osgWrappers\osg\ImpostorSprite.cpp -# End Source File - # Begin Source File SOURCE=..\..\..\src\osgWrappers\osg\Light.cpp # End Source File diff --git a/examples/osgimpostor/GNUmakefile b/examples/osgimpostor/GNUmakefile index 450300541..f246d7551 100644 --- a/examples/osgimpostor/GNUmakefile +++ b/examples/osgimpostor/GNUmakefile @@ -5,7 +5,7 @@ CXXFILES =\ TestManipulator.cpp\ osgimpostor.cpp\ -LIBS += -losgProducer -lProducer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgProducer -lProducer -losgText -losgSim -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) INSTFILES = \ $(CXXFILES)\ diff --git a/examples/osgimpostor/GNUmakefile.inst b/examples/osgimpostor/GNUmakefile.inst index d9af0fca5..121b270c6 100644 --- a/examples/osgimpostor/GNUmakefile.inst +++ b/examples/osgimpostor/GNUmakefile.inst @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgimpostor.cpp\ -LIBS += -losgProducer -lProducer -losgDB -losgText -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgProducer -lProducer -losgSim -losgDB -losgText -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgimpostor diff --git a/examples/osgimpostor/osgimpostor.cpp b/examples/osgimpostor/osgimpostor.cpp index d593846d0..68f49f885 100644 --- a/examples/osgimpostor/osgimpostor.cpp +++ b/examples/osgimpostor/osgimpostor.cpp @@ -1,11 +1,11 @@ #include -#include #include #include #include #include -#include +#include +#include #include @@ -196,7 +196,7 @@ void LayoutAsGrid() if (UseImpostor) { - osg::Impostor * impostor = new osg::Impostor(); + osgSim::Impostor * impostor = new osgSim::Impostor(); impostor->setImpostorThreshold(static_cast (Threshold)); impostor->addChild(groups[i]); impostor->setRange(0, 0.0f, 1e7f); @@ -258,7 +258,7 @@ int main( int argc, char **argv ) osg::Node* model = osgDB::readNodeFiles(arguments); if (model) { - // the osgUtil::InsertImpostorsVisitor used lower down to insert impostors + // 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. @@ -268,7 +268,7 @@ int main( int argc, char **argv ) if (bs.valid()) { - osg::Impostor* impostor = new osg::Impostor; + osgSim::Impostor* impostor = new osgSim::Impostor; // standard LOD settings impostor->addChild(model); @@ -295,7 +295,7 @@ int main( int argc, char **argv ) // now insert impostors in the model using the InsertImpostorsVisitor. - osgUtil::InsertImpostorsVisitor ov; + osgSim::InsertImpostorsVisitor ov; // traverse the model and collect all osg::Group's and osg::LOD's. // however, don't traverse the rootnode since we want to keep it as diff --git a/examples/osgvertexprogram/osgvertexprogram.cpp b/examples/osgvertexprogram/osgvertexprogram.cpp index 49a55a02d..13b2242a7 100644 --- a/examples/osgvertexprogram/osgvertexprogram.cpp +++ b/examples/osgvertexprogram/osgvertexprogram.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/examples/osgvolume/osgvolume.cpp b/examples/osgvolume/osgvolume.cpp index 022756ff4..3b7b43147 100644 --- a/examples/osgvolume/osgvolume.cpp +++ b/examples/osgvolume/osgvolume.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/include/osg/NodeVisitor b/include/osg/NodeVisitor index 6fc136eb2..738cbcde4 100644 --- a/include/osg/NodeVisitor +++ b/include/osg/NodeVisitor @@ -26,7 +26,6 @@ class ClipNode; class CoordinateSystemNode; class Geode; class Group; -class Impostor; class LightSource; class LOD; class MatrixTransform; @@ -241,7 +240,6 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced virtual void apply(Sequence& node) { apply((Group&)node); } virtual void apply(LOD& node) { apply((Group&)node); } virtual void apply(PagedLOD& node) { apply((LOD&)node); } - virtual void apply(Impostor& node) { apply((LOD&)node); } virtual void apply(ClearNode& node) { apply((Group&)node); } virtual void apply(OccluderNode& node) { apply((Group&)node); } diff --git a/include/osgGA/EventVisitor b/include/osgGA/EventVisitor index 3586f23d8..bc9f22635 100644 --- a/include/osgGA/EventVisitor +++ b/include/osgGA/EventVisitor @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -81,7 +80,6 @@ class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor virtual void apply(osg::Projection& node) { handle_callbacks_and_traverse(node); } virtual void apply(osg::Switch& node) { handle_callbacks_and_traverse(node); } virtual void apply(osg::LOD& node) { handle_callbacks_and_traverse(node); } - virtual void apply(osg::Impostor& node) { handle_callbacks_and_traverse(node); } virtual void apply(osg::OccluderNode& node) { handle_callbacks_and_traverse(node); } diff --git a/include/osg/Impostor b/include/osgSim/Impostor similarity index 88% rename from include/osg/Impostor rename to include/osgSim/Impostor index 0f10a054f..30596d1ab 100644 --- a/include/osg/Impostor +++ b/include/osgSim/Impostor @@ -11,14 +11,15 @@ * OpenSceneGraph Public License for more details. */ -#ifndef OSG_IMPOSTOR -#define OSG_IMPOSTOR 1 +#ifndef OSGSIM_IMPOSTOR +#define OSGSIM_IMPOSTOR 1 #include -#include #include -namespace osg { +#include + +namespace osgSim { /** Impostor - is a form of Level Of Detail group node which allows both switching * between children depending on distance from eye point and image caching. @@ -58,18 +59,20 @@ namespace osg { * 4) Shrinking of the ImpostorSprite size to more closely fit the underlying * geometry. */ -class OSG_EXPORT Impostor : public LOD +class OSGSIM_EXPORT Impostor : public osg::LOD { public : Impostor(); - Impostor(const Impostor& es, const CopyOp& copyop=CopyOp::SHALLOW_COPY): - LOD(es,copyop), + Impostor(const Impostor& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): + osg::LOD(es,copyop), _impostorThreshold(es._impostorThreshold) {} - META_Node(osg, Impostor); + META_Node(osgSim, Impostor); + + virtual void traverse(osg::NodeVisitor& nv); - typedef std::vector< ref_ptr > ImpostorSpriteList; + typedef std::vector< osg::ref_ptr > ImpostorSpriteList; /** Set the Impostor threshold distance. * For eye points further than this threshold the Imposter is used if appropriate, @@ -103,7 +106,8 @@ class OSG_EXPORT Impostor : public LOD virtual bool computeBound() const; - mutable buffered_object _impostorSpriteListBuffer; + mutable osg::buffered_object _impostorSpriteListBuffer; + float _impostorThreshold; diff --git a/include/osg/ImpostorSprite b/include/osgSim/ImpostorSprite similarity index 73% rename from include/osg/ImpostorSprite rename to include/osgSim/ImpostorSprite index 8787189a2..077e42298 100644 --- a/include/osg/ImpostorSprite +++ b/include/osgSim/ImpostorSprite @@ -17,13 +17,14 @@ #include #include #include -#include #include #include +#include -namespace osg { +#include + +namespace osgSim { -class Texture2D; class Impostor; class ImpostorSpriteManager; @@ -33,21 +34,21 @@ class ImpostorSpriteManager; * automatically generated by the osgUtil::CullVisitor so it not * necessary to deal with it directly. */ -class OSG_EXPORT ImpostorSprite : public Drawable +class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable { public: ImpostorSprite(); /** Clone an object of the same type as an ImpostorSprite. */ - virtual Object* cloneType() const { return new ImpostorSprite(); } + virtual osg::Object* cloneType() const { return new ImpostorSprite(); } /** Clone on ImpostorSprite just returns a clone of type, * since it is not appropriate to share data of an ImpostorSprite. */ - virtual Object* clone(const CopyOp&) const { return new ImpostorSprite(); } - virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } - virtual const char* libraryName() const { return "osg"; } + virtual osg::Object* clone(const osg::CopyOp&) const { return new ImpostorSprite(); } + virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=NULL; } + virtual const char* libraryName() const { return "osgSim"; } virtual const char* className() const { return "ImpostorSprite"; } /** Set the parent, which must be an Impostor. @@ -63,10 +64,10 @@ class OSG_EXPORT ImpostorSprite : public Drawable const Impostor* getParent() const { return _parent; } /** Set the eye point for when the ImpostorSprite was snapped. */ - inline void setStoredLocalEyePoint(const Vec3& v) { _storedLocalEyePoint=v; } + inline void setStoredLocalEyePoint(const osg::Vec3& v) { _storedLocalEyePoint=v; } /** Get the eye point for when the ImpostorSprite was snapped. */ - inline const Vec3& getStoredLocalEyePoint() const { return _storedLocalEyePoint; } + inline const osg::Vec3& getStoredLocalEyePoint() const { return _storedLocalEyePoint; } /** Set the frame number for when the ImpostorSprite was last used in rendering. */ inline void setLastFrameUsed(int frameNumber) { _lastFrameUsed = frameNumber; } @@ -78,20 +79,20 @@ class OSG_EXPORT ImpostorSprite : public Drawable /** Get the coordinates of the corners of the quad. * Stored in the order, [0] - top_left, [1] - bottom_left, [2] - bottom_right, [3] - top_left. */ - inline Vec3* getCoords() { return _coords; } + inline osg::Vec3* getCoords() { return _coords; } /** Get the const coordinates of the corners of the quad. */ - inline const Vec3* getCoords() const { return _coords; } + inline const osg::Vec3* getCoords() const { return _coords; } /** Get the texture coordinates of the corners of the quad. * Stored in the order, [0] - top_left, [1] - bottom_left, [2] - bottom_right, [3] - top_left. */ - inline Vec2* getTexCoords() { return _texcoords; } + inline osg::Vec2* getTexCoords() { return _texcoords; } /** Get the const texture coordinates of the corners of the quad. */ - inline const Vec2* getTexCoords() const { return _texcoords; } + inline const osg::Vec2* getTexCoords() const { return _texcoords; } /** Get the control coordinates of the corners of the quad. * The control coordinates are the corners of the quad projected @@ -105,26 +106,26 @@ class OSG_EXPORT ImpostorSprite : public Drawable * can then be used to determine whether the impostor needs to be updated. * Stored in the order, [0] - top_left, [1] - bottom_left, [2] - bottom_right, [3] - top_left. */ - inline Vec3* getControlCoords() { return _controlcoords; } + inline osg::Vec3* getControlCoords() { return _controlcoords; } /** Get the const control coordinates of the corners of the quad. */ - inline const Vec3* getControlCoords() const { return _controlcoords; } + inline const osg::Vec3* getControlCoords() const { return _controlcoords; } /** Calculate the pixel error value for passing in the ModelViewProjectionWindow transform, * which transform local coords into screen space. */ - float calcPixelError(const Matrix& MVPW) const; + float calcPixelError(const osg::Matrix& MVPW) const; - void setTexture(Texture2D* tex,int s,int t); - Texture2D* getTexture() { return _texture; } - const Texture2D* getTexture() const { return _texture; } + void setTexture(osg::Texture2D* tex,int s,int t); + osg::Texture2D* getTexture() { return _texture; } + const osg::Texture2D* getTexture() const { return _texture; } int s() const { return _s; } int t() const { return _t; } /** Draw ImpostorSprite directly. */ - virtual void drawImplementation(State& state) const; + virtual void drawImplementation(osg::State& state) const; /** Return true, osg::ImpostorSprite does support accept(AttributeFunctor&). */ virtual bool supports(const AttributeFunctor&) const { return true; } @@ -139,13 +140,13 @@ class OSG_EXPORT ImpostorSprite : public Drawable virtual void accept(ConstAttributeFunctor& af) const; /** Return true, osg::ImpostorSprite does support accept(PrimitiveFunctor&). */ - virtual bool supports(const PrimitiveFunctor&) const { return true; } + virtual bool supports(const osg::PrimitiveFunctor&) const { return true; } /** Accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has. */ - virtual void accept(PrimitiveFunctor& pf) const; + virtual void accept(osg::PrimitiveFunctor& pf) const; // for debugging purposes. - Vec4 _color; + osg::Vec4 _color; protected: @@ -158,7 +159,7 @@ class OSG_EXPORT ImpostorSprite : public Drawable Impostor* _parent; - friend class osg::ImpostorSpriteManager; + friend class osgSim::ImpostorSpriteManager; // support for a double linked list managed by the // ImposotorSpriteManager. @@ -168,13 +169,13 @@ class OSG_EXPORT ImpostorSprite : public Drawable int _lastFrameUsed; - Vec3 _storedLocalEyePoint; + osg::Vec3 _storedLocalEyePoint; - Vec3 _coords[4]; - Vec2 _texcoords[4]; - Vec3 _controlcoords[4]; + osg::Vec3 _coords[4]; + osg::Vec2 _texcoords[4]; + osg::Vec3 _controlcoords[4]; - Texture2D* _texture; + osg::Texture2D* _texture; int _s; int _t; @@ -182,7 +183,7 @@ class OSG_EXPORT ImpostorSprite : public Drawable }; /** Helper class for managing the reuse of ImpostorSprite resources. */ -class OSG_EXPORT ImpostorSpriteManager : public Referenced +class OSGSIM_EXPORT ImpostorSpriteManager : public osg::Referenced { public: @@ -200,7 +201,7 @@ class OSG_EXPORT ImpostorSpriteManager : public Referenced ImpostorSprite* createOrReuseImpostorSprite(int s,int t,int frameNumber); - StateSet* createOrReuseStateSet(); + osg::StateSet* createOrReuseStateSet(); void reset(); @@ -209,15 +210,15 @@ class OSG_EXPORT ImpostorSpriteManager : public Referenced ~ImpostorSpriteManager(); - ref_ptr _texenv; - ref_ptr _alphafunc; + osg::ref_ptr _texenv; + osg::ref_ptr _alphafunc; - ImpostorSprite* _first; - ImpostorSprite* _last; + ImpostorSprite* _first; + ImpostorSprite* _last; - typedef std::vector< ref_ptr > StateSetList; - StateSetList _stateSetList; - unsigned int _reuseStateSetIndex; + typedef std::vector< osg::ref_ptr > StateSetList; + StateSetList _stateSetList; + unsigned int _reuseStateSetIndex; }; diff --git a/include/osgUtil/InsertImpostorsVisitor b/include/osgSim/InsertImpostorsVisitor similarity index 87% rename from include/osgUtil/InsertImpostorsVisitor rename to include/osgSim/InsertImpostorsVisitor index 403fb7940..6a46c226f 100644 --- a/include/osgUtil/InsertImpostorsVisitor +++ b/include/osgSim/InsertImpostorsVisitor @@ -11,20 +11,18 @@ * OpenSceneGraph Public License for more details. */ -#ifndef OSGUTIL_INSERTIMPOSTORSVISITOR -#define OSGUTIL_INSERTIMPOSTORSVISITOR +#ifndef OSGSIM_INSERTIMPOSTORSVISITOR +#define OSGSIM_INSERTIMPOSTORSVISITOR #include -#include +#include -#include - -namespace osgUtil { +namespace osgSim { /** Insert impostor nodes into scene graph. * For example of usage see examples/osgimpostor. */ -class OSGUTIL_EXPORT InsertImpostorsVisitor : public osg::NodeVisitor +class OSGSIM_EXPORT InsertImpostorsVisitor : public osg::NodeVisitor { public: @@ -46,8 +44,6 @@ class OSGUTIL_EXPORT InsertImpostorsVisitor : public osg::NodeVisitor virtual void apply(osg::LOD& node); - virtual void apply(osg::Impostor& node); - /* Insert the required impostors into the scene graph. */ void insertImpostors(); diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index dcfc522a0..0ee229ee8 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -77,7 +76,6 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac virtual void apply(osg::LOD& node); virtual void apply(osg::ClearNode& node); virtual void apply(osg::OccluderNode& node); - virtual void apply(osg::Impostor& node); void setClearNode(const osg::ClearNode* earthSky) { _clearNode = earthSky; } const osg::ClearNode* getClearNode() const { return _clearNode.get(); } @@ -250,11 +248,6 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac else acceptNode->accept(*this); } - - /** Create an impostor sprite by setting up a pre-rendering stage - * to generate the impostor texture. */ - osg::ImpostorSprite* createImpostorSprite(osg::Impostor& node); - osg::ref_ptr _clearNode; osg::ref_ptr _rootRenderGraph; @@ -274,8 +267,6 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac inline RenderLeaf* createOrReuseRenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* matrix, float depth=0.0f); - osg::ref_ptr _impostorSpriteManager; - osg::ref_ptr _state; diff --git a/include/osgUtil/DisplayRequirementsVisitor b/include/osgUtil/DisplayRequirementsVisitor index e9a3b5090..073edacac 100644 --- a/include/osgUtil/DisplayRequirementsVisitor +++ b/include/osgUtil/DisplayRequirementsVisitor @@ -48,8 +48,6 @@ class OSGUTIL_EXPORT DisplayRequirementsVisitor : public osg::NodeVisitor virtual void apply(osg::Node& node); virtual void apply(osg::Geode& geode); - - virtual void apply(osg::Impostor& impostor); protected: diff --git a/include/osgUtil/UpdateVisitor b/include/osgUtil/UpdateVisitor index e7c04940e..a86d1a813 100644 --- a/include/osgUtil/UpdateVisitor +++ b/include/osgUtil/UpdateVisitor @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -57,7 +56,6 @@ class OSGUTIL_EXPORT UpdateVisitor : public osg::NodeVisitor virtual void apply(osg::Projection& node) { handle_callbacks_and_traverse(node); } virtual void apply(osg::Switch& node) { handle_callbacks_and_traverse(node); } virtual void apply(osg::LOD& node) { handle_callbacks_and_traverse(node); } - virtual void apply(osg::Impostor& node) { handle_callbacks_and_traverse(node); } virtual void apply(osg::OccluderNode& node) { handle_callbacks_and_traverse(node); } diff --git a/src/osg/GNUmakefile b/src/osg/GNUmakefile index 64e04de31..da7ab5bfa 100644 --- a/src/osg/GNUmakefile +++ b/src/osg/GNUmakefile @@ -45,8 +45,6 @@ CXXFILES =\ Group.cpp\ Image.cpp\ ImageStream.cpp\ - Impostor.cpp\ - ImpostorSprite.cpp\ Light.cpp\ LightModel.cpp\ LightSource.cpp\ diff --git a/src/osg/Impostor.cpp b/src/osg/Impostor.cpp deleted file mode 100644 index c14c35ed1..000000000 --- a/src/osg/Impostor.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield - * - * 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 - * OpenSceneGraph Public License for more details. -*/ -#include - -#include - -using namespace osg; - -Impostor::Impostor() -{ - _impostorThreshold = -1.0f; -} - - -ImpostorSprite* Impostor::findBestImpostorSprite(unsigned int contextID, const osg::Vec3& currLocalEyePoint) const -{ - ImpostorSpriteList& impostorSpriteList = _impostorSpriteListBuffer[contextID]; - - float min_distance2 = FLT_MAX; - ImpostorSprite* impostorSprite = NULL; - for(ImpostorSpriteList::iterator itr=impostorSpriteList.begin(); - itr!=impostorSpriteList.end(); - ++itr) - { - float distance2 = (currLocalEyePoint-(*itr)->getStoredLocalEyePoint()).length2(); - if (distance2get(); - } - } - return impostorSprite; -} - -void Impostor::addImpostorSprite(unsigned int contextID, ImpostorSprite* is) -{ - if (is && is->getParent()!=this) - { - ImpostorSpriteList& impostorSpriteList = _impostorSpriteListBuffer[contextID]; - - // add it to my impostor list first, so it remains referenced - // when its reference in the previous_owner is removed. - impostorSpriteList.push_back(is); - - if (is->getParent()) - { - Impostor* previous_owner = is->getParent(); - ImpostorSpriteList& isl = previous_owner->_impostorSpriteListBuffer[contextID]; - - // find and erase reference to is. - for(ImpostorSpriteList::iterator itr=isl.begin(); - itr!=isl.end(); - ++itr) - { - if ((*itr)==is) - { - isl.erase(itr); - break; - } - } - } - is->setParent(this); - - } -} - -bool Impostor::computeBound() const -{ - return LOD::computeBound(); -} diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp index 4a1f4bcfa..e4e476e53 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -951,7 +951,7 @@ osg::Node* DataInputStream::readNode() ((ive::MultiSwitch*)(node))->read(this); } else if(nodeTypeID== IVEIMPOSTOR){ - node = new osg::Impostor(); + node = new osgSim::Impostor(); ((ive::Impostor*)(node))->read(this); } else if(nodeTypeID== IVEOCCLUDERNODE){ diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp index d687a8d0f..c035aaaf0 100644 --- a/src/osgPlugins/ive/DataOutputStream.cpp +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -706,7 +706,7 @@ void DataOutputStream::writeNode(const osg::Node* node) else if(dynamic_cast(node)){ ((ive::Sequence*)(node))->write(this); } - else if(dynamic_cast(node)){ + else if(dynamic_cast(node)){ ((ive::Impostor*)(node))->write(this); } else if(dynamic_cast(node)){ diff --git a/src/osgPlugins/ive/Impostor.h b/src/osgPlugins/ive/Impostor.h index 2d6444c1a..43b97b79b 100644 --- a/src/osgPlugins/ive/Impostor.h +++ b/src/osgPlugins/ive/Impostor.h @@ -1,11 +1,11 @@ #ifndef IVE_IMPOSTOR #define IVE_IMPOSTOR 1 -#include +#include #include "ReadWrite.h" namespace ive{ -class Impostor : public osg::Impostor, public ReadWrite { +class Impostor : public osgSim::Impostor, public ReadWrite { public: void write(DataOutputStream* out); void read(DataInputStream* in); diff --git a/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp b/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp index 7c09bb3b3..8cfc05f36 100644 --- a/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp +++ b/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp @@ -75,7 +75,6 @@ class PrintVisitor : public NodeVisitor virtual void apply(Projection& node) { apply((Group&)node); } virtual void apply(Switch& node) { apply((Group&)node); } virtual void apply(LOD& node) { apply((Group&)node); } - virtual void apply(Impostor& node) { apply((LOD&)node); } protected: diff --git a/src/osgPlugins/osg/GNUmakefile b/src/osgPlugins/osg/GNUmakefile index d029dd61a..f1227df9c 100644 --- a/src/osgPlugins/osg/GNUmakefile +++ b/src/osgPlugins/osg/GNUmakefile @@ -24,7 +24,6 @@ CXXFILES =\ Geometry.cpp\ Group.cpp\ Image.cpp\ - Impostor.cpp\ Light.cpp\ LightModel.cpp\ LightSource.cpp\ diff --git a/src/osgPlugins/osgSim/GNUmakefile b/src/osgPlugins/osgSim/GNUmakefile index a4829edbc..7749f1038 100644 --- a/src/osgPlugins/osgSim/GNUmakefile +++ b/src/osgPlugins/osgSim/GNUmakefile @@ -9,6 +9,7 @@ CXXFILES =\ IO_MultiSwitch.cpp\ IO_Sector.cpp\ IO_VisibilityGroup.cpp\ + IO_Impostor.cpp\ LIBS += -losgSim -losgText $(OSG_LIBS) $(OTHER_LIBS) diff --git a/src/osgSim/GNUmakefile b/src/osgSim/GNUmakefile index b7f424acb..dc1248cea 100644 --- a/src/osgSim/GNUmakefile +++ b/src/osgSim/GNUmakefile @@ -3,19 +3,22 @@ include $(TOPDIR)/Make/makedefs CXXFILES = \ - BlinkSequence.cpp\ - ColorRange.cpp\ - DOFTransform.cpp\ - LightPoint.cpp\ - LightPointDrawable.cpp\ - LightPointNode.cpp\ - ScalarBar.cpp\ - ScalarsToColors.cpp\ - Sector.cpp\ - SphereSegment.cpp\ - MultiSwitch.cpp\ - Version.cpp\ - VisibilityGroup.cpp\ + BlinkSequence.cpp\ + ColorRange.cpp\ + DOFTransform.cpp\ + LightPoint.cpp\ + LightPointDrawable.cpp\ + LightPointNode.cpp\ + Impostor.cpp\ + ImpostorSprite.cpp\ + InsertImpostorsVisitor.cpp\ + ScalarBar.cpp\ + ScalarsToColors.cpp\ + Sector.cpp\ + SphereSegment.cpp\ + MultiSwitch.cpp\ + Version.cpp\ + VisibilityGroup.cpp\ DEF += -DOSGSIM_LIBRARY diff --git a/src/osgSim/Impostor.cpp b/src/osgSim/Impostor.cpp new file mode 100644 index 000000000..01fafaee6 --- /dev/null +++ b/src/osgSim/Impostor.cpp @@ -0,0 +1,536 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield + * + * 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 + * OpenSceneGraph Public License for more details. +*/ +#include + +#include + +using namespace osgSim; + +Impostor::Impostor() +{ + _impostorThreshold = -1.0f; +} + + +ImpostorSprite* Impostor::findBestImpostorSprite(unsigned int contextID, const osg::Vec3& currLocalEyePoint) const +{ + ImpostorSpriteList& impostorSpriteList = _impostorSpriteListBuffer[contextID]; + + float min_distance2 = FLT_MAX; + ImpostorSprite* impostorSprite = NULL; + for(ImpostorSpriteList::iterator itr=impostorSpriteList.begin(); + itr!=impostorSpriteList.end(); + ++itr) + { + float distance2 = (currLocalEyePoint-(*itr)->getStoredLocalEyePoint()).length2(); + if (distance2get(); + } + } + return impostorSprite; +} + +void Impostor::addImpostorSprite(unsigned int contextID, ImpostorSprite* is) +{ + if (is && is->getParent()!=this) + { + ImpostorSpriteList& impostorSpriteList = _impostorSpriteListBuffer[contextID]; + + // add it to my impostor list first, so it remains referenced + // when its reference in the previous_owner is removed. + impostorSpriteList.push_back(is); + + if (is->getParent()) + { + Impostor* previous_owner = is->getParent(); + ImpostorSpriteList& isl = previous_owner->_impostorSpriteListBuffer[contextID]; + + // find and erase reference to is. + for(ImpostorSpriteList::iterator itr=isl.begin(); + itr!=isl.end(); + ++itr) + { + if ((*itr)==is) + { + isl.erase(itr); + break; + } + } + } + is->setParent(this); + + } +} + +bool Impostor::computeBound() const +{ + return LOD::computeBound(); +} + +void Impostor::traverse(osg::NodeVisitor& nv) +{ + LOD::traverse(nv); +} + + +#if 0 + +// From CullVisitor header + + /** Create an impostor sprite by setting up a pre-rendering stage + * to generate the impostor texture. */ + osg::ImpostorSprite* createImpostorSprite(osg::Impostor& node); + + osg::ref_ptr _impostorSpriteManager; + +// From CullVisitor constructor + + _impostorSpriteManager = new ImpostorSpriteManager; + +// From CullVisitor reset + if (_impostorSpriteManager.valid()) _impostorSpriteManager->reset(); + + +// Form CullVisitor.cpp + +void CullVisitor::apply(Impostor& node) +{ + + if (isCulled(node)) return; + + osg::Vec3 eyeLocal = getEyeLocal(); + + // push the culling mode. + pushCurrentMask(); + + // push the node's state. + StateSet* node_state = node.getStateSet(); + if (node_state) pushStateSet(node_state); + + const BoundingSphere& bs = node.getBound(); + + unsigned int contextID = 0; + if (_state.valid()) contextID = _state->getContextID(); + + float distance2 = (eyeLocal-bs.center()).length2(); + if (!_impostorActive || + distance2*_LODScale*_LODScalecalcPixelError(getMVPW()); + + if (error>_impostorPixelErrorThreshold) + { + // chosen impostor sprite pixel error is too great to use + // from this eye point, therefore invalidate it. + impostorSprite=NULL; + } + } + + +// need to think about sprite reuse and support for multiple context's. + + if (impostorSprite==NULL) + { + // no appropriate sprite has been found therefore need to create + // one for use. + + // create the impostor sprite. + impostorSprite = createImpostorSprite(node); + + //if (impostorSprite) impostorSprite->_color.set(0.0f,0.0f,1.0f,1.0f); + + } + //else impostorSprite->_color.set(1.0f,1.0f,1.0f,1.0f); + + if (impostorSprite) + { + + // update frame number to show that impostor is in action. + impostorSprite->setLastFrameUsed(getTraversalNumber()); + + if (_computeNearFar) updateCalculatedNearFar(matrix,*impostorSprite, false); + + StateSet* stateset = impostorSprite->getStateSet(); + + if (stateset) pushStateSet(stateset); + + addDrawableAndDepth(impostorSprite,&matrix,distance(node.getCenter(),matrix)); + + if (stateset) popStateSet(); + + + } + else + { + // no impostor has been selected or created so default to + // traversing the usual LOD selected child. + handle_cull_callbacks_and_traverse(node); + } + + } + + // pop the node's state off the render graph stack. + if (node_state) popStateSet(); + + // pop the culling mode. + popCurrentMask(); +} + +ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node) +{ + + unsigned int contextID = 0; + if (_state.valid()) contextID = _state->getContextID(); + + // default to true right now, will dertermine if perspective from the + // projection matrix... + bool isPerspectiveProjection = true; + + const Matrix& matrix = getModelViewMatrix(); + const BoundingSphere& bs = node.getBound(); + osg::Vec3 eye_local = getEyeLocal(); + + if (!bs.valid()) + { + osg::notify(osg::WARN) << "bb invalid"<<&node< rtts = new RenderToTextureStage; + + // set up lighting. + // currently ignore lights in the scene graph itself.. + // will do later. + RenderStage* previous_stage = _currentRenderBin->getStage(); + + // set up the background color and clear mask. + osg::Vec4 clear_color = previous_stage->getClearColor(); + clear_color[3] = 0.0f; // set the alpha to zero. + rtts->setClearColor(clear_color); + rtts->setClearMask(previous_stage->getClearMask()); + + // set up to charge the same RenderStageLighting is the parent previous stage. + rtts->setRenderStageLighting(previous_stage->getRenderStageLighting()); + + + // record the render bin, to be restored after creation + // of the render to text + RenderBin* previousRenderBin = _currentRenderBin; + + // set the current renderbin to be the newly created stage. + _currentRenderBin = rtts.get(); + + // create quad coords (in local coords) + + Vec3 center_local = bs.center(); + Vec3 camera_up_local = getUpLocal(); + Vec3 lv_local = center_local-eye_local; + + float distance_local = lv_local.length(); + lv_local /= distance_local; + + Vec3 sv_local = lv_local^camera_up_local; + sv_local.normalize(); + + Vec3 up_local = sv_local^lv_local; + + + + float width = bs.radius(); + if (isPerspectiveProjection) + { + // expand the width to account for projection onto sprite. + width *= (distance_local/sqrtf(distance_local*distance_local-bs.radius2())); + } + + // scale up and side vectors to sprite width. + up_local *= width; + sv_local *= width; + + // create the corners of the sprite. + Vec3 c00(center_local - sv_local - up_local); + Vec3 c10(center_local + sv_local - up_local); + Vec3 c01(center_local - sv_local + up_local); + Vec3 c11(center_local + sv_local + up_local); + +// adjust camera left,right,up,down to fit (in world coords) + + Vec3 near_local ( center_local-lv_local*width ); + Vec3 far_local ( center_local+lv_local*width ); + Vec3 top_local ( center_local+up_local); + Vec3 right_local ( center_local+sv_local); + + Vec3 near_world = near_local * matrix; + Vec3 far_world = far_local * matrix; + Vec3 top_world = top_local * matrix; + Vec3 right_world = right_local * matrix; + + float znear = (near_world-eye_world).length(); + float zfar = (far_world-eye_world).length(); + + float top = (top_world-center_world).length(); + float right = (right_world-center_world).length(); + + znear *= 0.9f; + zfar *= 1.1f; + + // set up projection. + osg::RefMatrix* projection = new osg::RefMatrix; + if (isPerspectiveProjection) + { + // deal with projection issue move the top and right points + // onto the near plane. + float ratio = znear/(center_world-eye_world).length(); + top *= ratio; + right *= ratio; + projection->makeFrustum(-right,right,-top,top,znear,zfar); + } + else + { + projection->makeOrtho(-right,right,-top,top,znear,zfar); + } + + pushProjectionMatrix(projection); + + Vec3 rotate_from = bs.center()-eye_local; + Vec3 rotate_to = getLookVectorLocal(); + + osg::RefMatrix* rotate_matrix = new osg::RefMatrix( + osg::Matrix::translate(-eye_local)* + osg::Matrix::rotate(rotate_from,rotate_to)* + osg::Matrix::translate(eye_local)* + getModelViewMatrix()); + + // pushing the cull view state will update it so it takes + // into account the new camera orientation. + pushModelViewMatrix(rotate_matrix); + + StateSet* localPreRenderState = _impostorSpriteManager->createOrReuseStateSet(); + + pushStateSet(localPreRenderState); + + { + + // traversing the usual LOD selected child. + handle_cull_callbacks_and_traverse(node); + + } + + popStateSet(); + + // restore the previous model view matrix. + popModelViewMatrix(); + + // restore the previous model view matrix. + popProjectionMatrix(); + + // restore the previous renderbin. + _currentRenderBin = previousRenderBin; + + + + if (rtts->getRenderGraphList().size()==0 && rtts->getRenderBinList().size()==0) + { + // getting to this point means that all the subgraph has been + // culled by small feature culling or is beyond LOD ranges. + return NULL; + } + + + + + const osg::Viewport& viewport = *getViewport(); + + + // calc texture size for eye, bs. + + // convert the corners of the sprite (in world coords) into their + // equivilant window coordinates by using the camera's project method. + const osg::Matrix& MVPW = getMVPW(); + Vec3 c00_win = c00 * MVPW; + Vec3 c11_win = c11 * MVPW; + +// adjust texture size to be nearest power of 2. + + float s = c11_win.x()-c00_win.x(); + float t = c11_win.y()-c00_win.y(); + + // may need to reverse sign of width or height if a matrix has + // been applied which flips the orientation of this subgraph. + if (s<0.0f) s = -s; + if (t<0.0f) t = -t; + + // bias value used to assist the rounding up or down of + // the texture dimensions to the nearest power of two. + // bias near 0.0 will almost always round down. + // bias near 1.0 will almost always round up. + float bias = 0.7f; + + float sp2 = logf((float)s)/logf(2.0f); + float rounded_sp2 = floorf(sp2+bias); + int new_s = (int)(powf(2.0f,rounded_sp2)); + + float tp2 = logf((float)t)/logf(2.0f); + float rounded_tp2 = floorf(tp2+bias); + int new_t = (int)(powf(2.0f,rounded_tp2)); + + // if dimension is bigger than window divide it down. + while (new_s>viewport.width()) new_s /= 2; + + // if dimension is bigger than window divide it down. + while (new_t>viewport.height()) new_t /= 2; + + + // offset the impostor viewport from the center of the main window + // viewport as often the edges of the viewport might be obscured by + // other windows, which can cause image/reading writing problems. + int center_x = viewport.x()+viewport.width()/2; + int center_y = viewport.y()+viewport.height()/2; + + Viewport* new_viewport = new Viewport; + new_viewport->setViewport(center_x-new_s/2,center_y-new_t/2,new_s,new_t); + rtts->setViewport(new_viewport); + + localPreRenderState->setAttribute(new_viewport); + + // create the impostor sprite. + ImpostorSprite* impostorSprite = + _impostorSpriteManager->createOrReuseImpostorSprite(new_s,new_t,getTraversalNumber()-_numFramesToKeepImpostorSprites); + + if (impostorSprite==NULL) + { + osg::notify(osg::WARN)<<"Warning: unable to create required impostor sprite."<setLastFrameUsed(getTraversalNumber()); + + + // have successfully created an impostor sprite so now need to + // add it into the impostor. + node.addImpostorSprite(contextID,impostorSprite); + + if (_depthSortImpostorSprites) + { + // the depth sort bin should probably be user definable, + // will look into this later. RO July 2001. + StateSet* stateset = impostorSprite->getStateSet(); + stateset->setRenderBinDetails(10,"DepthSortedBin"); + } + + Texture2D* texture = impostorSprite->getTexture(); + + // update frame number to show that impostor is in action. + impostorSprite->setLastFrameUsed(getTraversalNumber()); + + Vec3* coords = impostorSprite->getCoords(); + Vec2* texcoords = impostorSprite->getTexCoords(); + + coords[0] = c01; + texcoords[0].set(0.0f,1.0f); + + coords[1] = c00; + texcoords[1].set(0.0f,0.0f); + + coords[2] = c10; + texcoords[2].set(1.0f,0.0f); + + coords[3] = c11; + texcoords[3].set(1.0f,1.0f); + + impostorSprite->dirtyBound(); + + Vec3* controlcoords = impostorSprite->getControlCoords(); + + if (isPerspectiveProjection) + { + // deal with projection issue by moving the coorners of the quad + // towards the eye point. + float ratio = width/(center_local-eye_local).length(); + float one_minus_ratio = 1.0f-ratio; + Vec3 eye_local_ratio = eye_local*ratio; + + controlcoords[0] = coords[0]*one_minus_ratio + eye_local_ratio; + controlcoords[1] = coords[1]*one_minus_ratio + eye_local_ratio; + controlcoords[2] = coords[2]*one_minus_ratio + eye_local_ratio; + controlcoords[3] = coords[3]*one_minus_ratio + eye_local_ratio; + } + else + { + // project the control points forward towards the eyepoint, + // but since this an othographics projection this projection is + // parallel. + Vec3 dv = lv_local*width; + + controlcoords[0] = coords[0]-dv; + controlcoords[1] = coords[1]-dv; + controlcoords[2] = coords[2]-dv; + controlcoords[3] = coords[3]-dv; + } + + impostorSprite->setStoredLocalEyePoint(eye_local); + + + // and the render to texture stage to the current stages + // dependancy list. + _currentRenderBin->getStage()->addToDependencyList(rtts.get()); + + // attach texture to the RenderToTextureStage. + rtts->setTexture(texture); + + // must sort the RenderToTextureStage so that all leaves are + // accounted correctly in all renderbins i.e depth sorted bins. + rtts->sort(); + + return impostorSprite; + +} + +#endif + diff --git a/src/osg/ImpostorSprite.cpp b/src/osgSim/ImpostorSprite.cpp similarity index 81% rename from src/osg/ImpostorSprite.cpp rename to src/osgSim/ImpostorSprite.cpp index a85e490b7..93fb8827e 100644 --- a/src/osg/ImpostorSprite.cpp +++ b/src/osgSim/ImpostorSprite.cpp @@ -19,13 +19,14 @@ #include #include -#include #include #include #include #include -using namespace osg; +#include + +using namespace osgSim; ImpostorSprite::ImpostorSprite() { @@ -52,7 +53,7 @@ ImpostorSprite::~ImpostorSprite() } } -float ImpostorSprite::calcPixelError(const Matrix& MVPW) const +float ImpostorSprite::calcPixelError(const osg::Matrix& MVPW) const { // find the maximum screen space pixel error between the control coords and the quad coners. float max_error_sqrd = 0.0f; @@ -60,8 +61,8 @@ float ImpostorSprite::calcPixelError(const Matrix& MVPW) const for(int i=0;i<4;++i) { - Vec3 projected_coord = _coords[i]*MVPW; - Vec3 projected_control = _controlcoords[i]*MVPW; + osg::Vec3 projected_coord = _coords[i]*MVPW; + osg::Vec3 projected_control = _controlcoords[i]*MVPW; float dx = (projected_coord.x()-projected_control.x()); float dy = (projected_coord.y()-projected_control.y()); @@ -74,7 +75,7 @@ float ImpostorSprite::calcPixelError(const Matrix& MVPW) const return sqrtf(max_error_sqrd); } -void ImpostorSprite::drawImplementation(State&) const +void ImpostorSprite::drawImplementation(osg::State&) const { // when the tex env is set to REPLACE, and the // texture is set up correctly the color has no effect. @@ -111,13 +112,13 @@ bool ImpostorSprite::computeBound() const if (!_bbox.valid()) { - notify(WARN) << "******* ImpostorSprite::computeBound() problem"<setMode(TexEnv::REPLACE); + _texenv = new osg::TexEnv; + _texenv->setMode(osg::TexEnv::REPLACE); _alphafunc = new osg::AlphaFunc; - _alphafunc->setFunction( AlphaFunc::GREATER, 0.000f ); + _alphafunc->setFunction( osg::AlphaFunc::GREATER, 0.000f ); _reuseStateSetIndex = 0; } @@ -262,21 +263,21 @@ ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,i // creating new impostor sprite. - StateSet* stateset = new StateSet; + osg::StateSet* stateset = new osg::StateSet; stateset->setMode(GL_CULL_FACE,osg::StateAttribute::OFF); stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); stateset->setMode(GL_BLEND,osg::StateAttribute::ON); - stateset->setRenderingHint( StateSet::TRANSPARENT_BIN ); + stateset->setRenderingHint( osg::StateSet::TRANSPARENT_BIN ); - stateset->setAttributeAndModes( _alphafunc.get(), StateAttribute::ON ); + stateset->setAttributeAndModes( _alphafunc.get(), osg::StateAttribute::ON ); - Texture2D* texture = new Texture2D; - texture->setFilter(Texture2D::MIN_FILTER,Texture2D::LINEAR); - texture->setFilter(Texture2D::MAG_FILTER,Texture2D::LINEAR); + osg::Texture2D* texture = new osg::Texture2D; + texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); + texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); - stateset->setTextureAttributeAndModes(0,texture,StateAttribute::ON); + stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON); stateset->setTextureAttribute(0,_texenv.get()); /* @@ -285,12 +286,12 @@ ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,i stateset->setAttribute(texenv); AlphaFunc* alphafunc = new osg::AlphaFunc; - alphafunc->setFunction( AlphaFunc::GREATER, 0.000f ); - stateset->setAttributeAndModes( alphafunc, StateAttribute::ON ); + alphafunc->setFunction( osg::AlphaFunc::GREATER, 0.000f ); + stateset->setAttributeAndModes( alphafunc, osg::StateAttribute::ON ); */ - // stateset->setMode( GL_ALPHA_TEST, StateAttribute::OFF ); + // stateset->setMode( GL_ALPHA_TEST, osg::StateAttribute::OFF ); ImpostorSprite* is = new ImpostorSprite; is->setStateSet(stateset); @@ -302,13 +303,13 @@ ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,i } -StateSet* ImpostorSpriteManager::createOrReuseStateSet() +osg::StateSet* ImpostorSpriteManager::createOrReuseStateSet() { if (_reuseStateSetIndex<_stateSetList.size()) { return _stateSetList[_reuseStateSetIndex++].get(); } - _stateSetList.push_back(new StateSet); + _stateSetList.push_back(new osg::StateSet); _reuseStateSetIndex=_stateSetList.size(); return _stateSetList.back().get(); } diff --git a/src/osgUtil/InsertImpostorsVisitor.cpp b/src/osgSim/InsertImpostorsVisitor.cpp similarity index 92% rename from src/osgUtil/InsertImpostorsVisitor.cpp rename to src/osgSim/InsertImpostorsVisitor.cpp index d8cb3db3d..bc889cb9c 100644 --- a/src/osgUtil/InsertImpostorsVisitor.cpp +++ b/src/osgSim/InsertImpostorsVisitor.cpp @@ -14,12 +14,13 @@ #pragma warning( disable : 4786 ) #endif -#include +#include +#include #include using namespace osg; -using namespace osgUtil; +using namespace osgSim; InsertImpostorsVisitor::InsertImpostorsVisitor() { @@ -55,18 +56,11 @@ void InsertImpostorsVisitor::apply(Group& node) void InsertImpostorsVisitor::apply(LOD& node) { - _lodList.push_back(&node); - - ++_numNestedImpostors; - if (_numNestedImpostors<_maximumNumNestedImpostors) + if (dynamic_cast(&node)==0) { - traverse(node); + _lodList.push_back(&node); } - --_numNestedImpostors; -} - -void InsertImpostorsVisitor::apply(Impostor& node) -{ + ++_numNestedImpostors; if (_numNestedImpostors<_maximumNumNestedImpostors) { @@ -149,9 +143,9 @@ void InsertImpostorsVisitor::insertImpostors() // take a copy of the original parent list // before we change it around by adding the lod // to an impostor. - Node::ParentList parentList = lod->getParents(); + osg::Node::ParentList parentList = lod->getParents(); - osg::Impostor* impostor = new Impostor; + Impostor* impostor = new Impostor; // standard LOD settings for(unsigned int ci=0;cigetNumChildren();++ci) diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index f1d341f62..366616c85 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -81,7 +81,6 @@ class PrintVisitor : public NodeVisitor virtual void apply(Projection& node) { apply((Group&)node); } virtual void apply(Switch& node) { apply((Group&)node); } virtual void apply(LOD& node) { apply((Group&)node); } - virtual void apply(Impostor& node) { apply((LOD&)node); } protected: @@ -98,7 +97,6 @@ CullVisitor::CullVisitor(): _computed_zfar(-FLT_MAX), _currentReuseRenderLeafIndex(0) { - _impostorSpriteManager = new ImpostorSpriteManager; // _nearFarRatio = 0.000005f; } @@ -142,7 +140,6 @@ void CullVisitor::reset() (*itr)->reset(); } - if (_impostorSpriteManager.valid()) _impostorSpriteManager->reset(); _nearPlaneCandidateMap.clear(); @@ -1062,429 +1059,3 @@ void CullVisitor::apply(osg::OccluderNode& node) -void CullVisitor::apply(Impostor& node) -{ - - if (isCulled(node)) return; - - osg::Vec3 eyeLocal = getEyeLocal(); - - // push the culling mode. - pushCurrentMask(); - - // push the node's state. - StateSet* node_state = node.getStateSet(); - if (node_state) pushStateSet(node_state); - - const BoundingSphere& bs = node.getBound(); - - unsigned int contextID = 0; - if (_state.valid()) contextID = _state->getContextID(); - - float distance2 = (eyeLocal-bs.center()).length2(); - if (!_impostorActive || - distance2*_LODScale*_LODScalecalcPixelError(getMVPW()); - - if (error>_impostorPixelErrorThreshold) - { - // chosen impostor sprite pixel error is too great to use - // from this eye point, therefore invalidate it. - impostorSprite=NULL; - } - } - - -// need to think about sprite reuse and support for multiple context's. - - if (impostorSprite==NULL) - { - // no appropriate sprite has been found therefore need to create - // one for use. - - // create the impostor sprite. - impostorSprite = createImpostorSprite(node); - - //if (impostorSprite) impostorSprite->_color.set(0.0f,0.0f,1.0f,1.0f); - - } - //else impostorSprite->_color.set(1.0f,1.0f,1.0f,1.0f); - - if (impostorSprite) - { - - // update frame number to show that impostor is in action. - impostorSprite->setLastFrameUsed(getTraversalNumber()); - - if (_computeNearFar) updateCalculatedNearFar(matrix,*impostorSprite, false); - - StateSet* stateset = impostorSprite->getStateSet(); - - if (stateset) pushStateSet(stateset); - - addDrawableAndDepth(impostorSprite,&matrix,distance(node.getCenter(),matrix)); - - if (stateset) popStateSet(); - - - } - else - { - // no impostor has been selected or created so default to - // traversing the usual LOD selected child. - handle_cull_callbacks_and_traverse(node); - } - - } - - // pop the node's state off the render graph stack. - if (node_state) popStateSet(); - - // pop the culling mode. - popCurrentMask(); -} - -ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node) -{ - - unsigned int contextID = 0; - if (_state.valid()) contextID = _state->getContextID(); - - // default to true right now, will dertermine if perspective from the - // projection matrix... - bool isPerspectiveProjection = true; - - const Matrix& matrix = getModelViewMatrix(); - const BoundingSphere& bs = node.getBound(); - osg::Vec3 eye_local = getEyeLocal(); - - if (!bs.valid()) - { - osg::notify(osg::WARN) << "bb invalid"<<&node< rtts = new RenderToTextureStage; - - // set up lighting. - // currently ignore lights in the scene graph itself.. - // will do later. - RenderStage* previous_stage = _currentRenderBin->getStage(); - - // set up the background color and clear mask. - osg::Vec4 clear_color = previous_stage->getClearColor(); - clear_color[3] = 0.0f; // set the alpha to zero. - rtts->setClearColor(clear_color); - rtts->setClearMask(previous_stage->getClearMask()); - - // set up to charge the same RenderStageLighting is the parent previous stage. - rtts->setRenderStageLighting(previous_stage->getRenderStageLighting()); - - - // record the render bin, to be restored after creation - // of the render to text - RenderBin* previousRenderBin = _currentRenderBin; - - // set the current renderbin to be the newly created stage. - _currentRenderBin = rtts.get(); - - // create quad coords (in local coords) - - Vec3 center_local = bs.center(); - Vec3 camera_up_local = getUpLocal(); - Vec3 lv_local = center_local-eye_local; - - float distance_local = lv_local.length(); - lv_local /= distance_local; - - Vec3 sv_local = lv_local^camera_up_local; - sv_local.normalize(); - - Vec3 up_local = sv_local^lv_local; - - - - float width = bs.radius(); - if (isPerspectiveProjection) - { - // expand the width to account for projection onto sprite. - width *= (distance_local/sqrtf(distance_local*distance_local-bs.radius2())); - } - - // scale up and side vectors to sprite width. - up_local *= width; - sv_local *= width; - - // create the corners of the sprite. - Vec3 c00(center_local - sv_local - up_local); - Vec3 c10(center_local + sv_local - up_local); - Vec3 c01(center_local - sv_local + up_local); - Vec3 c11(center_local + sv_local + up_local); - -// adjust camera left,right,up,down to fit (in world coords) - - Vec3 near_local ( center_local-lv_local*width ); - Vec3 far_local ( center_local+lv_local*width ); - Vec3 top_local ( center_local+up_local); - Vec3 right_local ( center_local+sv_local); - - Vec3 near_world = near_local * matrix; - Vec3 far_world = far_local * matrix; - Vec3 top_world = top_local * matrix; - Vec3 right_world = right_local * matrix; - - float znear = (near_world-eye_world).length(); - float zfar = (far_world-eye_world).length(); - - float top = (top_world-center_world).length(); - float right = (right_world-center_world).length(); - - znear *= 0.9f; - zfar *= 1.1f; - - // set up projection. - osg::RefMatrix* projection = new osg::RefMatrix; - if (isPerspectiveProjection) - { - // deal with projection issue move the top and right points - // onto the near plane. - float ratio = znear/(center_world-eye_world).length(); - top *= ratio; - right *= ratio; - projection->makeFrustum(-right,right,-top,top,znear,zfar); - } - else - { - projection->makeOrtho(-right,right,-top,top,znear,zfar); - } - - pushProjectionMatrix(projection); - - Vec3 rotate_from = bs.center()-eye_local; - Vec3 rotate_to = getLookVectorLocal(); - - osg::RefMatrix* rotate_matrix = new osg::RefMatrix( - osg::Matrix::translate(-eye_local)* - osg::Matrix::rotate(rotate_from,rotate_to)* - osg::Matrix::translate(eye_local)* - getModelViewMatrix()); - - // pushing the cull view state will update it so it takes - // into account the new camera orientation. - pushModelViewMatrix(rotate_matrix); - - StateSet* localPreRenderState = _impostorSpriteManager->createOrReuseStateSet(); - - pushStateSet(localPreRenderState); - - { - - // traversing the usual LOD selected child. - handle_cull_callbacks_and_traverse(node); - - } - - popStateSet(); - - // restore the previous model view matrix. - popModelViewMatrix(); - - // restore the previous model view matrix. - popProjectionMatrix(); - - // restore the previous renderbin. - _currentRenderBin = previousRenderBin; - - - - if (rtts->getRenderGraphList().size()==0 && rtts->getRenderBinList().size()==0) - { - // getting to this point means that all the subgraph has been - // culled by small feature culling or is beyond LOD ranges. - return NULL; - } - - - - - const osg::Viewport& viewport = *getViewport(); - - - // calc texture size for eye, bs. - - // convert the corners of the sprite (in world coords) into their - // equivilant window coordinates by using the camera's project method. - const osg::Matrix& MVPW = getMVPW(); - Vec3 c00_win = c00 * MVPW; - Vec3 c11_win = c11 * MVPW; - -// adjust texture size to be nearest power of 2. - - float s = c11_win.x()-c00_win.x(); - float t = c11_win.y()-c00_win.y(); - - // may need to reverse sign of width or height if a matrix has - // been applied which flips the orientation of this subgraph. - if (s<0.0f) s = -s; - if (t<0.0f) t = -t; - - // bias value used to assist the rounding up or down of - // the texture dimensions to the nearest power of two. - // bias near 0.0 will almost always round down. - // bias near 1.0 will almost always round up. - float bias = 0.7f; - - float sp2 = logf((float)s)/logf(2.0f); - float rounded_sp2 = floorf(sp2+bias); - int new_s = (int)(powf(2.0f,rounded_sp2)); - - float tp2 = logf((float)t)/logf(2.0f); - float rounded_tp2 = floorf(tp2+bias); - int new_t = (int)(powf(2.0f,rounded_tp2)); - - // if dimension is bigger than window divide it down. - while (new_s>viewport.width()) new_s /= 2; - - // if dimension is bigger than window divide it down. - while (new_t>viewport.height()) new_t /= 2; - - - // offset the impostor viewport from the center of the main window - // viewport as often the edges of the viewport might be obscured by - // other windows, which can cause image/reading writing problems. - int center_x = viewport.x()+viewport.width()/2; - int center_y = viewport.y()+viewport.height()/2; - - Viewport* new_viewport = new Viewport; - new_viewport->setViewport(center_x-new_s/2,center_y-new_t/2,new_s,new_t); - rtts->setViewport(new_viewport); - - localPreRenderState->setAttribute(new_viewport); - - // create the impostor sprite. - ImpostorSprite* impostorSprite = - _impostorSpriteManager->createOrReuseImpostorSprite(new_s,new_t,getTraversalNumber()-_numFramesToKeepImpostorSprites); - - if (impostorSprite==NULL) - { - osg::notify(osg::WARN)<<"Warning: unable to create required impostor sprite."<setLastFrameUsed(getTraversalNumber()); - - - // have successfully created an impostor sprite so now need to - // add it into the impostor. - node.addImpostorSprite(contextID,impostorSprite); - - if (_depthSortImpostorSprites) - { - // the depth sort bin should probably be user definable, - // will look into this later. RO July 2001. - StateSet* stateset = impostorSprite->getStateSet(); - stateset->setRenderBinDetails(10,"DepthSortedBin"); - } - - Texture2D* texture = impostorSprite->getTexture(); - - // update frame number to show that impostor is in action. - impostorSprite->setLastFrameUsed(getTraversalNumber()); - - Vec3* coords = impostorSprite->getCoords(); - Vec2* texcoords = impostorSprite->getTexCoords(); - - coords[0] = c01; - texcoords[0].set(0.0f,1.0f); - - coords[1] = c00; - texcoords[1].set(0.0f,0.0f); - - coords[2] = c10; - texcoords[2].set(1.0f,0.0f); - - coords[3] = c11; - texcoords[3].set(1.0f,1.0f); - - impostorSprite->dirtyBound(); - - Vec3* controlcoords = impostorSprite->getControlCoords(); - - if (isPerspectiveProjection) - { - // deal with projection issue by moving the coorners of the quad - // towards the eye point. - float ratio = width/(center_local-eye_local).length(); - float one_minus_ratio = 1.0f-ratio; - Vec3 eye_local_ratio = eye_local*ratio; - - controlcoords[0] = coords[0]*one_minus_ratio + eye_local_ratio; - controlcoords[1] = coords[1]*one_minus_ratio + eye_local_ratio; - controlcoords[2] = coords[2]*one_minus_ratio + eye_local_ratio; - controlcoords[3] = coords[3]*one_minus_ratio + eye_local_ratio; - } - else - { - // project the control points forward towards the eyepoint, - // but since this an othographics projection this projection is - // parallel. - Vec3 dv = lv_local*width; - - controlcoords[0] = coords[0]-dv; - controlcoords[1] = coords[1]-dv; - controlcoords[2] = coords[2]-dv; - controlcoords[3] = coords[3]-dv; - } - - impostorSprite->setStoredLocalEyePoint(eye_local); - - - // and the render to texture stage to the current stages - // dependancy list. - _currentRenderBin->getStage()->addToDependencyList(rtts.get()); - - // attach texture to the RenderToTextureStage. - rtts->setTexture(texture); - - // must sort the RenderToTextureStage so that all leaves are - // accounted correctly in all renderbins i.e depth sorted bins. - rtts->sort(); - - return impostorSprite; - -} diff --git a/src/osgUtil/DisplayRequirementsVisitor.cpp b/src/osgUtil/DisplayRequirementsVisitor.cpp index 32d9c4cf2..f448a66e5 100644 --- a/src/osgUtil/DisplayRequirementsVisitor.cpp +++ b/src/osgUtil/DisplayRequirementsVisitor.cpp @@ -56,6 +56,18 @@ void DisplayRequirementsVisitor::apply(Node& node) osg::StateSet* stateset = node.getStateSet(); if (stateset) applyStateSet(*stateset); + if (strcmp(node.className(),"Impostor")==0) + { + if (!_ds) _ds = new osg::DisplaySettings; + + unsigned int min = 1; // number alpha bits we need at least. + if (min>_ds->getMinimumNumAlphaBits()) + { + // only update if new minimum exceeds previous minimum. + _ds->setMinimumNumAlphaBits(min); + } + } + traverse(node); } @@ -70,17 +82,3 @@ void DisplayRequirementsVisitor::apply(Geode& geode) if (stateset) applyStateSet(*stateset); } } - -void DisplayRequirementsVisitor::apply(Impostor& impostor) -{ - if (!_ds) _ds = new osg::DisplaySettings; - - unsigned int min = 1; // number alpha bits we need at least. - if (min>_ds->getMinimumNumAlphaBits()) - { - // only update if new minimum exceeds previous minimum. - _ds->setMinimumNumAlphaBits(min); - } - - apply((Node&)impostor); -} diff --git a/src/osgUtil/GNUmakefile b/src/osgUtil/GNUmakefile index 35bfe8cf9..2c9047cf6 100644 --- a/src/osgUtil/GNUmakefile +++ b/src/osgUtil/GNUmakefile @@ -10,7 +10,6 @@ CXXFILES = \ DisplayRequirementsVisitor.cpp\ HalfWayMapGenerator.cpp\ HighlightMapGenerator.cpp\ - InsertImpostorsVisitor.cpp\ IntersectVisitor.cpp\ Optimizer.cpp\ RenderBin.cpp\ diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index 1f9b5d517..2a330a872 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/src/osgUtil/RenderBin.cpp b/src/osgUtil/RenderBin.cpp index d7885cac6..7b5d11e63 100644 --- a/src/osgUtil/RenderBin.cpp +++ b/src/osgUtil/RenderBin.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -351,7 +350,6 @@ bool RenderBin::getStats(Statistics* primStats) { // then tot up the primtive types and no vertices. dw->accept(*primStats); // use sub-class to find the stats for each drawable - if (typeid(*dw)==typeid(osg::ImpostorSprite)) primStats->addImpostor(1); } somestats = true; @@ -374,7 +372,6 @@ bool RenderBin::getStats(Statistics* primStats) { // then tot up the primtive types and no vertices. dw->accept(*primStats); // use sub-class to find the stats for each drawable - if (typeid(*dw)==typeid(osg::ImpostorSprite)) primStats->addImpostor(1); } } somestats=true; diff --git a/src/osgWrappers/osg/GNUmakefile b/src/osgWrappers/osg/GNUmakefile index 758ae071a..d9186f5e3 100644 --- a/src/osgWrappers/osg/GNUmakefile +++ b/src/osgWrappers/osg/GNUmakefile @@ -43,8 +43,6 @@ CXXFILES =\ Group.cpp\ Image.cpp\ ImageStream.cpp\ - Impostor.cpp\ - ImpostorSprite.cpp\ Light.cpp\ LightModel.cpp\ LightSource.cpp\ diff --git a/src/osgWrappers/osg/Impostor.cpp b/src/osgWrappers/osg/Impostor.cpp deleted file mode 100644 index fb0e6ed02..000000000 --- a/src/osgWrappers/osg/Impostor.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// *************************************************************************** -// -// Generated automatically by genwrapper. -// Please DO NOT EDIT this file! -// -// *************************************************************************** - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -TYPE_NAME_ALIAS(std::vector< osg::ref_ptr< osg::ImpostorSprite > >, osg::Impostor::ImpostorSpriteList); - -BEGIN_OBJECT_REFLECTOR(osg::Impostor) - BaseType(osg::LOD); - Constructor0(); - ConstructorWithDefaults2(IN, const osg::Impostor &, es, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY); - Method0(osg::Object *, cloneType); - Method1(osg::Object *, clone, IN, const osg::CopyOp &, copyop); - Method1(bool, isSameKindAs, IN, const osg::Object *, obj); - Method0(const char *, className); - Method0(const char *, libraryName); - Method1(void, accept, IN, osg::NodeVisitor &, nv); - Method1(void, setImpostorThreshold, IN, float, distance); - Method0(float, getImpostorThreshold); - MethodWithDefaults1(void, setImpostorThresholdToBound, IN, float, ratio, 1.0f); - Method2(osg::ImpostorSprite *, findBestImpostorSprite, IN, unsigned int, contextID, IN, const osg::Vec3 &, currLocalEyePoint); - Method2(void, addImpostorSprite, IN, unsigned int, contextID, IN, osg::ImpostorSprite *, is); - Method1(osg::Impostor::ImpostorSpriteList &, getImpostorSpriteList, IN, unsigned int, contexID); - Method1(const osg::Impostor::ImpostorSpriteList &, getImpostorSpriteList, IN, unsigned int, contexID); - Property(float, ImpostorThreshold); - WriteOnlyProperty(float, ImpostorThresholdToBound); -END_REFLECTOR - -BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osg::ImpostorSprite >) - Constructor0(); - Constructor1(IN, osg::ImpostorSprite *, t); - Constructor1(IN, const osg::ref_ptr< osg::ImpostorSprite > &, rp); - Method0(bool, valid); - Method0(osg::ImpostorSprite *, get); - Method0(const osg::ImpostorSprite *, get); - Method0(osg::ImpostorSprite *, take); - Method0(osg::ImpostorSprite *, release); - ReadOnlyProperty(osg::ImpostorSprite *, ); -END_REFLECTOR - -STD_VECTOR_REFLECTOR(std::vector< osg::ref_ptr< osg::ImpostorSprite > >); - diff --git a/src/osgWrappers/osg/ImpostorSprite.cpp b/src/osgWrappers/osg/ImpostorSprite.cpp deleted file mode 100644 index 863bf3af5..000000000 --- a/src/osgWrappers/osg/ImpostorSprite.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// *************************************************************************** -// -// Generated automatically by genwrapper. -// Please DO NOT EDIT this file! -// -// *************************************************************************** - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -BEGIN_OBJECT_REFLECTOR(osg::ImpostorSprite) - BaseType(osg::Drawable); - Constructor0(); - Method0(osg::Object *, cloneType); - Method1(osg::Object *, clone, IN, const osg::CopyOp &, x); - Method1(bool, isSameKindAs, IN, const osg::Object *, obj); - Method0(const char *, libraryName); - Method0(const char *, className); - Method1(void, setParent, IN, osg::Impostor *, parent); - Method0(osg::Impostor *, getParent); - Method0(const osg::Impostor *, getParent); - Method1(void, setStoredLocalEyePoint, IN, const osg::Vec3 &, v); - Method0(const osg::Vec3 &, getStoredLocalEyePoint); - Method1(void, setLastFrameUsed, IN, int, frameNumber); - Method0(int, getLastFrameUsed); - Method0(osg::Vec3 *, getCoords); - Method0(const osg::Vec3 *, getCoords); - Method0(osg::Vec2 *, getTexCoords); - Method0(const osg::Vec2 *, getTexCoords); - Method0(osg::Vec3 *, getControlCoords); - Method0(const osg::Vec3 *, getControlCoords); - Method1(float, calcPixelError, IN, const osg::Matrix &, MVPW); - Method3(void, setTexture, IN, osg::Texture2D *, tex, IN, int, s, IN, int, t); - Method0(osg::Texture2D *, getTexture); - Method0(const osg::Texture2D *, getTexture); - Method0(int, s); - Method0(int, t); - Method1(void, drawImplementation, IN, osg::State &, state); - Method1(bool, supports, IN, const osg::Drawable::AttributeFunctor &, x); - Method1(void, accept, IN, osg::Drawable::AttributeFunctor &, af); - Method1(bool, supports, IN, const osg::Drawable::ConstAttributeFunctor &, x); - Method1(void, accept, IN, osg::Drawable::ConstAttributeFunctor &, af); - Method1(bool, supports, IN, const osg::PrimitiveFunctor &, x); - Method1(void, accept, IN, osg::PrimitiveFunctor &, pf); - ReadOnlyProperty(osg::Vec3 *, ControlCoords); - ReadOnlyProperty(osg::Vec3 *, Coords); - Property(int, LastFrameUsed); - Property(osg::Impostor *, Parent); - Property(const osg::Vec3 &, StoredLocalEyePoint); - ReadOnlyProperty(osg::Vec2 *, TexCoords); - ReadOnlyProperty(osg::Texture2D *, Texture); -END_REFLECTOR - -BEGIN_OBJECT_REFLECTOR(osg::ImpostorSpriteManager) - BaseType(osg::Referenced); - Constructor0(); - Method0(bool, empty); - Method0(osg::ImpostorSprite *, first); - Method0(osg::ImpostorSprite *, last); - Method1(void, push_back, IN, osg::ImpostorSprite *, is); - Method1(void, remove, IN, osg::ImpostorSprite *, is); - Method3(osg::ImpostorSprite *, createOrReuseImpostorSprite, IN, int, s, IN, int, t, IN, int, frameNumber); - Method0(osg::StateSet *, createOrReuseStateSet); - Method0(void, reset); -END_REFLECTOR -