Moved osg::Impostor to osgSim::Impostor, as Impostor isn't a core feature.

This commit is contained in:
Robert Osfield
2005-05-01 19:48:49 +00:00
parent 7de1265059
commit 03232ec667
41 changed files with 702 additions and 845 deletions

View File

@@ -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); }

View File

@@ -23,7 +23,6 @@
#include <osg/LightSource>
#include <osg/Transform>
#include <osg/Projection>
#include <osg/Impostor>
#include <osg/OccluderNode>
#include <osgGA/GUIEventAdapter>
@@ -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); }

View File

@@ -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 <osg/LOD>
#include <osg/ImpostorSprite>
#include <osg/buffered_value>
namespace osg {
#include <osgSim/ImpostorSprite>
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<ImpostorSprite> > ImpostorSpriteList;
typedef std::vector< osg::ref_ptr<ImpostorSprite> > 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<ImpostorSpriteList> _impostorSpriteListBuffer;
mutable osg::buffered_object<ImpostorSpriteList> _impostorSpriteListBuffer;
float _impostorThreshold;

View File

@@ -17,13 +17,14 @@
#include <osg/Vec2>
#include <osg/BoundingSphere>
#include <osg/Drawable>
#include <osg/ImpostorSprite>
#include <osg/AlphaFunc>
#include <osg/TexEnv>
#include <osg/Texture2D>
namespace osg {
#include <osgSim/Export>
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<const ImpostorSprite*>(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<const ImpostorSprite*>(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> _texenv;
ref_ptr<AlphaFunc> _alphafunc;
osg::ref_ptr<osg::TexEnv> _texenv;
osg::ref_ptr<osg::AlphaFunc> _alphafunc;
ImpostorSprite* _first;
ImpostorSprite* _last;
ImpostorSprite* _first;
ImpostorSprite* _last;
typedef std::vector< ref_ptr<StateSet> > StateSetList;
StateSetList _stateSetList;
unsigned int _reuseStateSetIndex;
typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetList;
StateSetList _stateSetList;
unsigned int _reuseStateSetIndex;
};

View File

@@ -11,20 +11,18 @@
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGUTIL_INSERTIMPOSTORSVISITOR
#define OSGUTIL_INSERTIMPOSTORSVISITOR
#ifndef OSGSIM_INSERTIMPOSTORSVISITOR
#define OSGSIM_INSERTIMPOSTORSVISITOR
#include <osg/NodeVisitor>
#include <osg/Impostor>
#include <osgSim/Impostor>
#include <osgUtil/Export>
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();

View File

@@ -24,7 +24,6 @@
#include <osg/Drawable>
#include <osg/StateSet>
#include <osg/State>
#include <osg/Impostor>
#include <osg/ClearNode>
#include <osg/Notify>
@@ -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<const osg::ClearNode> _clearNode;
osg::ref_ptr<RenderGraph> _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<osg::ImpostorSpriteManager> _impostorSpriteManager;
osg::ref_ptr<osg::State> _state;

View File

@@ -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:

View File

@@ -23,7 +23,6 @@
#include <osg/LightSource>
#include <osg/Transform>
#include <osg/Projection>
#include <osg/Impostor>
#include <osg/OccluderNode>
#include <osgUtil/Export>
@@ -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); }