Synch with 20010921
This commit is contained in:
@@ -14,12 +14,23 @@ class SG_EXPORT AlphaFunc : public StateAttribute
|
||||
|
||||
|
||||
AlphaFunc();
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const AlphaFunc*>(obj)!=0L; }
|
||||
virtual Object* clone() const { return new AlphaFunc(); }
|
||||
virtual const char* className() const { return "AlphaFunc"; }
|
||||
|
||||
virtual const Type getType() const { return ALPHAFUNC; }
|
||||
|
||||
META_StateAttribute(AlphaFunc,ALPHAFUNC);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(AlphaFunc,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_comparisonFunc)
|
||||
COMPARE_StateAttribute_Parameter(_referenceValue)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
ds.setMode(GL_ALPHA_TEST,value);
|
||||
|
||||
@@ -22,11 +22,7 @@ class SG_EXPORT Billboard : public Geode
|
||||
|
||||
Billboard();
|
||||
|
||||
virtual Object* clone() const { return new Billboard(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Billboard*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Billboard"; }
|
||||
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
|
||||
|
||||
META_Node(Billboard);
|
||||
|
||||
/** Set the axis about which all the billboard's drawable rotate. */
|
||||
inline void setAxis(const Vec3& axis) { _axis = axis; }
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Quat>
|
||||
#include <osg/ClippingVolume>
|
||||
#include <osg/Viewport>
|
||||
|
||||
namespace osg {
|
||||
|
||||
@@ -58,6 +59,9 @@ class SG_EXPORT Camera: public osg::Referenced
|
||||
void setPerspective(const double fovy,const double aspectRatio,
|
||||
const double zNear, const double zFar);
|
||||
|
||||
/** Set a sysmetical perspective projection using field of view.*/
|
||||
void setFOV(const double fovx,const double fovy,
|
||||
const double zNear, const double zFar);
|
||||
|
||||
/** Set the near and far clipping planes.*/
|
||||
void setNearFar(const double zNear, const double zFar);
|
||||
@@ -65,16 +69,32 @@ class SG_EXPORT Camera: public osg::Referenced
|
||||
/** Use in combination with adjustAspectRatio, to control
|
||||
* the change in frustum clipping planes to account for
|
||||
* changes in windows aspect ratio,*/
|
||||
enum AdjustAxis
|
||||
enum AdjustAspectRatioMode
|
||||
{
|
||||
ADJUST_VERTICAL,
|
||||
ADJUST_HORIZONTAL
|
||||
};
|
||||
|
||||
/** Set the way that the vertical or horizontal dimensions of the window
|
||||
* are adjusted on a resize. */
|
||||
void setAdjustAspectRatioMode(const AdjustAspectRatioMode aam) { _adjustAspectRatioMode = aam; }
|
||||
|
||||
/** Get the way that the vertical or horizontal dimensions of the window
|
||||
* are adjusted on a resize. */
|
||||
const AdjustAspectRatioMode getAdjustAspectRatioMode() const { return _adjustAspectRatioMode; }
|
||||
|
||||
/** Adjust the clipping planes to account for a new window aspcect ratio.
|
||||
* Typicall used after resizeing a window. Aspect ratio is defined as
|
||||
* width/height.*/
|
||||
void adjustAspectRatio(const double newAspectRatio, const AdjustAxis aa = ADJUST_HORIZONTAL);
|
||||
void adjustAspectRatio(const double newAspectRatio)
|
||||
{
|
||||
adjustAspectRatio(newAspectRatio,_adjustAspectRatioMode);
|
||||
}
|
||||
|
||||
/** Adjust the clipping planes to account for a new window aspcect ratio.
|
||||
* Typicall used after resizeing a window. Aspect ratio is defined as
|
||||
* width/height.*/
|
||||
void adjustAspectRatio(const double newAspectRatio, const AdjustAspectRatioMode aa);
|
||||
|
||||
const double left() const;
|
||||
const double right() const;
|
||||
@@ -223,11 +243,11 @@ class SG_EXPORT Camera: public osg::Referenced
|
||||
|
||||
/** Map object coordinates into windows coordinates.
|
||||
* Equivilant to gluProject(...). */
|
||||
const bool project(const Vec3& obj,const int* viewport,Vec3& win) const;
|
||||
const bool project(const Vec3& obj,const Viewport& viewport,Vec3& win) const;
|
||||
|
||||
/** Map window coordinates into object coordinates.
|
||||
* Equivilant to gluUnProject(...). */
|
||||
const bool unproject(const Vec3& win,const int* viewport,Vec3& obj) const;
|
||||
const bool unproject(const Vec3& win,const Viewport& viewport,Vec3& obj) const;
|
||||
|
||||
|
||||
protected:
|
||||
@@ -239,6 +259,9 @@ class SG_EXPORT Camera: public osg::Referenced
|
||||
// projection details.
|
||||
ProjectionType _projectionType;
|
||||
|
||||
// how the window dimensions should be altered during a window resize.
|
||||
AdjustAspectRatioMode _adjustAspectRatioMode;
|
||||
|
||||
// note, in Frustum/Perspective mode these values are scaled
|
||||
// by the zNear from when they were initialised to ensure that
|
||||
// subsequent changes in zNear do not affect them.
|
||||
|
||||
@@ -14,17 +14,25 @@ class SG_EXPORT ClipPlane : public StateAttribute
|
||||
|
||||
ClipPlane();
|
||||
|
||||
/** return a shallow copy of a node, with Object* return type.*/
|
||||
virtual Object* clone() const { return new ClipPlane(); }
|
||||
|
||||
/** return true if this and obj are of the same kind of object.*/
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ClipPlane*>(obj)!=NULL; }
|
||||
|
||||
/** return the name of the node's class type.*/
|
||||
virtual const char* className() const { return "ClipPlane"; }
|
||||
|
||||
virtual const Type getType() const { return (Type)(CLIPPLANE+_clipPlaneNum); }
|
||||
META_StateAttribute(ClipPlane, (Type)(CLIPPLANE+_clipPlaneNum));
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(ClipPlane,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_clipPlaneNum)
|
||||
COMPARE_StateAttribute_Parameter(_clipPlane[0])
|
||||
COMPARE_StateAttribute_Parameter(_clipPlane[1])
|
||||
COMPARE_StateAttribute_Parameter(_clipPlane[2])
|
||||
COMPARE_StateAttribute_Parameter(_clipPlane[3])
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
ds.setMode((GLMode)(GL_CLIP_PLANE0+_clipPlaneNum),value);
|
||||
@@ -62,7 +70,7 @@ class SG_EXPORT ClipPlane : public StateAttribute
|
||||
|
||||
virtual ~ClipPlane();
|
||||
|
||||
double* _clipPlane;
|
||||
double _clipPlane[4];
|
||||
unsigned int _clipPlaneNum;
|
||||
|
||||
};
|
||||
|
||||
@@ -15,12 +15,25 @@ class SG_EXPORT ColorMask : public StateAttribute
|
||||
|
||||
|
||||
ColorMask();
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ColorMask*>(obj)!=0L; }
|
||||
virtual Object* clone() const { return new ColorMask(); }
|
||||
virtual const char* className() const { return "ColorMask"; }
|
||||
|
||||
virtual const Type getType() const { return COLORMASK; }
|
||||
|
||||
META_StateAttribute(ColorMask, COLORMASK);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(ColorMask,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_red)
|
||||
COMPARE_StateAttribute_Parameter(_green)
|
||||
COMPARE_StateAttribute_Parameter(_blue)
|
||||
COMPARE_StateAttribute_Parameter(_alpha)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
inline void setMask(bool red,bool green,bool blue,bool alpha)
|
||||
{
|
||||
_red = red;
|
||||
|
||||
@@ -14,12 +14,22 @@ class SG_EXPORT CullFace : public StateAttribute
|
||||
public :
|
||||
|
||||
CullFace();
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const CullFace*>(obj)!=0L; }
|
||||
virtual Object* clone() const { return new CullFace(); }
|
||||
virtual const char* className() const { return "CullFace"; }
|
||||
|
||||
virtual const Type getType() const { return CULLFACE; }
|
||||
|
||||
META_StateAttribute(CullFace, CULLFACE);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(CullFace,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_mode)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
ds.setMode(GL_CULL_FACE,value);
|
||||
|
||||
@@ -15,12 +15,25 @@ class SG_EXPORT Depth : public StateAttribute
|
||||
|
||||
|
||||
Depth();
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Depth*>(obj)!=0L; }
|
||||
virtual Object* clone() const { return new Depth(); }
|
||||
virtual const char* className() const { return "Depth"; }
|
||||
|
||||
virtual const Type getType() const { return DEPTH; }
|
||||
|
||||
META_StateAttribute(Depth, DEPTH);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(Depth,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_func)
|
||||
COMPARE_StateAttribute_Parameter(_depthWriteMask)
|
||||
COMPARE_StateAttribute_Parameter(_zNear)
|
||||
COMPARE_StateAttribute_Parameter(_zFar)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
ds.setMode(GL_DEPTH_TEST,value);
|
||||
|
||||
@@ -15,12 +15,26 @@ class SG_EXPORT Fog : public StateAttribute
|
||||
public :
|
||||
|
||||
Fog();
|
||||
virtual Object* clone() const { return new Fog(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Fog*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Fog"; }
|
||||
|
||||
virtual const Type getType() const { return FOG; }
|
||||
META_StateAttribute(Fog,FOG);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(Fog,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_mode)
|
||||
COMPARE_StateAttribute_Parameter(_density)
|
||||
COMPARE_StateAttribute_Parameter(_start)
|
||||
COMPARE_StateAttribute_Parameter(_end)
|
||||
COMPARE_StateAttribute_Parameter(_color)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
ds.setMode(GL_FOG,value);
|
||||
|
||||
@@ -13,12 +13,22 @@ class SG_EXPORT FrontFace : public StateAttribute
|
||||
public :
|
||||
|
||||
FrontFace();
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const FrontFace*>(obj)!=0L; }
|
||||
virtual Object* clone() const { return new FrontFace(); }
|
||||
virtual const char* className() const { return "FrontFace"; }
|
||||
|
||||
virtual const Type getType() const { return FRONTFACE; }
|
||||
|
||||
META_StateAttribute(FrontFace, FRONTFACE);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(FrontFace,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_mode)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
enum Mode {
|
||||
CLOCKWISE = GL_CW,
|
||||
COUNTER_CLOCKWISE = GL_CCW
|
||||
|
||||
@@ -16,10 +16,7 @@ class SG_EXPORT Geode : public Node
|
||||
|
||||
Geode();
|
||||
|
||||
virtual Object* clone() const { return new Geode(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Geode*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Geode"; }
|
||||
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
|
||||
META_Node(Geode);
|
||||
|
||||
/** Add Drawable to Geode.
|
||||
* If gset is not NULL and is not contained in Geode then increment its
|
||||
@@ -58,7 +55,7 @@ class SG_EXPORT Geode : public Node
|
||||
/** return geoset at position i.*/
|
||||
inline const Drawable* getDrawable( const int i ) const { return _drawables[i].get(); }
|
||||
|
||||
/** return true is geoset is contained within Geode.*/
|
||||
/** return true if geoset is contained within Geode.*/
|
||||
inline const bool containsDrawable(const Drawable* gset) const
|
||||
{
|
||||
|
||||
|
||||
@@ -17,12 +17,9 @@ class SG_EXPORT Group : public Node
|
||||
typedef std::vector<ref_ptr<Node> > ChildList;
|
||||
|
||||
Group();
|
||||
|
||||
virtual Object* clone() const { return new Group(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Group*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Group"; }
|
||||
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
|
||||
|
||||
META_Node(Group);
|
||||
|
||||
virtual void traverse(NodeVisitor& nv);
|
||||
|
||||
/** Add Node to Group.
|
||||
|
||||
@@ -49,10 +49,7 @@ class SG_EXPORT Impostor : public LOD
|
||||
public :
|
||||
Impostor();
|
||||
|
||||
virtual Object* clone() const { return new Impostor(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Impostor*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Impostor"; }
|
||||
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
|
||||
META_Node(Impostor);
|
||||
|
||||
typedef std::vector< ref_ptr<ImpostorSprite> > ImpostorSpriteList;
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <osg/Drawable>
|
||||
#include <osg/Camera>
|
||||
#include <osg/ImpostorSprite>
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/TexEnv>
|
||||
|
||||
namespace osg {
|
||||
|
||||
@@ -91,7 +93,7 @@ class SG_EXPORT ImpostorSprite : public Drawable
|
||||
|
||||
|
||||
/** calculate the pixel error value for current camera position and object position.*/
|
||||
const float calcPixelError(const Camera& camera,const int* viewport,const osg::Matrix* matrix) const;
|
||||
const float calcPixelError(const Camera& camera,const Viewport& viewport,const osg::Matrix* matrix) const;
|
||||
|
||||
|
||||
void setTexture(Texture* tex,int s,int t);
|
||||
@@ -165,8 +167,11 @@ class SG_EXPORT ImpostorSpriteManager : public Referenced
|
||||
|
||||
~ImpostorSpriteManager();
|
||||
|
||||
ImpostorSprite* _first;
|
||||
ImpostorSprite* _last;
|
||||
ref_ptr<TexEnv> _texenv;
|
||||
ref_ptr<AlphaFunc> _alphafunc;
|
||||
|
||||
ImpostorSprite* _first;
|
||||
ImpostorSprite* _last;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -17,10 +17,8 @@ class SG_EXPORT LOD : public Group
|
||||
public :
|
||||
LOD() {}
|
||||
|
||||
virtual Object* clone() const { return new LOD(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const LOD*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "LOD"; }
|
||||
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
|
||||
META_Node(LOD);
|
||||
|
||||
virtual void traverse(NodeVisitor& nv);
|
||||
|
||||
/** Sets the value of range list element index to range which
|
||||
|
||||
@@ -15,22 +15,31 @@ class SG_EXPORT Light : public StateAttribute
|
||||
|
||||
Light();
|
||||
|
||||
/** return a shallow copy of a node, with Object* return type.*/
|
||||
virtual Object* clone() const { return new Light(); }
|
||||
META_StateAttribute(Light, (Type)(LIGHT_0+_lightnum));
|
||||
|
||||
/** return true if this and obj are of the same kind of object.*/
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Light*>(obj)!=NULL; }
|
||||
|
||||
/** return the name of the node's class type.*/
|
||||
virtual const char* className() const { return "Light"; }
|
||||
|
||||
virtual const Type getType() const { return LIGHTING; }
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
ds.setMode((GLMode)(GL_LIGHT0+_lightnum),value);
|
||||
}
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(Light,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_lightnum)
|
||||
COMPARE_StateAttribute_Parameter(_on)
|
||||
COMPARE_StateAttribute_Parameter(_ambient)
|
||||
COMPARE_StateAttribute_Parameter(_diffuse)
|
||||
COMPARE_StateAttribute_Parameter(_specular)
|
||||
COMPARE_StateAttribute_Parameter(_position)
|
||||
COMPARE_StateAttribute_Parameter(_direction)
|
||||
COMPARE_StateAttribute_Parameter(_constant_attenuation)
|
||||
COMPARE_StateAttribute_Parameter(_linear_attenuation)
|
||||
COMPARE_StateAttribute_Parameter(_quadratic_attenuation)
|
||||
COMPARE_StateAttribute_Parameter(_spot_exponent)
|
||||
COMPARE_StateAttribute_Parameter(_spot_cutoff)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn the light on.
|
||||
|
||||
@@ -14,10 +14,7 @@ class SG_EXPORT LightSource : public Node
|
||||
|
||||
LightSource();
|
||||
|
||||
virtual Object* clone() const { return new LightSource(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const LightSource*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "LightSource"; }
|
||||
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
|
||||
META_Node(LightSource);
|
||||
|
||||
/** Set the attached light.*/
|
||||
inline void setLight(Light* light) { _light = light; }
|
||||
|
||||
@@ -14,12 +14,37 @@ class SG_EXPORT Material : public StateAttribute
|
||||
|
||||
|
||||
Material();
|
||||
virtual Object* clone() const { return new Material(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Material*>(obj)!=NULL; }
|
||||
const char* className() const { return "Material"; }
|
||||
|
||||
virtual const Type getType() const { return MATERIAL; }
|
||||
META_StateAttribute(Material, MATERIAL);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(Material,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_colorMode)
|
||||
COMPARE_StateAttribute_Parameter(_ambientFrontAndBack)
|
||||
COMPARE_StateAttribute_Parameter(_ambientFront)
|
||||
COMPARE_StateAttribute_Parameter(_ambientBack)
|
||||
COMPARE_StateAttribute_Parameter(_diffuseFrontAndBack)
|
||||
COMPARE_StateAttribute_Parameter(_diffuseFront)
|
||||
COMPARE_StateAttribute_Parameter(_diffuseBack)
|
||||
COMPARE_StateAttribute_Parameter(_specularFrontAndBack)
|
||||
COMPARE_StateAttribute_Parameter(_specularFront)
|
||||
COMPARE_StateAttribute_Parameter(_specularBack)
|
||||
COMPARE_StateAttribute_Parameter(_emissionFrontAndBack)
|
||||
COMPARE_StateAttribute_Parameter(_emissionFront)
|
||||
COMPARE_StateAttribute_Parameter(_emissionBack)
|
||||
COMPARE_StateAttribute_Parameter(_shininessFrontAndBack)
|
||||
COMPARE_StateAttribute_Parameter(_shininessFront)
|
||||
COMPARE_StateAttribute_Parameter(_shininessBack)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
// Have to think about the role of _colorMode
|
||||
|
||||
@@ -14,113 +14,193 @@ using namespace std;
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** 4x4 Matrix for storage & manipulation of transformations in scene graph.
|
||||
Provides basic maths operations, IO and via osg::Object reference counting.
|
||||
You can directly load the matrix with OpenGL's LoadMatrixf() function via
|
||||
the public member _mat as the matrix is stored in the OpenGL format.
|
||||
Caution: The disadvantage of this feature is, that the matrix access is
|
||||
'transposed' if you compare it with the standard C/C++ 2d-array-access
|
||||
convention . I.e. _mat[i][j] accesses the ith column of the jth row in the
|
||||
4x4 matrix.
|
||||
*/
|
||||
class Quat;
|
||||
|
||||
class SG_EXPORT Matrix : public Object
|
||||
{
|
||||
// private:
|
||||
public:
|
||||
float _mat[4][4];
|
||||
bool fully_realized;
|
||||
|
||||
public:
|
||||
// const char* name() { return "My Matrix "; }
|
||||
META_Object(Matrix);
|
||||
|
||||
Matrix();
|
||||
Matrix(const Matrix& matrix);
|
||||
Matrix( const Matrix& other );
|
||||
explicit Matrix( float const * const def );
|
||||
Matrix( float a00, float a01, float a02, float a03,
|
||||
float a10, float a11, float a12, float a13,
|
||||
float a20, float a21, float a22, float a23,
|
||||
float a30, float a31, float a32, float a33);
|
||||
|
||||
Matrix& operator = (const Matrix& matrix);
|
||||
virtual ~Matrix() {}
|
||||
|
||||
virtual ~Matrix();
|
||||
Matrix& operator = (const Matrix& );
|
||||
|
||||
virtual Object* clone() const { return new Matrix(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Matrix*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Matrix"; }
|
||||
int compare(const Matrix& m) const { return memcmp(_mat,m._mat,sizeof(_mat)); }
|
||||
|
||||
void makeIdent();
|
||||
bool operator < (const Matrix& m) const { return compare(m)<0; }
|
||||
bool operator == (const Matrix& m) const { return compare(m)==0; }
|
||||
bool operator != (const Matrix& m) const { return compare(m)!=0; }
|
||||
|
||||
void set(const float* m);
|
||||
inline float& operator()(int col, int row) { return _mat[row][col]; }
|
||||
inline float operator()(int col, int row) const { return _mat[row][col]; }
|
||||
|
||||
void set( float const * const );
|
||||
void set( float a00, float a01, float a02, float a03,
|
||||
float a10, float a11, float a12, float a13,
|
||||
float a20, float a21, float a22, float a23,
|
||||
float a30, float a31, float a32, float a33);
|
||||
const float * values() { return (const float *)_mat; }
|
||||
|
||||
void copy(const Matrix& matrix);
|
||||
void makeIdent();
|
||||
void makeScale( const Vec3& );
|
||||
void makeScale( float, float, float );
|
||||
|
||||
void makeTrans( const Vec3& );
|
||||
void makeTrans( float, float, float );
|
||||
//TODO: original preTrans was optimized (M=Tr*M)
|
||||
// but also has the assumption that M (this) is an affine transformation Matrix
|
||||
// can I still do something to optimize the same case now?
|
||||
|
||||
void makeScale(float sx, float sy, float sz);
|
||||
void preScale( float sx, float sy, float sz, const Matrix& m );
|
||||
void postScale( const Matrix& m, float sx, float sy, float sz );
|
||||
|
||||
void preScale( float sx, float sy, float sz );
|
||||
void postScale( float sx, float sy, float sz );
|
||||
|
||||
void makeRot( const Vec3& from, const Vec3& to );
|
||||
void makeRot( float angle, const Vec3& orientation );
|
||||
void makeRot( float angle, float x, float y, float z );
|
||||
void makeRot( const Quat& );
|
||||
void makeRot( float, float, float ); //Euler angles
|
||||
|
||||
void makeTrans( float tx, float ty, float tz );
|
||||
void preTrans( float tx, float ty, float tz, const Matrix& m );
|
||||
void postTrans( const Matrix& m, float tx, float ty, float tz );
|
||||
|
||||
void preTrans( float tx, float ty, float tz );
|
||||
void postTrans( float tx, float ty, float tz );
|
||||
|
||||
bool invert( const Matrix& );
|
||||
bool invertAffine( const Matrix& );
|
||||
|
||||
/**
|
||||
* Calc the rotation matrix which aligns vector \a old_vec with
|
||||
* vector \a new_vec. Both \a old_vec and \a new_vec must have
|
||||
* length 1.0.
|
||||
*/
|
||||
void makeRot( const Vec3& old_vec, const Vec3& new_vec );
|
||||
//basic utility functions to create new matrices or vectors
|
||||
inline static Matrix scale( const Vec3& );
|
||||
inline static Matrix scale( float, float, float );
|
||||
inline static Matrix trans( const Vec3& );
|
||||
inline static Matrix trans( float, float, float );
|
||||
inline static Matrix rotate( const Vec3&, const Vec3& );
|
||||
inline static Matrix rotate( float, float, float, float );
|
||||
inline static Matrix rotate( const Quat& );
|
||||
|
||||
inline Vec3 preMult( const Vec3& v ) const;
|
||||
inline Vec3 postMult( const Vec3& v ) const;
|
||||
inline Vec3 operator* ( const Vec3& v ) const;
|
||||
inline Vec4 preMult( const Vec4& v ) const;
|
||||
inline Vec4 postMult( const Vec4& v ) const;
|
||||
inline Vec4 operator* ( const Vec4& v ) const;
|
||||
|
||||
//start of Deprecated methods
|
||||
|
||||
void makeRot( float deg, float x, float y, float z );
|
||||
void preRot( float deg, float x, float y, float z, const Matrix& m );
|
||||
void postRot( const Matrix& m, float deg, float x, float y, float z );
|
||||
|
||||
void preRot( float deg, float x, float y, float z );
|
||||
void postRot( float deg, float x, float y, float z );
|
||||
|
||||
void setTrans( float tx, float ty, float tz );
|
||||
void setTrans( const Vec3& v );
|
||||
Vec3 getTrans() const { return Vec3(_mat[3][0],_mat[3][1],_mat[3][2]); }
|
||||
|
||||
void preMult(const Matrix& m);
|
||||
void postMult(const Matrix& m);
|
||||
void mult(const Matrix& lhs,const Matrix& rhs);
|
||||
|
||||
Matrix operator * (const Matrix& m) const;
|
||||
void copy( const Matrix& );
|
||||
void preScale( float sx, float sy, float sz, const Matrix& m );
|
||||
void postScale( const Matrix& m, float sx, float sy, float sz );
|
||||
void preScale( float sx, float sy, float sz );
|
||||
void postScale( float sx, float sy, float sz );
|
||||
|
||||
void preTrans( float tx, float ty, float tz, const Matrix& m );
|
||||
void postTrans( const Matrix& m, float tx, float ty, float tz );
|
||||
void preTrans( float tx, float ty, float tz);
|
||||
void postTrans( float tx, float ty, float tz );
|
||||
|
||||
void preRot( float deg, float x, float y, float z, const Matrix& m );
|
||||
void postRot( const Matrix& m, float deg, float x, float y, float z );
|
||||
void preRot( float deg, float x, float y, float z );
|
||||
void postRot( float deg, float x, float y, float z );
|
||||
|
||||
/** apply apply an 3x3 transform of v*M[0..2,0..2] */
|
||||
inline static Vec3 transform3x3(const Vec3& v,const Matrix& m);
|
||||
/** apply apply an 3x3 transform of M[0..2,0..2]*v */
|
||||
inline static Vec3 transform3x3(const Matrix& m,const Vec3& v);
|
||||
|
||||
//end of Deprecated methods
|
||||
|
||||
/** post multipy v. ie. (m*v) */
|
||||
inline Vec3 operator * (const Vec3& v) const;
|
||||
|
||||
/** pre multipy v. ie. (v*m) */
|
||||
friend inline Vec3 operator * (const Vec3& v,const Matrix& m);
|
||||
// basic Matrix multiplication, our workhorse methods.
|
||||
void mult( const Matrix&, const Matrix& );
|
||||
void preMult( const Matrix& );
|
||||
void postMult( const Matrix& );
|
||||
|
||||
/** post multipy v. ie. (m*v) */
|
||||
inline Vec4 operator * (const Vec4& v) const;
|
||||
// Helper class to optimize product expressions somewhat
|
||||
class MatrixProduct {
|
||||
public:
|
||||
const Matrix& A;
|
||||
const Matrix& B;
|
||||
|
||||
/** pre multipy v. ie. (v*m) */
|
||||
friend inline Vec4 operator * (const Vec4& v,const Matrix& m);
|
||||
MatrixProduct( const Matrix& lhs, const Matrix& rhs ) : A(lhs), B(rhs) {}
|
||||
};
|
||||
|
||||
friend inline ostream& operator << (ostream& output, const Matrix& matrix);
|
||||
inline MatrixProduct operator * ( const Matrix& other ) const
|
||||
{ return MatrixProduct(*this, other); }
|
||||
|
||||
bool invert(const Matrix& m);
|
||||
inline void operator *= ( const Matrix& other )
|
||||
{ if( this == &other ) {
|
||||
Matrix temp(other);
|
||||
postMult( temp );
|
||||
}
|
||||
else postMult( other );
|
||||
}
|
||||
inline void operator = ( const MatrixProduct& p )
|
||||
{
|
||||
if( this == &(p.A)) postMult(p.B);
|
||||
else if( this == &(p.B)) preMult(p.A);
|
||||
else mult( p.A, p.B );
|
||||
}
|
||||
|
||||
public :
|
||||
float _mat[4][4];
|
||||
|
||||
protected:
|
||||
Matrix( const MatrixProduct& p ) //allows implicit evaluation of the product
|
||||
{ mult( p.A, p.B ); }
|
||||
};
|
||||
|
||||
inline Vec3 Matrix::operator * (const Vec3& v) const
|
||||
//static utility methods
|
||||
inline Matrix Matrix::scale(float sx, float sy, float sz)
|
||||
{
|
||||
Matrix m;
|
||||
m.makeScale(sx,sy,sz);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline Matrix Matrix::scale(const Vec3& v )
|
||||
{
|
||||
return scale(v.x(), v.y(), v.z() );
|
||||
}
|
||||
|
||||
inline Matrix Matrix::trans(float tx, float ty, float tz)
|
||||
{
|
||||
Matrix m;
|
||||
m.makeTrans(tx,ty,tz);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline Matrix Matrix::trans(const Vec3& v )
|
||||
{
|
||||
return trans(v.x(), v.y(), v.z() );
|
||||
}
|
||||
|
||||
inline Matrix Matrix::rotate( const Quat& q )
|
||||
{
|
||||
Matrix m;
|
||||
m.makeRot( q );
|
||||
return m;
|
||||
}
|
||||
inline Matrix Matrix::rotate(float angle, float x, float y, float z )
|
||||
{
|
||||
Matrix m;
|
||||
m.makeRot(angle,x,y,z);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline Matrix Matrix::rotate(const Vec3& from, const Vec3& to )
|
||||
{
|
||||
Matrix m;
|
||||
m.makeRot(from,to);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline Vec3 Matrix::postMult( const Vec3& v ) const
|
||||
{
|
||||
float d = 1.0f/(_mat[3][0]*v.x()+_mat[3][1]*v.y()+_mat[3][2]*v.z()+_mat[3][3]) ;
|
||||
return Vec3( (_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3])*d,
|
||||
@@ -128,16 +208,15 @@ inline Vec3 Matrix::operator * (const Vec3& v) const
|
||||
(_mat[2][0]*v.x() + _mat[2][1]*v.y() + _mat[2][2]*v.z() + _mat[2][3])*d) ;
|
||||
}
|
||||
|
||||
|
||||
inline Vec3 operator * (const Vec3& v,const Matrix& m)
|
||||
inline Vec3 Matrix::preMult( const Vec3& v ) const
|
||||
{
|
||||
float d = 1.0f/(m._mat[0][3]*v.x()+m._mat[1][3]*v.y()+m._mat[2][3]*v.z()+m._mat[3][3]) ;
|
||||
return Vec3( (m._mat[0][0]*v.x() + m._mat[1][0]*v.y() + m._mat[2][0]*v.z() + m._mat[3][0])*d,
|
||||
(m._mat[0][1]*v.x() + m._mat[1][1]*v.y() + m._mat[2][1]*v.z() + m._mat[3][1])*d,
|
||||
(m._mat[0][2]*v.x() + m._mat[1][2]*v.y() + m._mat[2][2]*v.z() + m._mat[3][2])*d);
|
||||
float d = 1.0f/(_mat[0][3]*v.x()+_mat[1][3]*v.y()+_mat[2][3]*v.z()+_mat[3][3]) ;
|
||||
return Vec3( (_mat[0][0]*v.x() + _mat[1][0]*v.y() + _mat[2][0]*v.z() + _mat[3][0])*d,
|
||||
(_mat[0][1]*v.x() + _mat[1][1]*v.y() + _mat[2][1]*v.z() + _mat[3][1])*d,
|
||||
(_mat[0][2]*v.x() + _mat[1][2]*v.y() + _mat[2][2]*v.z() + _mat[3][2])*d);
|
||||
}
|
||||
|
||||
inline Vec4 Matrix::operator * (const Vec4& v) const
|
||||
inline Vec4 Matrix::postMult( const Vec4& v ) const
|
||||
{
|
||||
return Vec4( (_mat[0][0]*v.x() + _mat[0][1]*v.y() + _mat[0][2]*v.z() + _mat[0][3]*v.w()),
|
||||
(_mat[1][0]*v.x() + _mat[1][1]*v.y() + _mat[1][2]*v.z() + _mat[1][3]*v.w()),
|
||||
@@ -145,15 +224,13 @@ inline Vec4 Matrix::operator * (const Vec4& v) const
|
||||
(_mat[3][0]*v.x() + _mat[3][1]*v.y() + _mat[3][2]*v.z() + _mat[3][3]*v.w())) ;
|
||||
}
|
||||
|
||||
|
||||
inline Vec4 operator * (const Vec4& v,const Matrix& m)
|
||||
inline Vec4 Matrix::preMult( const Vec4& v ) const
|
||||
{
|
||||
return Vec4( (m._mat[0][0]*v.x() + m._mat[1][0]*v.y() + m._mat[2][0]*v.z() + m._mat[3][0]*v.w()),
|
||||
(m._mat[0][1]*v.x() + m._mat[1][1]*v.y() + m._mat[2][1]*v.z() + m._mat[3][1]*v.w()),
|
||||
(m._mat[0][2]*v.x() + m._mat[1][2]*v.y() + m._mat[2][2]*v.z() + m._mat[3][2]*v.w()),
|
||||
(m._mat[0][3]*v.x() + m._mat[1][3]*v.y() + m._mat[2][3]*v.z() + m._mat[3][3]*v.w()));
|
||||
return Vec4( (_mat[0][0]*v.x() + _mat[1][0]*v.y() + _mat[2][0]*v.z() + _mat[3][0]*v.w()),
|
||||
(_mat[0][1]*v.x() + _mat[1][1]*v.y() + _mat[2][1]*v.z() + _mat[3][1]*v.w()),
|
||||
(_mat[0][2]*v.x() + _mat[1][2]*v.y() + _mat[2][2]*v.z() + _mat[3][2]*v.w()),
|
||||
(_mat[0][3]*v.x() + _mat[1][3]*v.y() + _mat[2][3]*v.z() + _mat[3][3]*v.w()));
|
||||
}
|
||||
|
||||
inline Vec3 Matrix::transform3x3(const Vec3& v,const Matrix& m)
|
||||
{
|
||||
return Vec3( (m._mat[0][0]*v.x() + m._mat[1][0]*v.y() + m._mat[2][0]*v.z()),
|
||||
@@ -168,17 +245,40 @@ inline Vec3 Matrix::transform3x3(const Matrix& m,const Vec3& v)
|
||||
(m._mat[2][0]*v.x() + m._mat[2][1]*v.y() + m._mat[2][2]*v.z()) ) ;
|
||||
}
|
||||
|
||||
inline ostream& operator << (ostream& output, const Matrix& matrix)
|
||||
|
||||
inline Vec3 operator* (const Vec3& v, const Matrix& m )
|
||||
{
|
||||
output << "{"<<endl
|
||||
<< " " << matrix._mat[0][0] << " " << matrix._mat[0][1] << " " << matrix._mat[0][2] << " " << matrix._mat[0][3] << endl
|
||||
<< " " << matrix._mat[1][0] << " " << matrix._mat[1][1] << " " << matrix._mat[1][2] << " " << matrix._mat[1][3] << endl
|
||||
<< " " << matrix._mat[2][0] << " " << matrix._mat[2][1] << " " << matrix._mat[2][2] << " " << matrix._mat[2][3] << endl
|
||||
<< " " << matrix._mat[3][0] << " " << matrix._mat[3][1] << " " << matrix._mat[3][2] << " " << matrix._mat[3][3] << endl
|
||||
<< "}" << endl;
|
||||
return output; // to enable cascading
|
||||
return m.preMult(v);
|
||||
}
|
||||
inline Vec4 operator* (const Vec4& v, const Matrix& m )
|
||||
{
|
||||
return m.preMult(v);
|
||||
}
|
||||
|
||||
};
|
||||
inline Vec3 Matrix::operator* (const Vec3& v) const
|
||||
{
|
||||
return postMult(v);
|
||||
}
|
||||
inline Vec4 Matrix::operator* (const Vec4& v) const
|
||||
{
|
||||
return postMult(v);
|
||||
}
|
||||
|
||||
inline ostream& operator<< (ostream& os, const Matrix& m )
|
||||
{
|
||||
os << "{"<<endl;
|
||||
for(int row=0; row<4; ++row) {
|
||||
os << "\t";
|
||||
for(int col=0; col<4; ++col)
|
||||
os << m(col,row) << " ";
|
||||
os << endl;
|
||||
}
|
||||
os << "}" << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
}; //namespace osg
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14,11 +14,6 @@
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
#define METAOBJ(name) \
|
||||
virtual Object* clone() const { return new name (); } \
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
||||
virtual const char* className() const { return #name; }
|
||||
|
||||
namespace osg {
|
||||
|
||||
class Quat;
|
||||
@@ -32,7 +27,7 @@ class SG_EXPORT Matrix : public Object
|
||||
|
||||
public:
|
||||
// const char* name() { return "My Matrix "; }
|
||||
METAOBJ(Matrix)
|
||||
META_Object(Matrix);
|
||||
|
||||
Matrix();
|
||||
Matrix( const Matrix& other );
|
||||
@@ -46,6 +41,12 @@ class SG_EXPORT Matrix : public Object
|
||||
|
||||
Matrix& operator = (const Matrix& );
|
||||
|
||||
int compare(const Matrix& m) const { return memcmp(_mat,m._mat,sizeof(_mat)); }
|
||||
|
||||
bool operator < (const Matrix& m) const { return compare(m)<0; }
|
||||
bool operator == (const Matrix& m) const { return compare(m)==0; }
|
||||
bool operator != (const Matrix& m) const { return compare(m)!=0; }
|
||||
|
||||
inline float& operator()(int col, int row) { return _mat[col][row]; }
|
||||
inline float operator()(int col, int row) const { return _mat[col][row]; }
|
||||
|
||||
|
||||
@@ -42,6 +42,12 @@ class SG_EXPORT Matrix : public Object
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Matrix*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Matrix"; }
|
||||
|
||||
int compare(const Matrix& m) const { return memcmp(_mat,m._mat,sizeof(_mat)); }
|
||||
|
||||
bool operator < (const Matrix& m) const { return compare(m)<0; }
|
||||
bool operator == (const Matrix& m) const { return compare(m)==0; }
|
||||
bool operator != (const Matrix& m) const { return compare(m)!=0; }
|
||||
|
||||
void makeIdent();
|
||||
|
||||
void set(const float* m);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <osg/StateSet>
|
||||
#include <osg/BoundingSphere>
|
||||
#include <osg/MemoryAdapter>
|
||||
#include <osg/NodeCallback>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include <string>
|
||||
@@ -15,6 +16,16 @@ namespace osg {
|
||||
class NodeVisitor;
|
||||
class Group;
|
||||
|
||||
/** META_Node macro define the standard clone, isSameKindAs, className
|
||||
* and accept methods. Use when subclassing from Node to make it
|
||||
* more convinient to define the required pure virtual methods.*/
|
||||
#define META_Node(name) \
|
||||
virtual Object* clone() const { return new name (); } \
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
||||
virtual const char* className() const { return #name; } \
|
||||
virtual void accept(NodeVisitor& nv) { if (nv.validNodeMask(*this)) nv.apply(*this); } \
|
||||
|
||||
|
||||
/** Base class for all internal nodes in the scene graph.
|
||||
Provides interface for most common node operations (Composite Pattern).
|
||||
*/
|
||||
@@ -59,7 +70,7 @@ class SG_EXPORT Node : public Object
|
||||
inline const ParentList& getParents() const { return _parents; }
|
||||
|
||||
/** Get the a copy of parent list of node. A copy is returned to
|
||||
* prevent modifiaction of the parent list.*/
|
||||
* prevent modification of the parent list.*/
|
||||
// inline ParentList getParents() { return _parents; }
|
||||
|
||||
inline Group* getParent(const int i) { return _parents[i]; }
|
||||
@@ -77,9 +88,22 @@ class SG_EXPORT Node : public Object
|
||||
inline const int getNumParents() const { return _parents.size(); }
|
||||
|
||||
|
||||
/** Set app node callback, called during app traversal. */
|
||||
void setAppCallback(NodeCallback* nc);
|
||||
|
||||
/** Get app node callback, called during app traversal. */
|
||||
inline NodeCallback* getAppCallback() { return _appCallback.get(); }
|
||||
|
||||
/** Get const app node callback, called during app traversal. */
|
||||
inline const NodeCallback* getAppCallback() const { return _appCallback.get(); }
|
||||
|
||||
/** Get the number of Children of this node which require App traversal,
|
||||
* since they have an AppCallback attached to them or their children.*/
|
||||
inline const int getNumChildrenRequiringAppTraversal() const { return _numChildrenRequiringAppTraversal; }
|
||||
|
||||
/**
|
||||
* Set user data. See MemoryAdapter documention for details
|
||||
* of how to specify memory managament of _userData.
|
||||
* of how to specify memory management of _userData.
|
||||
*/
|
||||
inline void setUserData(void* data,MemoryAdapter* ma=0L)
|
||||
{
|
||||
@@ -173,6 +197,11 @@ class SG_EXPORT Node : public Object
|
||||
ParentList _parents;
|
||||
friend Group;
|
||||
|
||||
ref_ptr<NodeCallback> _appCallback;
|
||||
int _numChildrenRequiringAppTraversal;
|
||||
|
||||
void setNumChildrenRequiringAppTraversal(const int num);
|
||||
|
||||
void* _userData;
|
||||
ref_ptr<MemoryAdapter> _memoryAdapter;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define OSG_NODEVISITOR 1
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/FrameStamp>
|
||||
|
||||
namespace osg {
|
||||
|
||||
@@ -38,12 +39,62 @@ class SG_EXPORT NodeVisitor : public Referenced
|
||||
to each traversal.*/
|
||||
virtual void reset() {}
|
||||
|
||||
|
||||
/** Set the traversal number. Typically used to denote the frame count.*/
|
||||
inline void setTraversalNumber(const int fn) { _traversalNumber = fn; }
|
||||
|
||||
/** Get the traversal number. Typically used to denote the frame count.*/
|
||||
inline const int getTraversalNumber() const { return _traversalNumber; }
|
||||
|
||||
/** Set the FrameStamp that this traversal is assoicated with.*/
|
||||
inline void setFrameStamp(FrameStamp* fs) { _frameStamp = fs; }
|
||||
|
||||
/** Get the FrameStamp that this traversal is assoicated with.*/
|
||||
inline const FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
|
||||
|
||||
|
||||
/** Set the TraversalMask of this NodeVisitor.
|
||||
* The TraversalMask is used by the NodeVisitor::validNodeMask() method
|
||||
* to determine whether to operate on a node and its subgraph.
|
||||
* validNodeMask() is called automaticaly in the Node::accept() method before
|
||||
* any call to NodeVisitor::apply(), apply() is only ever called if validNodeMask
|
||||
* returns true. Note, if NodeVisitor::_traversalMask is 0 then all operations
|
||||
* will be swithced off for all nodes. Whereas setting both _traversalMask and
|
||||
* _nodeMaskOverride to 0xffffffff will allow a visitor to work on all nodes
|
||||
* regardless of their own Node::_nodeMask state.*/
|
||||
inline void setTraversalMask(const Node::NodeMask mask) { _traversalMask = mask; }
|
||||
|
||||
/** Get the TraversalMask.*/
|
||||
inline const Node::NodeMask getTraversalMask() const { return _traversalMask; }
|
||||
|
||||
/** Set the NodeMaskOverride mask.
|
||||
* Used in validNodeMask() to determine whether to operate on a node or its
|
||||
* subgraph, by OR'ing NodeVisitor::_nodeMaskOverride with the Node's own Node::_nodeMask.
|
||||
* Typically used to force on nodes which may have
|
||||
* been switched off by their own Node::_nodeMask.*/
|
||||
inline void setNodeMaskOverride(const Node::NodeMask mask) { _nodeMaskOverride = mask; }
|
||||
|
||||
/** Get the NodeMaskOverride mask.*/
|
||||
inline const Node::NodeMask getNodeMaskOverride() const { return _nodeMaskOverride; }
|
||||
|
||||
/** Method to called by Node and its subclass' Node::accept() method, if the result is true
|
||||
* to be used to cull operations of nodes and their subgraphs.
|
||||
* Return true if the result of a bit wise and of the NodeVisitor::_traversalMask
|
||||
* with the bit or between NodeVistor::_nodeMaskOverride and the Node::_nodeMask.
|
||||
* default values for _traversalMask is 0xffffffff, _nodeMaskOverride is 0x0,
|
||||
* and osg::Node::_nodeMask is 0xffffffff. */
|
||||
inline const bool validNodeMask(const osg::Node& node) const
|
||||
{
|
||||
return (getTraversalMask() & (getNodeMaskOverride() | node.getNodeMask()))!=0;
|
||||
}
|
||||
|
||||
/** Set the traversal mode for Node::traverse() to use when
|
||||
deciding which children of a node to traverse. If a
|
||||
NodeVisitor has been attached via setTraverseVisitor()
|
||||
and the new mode is not TRAVERSE_VISITOR then the attached
|
||||
visitor is detached. Default mode is TRAVERSE_NONE.*/
|
||||
void setTraversalMode(const TraversalMode mode);
|
||||
|
||||
/** Get the traversal mode.*/
|
||||
inline const TraversalMode getTraversalMode() const { return _traversalMode; }
|
||||
|
||||
@@ -54,7 +105,7 @@ class SG_EXPORT NodeVisitor : public Referenced
|
||||
/** Get the traversal visitor, returns NULL if none is attached.*/
|
||||
NodeVisitor* getTraversalVisitor() { return _traversalVisitor.get(); }
|
||||
|
||||
/** Inline method for passing handling traversal of a nodes.
|
||||
/** Inline method for handling traversal of a nodes.
|
||||
If you intend to use the visitor for actively traversing
|
||||
the scene graph then make sure the accept() methods call
|
||||
this method unless they handle traversal directly.*/
|
||||
@@ -80,8 +131,15 @@ class SG_EXPORT NodeVisitor : public Referenced
|
||||
|
||||
protected:
|
||||
|
||||
int _traversalNumber;
|
||||
|
||||
ref_ptr<FrameStamp> _frameStamp;
|
||||
|
||||
ref_ptr<NodeVisitor> _traversalVisitor;
|
||||
|
||||
TraversalMode _traversalMode;
|
||||
Node::NodeMask _traversalMask;
|
||||
Node::NodeMask _nodeMaskOverride;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,16 @@
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** META_Object macro define the standard clone, isSameKindAs and className methods.
|
||||
* Use when subclassing from Object to make it more convinient to define
|
||||
* the standard pure virtual clone, isSameKindAs and className methods
|
||||
* which are required for all Object subclasses.*/
|
||||
#define META_Object(name) \
|
||||
virtual Object* clone() const { return new name (); } \
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
||||
virtual const char* className() const { return #name; }
|
||||
|
||||
|
||||
/** Base class/standard interface for objects which require IO support,
|
||||
cloning and reference counting.
|
||||
Based on GOF Composite, Prototype and Template Method patterns.
|
||||
|
||||
@@ -13,12 +13,24 @@ class SG_EXPORT Point : public StateAttribute
|
||||
public :
|
||||
|
||||
Point();
|
||||
virtual Object* clone() const { return new Point(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Point*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Point"; }
|
||||
|
||||
virtual const Type getType() const { return POINT; }
|
||||
META_StateAttribute(Point, POINT);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(Point,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_size)
|
||||
COMPARE_StateAttribute_Parameter(_fadeThresholdSize)
|
||||
COMPARE_StateAttribute_Parameter(_distanceAttenuation)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
ds.setMode(GL_POINT_SMOOTH,value);
|
||||
|
||||
@@ -13,11 +13,23 @@ class SG_EXPORT PolygonMode : public StateAttribute
|
||||
public :
|
||||
|
||||
PolygonMode();
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const PolygonMode*>(obj)!=0L; }
|
||||
virtual Object* clone() const { return new PolygonMode(); }
|
||||
virtual const char* className() const { return "PolygonMode"; }
|
||||
|
||||
virtual const Type getType() const { return POLYGONMODE; }
|
||||
|
||||
META_StateAttribute(PolygonMode, POLYGONMODE);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(PolygonMode,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_frontAndBack)
|
||||
COMPARE_StateAttribute_Parameter(_modeFront)
|
||||
COMPARE_StateAttribute_Parameter(_modeBack)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
enum Face {
|
||||
FRONT,
|
||||
|
||||
@@ -12,11 +12,22 @@ class SG_EXPORT PolygonOffset : public StateAttribute
|
||||
public :
|
||||
|
||||
PolygonOffset();
|
||||
virtual Object* clone() const { return new PolygonOffset(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const PolygonOffset*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "PolygonOffset"; }
|
||||
|
||||
virtual const Type getType() const { return POLYGONOFFSET; }
|
||||
META_StateAttribute(PolygonOffset, POLYGONOFFSET);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(PolygonOffset,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_factor)
|
||||
COMPARE_StateAttribute_Parameter(_units)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include <osg/StateSet>
|
||||
#include <osg/Matrix>
|
||||
|
||||
#include <osg/FrameStamp>
|
||||
#include <osg/Camera>
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
@@ -82,15 +85,21 @@ class SG_EXPORT State : public Referenced
|
||||
inline const unsigned int getContextID() const { return _contextID; }
|
||||
|
||||
|
||||
/** Set the frame stamp for the current frame.*/
|
||||
inline void setFrameStamp(FrameStamp* fs) { _frameStamp = fs; }
|
||||
|
||||
/** Set the frame stamp for the current frame.*/
|
||||
inline const FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
|
||||
|
||||
/** Set the frame number.*/
|
||||
inline void setFrameNumber(unsigned int fn) { _frameNumber = fn; }
|
||||
|
||||
/** Get the frame number.*/
|
||||
inline unsigned int getFrameNumber() const { return _frameNumber; }
|
||||
/** Set the camera. Note, nothing is applied, the camera is just used
|
||||
* used in the State object to pass the current camera to Drawables
|
||||
* during rendering. */
|
||||
inline void setCamera(Camera* camera) { _camera = camera; }
|
||||
|
||||
/** Get the camera */
|
||||
inline const Camera* getCamera() const { return _camera.get(); }
|
||||
|
||||
/** Increment the frame number. Done once per frame.*/
|
||||
inline void incrementFrameNumber() { ++_frameNumber; }
|
||||
|
||||
|
||||
/** Set the hint to OpenGL routines to do fine grained OpenGL error checking.*/
|
||||
@@ -101,8 +110,9 @@ class SG_EXPORT State : public Referenced
|
||||
|
||||
private:
|
||||
|
||||
unsigned int _contextID;
|
||||
unsigned int _frameNumber;
|
||||
unsigned int _contextID;
|
||||
ref_ptr<FrameStamp> _frameStamp;
|
||||
ref_ptr<Camera> _camera;
|
||||
|
||||
typedef std::vector<StateAttribute::GLModeValue> ValueVec;
|
||||
|
||||
@@ -173,7 +183,8 @@ class SG_EXPORT State : public Referenced
|
||||
|
||||
ModeMap _modeMap;
|
||||
AttributeMap _attributeMap;
|
||||
StateSetStack _drawStateStack;
|
||||
StateSetStack _drawStateStack;
|
||||
|
||||
|
||||
bool _fineGrainedErrorDetection;
|
||||
|
||||
|
||||
@@ -4,12 +4,42 @@
|
||||
#include <osg/Object>
|
||||
#include <osg/GL>
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
namespace osg {
|
||||
|
||||
// forward declare State & StateSet
|
||||
class State;
|
||||
class StateSet;
|
||||
|
||||
/** META_StateAttribute macro define the standard clone, isSameKindAs,
|
||||
* className and getType methods.
|
||||
* Use when subclassing from Object to make it more convinient to define
|
||||
* the standard pure virtual methods which are required for all Object
|
||||
* subclasses.*/
|
||||
#define META_StateAttribute(name,type) \
|
||||
virtual Object* clone() const { return new name (); } \
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
||||
virtual const char* className() const { return #name; } \
|
||||
virtual const Type getType() const { return type; }
|
||||
|
||||
/** COMPARE_StateAttribute_Types macro is a helper for implementing the StatateAtribute::compare(..) method.*/
|
||||
#define COMPARE_StateAttribute_Types(TYPE,rhs_attribute) \
|
||||
if (this==&rhs_attribute) return 0;\
|
||||
const std::type_info* type_lhs = &typeid(*this);\
|
||||
const std::type_info* type_rhs = &typeid(rhs_attribute);\
|
||||
if (type_lhs->before(*type_rhs)) return -1;\
|
||||
if (*type_lhs != *type_rhs) return 1;\
|
||||
const TYPE& rhs = static_cast<const TYPE&>(rhs_attribute);
|
||||
|
||||
|
||||
/** COMPARE_StateAttribute_Parameter macro is a helper for implementing the StatateAtribute::compare(..) method.
|
||||
* Macro assumes that variable rhs has been corrected defined by code preceesing
|
||||
* macro.*/
|
||||
#define COMPARE_StateAttribute_Parameter(parameter) \
|
||||
if (parameter<rhs.parameter) return -1; \
|
||||
if (rhs.parameter<parameter) return 1;
|
||||
|
||||
/** Base class for state attribues.
|
||||
*/
|
||||
class SG_EXPORT StateAttribute : public Object
|
||||
@@ -50,6 +80,9 @@ class SG_EXPORT StateAttribute : public Object
|
||||
INHERIT = 0x4
|
||||
};
|
||||
|
||||
/** Type identifier to differentiate between different state types. */
|
||||
typedef unsigned int Type;
|
||||
|
||||
/** Values of StateAttribute::Type used to aid identification
|
||||
* of diffenent StateAttribute subclasses. Each subclass defines
|
||||
* it own value in the virtual Type getType() method. When
|
||||
@@ -58,7 +91,7 @@ class SG_EXPORT StateAttribute : public Object
|
||||
* enum as a guide of what values to use. If your new subclass
|
||||
* needs to override a standard StateAttriubte then simple use
|
||||
* that types value. */
|
||||
enum Type
|
||||
enum Types
|
||||
{
|
||||
ALPHAFUNC =1,
|
||||
ANTIALIAS =2,
|
||||
@@ -66,30 +99,39 @@ class SG_EXPORT StateAttribute : public Object
|
||||
CULLFACE =4,
|
||||
FOG =5,
|
||||
FRONTFACE =6,
|
||||
LIGHTING =7,
|
||||
MATERIAL =8,
|
||||
POINT =9,
|
||||
POLYGONMODE =10,
|
||||
POLYGONOFFSET =11,
|
||||
TEXENV =12,
|
||||
TEXGEN =13,
|
||||
TEXMAT =14,
|
||||
TEXTURE =15,
|
||||
LIGHT =7,
|
||||
LIGHT_0 =LIGHT+0,
|
||||
LIGHT_1 =LIGHT+1,
|
||||
LIGHT_2 =LIGHT+2,
|
||||
LIGHT_3 =LIGHT+3,
|
||||
LIGHT_4 =LIGHT+4,
|
||||
LIGHT_5 =LIGHT+5,
|
||||
LIGHT_6 =LIGHT+6,
|
||||
LIGHT_7 =LIGHT+7,
|
||||
MATERIAL =15,
|
||||
POINT =16,
|
||||
POLYGONMODE =17,
|
||||
POLYGONOFFSET =18,
|
||||
TEXENV =19,
|
||||
TEXGEN =20,
|
||||
TEXMAT =21,
|
||||
TEXTURE =22,
|
||||
TEXTURE_0 =TEXTURE+0,
|
||||
TEXTURE_1 =TEXTURE+1,
|
||||
TEXTURE_2 =TEXTURE+2,
|
||||
TEXTURE_3 =TEXTURE+3,
|
||||
TRANSPARENCY =19,
|
||||
STENCIL =20,
|
||||
COLORMASK =21,
|
||||
CLIPPLANE =23,
|
||||
TRANSPARENCY =26,
|
||||
STENCIL =27,
|
||||
COLORMASK =28,
|
||||
CLIPPLANE =29,
|
||||
CLIPPLANE_0 =CLIPPLANE+0,
|
||||
CLIPPLANE_1 =CLIPPLANE+1,
|
||||
CLIPPLANE_2 =CLIPPLANE+2,
|
||||
CLIPPLANE_3 =CLIPPLANE+3,
|
||||
CLIPPLANE_4 =CLIPPLANE+4,
|
||||
CLIPPLANE_5 =CLIPPLANE+5,
|
||||
DEPTH =29
|
||||
DEPTH =35,
|
||||
VIEWPORT =36
|
||||
};
|
||||
|
||||
StateAttribute() {}
|
||||
@@ -105,6 +147,14 @@ class SG_EXPORT StateAttribute : public Object
|
||||
|
||||
/** return the Type idenitifer of the attribute's class type.*/
|
||||
virtual const Type getType() const = 0;
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const = 0;
|
||||
|
||||
bool operator < (const StateAttribute& rhs) const { return compare(rhs)<0; }
|
||||
bool operator == (const StateAttribute& rhs) const { return compare(rhs)==0; }
|
||||
bool operator != (const StateAttribute& rhs) const { return compare(rhs)!=0; }
|
||||
|
||||
|
||||
virtual void setStateSetModes(StateSet&,const GLModeValue) const
|
||||
{
|
||||
|
||||
@@ -83,22 +83,6 @@ class SG_EXPORT StateSet : public Object
|
||||
/** return the const list of all StateAttributes contained in this const StateSet.*/
|
||||
inline const AttributeList& getAttributeList() const { return _attributeList; }
|
||||
|
||||
/** tempory type def to support tempory method getModeVector.*/
|
||||
typedef std::vector<std::pair<StateAttribute::GLMode,StateAttribute::GLModeValue> > ModeVector;
|
||||
/** get method which copies this StateSet's osg::GLModeValues's into
|
||||
* a std::vector. method is overlaps on the propper get method -
|
||||
* getModeList and only exists to get round a crash under Windows.
|
||||
* Will be removed once problem is fixed.*/
|
||||
const ModeVector getModeVector() const;
|
||||
|
||||
/** tempory type def to support tempory method getAttributeVector.*/
|
||||
typedef std::vector<const StateAttribute*> AttributeVector;
|
||||
/** get method which copies this StateSet's osg::StateAttribute's into
|
||||
* a std::vector. method is overlaps on the propper get method -
|
||||
* getAttributeList and only exists to get round a crash under Windows.
|
||||
* Will be removed once problem is fixed.*/
|
||||
const AttributeVector getAttributeVector() const;
|
||||
|
||||
enum RenderingHint
|
||||
{
|
||||
DEFAULT_BIN = 0,
|
||||
|
||||
@@ -15,12 +15,28 @@ class SG_EXPORT Stencil : public StateAttribute
|
||||
|
||||
|
||||
Stencil();
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Stencil*>(obj)!=0L; }
|
||||
virtual Object* clone() const { return new Stencil(); }
|
||||
virtual const char* className() const { return "Stencil"; }
|
||||
|
||||
virtual const Type getType() const { return STENCIL; }
|
||||
|
||||
META_StateAttribute(Stencil, STENCIL);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(Stencil,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_func)
|
||||
COMPARE_StateAttribute_Parameter(_funcRef)
|
||||
COMPARE_StateAttribute_Parameter(_funcMask)
|
||||
COMPARE_StateAttribute_Parameter(_sfail)
|
||||
COMPARE_StateAttribute_Parameter(_zfail)
|
||||
COMPARE_StateAttribute_Parameter(_zpass)
|
||||
COMPARE_StateAttribute_Parameter(_writeMask)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
ds.setMode(GL_STENCIL_TEST,value);
|
||||
|
||||
@@ -27,10 +27,8 @@ class SG_EXPORT Switch : public Group
|
||||
|
||||
Switch();
|
||||
|
||||
virtual Object* clone() const { return new Switch(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Switch*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Switch"; }
|
||||
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
|
||||
META_Node(Switch);
|
||||
|
||||
virtual void traverse(NodeVisitor& nv);
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,11 +12,21 @@ class SG_EXPORT TexEnv : public StateAttribute
|
||||
public :
|
||||
|
||||
TexEnv( void );
|
||||
virtual Object* clone() const { return new TexEnv(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const TexEnv*>(obj)!=0L; }
|
||||
virtual const char* className() const { return "TexEnv"; }
|
||||
|
||||
virtual const Type getType() const { return TEXENV; }
|
||||
META_StateAttribute(TexEnv, TEXENV);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(TexEnv,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_mode)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
enum Mode {
|
||||
DECAL = GL_DECAL,
|
||||
|
||||
@@ -13,12 +13,26 @@ class SG_EXPORT TexGen : public StateAttribute
|
||||
public :
|
||||
|
||||
TexGen( void );
|
||||
virtual Object* clone() const { return new TexGen(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const TexGen*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "TexGen"; }
|
||||
|
||||
virtual const Type getType() const { return TEXGEN; }
|
||||
|
||||
META_StateAttribute(TexGen, TEXGEN);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(TexGen,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_mode)
|
||||
COMPARE_StateAttribute_Parameter(_plane_s)
|
||||
COMPARE_StateAttribute_Parameter(_plane_s)
|
||||
COMPARE_StateAttribute_Parameter(_plane_r)
|
||||
COMPARE_StateAttribute_Parameter(_plane_q)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
ds.setMode(GL_TEXTURE_GEN_S,value);
|
||||
|
||||
@@ -11,12 +11,22 @@ class SG_EXPORT TexMat : public StateAttribute
|
||||
{
|
||||
public :
|
||||
TexMat( void );
|
||||
virtual Object* clone() const { return new TexMat(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const TexMat*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "TexMat"; }
|
||||
|
||||
virtual const Type getType() const { return TEXMAT; }
|
||||
META_StateAttribute(TexMat, TEXMAT);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(TexMat,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_matrix)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
/** Set the texture matrix */
|
||||
inline void setMatrix(const Matrix& matrix) { _matrix = matrix; }
|
||||
|
||||
|
||||
@@ -60,12 +60,12 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
public :
|
||||
|
||||
Texture();
|
||||
virtual Object* clone() const { return new Texture(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Texture*>(obj)!=0L; }
|
||||
virtual const char* className() const { return "Texture"; }
|
||||
|
||||
virtual const Type getType() const { return (Type)(TEXTURE_0+_textureUnit); }
|
||||
META_StateAttribute(Texture,(Type)(TEXTURE_0+_textureUnit));
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& rhs) const;
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
ds.setMode(GL_TEXTURE_2D,value);
|
||||
@@ -210,7 +210,7 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
}
|
||||
|
||||
/** Get the handle to the texture object for the current context.*/
|
||||
inline uint& getHandle(const uint contextID) const
|
||||
inline GLuint& getHandle(const uint contextID) const
|
||||
{
|
||||
// pad out handle list if required.
|
||||
while (_handleList.size()<=contextID)
|
||||
@@ -240,7 +240,7 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
* OpenGL texture objects to cached until they can be deleted
|
||||
* by the OpenGL context in which they were created, specified
|
||||
* by contextID.*/
|
||||
static void deleteTextureObject(uint contextID,uint handle);
|
||||
static void deleteTextureObject(uint contextID,GLuint handle);
|
||||
|
||||
/** flush all the cached display list which need to be deleted
|
||||
* in the OpenGL context related to contextID.*/
|
||||
@@ -251,7 +251,7 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
|
||||
virtual ~Texture();
|
||||
|
||||
typedef std::vector<uint> TextureNameList;
|
||||
typedef std::vector<GLuint> TextureNameList;
|
||||
mutable TextureNameList _handleList;
|
||||
|
||||
typedef std::vector<uint> ImageModifiedTag;
|
||||
|
||||
@@ -3,19 +3,20 @@
|
||||
|
||||
#include <osg/Export>
|
||||
|
||||
#ifdef macintosh
|
||||
//#define __TIMESIZE_DOUBLE__
|
||||
#include <ctime>
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
#ifdef WIN32
|
||||
typedef __int64 Timer_t;
|
||||
#elif defined macintosh
|
||||
typedef double Timer_t;
|
||||
typedef __int64 Timer_t;
|
||||
#elif defined(__linux) || defined(__FreeBSD__)
|
||||
typedef unsigned long long Timer_t;
|
||||
#elif defined(__sgi)
|
||||
typedef unsigned long long Timer_t;
|
||||
#elif defined(unix)
|
||||
typedef unsigned long long Timer_t;
|
||||
#else
|
||||
typedef unsigned long long Timer_t;
|
||||
#include <ctime>
|
||||
typedef std::clock_t Timer_t;
|
||||
#endif
|
||||
|
||||
/** A high resolution, low latency time stamper.*/
|
||||
@@ -23,69 +24,108 @@ class SG_EXPORT Timer {
|
||||
|
||||
public:
|
||||
|
||||
Timer( void );
|
||||
~Timer( void );
|
||||
Timer();
|
||||
~Timer() {}
|
||||
|
||||
inline Timer_t tick();
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma optimize("",off)
|
||||
inline Timer_t tick( void )
|
||||
{
|
||||
volatile Timer_t ts;
|
||||
volatile unsigned int HighPart;
|
||||
volatile unsigned int LowPart;
|
||||
_asm
|
||||
{
|
||||
xor eax, eax // Used when QueryPerformanceCounter()
|
||||
xor edx, edx // not supported or minimal overhead
|
||||
_emit 0x0f // desired
|
||||
_emit 0x31 //
|
||||
mov HighPart,edx
|
||||
mov LowPart,eax
|
||||
}
|
||||
//ts = LowPart | HighPart >> 32;
|
||||
*((unsigned int*)&ts) = LowPart;
|
||||
*((unsigned int*)&ts+1) = HighPart;
|
||||
return ts;
|
||||
}
|
||||
#pragma optimize("",on)
|
||||
#endif
|
||||
#if defined(__linux) || defined(__FreeBSD__)
|
||||
#define CLK(x) __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x))
|
||||
inline Timer_t tick( void ) {Timer_t x;CLK(x);return x;}
|
||||
#endif
|
||||
#ifdef __sgi
|
||||
inline Timer_t tick( void ) { return *clk; }
|
||||
#endif
|
||||
|
||||
#ifdef macintosh
|
||||
// because __TIMESIZE_DOUBLE__ is defined
|
||||
// clock resolution is now: 100000 CLOCKS_PER_SEC instead of 60
|
||||
inline Timer_t tick( void ) { return std::clock(); }
|
||||
#endif
|
||||
double delta_s( Timer_t t1, Timer_t t2 );
|
||||
double delta_m( Timer_t t1, Timer_t t2 );
|
||||
|
||||
Timer_t delta_u( Timer_t t1, Timer_t t2 );
|
||||
Timer_t delta_n( Timer_t t1, Timer_t t2 );
|
||||
|
||||
inline double delta_s( Timer_t t1, Timer_t t2 ) const { return (double)(t2 - t1)*_secsPerClick; }
|
||||
inline double delta_m( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e3; }
|
||||
inline double delta_u( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e6; }
|
||||
inline double delta_n( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e9; }
|
||||
|
||||
private :
|
||||
|
||||
double microseconds_per_click;
|
||||
double nanoseconds_per_click;
|
||||
unsigned long *clk;
|
||||
int cycleCntrSize;
|
||||
static unsigned long dummy;
|
||||
|
||||
static int inited;
|
||||
static double cpu_mhz;
|
||||
void init( void );
|
||||
double _secsPerClick;
|
||||
bool _useStandardClock;
|
||||
|
||||
#ifdef __sgi
|
||||
unsigned long* _clockAddress;
|
||||
int _cycleCntrSize;
|
||||
static unsigned long _dummy;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#include <time.h>
|
||||
#pragma optimize("",off)
|
||||
inline Timer_t Timer::tick( void )
|
||||
{
|
||||
if (_useStandardClock) return clock();
|
||||
|
||||
volatile Timer_t ts;
|
||||
volatile unsigned int HighPart;
|
||||
volatile unsigned int LowPart;
|
||||
_asm
|
||||
{
|
||||
xor eax, eax // Used when QueryPerformanceCounter()
|
||||
xor edx, edx // not supported or minimal overhead
|
||||
_emit 0x0f // desired
|
||||
_emit 0x31 //
|
||||
mov HighPart,edx
|
||||
mov LowPart,eax
|
||||
}
|
||||
//ts = LowPart | HighPart >> 32;
|
||||
*((unsigned int*)&ts) = LowPart;
|
||||
*((unsigned int*)&ts+1) = HighPart;
|
||||
return ts;
|
||||
}
|
||||
#pragma optimize("",on)
|
||||
|
||||
#elif defined(__linux) || defined(__FreeBSD__)
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#define CLK(x) __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x))
|
||||
inline Timer_t Timer::tick()
|
||||
{
|
||||
if (_useStandardClock)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec;
|
||||
}
|
||||
else
|
||||
{
|
||||
Timer_t x;CLK(x);return x;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__sgi)
|
||||
|
||||
#include <sys/time.h>
|
||||
inline Timer_t Timer::tick()
|
||||
{
|
||||
if (_useStandardClock)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec;
|
||||
}
|
||||
else
|
||||
{
|
||||
return *_sgiClockAddress;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(unix)
|
||||
|
||||
#include <sys/time.h>
|
||||
inline Timer_t Timer::tick()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// no choice, always use std::clock()
|
||||
inline Timer_t Timer::tick( void ) { return std::clock(); }
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -17,10 +17,7 @@ class SG_EXPORT Transform : public Group
|
||||
Transform();
|
||||
Transform(const Matrix& matix);
|
||||
|
||||
virtual Object* clone() const { return new Transform(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Transform*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "Transform"; }
|
||||
virtual void accept(NodeVisitor& nv) { nv.apply(*this); }
|
||||
META_Node(Transform);
|
||||
|
||||
void setMatrix(const Matrix& mat );
|
||||
inline Matrix& getMatrix() { return *_matrix; }
|
||||
|
||||
@@ -12,12 +12,23 @@ class SG_EXPORT Transparency : public StateAttribute
|
||||
public :
|
||||
|
||||
Transparency();
|
||||
virtual Object* clone() const { return new Transparency(); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Transparency*>(obj)!=0L; }
|
||||
virtual const char* className() const { return "Transparency"; }
|
||||
|
||||
virtual const Type getType() const { return TRANSPARENCY; }
|
||||
|
||||
META_StateAttribute(Transparency,TRANSPARENCY);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(Transparency,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_source_factor)
|
||||
COMPARE_StateAttribute_Parameter(_destination_factor)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void setStateSetModes(StateSet& ds,const GLModeValue value) const
|
||||
{
|
||||
ds.setMode(GL_BLEND,value);
|
||||
|
||||
@@ -15,12 +15,25 @@ class SG_EXPORT Viewport : public StateAttribute
|
||||
|
||||
|
||||
Viewport();
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Viewport*>(obj)!=0L; }
|
||||
virtual Object* clone() const { return new Viewport(); }
|
||||
virtual const char* className() const { return "Viewport"; }
|
||||
|
||||
virtual const Type getType() const { return VIEWPORT; }
|
||||
|
||||
META_StateAttribute(Viewport,VIEWPORT);
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
{
|
||||
// check the types are equal and then create the rhs variable
|
||||
// used by the COMPARE_StateAttribute_Paramter macro's below.
|
||||
COMPARE_StateAttribute_Types(Viewport,sa)
|
||||
|
||||
// compare each paramter in turn against the rhs.
|
||||
COMPARE_StateAttribute_Parameter(_x)
|
||||
COMPARE_StateAttribute_Parameter(_y)
|
||||
COMPARE_StateAttribute_Parameter(_width)
|
||||
COMPARE_StateAttribute_Parameter(_height)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
inline void setViewport(const int x,const int y,const int width,const int height)
|
||||
{
|
||||
_x = x;
|
||||
|
||||
@@ -72,14 +72,14 @@ class OSGGLUT_EXPORT Viewer : public osgUtil::GUIActionAdapter
|
||||
// initialize the clock.
|
||||
long initClock();
|
||||
// time since initClock() in seconds.
|
||||
float clockSeconds() { return _timer.delta_s(_initialTick,clockTick()); }
|
||||
double clockSeconds() { return _timer.delta_s(_initialTick,clockTick()); }
|
||||
|
||||
// update the number of ticks since the last frame update.
|
||||
osg::Timer_t updateFrameTick();
|
||||
|
||||
// time from the current frame update and the previous one in seconds.
|
||||
float frameSeconds() { return _timer.delta_s(_lastFrameTick,_frameTick); }
|
||||
float frameRate() { return 1.0f/frameSeconds(); }
|
||||
double frameSeconds() { return _timer.delta_s(_lastFrameTick,_frameTick); }
|
||||
double frameRate() { return 1.0/frameSeconds(); }
|
||||
|
||||
void help(ostream& fout);
|
||||
|
||||
@@ -176,6 +176,10 @@ class OSGGLUT_EXPORT Viewer : public osgUtil::GUIActionAdapter
|
||||
osg::Timer_t frameTick();
|
||||
|
||||
|
||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef OSGUTIL_NEWCULLVISITOR
|
||||
#define OSGUTIL_NEWCULLVISITOR 1
|
||||
#ifndef OSGUTIL_CULLVISITOR
|
||||
#define OSGUTIL_CULLVISITOR 1
|
||||
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/BoundingSphere>
|
||||
@@ -36,7 +36,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
CullVisitor();
|
||||
virtual ~CullVisitor();
|
||||
|
||||
void reset();
|
||||
virtual void reset();
|
||||
|
||||
virtual void apply(osg::Node&);
|
||||
virtual void apply(osg::Geode& node);
|
||||
@@ -100,33 +100,17 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
/** Returns the current CullingMode.*/
|
||||
CullViewState::CullingMode getCullingMode() const;
|
||||
|
||||
|
||||
/** Set the viewport.
|
||||
* Used to enable the CullVisitor can make decision
|
||||
* such as based on viewport dimensions,.*/
|
||||
void setViewport(int x,int y,int width,int height)
|
||||
{
|
||||
_view[0] = x;
|
||||
_view[1] = y;
|
||||
_view[2] = width;
|
||||
_view[3] = height;
|
||||
}
|
||||
|
||||
* such as based on viewport dimensions.*/
|
||||
void setViewport(osg::Viewport* viewport) { _viewport = viewport; }
|
||||
|
||||
/** Get the const viewport. */
|
||||
const osg::Viewport* getViewport() const { return _viewport.get(); }
|
||||
|
||||
/** Get the viewport. */
|
||||
void getViewport(int& x,int& y,int& width,int& height)
|
||||
{
|
||||
x = _view[0];
|
||||
y = _view[1];
|
||||
width = _view[2];
|
||||
height = _view[3];
|
||||
}
|
||||
|
||||
|
||||
/** Set the frame number.*/
|
||||
inline void setFrameNumber(const int fn) { _frameNumber = fn; }
|
||||
|
||||
/** Get the frame number.*/
|
||||
inline const int getFrameNumber() const { return _frameNumber; }
|
||||
|
||||
osg::Viewport* getViewport() { return _viewport.get(); }
|
||||
|
||||
void pushCullViewState(const osg::Matrix* matrix=NULL);
|
||||
void popCullViewState();
|
||||
@@ -276,8 +260,6 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
* to generate the impostor texture. */
|
||||
osg::ImpostorSprite* createImpostorSprite(osg::Impostor& node);
|
||||
|
||||
int _frameNumber;
|
||||
|
||||
typedef std::vector< osg::ref_ptr<CullViewState> > CullViewStateStack;
|
||||
CullViewStateStack _viewStateStack;
|
||||
osg::ref_ptr<CullViewState> _tvs;
|
||||
@@ -301,7 +283,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
TransparencySortMode _tsm;
|
||||
|
||||
// viewport x,y,width,height respectiveyly.
|
||||
int _view[4];
|
||||
osg::ref_ptr<osg::Viewport> _viewport;
|
||||
|
||||
bool _impostorActive;
|
||||
bool _depthSortImpostorSprites;
|
||||
|
||||
@@ -30,23 +30,15 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
||||
virtual void reset();
|
||||
|
||||
|
||||
/** Set the viewport of the scene view. */
|
||||
void setViewport(int x,int y,int width,int height)
|
||||
{
|
||||
_view[0] = x;
|
||||
_view[1] = y;
|
||||
_view[2] = width;
|
||||
_view[3] = height;
|
||||
}
|
||||
|
||||
/** Get the viewport of the scene view. */
|
||||
void getViewport(int& x,int& y,int& width,int& height) const
|
||||
{
|
||||
x = _view[0];
|
||||
y = _view[1];
|
||||
width = _view[2];
|
||||
height = _view[3];
|
||||
}
|
||||
/** Set the viewport.*/
|
||||
void setViewport(osg::Viewport* viewport) { _viewport = viewport; }
|
||||
|
||||
/** Get the const viewport. */
|
||||
const osg::Viewport* getViewport() const { return _viewport.get(); }
|
||||
|
||||
/** Get the viewport. */
|
||||
osg::Viewport* getViewport() { return _viewport.get(); }
|
||||
|
||||
|
||||
|
||||
/** Set the clear mask used in glClear(..).
|
||||
@@ -132,7 +124,7 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
||||
osg::ref_ptr<osg::Camera> _camera;
|
||||
|
||||
// viewport x,y,width,height.
|
||||
GLint _view[4];
|
||||
osg::ref_ptr<osg::Viewport> _viewport;
|
||||
|
||||
GLbitfield _clearMask;
|
||||
osg::Vec4 _clearColor;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <osg/StateSet>
|
||||
#include <osg/Light>
|
||||
#include <osg/Camera>
|
||||
#include <osg/FrameStamp>
|
||||
|
||||
#include <osgUtil/CullVisitor>
|
||||
|
||||
@@ -22,6 +23,11 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
/** Constrcut a default scene view.*/
|
||||
SceneView();
|
||||
|
||||
/** Set scene view to use default global state, light, camera
|
||||
* and render visitor.
|
||||
*/
|
||||
void setDefaults();
|
||||
|
||||
/** Set the data which to view. The data will typically be
|
||||
* an osg::Scene but can be any osg::Node type.
|
||||
*/
|
||||
@@ -36,28 +42,37 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
*/
|
||||
const osg::Node* getSceneData() const { return _sceneData.get(); }
|
||||
|
||||
/** Set the viewport of the scene view. */
|
||||
/** Set the viewport of the scene view to use specfied osg::Viewport. */
|
||||
void setViewport(osg::Viewport* viewport)
|
||||
{
|
||||
if (viewport) _viewport = viewport;
|
||||
else
|
||||
{
|
||||
// ensure that _viewport is always valid.
|
||||
_viewport = new osg::Viewport;
|
||||
}
|
||||
}
|
||||
|
||||
/** Set the viewport of the scene view to specified dimensions. */
|
||||
void setViewport(int x,int y,int width,int height)
|
||||
{
|
||||
_view[0] = x;
|
||||
_view[1] = y;
|
||||
_view[2] = width;
|
||||
_view[3] = height;
|
||||
_viewport->setViewport(x,y,width,height);
|
||||
}
|
||||
|
||||
|
||||
/** Get the const viewport. */
|
||||
const osg::Viewport* getViewport() const { return _viewport.get(); }
|
||||
|
||||
/** Get the viewport. */
|
||||
osg::Viewport* getViewport() { return _viewport.get(); }
|
||||
|
||||
/** Get the viewport of the scene view. */
|
||||
void getViewport(int& x,int& y,int& width,int& height)
|
||||
{
|
||||
x = _view[0];
|
||||
y = _view[1];
|
||||
width = _view[2];
|
||||
height = _view[3];
|
||||
_viewport->getViewport(x,y,width,height);
|
||||
}
|
||||
|
||||
/** Set scene view to use default global state, light, camera
|
||||
* and render visitor.
|
||||
*/
|
||||
void setDefaults();
|
||||
|
||||
|
||||
/** Set the background color used in glClearColor().
|
||||
Defaults to an off blue color.*/
|
||||
@@ -155,6 +170,14 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
bool projectObjectIntoWindow(const osg::Vec3& object,osg::Vec3& window) const;
|
||||
|
||||
|
||||
/** Set the frame stamp for the current frame.*/
|
||||
inline void setFrameStamp(osg::FrameStamp* fs) { _frameStamp = fs; }
|
||||
|
||||
/** Set the frame stamp for the current frame.*/
|
||||
inline const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
|
||||
|
||||
|
||||
|
||||
/** do app traversal of attached scene graph using App NodeVisitor.*/
|
||||
virtual void app();
|
||||
|
||||
@@ -179,6 +202,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
osg::ref_ptr<osgUtil::RenderGraph> _rendergraph;
|
||||
osg::ref_ptr<osgUtil::RenderStage> _renderStage;
|
||||
|
||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||
|
||||
bool _need_compile;
|
||||
bool _calc_nearfar;
|
||||
@@ -190,14 +214,12 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
|
||||
float _lodBias;
|
||||
|
||||
// viewport x,y,width,height respectiveyly.
|
||||
GLint _view[4];
|
||||
osg::ref_ptr<osg::Viewport> _viewport;
|
||||
|
||||
LightingMode _lightingMode;
|
||||
|
||||
bool _prioritizeTextures;
|
||||
|
||||
int _frameNumber;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -44,6 +44,8 @@ class OSGUTIL_EXPORT Tesselator
|
||||
|
||||
struct VertexIndexSet
|
||||
{
|
||||
VertexIndexSet() {}
|
||||
|
||||
VertexIndexSet(Tesselator* tess,const osg::Vec3& vec,osg::uint index)
|
||||
{
|
||||
set(tess,vec,index);
|
||||
|
||||
@@ -39,16 +39,16 @@ class OSGUTIL_EXPORT VisualsRequirementsVisitor : public osg::NodeVisitor
|
||||
const bool requiresDepthBuffer() const { return _requiresDepthBuffer; }
|
||||
|
||||
|
||||
void setMinumumNumAlphaBits(const unsigned int bits) { _minimumNumberAlphaBits = bits; }
|
||||
void setMinimumNumAlphaBits(const unsigned int bits) { _minimumNumberAlphaBits = bits; }
|
||||
|
||||
const unsigned int getMinumumNumAlphaBits() const { return _minimumNumberAlphaBits; }
|
||||
const unsigned int getMinimumNumAlphaBits() const { return _minimumNumberAlphaBits; }
|
||||
|
||||
const bool requiresAlphaBuffer() const { return _minimumNumberAlphaBits!=0; }
|
||||
|
||||
|
||||
void setMinumumNumStencilBits(const unsigned int bits) { _minimumNumberStencilBits = bits; }
|
||||
void setMinimumNumStencilBits(const unsigned int bits) { _minimumNumberStencilBits = bits; }
|
||||
|
||||
const unsigned int getMinumumNumStencilBits() const { return _minimumNumberStencilBits; }
|
||||
const unsigned int getMinimumNumStencilBits() const { return _minimumNumberStencilBits; }
|
||||
|
||||
const bool requiresStencilBuffer() const { return _minimumNumberStencilBits!=0; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user