Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old osg::Object::clone() has changed so that it now requires a Cloner as paramter. This is passed on to the copy constructor to help control the shallow vs deep copying. The old functionality of clone() which was clone of type has been renamed to cloneType(). Updated all of the OSG to work with these new conventions, implemention all the required copy constructors etc. A couple of areas will do shallow copies by design, a couple of other still need to be updated to do either shallow or deep. Neither of the shallow or deep copy operations have been tested yet, only the old functionality of the OSG has been checked so far, such running the viewer on various demo datasets. Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which was not checking that Group didn't have have any attached StateSet's, Callbacks or UserData. These checks have now been added, which fixes a bug which was revealled by the new osgscribe demo, this related to removal of group acting as state decorator. method
This commit is contained in:
parent
7f65110322
commit
f612924a45
@ -361,6 +361,10 @@ SOURCE=..\..\Include\Osg\CullFace
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\Include\Osg\DeepCopy
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Include\Osg\Depth
|
SOURCE=..\..\Include\Osg\Depth
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@ -521,6 +525,10 @@ SOURCE=..\..\Include\Osg\ShadeModel
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\Include\Osg\ShallowCopy
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Include\Osg\State
|
SOURCE=..\..\Include\Osg\State
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -19,6 +19,12 @@ class SG_EXPORT AlphaFunc : public StateAttribute
|
|||||||
|
|
||||||
AlphaFunc();
|
AlphaFunc();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
AlphaFunc(const AlphaFunc& af,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(af,cloner),
|
||||||
|
_comparisonFunc(af._comparisonFunc),
|
||||||
|
_referenceValue(af._referenceValue) {}
|
||||||
|
|
||||||
META_StateAttribute(AlphaFunc,ALPHAFUNC);
|
META_StateAttribute(AlphaFunc,ALPHAFUNC);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -25,6 +25,9 @@ class SG_EXPORT Billboard : public Geode
|
|||||||
|
|
||||||
Billboard();
|
Billboard();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Billboard(const Billboard&,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
META_Node(Billboard);
|
META_Node(Billboard);
|
||||||
|
|
||||||
/** Set the billboard rotation mode. */
|
/** Set the billboard rotation mode. */
|
||||||
|
@ -17,6 +17,17 @@ class SG_EXPORT ClipPlane : public StateAttribute
|
|||||||
public :
|
public :
|
||||||
|
|
||||||
ClipPlane();
|
ClipPlane();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
ClipPlane(const ClipPlane& cp,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(cp,cloner)
|
||||||
|
{
|
||||||
|
_clipPlane[0]=cp._clipPlane[0];
|
||||||
|
_clipPlane[1]=cp._clipPlane[1];
|
||||||
|
_clipPlane[2]=cp._clipPlane[2];
|
||||||
|
_clipPlane[3]=cp._clipPlane[3];
|
||||||
|
_clipPlaneNum=cp._clipPlaneNum;
|
||||||
|
}
|
||||||
|
|
||||||
META_StateAttribute(ClipPlane, (Type)(CLIPPLANE+_clipPlaneNum));
|
META_StateAttribute(ClipPlane, (Type)(CLIPPLANE+_clipPlaneNum));
|
||||||
|
|
||||||
|
@ -19,6 +19,14 @@ class SG_EXPORT ColorMask : public StateAttribute
|
|||||||
|
|
||||||
|
|
||||||
ColorMask();
|
ColorMask();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
ColorMask(const ColorMask& cm,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(cm,cloner),
|
||||||
|
_red(cm._red),
|
||||||
|
_green(cm._green),
|
||||||
|
_blue(cm._blue),
|
||||||
|
_alpha(cm._alpha) {}
|
||||||
|
|
||||||
META_StateAttribute(ColorMask, COLORMASK);
|
META_StateAttribute(ColorMask, COLORMASK);
|
||||||
|
|
||||||
|
@ -14,7 +14,13 @@ namespace osg {
|
|||||||
class SG_EXPORT ColorMatrix : public StateAttribute
|
class SG_EXPORT ColorMatrix : public StateAttribute
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
ColorMatrix( void );
|
|
||||||
|
ColorMatrix();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
ColorMatrix(const ColorMatrix& cm,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(cm,cloner),
|
||||||
|
_matrix(cm._matrix) {}
|
||||||
|
|
||||||
META_StateAttribute(ColorMatrix, COLORMATRIX);
|
META_StateAttribute(ColorMatrix, COLORMATRIX);
|
||||||
|
|
||||||
|
@ -19,6 +19,11 @@ class SG_EXPORT CullFace : public StateAttribute
|
|||||||
|
|
||||||
CullFace();
|
CullFace();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
CullFace(const CullFace& cf,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(cf,cloner),
|
||||||
|
_mode(cf._mode) {}
|
||||||
|
|
||||||
META_StateAttribute(CullFace, CULLFACE);
|
META_StateAttribute(CullFace, CULLFACE);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
58
include/osg/DeepCopy
Normal file
58
include/osg/DeepCopy
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
||||||
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||||
|
//as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
#ifndef OSG_DEEPWCOPY
|
||||||
|
#define OSG_DEEPWCOPY 1
|
||||||
|
|
||||||
|
#include <osg/Node>
|
||||||
|
#include <osg/StateSet>
|
||||||
|
#include <osg/Texture>
|
||||||
|
|
||||||
|
namespace osg {
|
||||||
|
|
||||||
|
|
||||||
|
/** Cloner Functor used to control the whether shallow or deep copy is used
|
||||||
|
* during copy construction and clone operation. The base Cloner acts as
|
||||||
|
* a shallow copy simply passing back the same pointer as passed in.*/
|
||||||
|
struct DeepCopy : public Cloner
|
||||||
|
{
|
||||||
|
|
||||||
|
enum CopyOptions
|
||||||
|
{
|
||||||
|
DEEP_COPY_OBJECTS = 1,
|
||||||
|
DEEP_COPY_NODES = 2,
|
||||||
|
DEEP_COPY_DRAWABLES = 4,
|
||||||
|
DEEP_COPY_STATESETS = 8,
|
||||||
|
DEEP_COPY_STATEATTRIBUTES = 16,
|
||||||
|
DEEP_COPY_TEXTURES = 32,
|
||||||
|
DEEP_COPY_IMAGES = 64,
|
||||||
|
DEEP_COPY_ALL = 0xffffffff
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef unsigned int CopyFlags;
|
||||||
|
|
||||||
|
DeepCopy(CopyFlags flags=DEEP_COPY_NODES):_flags(flags) {}
|
||||||
|
|
||||||
|
virtual ~DeepCopy() {};
|
||||||
|
|
||||||
|
// note can't clone a refernced object since it doens't have clone
|
||||||
|
// method so we have to assume shallow copy and pass back the pointer.
|
||||||
|
virtual Referenced* operator() (const Referenced* ref) const { return ref; }
|
||||||
|
|
||||||
|
virtual Object* operator() (const Object* obj) const { if (obj && _flags&DEEP_COPY_OBJECTS) return obj->clone(*this); else return NULL; }
|
||||||
|
virtual Node* operator() (const Node* node) const { if (obj && _flags&DEEP_COPY_NODES) return node->clone(*this); }
|
||||||
|
virtual Drawable* operator() (const Drawable* drawable) const { if (drawable && _flags&DEEP_COPY_DRAWABLES) return drawable->clone(*this); }
|
||||||
|
virtual StateSet* operator() (const StateSet* stateset) const { if (stateset && _flags&DEEP_COPY_STATESETS) return stateset->clone(*this); }
|
||||||
|
virtual StateAttribute* operator() (const StateAttribute* attr) const { if (attr && _flags&DEEP_COPY_STATEATTRIBUTES) return attr->clone(*this); }
|
||||||
|
virtual Texture* operator() (const Texture* text) const { if (text && _flags&DEEP_COPY_TEXTURES) return text->clone(*this); }
|
||||||
|
virtual Image* operator() (const Image* image) const { if (image && _flags&DEEP_COPY_IMAGES) return image->clone(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
CopyFlags _flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -20,6 +20,15 @@ class SG_EXPORT Depth : public StateAttribute
|
|||||||
|
|
||||||
Depth();
|
Depth();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Depth(const Depth& dp,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(dp,cloner),
|
||||||
|
_func(dp._func),
|
||||||
|
_depthWriteMask(dp._depthWriteMask),
|
||||||
|
_zNear(dp._zNear),
|
||||||
|
_zFar(dp._zFar) {}
|
||||||
|
|
||||||
|
|
||||||
META_StateAttribute(Depth, DEPTH);
|
META_StateAttribute(Depth, DEPTH);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -55,6 +55,16 @@ class SG_EXPORT Drawable : public Object
|
|||||||
|
|
||||||
Drawable();
|
Drawable();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Drawable(const Drawable& drawable,const Cloner& cloner=ShallowCopy()):
|
||||||
|
Object(drawable,cloner),
|
||||||
|
_dstate(cloner(drawable._dstate.get())),
|
||||||
|
_supportsDisplayList(drawable._supportsDisplayList),
|
||||||
|
_useDisplayList(drawable._useDisplayList),
|
||||||
|
_globjList(drawable._globjList),
|
||||||
|
_bbox(drawable._bbox),
|
||||||
|
_bbox_computed(drawable._bbox_computed) {}
|
||||||
|
|
||||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Drawable*>(obj)!=NULL; }
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Drawable*>(obj)!=NULL; }
|
||||||
virtual const char* className() const { return "Drawable"; }
|
virtual const char* className() const { return "Drawable"; }
|
||||||
|
|
||||||
|
@ -26,6 +26,12 @@ class SG_EXPORT EarthSky : public Group
|
|||||||
|
|
||||||
EarthSky();
|
EarthSky();
|
||||||
|
|
||||||
|
EarthSky(const EarthSky& es, const Cloner& cloner=ShallowCopy()):
|
||||||
|
Group(es,cloner),
|
||||||
|
_requiresClear(es._requiresClear),
|
||||||
|
_clearColor(es._clearColor) {}
|
||||||
|
|
||||||
|
|
||||||
META_Node(EarthSky);
|
META_Node(EarthSky);
|
||||||
|
|
||||||
/** Sets the flag which control whether a glClear is required at the beginning of each frame. */
|
/** Sets the flag which control whether a glClear is required at the beginning of each frame. */
|
||||||
|
@ -20,6 +20,15 @@ class SG_EXPORT Fog : public StateAttribute
|
|||||||
|
|
||||||
Fog();
|
Fog();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Fog(const Fog& fog,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(fog,cloner),
|
||||||
|
_mode(fog._mode),
|
||||||
|
_density(fog._density),
|
||||||
|
_start(fog._start),
|
||||||
|
_end(fog._end),
|
||||||
|
_color(fog._color) {}
|
||||||
|
|
||||||
META_StateAttribute(Fog,FOG);
|
META_StateAttribute(Fog,FOG);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -18,6 +18,11 @@ class SG_EXPORT FrontFace : public StateAttribute
|
|||||||
|
|
||||||
FrontFace();
|
FrontFace();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
FrontFace(const FrontFace& ff,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(ff,cloner),
|
||||||
|
_mode(ff._mode) {}
|
||||||
|
|
||||||
META_StateAttribute(FrontFace, FRONTFACE);
|
META_StateAttribute(FrontFace, FRONTFACE);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -146,8 +146,16 @@ class SG_EXPORT GeoSet : public Drawable
|
|||||||
};
|
};
|
||||||
|
|
||||||
GeoSet();
|
GeoSet();
|
||||||
virtual Object* clone() const { return new GeoSet(); }
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
GeoSet(const GeoSet& geoset,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
|
virtual Object* cloneType() const { return new GeoSet(); }
|
||||||
|
|
||||||
|
virtual Object* clone(const Cloner& cloner) const { return new GeoSet(*this,cloner); }
|
||||||
|
|
||||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const GeoSet*>(obj)!=NULL; }
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const GeoSet*>(obj)!=NULL; }
|
||||||
|
|
||||||
virtual const char* className() const { return "GeoSet"; }
|
virtual const char* className() const { return "GeoSet"; }
|
||||||
|
|
||||||
|
|
||||||
@ -165,7 +173,6 @@ class SG_EXPORT GeoSet : public Drawable
|
|||||||
void computeNumVerts() const;
|
void computeNumVerts() const;
|
||||||
|
|
||||||
/** get the number of coords required by the defined primitives. */
|
/** get the number of coords required by the defined primitives. */
|
||||||
// inline const int getNumCoords() const
|
|
||||||
inline const int getNumCoords() const
|
inline const int getNumCoords() const
|
||||||
{ if( _numcoords == 0 ) computeNumVerts(); return _numcoords; }
|
{ if( _numcoords == 0 ) computeNumVerts(); return _numcoords; }
|
||||||
/** get a pointer to Vec3 coord array. */
|
/** get a pointer to Vec3 coord array. */
|
||||||
|
@ -20,6 +20,9 @@ class SG_EXPORT Geode : public Node
|
|||||||
|
|
||||||
Geode();
|
Geode();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Geode(const Geode&,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
META_Node(Geode);
|
META_Node(Geode);
|
||||||
|
|
||||||
/** Add Drawable to Geode.
|
/** Add Drawable to Geode.
|
||||||
|
@ -22,6 +22,9 @@ class SG_EXPORT Group : public Node
|
|||||||
|
|
||||||
Group();
|
Group();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Group(const Group&,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
META_Node(Group);
|
META_Node(Group);
|
||||||
|
|
||||||
virtual void traverse(NodeVisitor& nv);
|
virtual void traverse(NodeVisitor& nv);
|
||||||
|
@ -20,8 +20,12 @@ class SG_EXPORT Image : public Object
|
|||||||
public :
|
public :
|
||||||
|
|
||||||
Image();
|
Image();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Image(const Image& image,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
virtual Object* clone() const { return new Image(); }
|
virtual Object* cloneType() const { return new Image(); }
|
||||||
|
virtual Object* clone(const Cloner& cloner) const { return new Image(*this,cloner); }
|
||||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Image*>(obj)!=0; }
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Image*>(obj)!=0; }
|
||||||
virtual const char* className() const { return "Image"; }
|
virtual const char* className() const { return "Image"; }
|
||||||
|
|
||||||
|
@ -53,6 +53,11 @@ class SG_EXPORT Impostor : public LOD
|
|||||||
public :
|
public :
|
||||||
Impostor();
|
Impostor();
|
||||||
|
|
||||||
|
Impostor(const Impostor& es, const Cloner& cloner=ShallowCopy()):
|
||||||
|
LOD(es,cloner),
|
||||||
|
_impostorSpriteList(),
|
||||||
|
_impostorThreshold(es._impostorThreshold) {}
|
||||||
|
|
||||||
META_Node(Impostor);
|
META_Node(Impostor);
|
||||||
|
|
||||||
typedef std::vector< ref_ptr<ImpostorSprite> > ImpostorSpriteList;
|
typedef std::vector< ref_ptr<ImpostorSprite> > ImpostorSpriteList;
|
||||||
|
@ -30,7 +30,13 @@ class SG_EXPORT ImpostorSprite : public Drawable
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ImpostorSprite();
|
ImpostorSprite();
|
||||||
virtual Object* clone() const { return new ImpostorSprite(); }
|
|
||||||
|
/** Clone an object of the same type as an ImpostorSprite.*/
|
||||||
|
virtual 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 Cloner&) const { return new ImpostorSprite(); }
|
||||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ImpostorSprite*>(obj)!=NULL; }
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ImpostorSprite*>(obj)!=NULL; }
|
||||||
virtual const char* className() const { return "ImpostorSprite"; }
|
virtual const char* className() const { return "ImpostorSprite"; }
|
||||||
|
|
||||||
|
@ -26,8 +26,12 @@ namespace osg {
|
|||||||
class SG_EXPORT LOD : public Group
|
class SG_EXPORT LOD : public Group
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
|
||||||
LOD() {}
|
LOD() {}
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
LOD(const LOD&,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
META_Node(LOD);
|
META_Node(LOD);
|
||||||
|
|
||||||
virtual void traverse(NodeVisitor& nv);
|
virtual void traverse(NodeVisitor& nv);
|
||||||
|
@ -18,6 +18,21 @@ class SG_EXPORT Light : public StateAttribute
|
|||||||
public :
|
public :
|
||||||
|
|
||||||
Light();
|
Light();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Light(const Light& light,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(light,cloner),
|
||||||
|
_lightnum(light._lightnum),
|
||||||
|
_ambient(light._ambient),
|
||||||
|
_diffuse(light._diffuse),
|
||||||
|
_specular(light._specular),
|
||||||
|
_position(light._position),
|
||||||
|
_direction(light._direction),
|
||||||
|
_constant_attenuation(light._constant_attenuation),
|
||||||
|
_linear_attenuation(light._linear_attenuation),
|
||||||
|
_quadratic_attenuation(light._quadratic_attenuation),
|
||||||
|
_spot_exponent(light._spot_exponent),
|
||||||
|
_spot_cutoff(light._spot_cutoff) {}
|
||||||
|
|
||||||
META_StateAttribute(Light, (Type)(LIGHT_0+_lightnum));
|
META_StateAttribute(Light, (Type)(LIGHT_0+_lightnum));
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ class SG_EXPORT LightSource : public Node
|
|||||||
|
|
||||||
LightSource();
|
LightSource();
|
||||||
|
|
||||||
|
LightSource(const LightSource& es, const Cloner& cloner=ShallowCopy()):
|
||||||
|
Node(es,cloner),
|
||||||
|
_light(dynamic_cast<osg::Light*>(cloner(es._light.get()))) {}
|
||||||
|
|
||||||
META_Node(LightSource);
|
META_Node(LightSource);
|
||||||
|
|
||||||
/** Set the attached light.*/
|
/** Set the attached light.*/
|
||||||
|
@ -17,6 +17,11 @@ class SG_EXPORT LineWidth : public StateAttribute
|
|||||||
|
|
||||||
LineWidth();
|
LineWidth();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
LineWidth(const LineWidth& lw,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(lw,cloner),
|
||||||
|
_width(lw._width) {}
|
||||||
|
|
||||||
META_StateAttribute(LineWidth, LINEWIDTH);
|
META_StateAttribute(LineWidth, LINEWIDTH);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -18,6 +18,26 @@ class SG_EXPORT Material : public StateAttribute
|
|||||||
|
|
||||||
|
|
||||||
Material();
|
Material();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Material(const Material& mat,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(mat,cloner),
|
||||||
|
_colorMode(mat._colorMode),
|
||||||
|
_ambientFrontAndBack(mat._ambientFrontAndBack),
|
||||||
|
_ambientFront(mat._ambientFront),
|
||||||
|
_ambientBack(mat._ambientBack),
|
||||||
|
_diffuseFrontAndBack(mat._diffuseFrontAndBack),
|
||||||
|
_diffuseFront(mat._diffuseFront),
|
||||||
|
_diffuseBack(mat._diffuseBack),
|
||||||
|
_specularFrontAndBack(mat._specularFrontAndBack),
|
||||||
|
_specularFront(mat._specularFront),
|
||||||
|
_specularBack(mat._specularBack),
|
||||||
|
_emissionFrontAndBack(mat._emissionFrontAndBack),
|
||||||
|
_emissionFront(mat._emissionFront),
|
||||||
|
_emissionBack(mat._emissionBack),
|
||||||
|
_shininessFrontAndBack(mat._shininessFrontAndBack),
|
||||||
|
_shininessFront(mat._shininessFront),
|
||||||
|
_shininessBack(mat._shininessBack) {}
|
||||||
|
|
||||||
META_StateAttribute(Material, MATERIAL);
|
META_StateAttribute(Material, MATERIAL);
|
||||||
|
|
||||||
|
@ -20,16 +20,19 @@ class SG_EXPORT Matrix : public Object
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
META_Object(Matrix);
|
|
||||||
|
|
||||||
Matrix();
|
Matrix();
|
||||||
Matrix( const Matrix& other );
|
Matrix( const Matrix& other);
|
||||||
explicit Matrix( float const * const def );
|
explicit Matrix( float const * const def );
|
||||||
Matrix( float a00, float a01, float a02, float a03,
|
Matrix( float a00, float a01, float a02, float a03,
|
||||||
float a10, float a11, float a12, float a13,
|
float a10, float a11, float a12, float a13,
|
||||||
float a20, float a21, float a22, float a23,
|
float a20, float a21, float a22, float a23,
|
||||||
float a30, float a31, float a32, float a33);
|
float a30, float a31, float a32, float a33);
|
||||||
|
|
||||||
|
virtual Object* cloneType() const { return new Matrix(); } \
|
||||||
|
virtual Object* clone(const Cloner&) const { return new Matrix(*this); } \
|
||||||
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Matrix*>(obj)!=NULL; } \
|
||||||
|
virtual const char* className() const { return "Matrix"; }
|
||||||
|
|
||||||
virtual ~Matrix() {}
|
virtual ~Matrix() {}
|
||||||
|
|
||||||
Matrix& operator = (const Matrix& );
|
Matrix& operator = (const Matrix& );
|
||||||
|
@ -23,7 +23,8 @@ class Group;
|
|||||||
* and accept methods. Use when subclassing from Node to make it
|
* and accept methods. Use when subclassing from Node to make it
|
||||||
* more convinient to define the required pure virtual methods.*/
|
* more convinient to define the required pure virtual methods.*/
|
||||||
#define META_Node(name) \
|
#define META_Node(name) \
|
||||||
virtual osg::Object* clone() const { return new name (); } \
|
virtual osg::Object* cloneType() const { return new name (); } \
|
||||||
|
virtual osg::Object* clone(const osg::Cloner& cloner) const { return new name (*this,cloner); } \
|
||||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
||||||
virtual const char* className() const { return #name; } \
|
virtual const char* className() const { return #name; } \
|
||||||
virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) nv.apply(*this); } \
|
virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) nv.apply(*this); } \
|
||||||
@ -41,8 +42,14 @@ class SG_EXPORT Node : public Object
|
|||||||
bounding sphere dirty flag to true.*/
|
bounding sphere dirty flag to true.*/
|
||||||
Node();
|
Node();
|
||||||
|
|
||||||
/** return a shallow copy of a node, with Object* return type.*/
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
virtual Object* clone() const { return new Node(); }
|
Node(const Node&,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
|
/** clone the an object of the same type as the node.*/
|
||||||
|
virtual Object* cloneType() const { return new Node(); }
|
||||||
|
|
||||||
|
/** return a clone of a node, with Object* return type.*/
|
||||||
|
virtual Object* clone(const Cloner& cloner) const { return new Node(*this,cloner); }
|
||||||
|
|
||||||
/** return true if this and obj are of the same kind of object.*/
|
/** return true if this and obj are of the same kind of object.*/
|
||||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Node*>(obj)!=NULL; }
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Node*>(obj)!=NULL; }
|
||||||
@ -74,7 +81,7 @@ class SG_EXPORT Node : public Object
|
|||||||
|
|
||||||
/** Get the a copy of parent list of node. A copy is returned to
|
/** Get the a copy of parent list of node. A copy is returned to
|
||||||
* prevent modification of the parent list.*/
|
* prevent modification of the parent list.*/
|
||||||
// inline ParentList getParents() { return _parents; }
|
inline ParentList getParents() { return _parents; }
|
||||||
|
|
||||||
inline Group* getParent(const int i) { return _parents[i]; }
|
inline Group* getParent(const int i) { return _parents[i]; }
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define OSG_OBJECT 1
|
#define OSG_OBJECT 1
|
||||||
|
|
||||||
#include <osg/Referenced>
|
#include <osg/Referenced>
|
||||||
|
#include <osg/ShallowCopy>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
@ -13,10 +14,11 @@ namespace osg {
|
|||||||
* Use when subclassing from Object to make it more convinient to define
|
* Use when subclassing from Object to make it more convinient to define
|
||||||
* the standard pure virtual clone, isSameKindAs and className methods
|
* the standard pure virtual clone, isSameKindAs and className methods
|
||||||
* which are required for all Object subclasses.*/
|
* which are required for all Object subclasses.*/
|
||||||
#define META_Object(name) \
|
#define META_Object(T) \
|
||||||
virtual osg::Object* clone() const { return new name (); } \
|
virtual osg::Object* cloneType() const { return new T (); } \
|
||||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
virtual osg::Object* clone(const osg::Cloner& cloner) const { return new T (*this,cloner); } \
|
||||||
virtual const char* className() const { return #name; }
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const T *>(obj)!=NULL; } \
|
||||||
|
virtual const char* className() const { return #T; }
|
||||||
|
|
||||||
|
|
||||||
/** Base class/standard interface for objects which require IO support,
|
/** Base class/standard interface for objects which require IO support,
|
||||||
@ -26,15 +28,25 @@ namespace osg {
|
|||||||
class SG_EXPORT Object : public Referenced
|
class SG_EXPORT Object : public Referenced
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
/** Construct an object. Note Object is a pure virtual base class
|
/** Construct an object. Note Object is a pure virtual base class
|
||||||
and therefore cannot be constructed on its own, only derived
|
and therefore cannot be constructed on its own, only derived
|
||||||
classes which override the clone and className methods are
|
classes which override the clone and className methods are
|
||||||
concrete classes and can be constructed.*/
|
concrete classes and can be constructed.*/
|
||||||
Object() {}
|
Object() {}
|
||||||
|
|
||||||
/** return a shallow copy of a node, with Object* return type.
|
/** Copy constructor, optional Cloner object can be used to control
|
||||||
|
* shallow vs deep copying of dynamic data.*/
|
||||||
|
Object(const Object&,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
|
/** Clone the type of an object, with Object* return type.
|
||||||
Must be defined by derived classes.*/
|
Must be defined by derived classes.*/
|
||||||
virtual Object* clone() const = 0;
|
virtual Object* cloneType() const = 0;
|
||||||
|
|
||||||
|
/** Clone the an object, with Object* return type.
|
||||||
|
Must be defined by derived classes.*/
|
||||||
|
virtual Object* clone(const Cloner&) const = 0;
|
||||||
|
|
||||||
virtual bool isSameKindAs(const Object*) const { return true; }
|
virtual bool isSameKindAs(const Object*) const { return true; }
|
||||||
|
|
||||||
@ -55,8 +67,7 @@ class SG_EXPORT Object : public Referenced
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** disallow any form of deep copy.*/
|
/** disallow any copy operator.*/
|
||||||
Object(Object&): Referenced() {}
|
|
||||||
Object& operator = (const Object&) { return *this; }
|
Object& operator = (const Object&) { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,6 +18,13 @@ class SG_EXPORT Point : public StateAttribute
|
|||||||
|
|
||||||
Point();
|
Point();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Point(const Point& point,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(point,cloner),
|
||||||
|
_size(point._size),
|
||||||
|
_fadeThresholdSize(point._fadeThresholdSize),
|
||||||
|
_distanceAttenuation(point._distanceAttenuation) {}
|
||||||
|
|
||||||
META_StateAttribute(Point, POINT);
|
META_StateAttribute(Point, POINT);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -18,6 +18,13 @@ class SG_EXPORT PolygonMode : public StateAttribute
|
|||||||
|
|
||||||
PolygonMode();
|
PolygonMode();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
PolygonMode(const PolygonMode& pm,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(pm,cloner),
|
||||||
|
_frontAndBack(pm._frontAndBack),
|
||||||
|
_modeFront(pm._modeFront),
|
||||||
|
_modeBack(pm._modeBack) {}
|
||||||
|
|
||||||
META_StateAttribute(PolygonMode, POLYGONMODE);
|
META_StateAttribute(PolygonMode, POLYGONMODE);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -17,6 +17,12 @@ class SG_EXPORT PolygonOffset : public StateAttribute
|
|||||||
|
|
||||||
PolygonOffset();
|
PolygonOffset();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
PolygonOffset(const PolygonOffset& po,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(po,cloner),
|
||||||
|
_factor(po._factor),
|
||||||
|
_units(po._units) {}
|
||||||
|
|
||||||
META_StateAttribute(PolygonOffset, POLYGONOFFSET);
|
META_StateAttribute(PolygonOffset, POLYGONOFFSET);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -19,6 +19,12 @@ class SG_EXPORT PositionAttitudeTransform : public Transform
|
|||||||
public :
|
public :
|
||||||
PositionAttitudeTransform();
|
PositionAttitudeTransform();
|
||||||
|
|
||||||
|
PositionAttitudeTransform(const PositionAttitudeTransform& pat,const Cloner& cloner=ShallowCopy()):
|
||||||
|
Transform(pat,cloner),
|
||||||
|
_position(pat._position),
|
||||||
|
_attitude(pat._attitude) {}
|
||||||
|
|
||||||
|
|
||||||
META_Node(PositionAttitudeTransform);
|
META_Node(PositionAttitudeTransform);
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,12 @@ class SG_EXPORT ShadeModel : public StateAttribute
|
|||||||
|
|
||||||
ShadeModel();
|
ShadeModel();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
ShadeModel(const ShadeModel& sm,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(sm,cloner),
|
||||||
|
_mode(sm._mode) {}
|
||||||
|
|
||||||
|
|
||||||
META_StateAttribute(ShadeModel, SHADEMODEL);
|
META_StateAttribute(ShadeModel, SHADEMODEL);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
41
include/osg/ShallowCopy
Normal file
41
include/osg/ShallowCopy
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
||||||
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||||
|
//as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
#ifndef OSG_SHALLOWCOPY
|
||||||
|
#define OSG_SHALLOWCOPY 1
|
||||||
|
|
||||||
|
namespace osg {
|
||||||
|
|
||||||
|
class Referenced;
|
||||||
|
class Object;
|
||||||
|
class Image;
|
||||||
|
class Texture;
|
||||||
|
class StateSet;
|
||||||
|
class StateAttribute;
|
||||||
|
class Node;
|
||||||
|
class Drawable;
|
||||||
|
|
||||||
|
/** Cloner Functor used to control the whether shallow or deep copy is used
|
||||||
|
* during copy construction and clone operation. The base Cloner acts as
|
||||||
|
* a shallow copy simply passing back the same pointer as passed in.*/
|
||||||
|
struct Cloner
|
||||||
|
{
|
||||||
|
virtual ~Cloner() {}
|
||||||
|
|
||||||
|
virtual Referenced* operator() (const Referenced* ref) const { return const_cast<Referenced*>(ref); }
|
||||||
|
virtual Object* operator() (const Object* obj) const { return const_cast<Object*>(obj); }
|
||||||
|
virtual Node* operator() (const Node* node) const { return const_cast<Node*>(node); }
|
||||||
|
virtual Drawable* operator() (const Drawable* drawable) const { return const_cast<Drawable*>(drawable); }
|
||||||
|
virtual StateSet* operator() (const StateSet* stateset) const { return const_cast<StateSet*>(stateset); }
|
||||||
|
virtual StateAttribute* operator() (const StateAttribute* attr) const { return const_cast<StateAttribute*>(attr); }
|
||||||
|
virtual Texture* operator() (const Texture* text) const { return const_cast<Texture*>(text); }
|
||||||
|
virtual Image* operator() (const Image* image) const { return const_cast<Image*>(image); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Convenience typedef so that users can use the more logical ShallowCopy in their own code.*/
|
||||||
|
typedef Cloner ShallowCopy;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -181,7 +181,7 @@ class SG_EXPORT State : public Referenced
|
|||||||
{
|
{
|
||||||
if (as.last_applied_attribute != attribute)
|
if (as.last_applied_attribute != attribute)
|
||||||
{
|
{
|
||||||
if (!as.global_default_attribute.valid()) as.global_default_attribute = dynamic_cast<StateAttribute*>(attribute->clone());
|
if (!as.global_default_attribute.valid()) as.global_default_attribute = dynamic_cast<StateAttribute*>(attribute->cloneType());
|
||||||
|
|
||||||
as.last_applied_attribute = attribute;
|
as.last_applied_attribute = attribute;
|
||||||
attribute->apply(*this);
|
attribute->apply(*this);
|
||||||
|
@ -22,8 +22,9 @@ class StateSet;
|
|||||||
* the standard pure virtual methods which are required for all Object
|
* the standard pure virtual methods which are required for all Object
|
||||||
* subclasses.*/
|
* subclasses.*/
|
||||||
#define META_StateAttribute(name,type) \
|
#define META_StateAttribute(name,type) \
|
||||||
virtual Object* clone() const { return new name (); } \
|
virtual osg::Object* cloneType() const { return new name(); } \
|
||||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
virtual osg::Object* clone(const osg::Cloner& cloner) const { return new name (*this,cloner); } \
|
||||||
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
||||||
virtual const char* className() const { return #name; } \
|
virtual const char* className() const { return #name; } \
|
||||||
virtual const Type getType() const { return type; }
|
virtual const Type getType() const { return type; }
|
||||||
|
|
||||||
@ -147,9 +148,18 @@ class SG_EXPORT StateAttribute : public Object
|
|||||||
};
|
};
|
||||||
|
|
||||||
StateAttribute() {}
|
StateAttribute() {}
|
||||||
|
|
||||||
|
StateAttribute(const StateAttribute& sa,const Cloner& cloner=ShallowCopy()):
|
||||||
|
Object(sa,cloner) {}
|
||||||
|
|
||||||
|
|
||||||
/** return a shallow copy of a node, with Object* return type.*/
|
/** Clone the type of an attribute, with Object* return type.
|
||||||
virtual Object* clone() const = 0;
|
Must be defined by derived classes.*/
|
||||||
|
virtual Object* cloneType() const = 0;
|
||||||
|
|
||||||
|
/** Clone an attribute, with Object* return type.
|
||||||
|
Must be defined by derived classes.*/
|
||||||
|
virtual Object* clone(const Cloner&) const = 0;
|
||||||
|
|
||||||
/** return true if this and obj are of the same kind of object.*/
|
/** return true if this and obj are of the same kind of object.*/
|
||||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const StateAttribute*>(obj)!=NULL; }
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const StateAttribute*>(obj)!=NULL; }
|
||||||
|
@ -28,9 +28,10 @@ class SG_EXPORT StateSet : public Object
|
|||||||
|
|
||||||
|
|
||||||
StateSet();
|
StateSet();
|
||||||
StateSet(const StateSet&);
|
StateSet(const StateSet&,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
virtual Object* clone() const { return new StateSet(); }
|
virtual Object* cloneType() const { return new StateSet(); }
|
||||||
|
virtual Object* clone(const Cloner& cloner) const { return new StateSet(*this,cloner); }
|
||||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const StateSet*>(obj)!=NULL; }
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const StateSet*>(obj)!=NULL; }
|
||||||
virtual const char* className() const { return "StateSet"; }
|
virtual const char* className() const { return "StateSet"; }
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#ifndef OSGUTIL_STATISTICS
|
#ifndef OSGUTIL_STATISTICS
|
||||||
#define OSGUTIL_STATISTICS 1
|
#define OSGUTIL_STATISTICS 1
|
||||||
|
|
||||||
#include <osg/Object>
|
#include <osg/Referenced>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ namespace osg {
|
|||||||
* each trifan or tristrip = (length-2) triangles and so on.
|
* each trifan or tristrip = (length-2) triangles and so on.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SG_EXPORT Statistics : public osg::Object
|
class SG_EXPORT Statistics : public osg::Referenced
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -52,9 +52,6 @@ class SG_EXPORT Statistics : public osg::Object
|
|||||||
|
|
||||||
|
|
||||||
~Statistics() {}; // no dynamic allocations, so no need to free
|
~Statistics() {}; // no dynamic allocations, so no need to free
|
||||||
virtual osg::Object* clone() const { return new Statistics(); }
|
|
||||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Statistics*>(obj)!=0L; }
|
|
||||||
virtual const char* className() const { return "Statistics"; }
|
|
||||||
|
|
||||||
enum statsType
|
enum statsType
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,18 @@ class SG_EXPORT Stencil : public StateAttribute
|
|||||||
|
|
||||||
Stencil();
|
Stencil();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Stencil(const Stencil& stencil,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(stencil,cloner),
|
||||||
|
_func(stencil._func),
|
||||||
|
_funcRef(stencil._funcRef),
|
||||||
|
_funcMask(stencil._funcMask),
|
||||||
|
_sfail(stencil._sfail),
|
||||||
|
_zfail(stencil._zfail),
|
||||||
|
_zpass(stencil._zpass),
|
||||||
|
_writeMask(stencil._writeMask) {}
|
||||||
|
|
||||||
|
|
||||||
META_StateAttribute(Stencil, STENCIL);
|
META_StateAttribute(Stencil, STENCIL);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -31,6 +31,9 @@ class SG_EXPORT Switch : public Group
|
|||||||
|
|
||||||
Switch();
|
Switch();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Switch(const Switch&,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
META_Node(Switch);
|
META_Node(Switch);
|
||||||
|
|
||||||
virtual void traverse(NodeVisitor& nv);
|
virtual void traverse(NodeVisitor& nv);
|
||||||
|
@ -15,7 +15,13 @@ class SG_EXPORT TexEnv : public StateAttribute
|
|||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
|
||||||
TexEnv( void );
|
TexEnv();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
TexEnv(const TexEnv& texenv,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(texenv,cloner),
|
||||||
|
_mode(texenv._mode) {}
|
||||||
|
|
||||||
|
|
||||||
META_StateAttribute(TexEnv, TEXENV);
|
META_StateAttribute(TexEnv, TEXENV);
|
||||||
|
|
||||||
|
@ -16,7 +16,16 @@ class SG_EXPORT TexGen : public StateAttribute
|
|||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
|
||||||
TexGen( void );
|
TexGen();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
TexGen(const TexGen& texgen,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(texgen,cloner),
|
||||||
|
_mode(texgen._mode),
|
||||||
|
_plane_s(texgen._plane_s),
|
||||||
|
_plane_t(texgen._plane_t),
|
||||||
|
_plane_r(texgen._plane_r),
|
||||||
|
_plane_q(texgen._plane_q) {}
|
||||||
|
|
||||||
META_StateAttribute(TexGen, TEXGEN);
|
META_StateAttribute(TexGen, TEXGEN);
|
||||||
|
|
||||||
|
@ -14,7 +14,13 @@ namespace osg {
|
|||||||
class SG_EXPORT TexMat : public StateAttribute
|
class SG_EXPORT TexMat : public StateAttribute
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
TexMat( void );
|
|
||||||
|
TexMat();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
TexMat(const TexMat& texmat,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(texmat,cloner),
|
||||||
|
_matrix(texmat._matrix) {}
|
||||||
|
|
||||||
META_StateAttribute(TexMat, TEXMAT);
|
META_StateAttribute(TexMat, TEXMAT);
|
||||||
|
|
||||||
|
@ -69,6 +69,27 @@ class SG_EXPORT Texture : public StateAttribute
|
|||||||
|
|
||||||
Texture();
|
Texture();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Texture(const Texture& text,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(text,cloner),
|
||||||
|
_handleList(text._handleList),
|
||||||
|
_modifiedTag(text._modifiedTag),
|
||||||
|
_textureObjectSize(text._textureObjectSize),
|
||||||
|
_image(cloner(text._image.get())),
|
||||||
|
_textureUnit(text._textureUnit),
|
||||||
|
_wrap_s(text._wrap_s),
|
||||||
|
_wrap_t(text._wrap_t),
|
||||||
|
_wrap_r(text._wrap_r),
|
||||||
|
_min_filter(text._min_filter),
|
||||||
|
_mag_filter(text._mag_filter),
|
||||||
|
_internalFormatMode(text._internalFormatMode),
|
||||||
|
_internalFormatValue(text._internalFormatValue),
|
||||||
|
_textureWidth(text._textureWidth),
|
||||||
|
_textureHeight(text._textureHeight),
|
||||||
|
_subloadMode(text._subloadMode),
|
||||||
|
_subloadOffsX(text._subloadOffsX),
|
||||||
|
_subloadOffsY(text._subloadOffsY) {}
|
||||||
|
|
||||||
META_StateAttribute(Texture,(Type)(TEXTURE_0+_textureUnit));
|
META_StateAttribute(Texture,(Type)(TEXTURE_0+_textureUnit));
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -26,7 +26,12 @@ namespace osg {
|
|||||||
class SG_EXPORT Transform : public Group
|
class SG_EXPORT Transform : public Group
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
|
||||||
Transform();
|
Transform();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Transform(const Transform&,const Cloner& cloner=ShallowCopy());
|
||||||
|
|
||||||
Transform(const Matrix& matix);
|
Transform(const Matrix& matix);
|
||||||
|
|
||||||
META_Node(Transform);
|
META_Node(Transform);
|
||||||
|
@ -17,6 +17,12 @@ class SG_EXPORT Transparency : public StateAttribute
|
|||||||
|
|
||||||
Transparency();
|
Transparency();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Transparency(const Transparency& trans,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(trans,cloner),
|
||||||
|
_source_factor(trans._source_factor),
|
||||||
|
_destination_factor(trans._destination_factor) {}
|
||||||
|
|
||||||
META_StateAttribute(Transparency,TRANSPARENCY);
|
META_StateAttribute(Transparency,TRANSPARENCY);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -20,6 +20,14 @@ class SG_EXPORT Viewport : public StateAttribute
|
|||||||
|
|
||||||
Viewport();
|
Viewport();
|
||||||
|
|
||||||
|
/** Copy constructor using Cloner to manage deep vs shallow copy.*/
|
||||||
|
Viewport(const Viewport& vp,const Cloner& cloner=ShallowCopy()):
|
||||||
|
StateAttribute(vp,cloner),
|
||||||
|
_x(vp._x),
|
||||||
|
_y(vp._y),
|
||||||
|
_width(vp._width),
|
||||||
|
_height(vp._height) {}
|
||||||
|
|
||||||
META_StateAttribute(Viewport,VIEWPORT);
|
META_StateAttribute(Viewport,VIEWPORT);
|
||||||
|
|
||||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||||
|
@ -33,189 +33,207 @@ class FTFont;
|
|||||||
|
|
||||||
namespace osgText {
|
namespace osgText {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/** META_Font macro define the standard clone, isSameKindAs,
|
||||||
// Font - FontBaseClass
|
* 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_Font(name) \
|
||||||
|
virtual osg::Object* cloneType() const { return new name(); } \
|
||||||
|
virtual osg::Object* clone(const osg::Cloner& cloner) const { return new name (*this,cloner); } \
|
||||||
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
|
||||||
|
virtual const char* className() const { return #name; } \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OSGTEXT_EXPORT Font : public osg::Object
|
class OSGTEXT_EXPORT Font : public osg::Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Font();
|
Font();
|
||||||
|
Font(const Font& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||||
|
Object(font,cloner),
|
||||||
|
_init(false),
|
||||||
|
_created(false),
|
||||||
|
_font(0L),
|
||||||
|
_fontName(font._fontName),
|
||||||
|
_pointSize(font._pointSize),
|
||||||
|
_res(font._res),
|
||||||
|
_textureSize(font._textureSize)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Font *>(obj)!=NULL; }
|
||||||
|
virtual const char* className() const { return "Font"; }
|
||||||
|
|
||||||
bool open(const char* font);
|
bool open(const char* font);
|
||||||
bool open(const std::string& font);
|
bool open(const std::string& font);
|
||||||
|
|
||||||
virtual bool create(osg::State& state,int pointSize, const unsigned int res = 72 );
|
|
||||||
virtual bool create(osg::State& state);
|
|
||||||
virtual void output(osg::State& state,const char* text);
|
|
||||||
|
|
||||||
virtual bool isOk(void) const { return _init; }
|
virtual bool create(osg::State& state,int pointSize, const unsigned int res = 72 );
|
||||||
virtual bool isCreated(void) const { return isOk() && _created; }
|
virtual bool create(osg::State& state);
|
||||||
|
virtual void output(osg::State& state,const char* text);
|
||||||
|
|
||||||
virtual float getWidth(const char* text) const;
|
virtual bool isOk(void) const { return _init; }
|
||||||
virtual int getHeight() const;
|
virtual bool isCreated(void) const { return isOk() && _created; }
|
||||||
virtual int getDescender() const;
|
|
||||||
virtual int getAscender() const;
|
|
||||||
|
|
||||||
int getPointSize(void) const { return _pointSize; }
|
virtual float getWidth(const char* text) const;
|
||||||
int getTextureSize(void) const { return _textureSize; }
|
virtual int getHeight() const;
|
||||||
const std::string& getFontName();
|
virtual int getDescender() const;
|
||||||
|
virtual int getAscender() const;
|
||||||
|
|
||||||
FTFont* getFont(void) { return _font; }
|
int getPointSize(void) const { return _pointSize; }
|
||||||
|
int getTextureSize(void) const { return _textureSize; }
|
||||||
|
const std::string& getFontName();
|
||||||
|
|
||||||
protected:
|
FTFont* getFont(void) { return _font; }
|
||||||
|
|
||||||
virtual ~Font();
|
protected:
|
||||||
|
|
||||||
virtual void clear();
|
virtual ~Font();
|
||||||
|
|
||||||
virtual FTFont* createFontObj(void)=0;
|
virtual void clear();
|
||||||
|
|
||||||
bool init(const std::string& font);
|
virtual FTFont* createFontObj(void)=0;
|
||||||
|
|
||||||
bool _init;
|
bool init(const std::string& font);
|
||||||
bool _created;
|
|
||||||
|
|
||||||
FTFont* _font;
|
bool _init;
|
||||||
std::string _fontName;
|
bool _created;
|
||||||
int _pointSize;
|
|
||||||
int _res;
|
FTFont* _font;
|
||||||
int _textureSize;
|
std::string _fontName;
|
||||||
|
int _pointSize;
|
||||||
|
int _res;
|
||||||
|
int _textureSize;
|
||||||
};
|
};
|
||||||
// Font
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// RasterFont
|
|
||||||
class OSGTEXT_EXPORT RasterFont:public Font
|
class OSGTEXT_EXPORT RasterFont:public Font
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RasterFont():Font(){;}
|
|
||||||
RasterFont(const std::string& font):Font(){;}
|
|
||||||
|
|
||||||
protected:
|
RasterFont():Font(){}
|
||||||
|
RasterFont(const RasterFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||||
|
Font(font,cloner) {}
|
||||||
|
RasterFont(const std::string& font):Font() {}
|
||||||
|
|
||||||
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RasterFont *>(obj)!=NULL; }
|
||||||
|
virtual const char* className() const { return "RasterFont"; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// RasterFont
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// VectorFont
|
|
||||||
class OSGTEXT_EXPORT VectorFont:public Font
|
class OSGTEXT_EXPORT VectorFont:public Font
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VectorFont():Font(){;}
|
VectorFont():Font(){}
|
||||||
VectorFont(const std::string& font):Font(){;}
|
VectorFont(const VectorFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||||
|
Font(font,cloner) {}
|
||||||
|
VectorFont(const std::string& font):Font(){}
|
||||||
|
|
||||||
protected:
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const VectorFont *>(obj)!=NULL; }
|
||||||
double _precision;
|
virtual const char* className() const { return "VectorFont"; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
double _precision;
|
||||||
};
|
};
|
||||||
|
|
||||||
// VectorFont
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// BitmapFont
|
|
||||||
class OSGTEXT_EXPORT BitmapFont:public RasterFont
|
class OSGTEXT_EXPORT BitmapFont:public RasterFont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
BitmapFont() {;}
|
BitmapFont() {}
|
||||||
|
BitmapFont(const BitmapFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||||
BitmapFont(const std::string& font,
|
RasterFont(font,cloner) {}
|
||||||
int point_size);
|
BitmapFont(const std::string& font,
|
||||||
|
int point_size);
|
||||||
META_Object(BitmapFont);
|
|
||||||
|
|
||||||
protected:
|
META_Font(BitmapFont);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
|
||||||
virtual FTFont* createFontObj(void);
|
virtual FTFont* createFontObj(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
// BitmapFont
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// PixmapFont
|
|
||||||
class OSGTEXT_EXPORT PixmapFont:public RasterFont
|
class OSGTEXT_EXPORT PixmapFont:public RasterFont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PixmapFont() {;}
|
PixmapFont() {}
|
||||||
|
PixmapFont(const PixmapFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||||
PixmapFont(const std::string& font,
|
RasterFont(font,cloner) {}
|
||||||
int point_size);
|
|
||||||
|
|
||||||
META_Object(PixmapFont);
|
|
||||||
|
|
||||||
protected:
|
PixmapFont(const std::string& font,
|
||||||
|
int point_size);
|
||||||
|
|
||||||
virtual FTFont* createFontObj(void);
|
META_Font(PixmapFont);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual FTFont* createFontObj(void);
|
||||||
|
|
||||||
};
|
};
|
||||||
// PixmapFont
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// TextureFont
|
|
||||||
|
|
||||||
class OSGTEXT_EXPORT TextureFont:public RasterFont
|
class OSGTEXT_EXPORT TextureFont:public RasterFont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TextureFont() {;}
|
TextureFont() {}
|
||||||
|
TextureFont(const TextureFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||||
TextureFont(const std::string& font,
|
RasterFont(font,cloner) {}
|
||||||
int point_size);
|
|
||||||
|
|
||||||
TextureFont(const std::string& font,
|
TextureFont(const std::string& font,
|
||||||
int point_size,
|
int point_size);
|
||||||
int textureSize );
|
|
||||||
|
|
||||||
META_Object(TextureFont);
|
|
||||||
|
|
||||||
protected:
|
TextureFont(const std::string& font,
|
||||||
|
int point_size,
|
||||||
|
int textureSize );
|
||||||
|
|
||||||
virtual FTFont* createFontObj(void);
|
META_Font(TextureFont);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual FTFont* createFontObj(void);
|
||||||
|
|
||||||
};
|
};
|
||||||
// PixmapFont
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OutlineFont
|
|
||||||
class OSGTEXT_EXPORT OutlineFont:public VectorFont
|
class OSGTEXT_EXPORT OutlineFont:public VectorFont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OutlineFont() {;}
|
OutlineFont() {}
|
||||||
|
OutlineFont(const OutlineFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||||
OutlineFont(const std::string& font,
|
VectorFont(font,cloner) {}
|
||||||
int point_size,
|
|
||||||
double precision);
|
|
||||||
|
|
||||||
META_Object(OutlineFont);
|
|
||||||
|
|
||||||
protected:
|
OutlineFont(const std::string& font,
|
||||||
|
int point_size,
|
||||||
|
double precision);
|
||||||
|
|
||||||
virtual FTFont* createFontObj(void);
|
META_Font(OutlineFont);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual FTFont* createFontObj(void);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
// OutlineFont
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// PolygonFont
|
|
||||||
class OSGTEXT_EXPORT PolygonFont:public VectorFont
|
class OSGTEXT_EXPORT PolygonFont:public VectorFont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PolygonFont() {;}
|
PolygonFont() {}
|
||||||
|
PolygonFont(const PolygonFont& font,const osg::Cloner& cloner=osg::ShallowCopy()):
|
||||||
|
VectorFont(font,cloner) {}
|
||||||
|
|
||||||
PolygonFont(const std::string& font,
|
PolygonFont(const std::string& font,
|
||||||
int point_size,
|
int point_size,
|
||||||
@ -225,15 +243,14 @@ public:
|
|||||||
int point_size,
|
int point_size,
|
||||||
double precision);
|
double precision);
|
||||||
|
|
||||||
META_Object(PolygonFont);
|
META_Font(PolygonFont);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual FTFont* createFontObj(void);
|
virtual FTFont* createFontObj(void);
|
||||||
|
|
||||||
};
|
};
|
||||||
// PolygonFont
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ class OSGTEXT_EXPORT Paragraph : public osg::Geode
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Paragraph();
|
Paragraph();
|
||||||
|
Paragraph(const Paragraph& paragraph,const osg::Cloner& cloner=osg::ShallowCopy());
|
||||||
Paragraph(const osg::Vec3& position,const std::string& text,osgText::Font* font);
|
Paragraph(const osg::Vec3& position,const std::string& text,osgText::Font* font);
|
||||||
|
|
||||||
META_Node(Paragraph)
|
META_Node(Paragraph)
|
||||||
|
@ -35,105 +35,108 @@ namespace osgText {
|
|||||||
|
|
||||||
class OSGTEXT_EXPORT Text : public osg::Drawable
|
class OSGTEXT_EXPORT Text : public osg::Drawable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum AlignmentType
|
enum AlignmentType
|
||||||
{ // from left to right, top to bottom
|
{ // from left to right, top to bottom
|
||||||
LEFT_TOP,
|
LEFT_TOP,
|
||||||
LEFT_CENTER,
|
LEFT_CENTER,
|
||||||
LEFT_BOTTOM,
|
LEFT_BOTTOM,
|
||||||
|
|
||||||
CENTER_TOP,
|
CENTER_TOP,
|
||||||
CENTER_CENTER,
|
CENTER_CENTER,
|
||||||
CENTER_BOTTOM,
|
CENTER_BOTTOM,
|
||||||
|
|
||||||
RIGHT_TOP,
|
RIGHT_TOP,
|
||||||
RIGHT_CENTER,
|
RIGHT_CENTER,
|
||||||
RIGHT_BOTTOM,
|
RIGHT_BOTTOM,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BoundingBoxType
|
enum BoundingBoxType
|
||||||
{
|
{
|
||||||
GEOMETRY,
|
GEOMETRY,
|
||||||
GLYPH,
|
GLYPH,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DrawModeType
|
enum DrawModeType
|
||||||
{ // from left to right, top to bottom
|
{ // from left to right, top to bottom
|
||||||
TEXT = 1<<0,
|
TEXT = 1<<0,
|
||||||
BOUNDINGBOX = 1<<1,
|
BOUNDINGBOX = 1<<1,
|
||||||
ALIGNEMENT = 1<<2,
|
ALIGNEMENT = 1<<2,
|
||||||
DEFAULT = TEXT,
|
DEFAULT = TEXT,
|
||||||
};
|
};
|
||||||
|
|
||||||
Text();
|
Text();
|
||||||
Text(Font* font);
|
Text(const Text& text,const osg::Cloner& cloner=osg::ShallowCopy());
|
||||||
|
Text(Font* font);
|
||||||
|
|
||||||
META_Object(Text);
|
virtual osg::Object* cloneType() const { return new Text(); }
|
||||||
|
virtual osg::Object* clone(const osg::Cloner& cloner) const { return new Text(*this,cloner); }
|
||||||
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Text*>(obj)!=NULL; }
|
||||||
|
virtual const char* className() const { return "Text"; }
|
||||||
|
|
||||||
void setPosition(const osg::Vec2& pos);
|
|
||||||
void setPosition(const osg::Vec3& pos);
|
|
||||||
const osg::Vec3& getPosition() const { return _pos; }
|
|
||||||
|
|
||||||
void setDrawMode(int mode) { _drawMode=mode; }
|
void setPosition(const osg::Vec2& pos);
|
||||||
int getDrawMode() const { return _drawMode; }
|
void setPosition(const osg::Vec3& pos);
|
||||||
|
const osg::Vec3& getPosition() const { return _pos; }
|
||||||
|
|
||||||
void setBoundingBox(int mode);
|
void setDrawMode(int mode) { _drawMode=mode; }
|
||||||
int getBoundingBox() const { return _boundingBoxType; }
|
int getDrawMode() const { return _drawMode; }
|
||||||
|
|
||||||
void setAlignment(int alignment);
|
void setBoundingBox(int mode);
|
||||||
int getAlignment() const { return _alignment; }
|
int getBoundingBox() const { return _boundingBoxType; }
|
||||||
|
|
||||||
void setFont(Font* font);
|
void setAlignment(int alignment);
|
||||||
Font* getFont() { return _font.get(); }
|
int getAlignment() const { return _alignment; }
|
||||||
const Font* getFont() const { return _font.get(); }
|
|
||||||
|
|
||||||
void setText(const char* text) { _text=text; }
|
void setFont(Font* font);
|
||||||
void setText(const std::string& text) { _text=text; }
|
Font* getFont() { return _font.get(); }
|
||||||
const std::string& getText() const { return _text; }
|
const Font* getFont() const { return _font.get(); }
|
||||||
|
|
||||||
virtual void drawImmediateMode(osg::State& state);
|
void setText(const char* text) { _text=text; }
|
||||||
virtual void drawBoundingBox(void);
|
void setText(const std::string& text) { _text=text; }
|
||||||
virtual void drawAlignment(void);
|
const std::string& getText() const { return _text; }
|
||||||
|
|
||||||
const osg::Vec3& getAlignmentPos() const { return _alignmentPos; };
|
|
||||||
|
|
||||||
|
virtual void drawImmediateMode(osg::State& state);
|
||||||
protected:
|
virtual void drawBoundingBox(void);
|
||||||
|
virtual void drawAlignment(void);
|
||||||
|
|
||||||
enum FontType
|
const osg::Vec3& getAlignmentPos() const { return _alignmentPos; };
|
||||||
{
|
|
||||||
UNDEF,
|
|
||||||
BITMAP,
|
|
||||||
PIXMAP,
|
|
||||||
OUTLINE,
|
|
||||||
POLYGON,
|
|
||||||
TEXTURE,
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual ~Text();
|
|
||||||
|
|
||||||
virtual void setDefaults(void);
|
|
||||||
virtual const bool computeBound(void) const;
|
|
||||||
virtual void calcBounds(osg::Vec3* min,osg::Vec3* max) const;
|
|
||||||
void initAlignment(osg::Vec3* min,osg::Vec3* max);
|
|
||||||
bool initAlignment(void);
|
|
||||||
|
|
||||||
osg::ref_ptr<Font> _font;
|
protected:
|
||||||
|
|
||||||
bool _init;
|
enum FontType
|
||||||
bool _initAlignment;
|
{
|
||||||
std::string _text;
|
UNDEF,
|
||||||
int _fontType;
|
BITMAP,
|
||||||
int _alignment;
|
PIXMAP,
|
||||||
int _drawMode;
|
OUTLINE,
|
||||||
int _boundingBoxType;
|
POLYGON,
|
||||||
|
TEXTURE,
|
||||||
osg::Vec3 _pos;
|
};
|
||||||
osg::Vec3 _alignmentPos;
|
|
||||||
|
virtual ~Text();
|
||||||
|
|
||||||
|
virtual void setDefaults(void);
|
||||||
|
virtual const bool computeBound(void) const;
|
||||||
|
virtual void calcBounds(osg::Vec3* min,osg::Vec3* max) const;
|
||||||
|
void initAlignment(osg::Vec3* min,osg::Vec3* max);
|
||||||
|
bool initAlignment(void);
|
||||||
|
|
||||||
|
osg::ref_ptr<Font> _font;
|
||||||
|
|
||||||
|
bool _init;
|
||||||
|
bool _initAlignment;
|
||||||
|
std::string _text;
|
||||||
|
int _fontType;
|
||||||
|
int _alignment;
|
||||||
|
int _drawMode;
|
||||||
|
int _boundingBoxType;
|
||||||
|
|
||||||
|
osg::Vec3 _pos;
|
||||||
|
osg::Vec3 _alignmentPos;
|
||||||
};
|
};
|
||||||
// Text
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object
|
|||||||
|
|
||||||
RenderBin();
|
RenderBin();
|
||||||
|
|
||||||
virtual osg::Object* clone() const { return new RenderBin(); }
|
virtual osg::Object* cloneType() const { return new RenderBin(); }
|
||||||
|
virtual osg::Object* clone(const osg::Cloner&) const { return new RenderBin(); } // note only implements a clone of type.
|
||||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderBin*>(obj)!=0L; }
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderBin*>(obj)!=0L; }
|
||||||
virtual const char* className() const { return "RenderBin"; }
|
virtual const char* className() const { return "RenderBin"; }
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
|||||||
|
|
||||||
|
|
||||||
RenderStage();
|
RenderStage();
|
||||||
virtual osg::Object* clone() const { return new RenderStage(); }
|
virtual osg::Object* cloneType(const osg::Cloner&) const { return new RenderStage(); }
|
||||||
|
virtual osg::Object* clone(const osg::Cloner&) const { return new RenderStage(); } // note only implements a clone of type.
|
||||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderStage*>(obj)!=0L; }
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderStage*>(obj)!=0L; }
|
||||||
virtual const char* className() const { return "RenderStage"; }
|
virtual const char* className() const { return "RenderStage"; }
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@ class OSGUTIL_EXPORT RenderStageLighting : public osg::Object
|
|||||||
|
|
||||||
|
|
||||||
RenderStageLighting();
|
RenderStageLighting();
|
||||||
virtual osg::Object* clone() const { return new RenderStageLighting(); }
|
virtual osg::Object* cloneType() const { return new RenderStageLighting(); }
|
||||||
|
virtual osg::Object* clone(const osg::Cloner&) const { return new RenderStageLighting(); } // note only implements a clone of type.
|
||||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderStageLighting*>(obj)!=0L; }
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderStageLighting*>(obj)!=0L; }
|
||||||
virtual const char* className() const { return "RenderStageLighting"; }
|
virtual const char* className() const { return "RenderStageLighting"; }
|
||||||
|
|
||||||
|
@ -20,7 +20,10 @@ class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage
|
|||||||
|
|
||||||
|
|
||||||
RenderToTextureStage();
|
RenderToTextureStage();
|
||||||
virtual osg::Object* clone() const { return new RenderToTextureStage(); }
|
|
||||||
|
|
||||||
|
virtual osg::Object* cloneType() const { return new RenderToTextureStage(); }
|
||||||
|
virtual osg::Object* clone(const osg::Cloner&) const { return new RenderToTextureStage(); } // note only implements a clone of type.
|
||||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderToTextureStage*>(obj)!=0L; }
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderToTextureStage*>(obj)!=0L; }
|
||||||
virtual const char* className() const { return "RenderToTextureStage"; }
|
virtual const char* className() const { return "RenderToTextureStage"; }
|
||||||
|
|
||||||
|
@ -124,9 +124,7 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
// run optimization over the scene graph
|
// run optimization over the scene graph
|
||||||
osgUtil::Optimizer optimzer;
|
osgUtil::Optimizer optimzer;
|
||||||
// turn off temporarily since the above single child decorator group gets
|
optimzer.optimize(rootnode);
|
||||||
// removed as the optimizer assumes its redundent. Will fix next. Robert.
|
|
||||||
// optimzer.optimize(rootnode);
|
|
||||||
|
|
||||||
// add a viewport to the viewer and attach the scene graph.
|
// add a viewport to the viewer and attach the scene graph.
|
||||||
viewer.addViewport( rootnode );
|
viewer.addViewport( rootnode );
|
||||||
|
@ -14,6 +14,12 @@ Billboard::Billboard()
|
|||||||
setCachedMode();
|
setCachedMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Billboard::Billboard(const Billboard& billboard,const Cloner& cloner):
|
||||||
|
Geode(billboard,cloner),
|
||||||
|
_mode(billboard._mode),
|
||||||
|
_axis(billboard._axis),
|
||||||
|
_positionList(billboard._positionList),
|
||||||
|
_cachedMode(billboard._cachedMode) {}
|
||||||
|
|
||||||
Billboard::~Billboard()
|
Billboard::~Billboard()
|
||||||
{
|
{
|
||||||
@ -91,7 +97,7 @@ const bool Billboard::removeDrawable( Drawable *gset )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Billboard::calcTransform(const Vec3& eye_local, const Vec3& up_local, const Vec3& pos_local, Matrix& mat) const
|
void Billboard::calcTransform(const Vec3& eye_local, const Vec3& /*up_local*/, const Vec3& pos_local, Matrix& mat) const
|
||||||
{
|
{
|
||||||
Vec3 ev(pos_local-eye_local);
|
Vec3 ev(pos_local-eye_local);
|
||||||
switch(_cachedMode)
|
switch(_cachedMode)
|
||||||
|
@ -49,6 +49,97 @@ GeoSet::GeoSet()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GeoSet::GeoSet(const GeoSet& geoset,const Cloner& cloner):
|
||||||
|
Drawable(geoset,cloner)
|
||||||
|
{
|
||||||
|
// ensure that the num of vertices etc have been set up before we copy.
|
||||||
|
geoset.computeNumVerts();
|
||||||
|
|
||||||
|
_adf = geoset._adf;
|
||||||
|
|
||||||
|
_numprims = geoset._numprims;
|
||||||
|
_primtype = geoset._primtype;
|
||||||
|
_needprimlen = geoset._needprimlen;
|
||||||
|
_oglprimtype = geoset._oglprimtype;
|
||||||
|
_primlength = geoset._primlength;
|
||||||
|
_flat_shaded_skip = geoset._flat_shaded_skip;
|
||||||
|
if (geoset._primLengths)
|
||||||
|
{
|
||||||
|
_primLengths = new int [_primlength];
|
||||||
|
memcpy(_primLengths,geoset._primLengths,_primlength);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_primLengths = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
_numcoords = geoset._numcoords;
|
||||||
|
_cindex = geoset._cindex;
|
||||||
|
if (geoset._coords)
|
||||||
|
{
|
||||||
|
_coords = new Vec3 [_numcoords];
|
||||||
|
memcpy(_coords,geoset._coords,_numcoords);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_coords = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
_normal_binding = geoset._normal_binding;
|
||||||
|
_numnormals = geoset._numnormals;
|
||||||
|
_nindex = geoset._nindex;
|
||||||
|
if (geoset._normals)
|
||||||
|
{
|
||||||
|
_normals = new Vec3 [_numnormals];
|
||||||
|
memcpy(_normals,geoset._normals,_numnormals);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_normals = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
_color_binding = geoset._color_binding;
|
||||||
|
_numcolors = geoset._numcolors;
|
||||||
|
_colindex = geoset._colindex;
|
||||||
|
if (geoset._colors)
|
||||||
|
{
|
||||||
|
_colors = new Vec4 [_numcolors];
|
||||||
|
memcpy(_colors,geoset._colors,_numcolors);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_colors = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
_texture_binding = geoset._texture_binding;
|
||||||
|
_numtcoords = geoset._numtcoords;
|
||||||
|
_tindex = geoset._tindex;
|
||||||
|
if (geoset._tcoords)
|
||||||
|
{
|
||||||
|
_tcoords = new Vec2 [_numtcoords];
|
||||||
|
memcpy(_tcoords,geoset._tcoords,_numtcoords);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_tcoords = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
_iaindex = geoset._iaindex;
|
||||||
|
_iaformat = geoset._iaformat;
|
||||||
|
_ogliaformat = geoset._ogliaformat;
|
||||||
|
_fast_path = geoset._fast_path;
|
||||||
|
if (geoset._iarray)
|
||||||
|
{
|
||||||
|
_iarray = 0L;
|
||||||
|
osg::notify(osg::WARN)<<"Warning :: GeoSet copy constructor error, copying of interleaved arrays unsupported."<<endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_iarray = 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define INDEX_ARRAY_DELETE(A) if (A._is_ushort) ushortList.insert(A._ptr._ushort); else uintList.insert(A._ptr._uint);
|
#define INDEX_ARRAY_DELETE(A) if (A._is_ushort) ushortList.insert(A._ptr._ushort); else uintList.insert(A._ptr._uint);
|
||||||
|
|
||||||
void GeoSet::AttributeDeleteFunctor::operator() (GeoSet* gset)
|
void GeoSet::AttributeDeleteFunctor::operator() (GeoSet* gset)
|
||||||
|
@ -10,6 +10,17 @@ Geode::Geode()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Geode::Geode(const Geode& geode,const Cloner& cloner):
|
||||||
|
Node(geode,cloner)
|
||||||
|
{
|
||||||
|
for(DrawableList::const_iterator itr=geode._drawables.begin();
|
||||||
|
itr!=geode._drawables.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
Drawable* drawable = cloner(itr->get());
|
||||||
|
if (drawable) _drawables.push_back(drawable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Geode::~Geode()
|
Geode::~Geode()
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,17 @@ Group::Group()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Group::Group(const Group& group,const Cloner& cloner):
|
||||||
|
Node(group,cloner)
|
||||||
|
{
|
||||||
|
for(ChildList::const_iterator itr=group._children.begin();
|
||||||
|
itr!=group._children.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
Node* child = cloner(itr->get());
|
||||||
|
if (child) _children.push_back(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Group::~Group()
|
Group::~Group()
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,30 @@ Image::Image()
|
|||||||
_modifiedTag = 0;
|
_modifiedTag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Image::Image(const Image& image,const Cloner& cloner):
|
||||||
|
Object(image,cloner),
|
||||||
|
_fileName(image._fileName),
|
||||||
|
_s(image._s), _t(image._t), _r(image._r),
|
||||||
|
_internalFormat(image._internalFormat),
|
||||||
|
_pixelFormat(image._pixelFormat),
|
||||||
|
_dataType(image._dataType),
|
||||||
|
_packing(image._packing),
|
||||||
|
_data(0L),
|
||||||
|
_modifiedTag(image._modifiedTag)
|
||||||
|
{
|
||||||
|
if (image._data)
|
||||||
|
{
|
||||||
|
int num_components =
|
||||||
|
_pixelFormat == GL_LUMINANCE ? 1 :
|
||||||
|
_pixelFormat == GL_LUMINANCE_ALPHA ? 2 :
|
||||||
|
_pixelFormat == GL_RGB ? 3 :
|
||||||
|
_pixelFormat == GL_RGBA ? 4 : 4;
|
||||||
|
|
||||||
|
int size = _s*_t*_r*num_components;
|
||||||
|
_data = (unsigned char*) malloc(size);
|
||||||
|
memcpy(_data,image._data,size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Image::~Image()
|
Image::~Image()
|
||||||
{
|
{
|
||||||
|
@ -29,12 +29,9 @@ ImpostorSprite::ImpostorSprite()
|
|||||||
|
|
||||||
_texture = NULL;
|
_texture = NULL;
|
||||||
_s = 0;
|
_s = 0;
|
||||||
_t = 0;
|
_t = 0;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ImpostorSprite::~ImpostorSprite()
|
ImpostorSprite::~ImpostorSprite()
|
||||||
{
|
{
|
||||||
if (_ism)
|
if (_ism)
|
||||||
|
@ -4,6 +4,15 @@
|
|||||||
|
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
|
|
||||||
|
LOD::LOD(const LOD& lod,const Cloner& cloner):
|
||||||
|
Group(lod,cloner),
|
||||||
|
_rangeList(lod._rangeList),
|
||||||
|
_rangeList2(lod._rangeList2),
|
||||||
|
_center(lod._center)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LOD::traverse(NodeVisitor& nv)
|
void LOD::traverse(NodeVisitor& nv)
|
||||||
{
|
{
|
||||||
switch(nv.getTraversalMode())
|
switch(nv.getTraversalMode())
|
||||||
|
@ -77,6 +77,7 @@ TARGET_INCLUDE_FILES = \
|
|||||||
osg/ColorMatrix\
|
osg/ColorMatrix\
|
||||||
osg/CullFace\
|
osg/CullFace\
|
||||||
osg/Depth\
|
osg/Depth\
|
||||||
|
osg/DeepCopy\
|
||||||
osg/DisplaySettings\
|
osg/DisplaySettings\
|
||||||
osg/Drawable\
|
osg/Drawable\
|
||||||
osg/EarthSky\
|
osg/EarthSky\
|
||||||
@ -113,6 +114,7 @@ TARGET_INCLUDE_FILES = \
|
|||||||
osg/Plane\
|
osg/Plane\
|
||||||
osg/Quat\
|
osg/Quat\
|
||||||
osg/Referenced\
|
osg/Referenced\
|
||||||
|
osg/ShallowCopy\
|
||||||
osg/State\
|
osg/State\
|
||||||
osg/StateAttribute\
|
osg/StateAttribute\
|
||||||
osg/StateSet\
|
osg/StateSet\
|
||||||
|
@ -26,7 +26,7 @@ using namespace osg;
|
|||||||
|
|
||||||
Matrix::Matrix() : Object(), fully_realized(false) {}
|
Matrix::Matrix() : Object(), fully_realized(false) {}
|
||||||
|
|
||||||
Matrix::Matrix( const Matrix& other ) : Object()
|
Matrix::Matrix( const Matrix& other) : Object()
|
||||||
{
|
{
|
||||||
set( (const float *) other._mat );
|
set( (const float *) other._mat );
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,22 @@ Node::Node()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node::Node(const Node& node,const Cloner& cloner):
|
||||||
|
Object(node,cloner),
|
||||||
|
_bsphere(_bsphere),
|
||||||
|
_bsphere_computed(node._bsphere_computed),
|
||||||
|
_name(node._name),
|
||||||
|
_parents(), // leave empty as parentList is managed by Group.
|
||||||
|
_appCallback(node._appCallback),
|
||||||
|
_numChildrenRequiringAppTraversal(node._numChildrenRequiringAppTraversal),
|
||||||
|
_cullingActive(node._cullingActive),
|
||||||
|
_numChildrenWithCullingDisabled(node._numChildrenWithCullingDisabled),
|
||||||
|
_userData(cloner(node._userData.get())),
|
||||||
|
_nodeMask(node._nodeMask),
|
||||||
|
_descriptions(node._descriptions),
|
||||||
|
_dstate(cloner(node._dstate.get()))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Node::~Node()
|
Node::~Node()
|
||||||
{
|
{
|
||||||
|
@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
|
|
||||||
// no non inline functions yet for Object...
|
Object::Object(const Object&,const Cloner&):
|
||||||
|
Referenced() {}
|
||||||
|
@ -21,8 +21,11 @@ StateSet::StateSet()
|
|||||||
setRendingBinToInherit();
|
setRendingBinToInherit();
|
||||||
}
|
}
|
||||||
|
|
||||||
StateSet::StateSet(const StateSet& rhs):Object()
|
StateSet::StateSet(const StateSet& rhs,const Cloner& cloner):Object(rhs,cloner)
|
||||||
{
|
{
|
||||||
|
// shallow copy right now, we should go through each attribute and
|
||||||
|
// use the cloner instead of attribute list copy.. on the TODO list. Robert. Jan 2002.
|
||||||
|
|
||||||
_modeList = rhs._modeList;
|
_modeList = rhs._modeList;
|
||||||
_attributeList = rhs._attributeList;
|
_attributeList = rhs._attributeList;
|
||||||
|
|
||||||
|
@ -13,6 +13,11 @@ Switch::Switch()
|
|||||||
_value = ALL_CHILDREN_OFF;
|
_value = ALL_CHILDREN_OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Switch::Switch(const Switch& sw,const Cloner& cloner):
|
||||||
|
Group(sw,cloner),
|
||||||
|
_value(sw._value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Switch::traverse(NodeVisitor& nv)
|
void Switch::traverse(NodeVisitor& nv)
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,16 @@ Transform::Transform()
|
|||||||
_worldToLocalDirty = false;
|
_worldToLocalDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Transform::Transform(const Transform& transform,const Cloner& cloner):
|
||||||
|
Group(transform,cloner),
|
||||||
|
_type(transform._type),
|
||||||
|
_mode(transform._mode),
|
||||||
|
_localToWorldDirty(transform._localToWorldDirty),
|
||||||
|
_localToWorld(transform._localToWorld),
|
||||||
|
_worldToLocalDirty(transform._worldToLocalDirty),
|
||||||
|
_worldToLocal(transform._localToWorld)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Transform::Transform(const Matrix& mat )
|
Transform::Transform(const Matrix& mat )
|
||||||
{
|
{
|
||||||
|
@ -328,7 +328,7 @@ osg::Object* Registry::readObjectOfType(const osg::Object& compObj,Input& fr)
|
|||||||
fr+=2;
|
fr+=2;
|
||||||
|
|
||||||
const DotOsgWrapper::Associates& assoc = wrapper->getAssociates();
|
const DotOsgWrapper::Associates& assoc = wrapper->getAssociates();
|
||||||
osg::Object* obj = proto->clone();
|
osg::Object* obj = proto->cloneType();
|
||||||
|
|
||||||
while(!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
while(!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||||
{
|
{
|
||||||
@ -396,7 +396,7 @@ osg::Object* Registry::readObject(DotOsgWrapperMap& dowMap,Input& fr)
|
|||||||
fr+=2;
|
fr+=2;
|
||||||
|
|
||||||
const DotOsgWrapper::Associates& assoc = wrapper->getAssociates();
|
const DotOsgWrapper::Associates& assoc = wrapper->getAssociates();
|
||||||
osg::Object* obj = proto->clone();
|
osg::Object* obj = proto->cloneType();
|
||||||
|
|
||||||
while(!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
while(!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||||
{
|
{
|
||||||
|
@ -96,8 +96,8 @@ open(const std::string& font)
|
|||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
std::string filename = findFontFile(font);
|
std::string filename = findFontFile(font);
|
||||||
if (filename.empty()) return false;
|
if (filename.empty()) return false;
|
||||||
|
|
||||||
_font=createFontObj();
|
_font=createFontObj();
|
||||||
if( _font!=NULL && _font->Open(filename.c_str()) )
|
if( _font!=NULL && _font->Open(filename.c_str()) )
|
||||||
@ -110,9 +110,10 @@ open(const std::string& font)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Font::
|
bool Font::open(const char* font)
|
||||||
open(const char* font)
|
{
|
||||||
{ return open(std::string(font)); }
|
return open(std::string(font));
|
||||||
|
}
|
||||||
|
|
||||||
bool Font::
|
bool Font::
|
||||||
create(osg::State& state,int pointSize,const unsigned int res)
|
create(osg::State& state,int pointSize,const unsigned int res)
|
||||||
@ -123,8 +124,7 @@ create(osg::State& state,int pointSize,const unsigned int res)
|
|||||||
return create(state);
|
return create(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Font::
|
bool Font::create(osg::State& state)
|
||||||
create(osg::State& state)
|
|
||||||
{
|
{
|
||||||
if(_init)
|
if(_init)
|
||||||
{
|
{
|
||||||
@ -143,8 +143,7 @@ create(osg::State& state)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::
|
void Font::output(osg::State& state,const char* text)
|
||||||
output(osg::State& state,const char* text)
|
|
||||||
{
|
{
|
||||||
if(_created)
|
if(_created)
|
||||||
_font->render(text,state.getContextID());
|
_font->render(text,state.getContextID());
|
||||||
@ -152,8 +151,7 @@ output(osg::State& state,const char* text)
|
|||||||
create(state,_pointSize);
|
create(state,_pointSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::
|
void Font::clear()
|
||||||
clear()
|
|
||||||
{
|
{
|
||||||
_init=false;
|
_init=false;
|
||||||
|
|
||||||
|
@ -8,6 +8,16 @@ Paragraph::Paragraph()
|
|||||||
_maxCharsPerLine = 80;
|
_maxCharsPerLine = 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Paragraph::Paragraph(const Paragraph& paragraph,const osg::Cloner& cloner):
|
||||||
|
Geode(paragraph,cloner),
|
||||||
|
_position(paragraph._position),
|
||||||
|
_text(paragraph._text),
|
||||||
|
_font(dynamic_cast<Font*>(cloner(paragraph._font.get()))),
|
||||||
|
_alignment(paragraph._alignment),
|
||||||
|
_maxCharsPerLine(paragraph._maxCharsPerLine)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Paragraph::Paragraph(const osg::Vec3& position,const std::string& text,osgText::Font* font)
|
Paragraph::Paragraph(const osg::Vec3& position,const std::string& text,osgText::Font* font)
|
||||||
{
|
{
|
||||||
_maxCharsPerLine = 80;
|
_maxCharsPerLine = 80;
|
||||||
|
@ -30,14 +30,27 @@ using namespace osgText;
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Text
|
// Text
|
||||||
Text::
|
Text::Text()
|
||||||
Text()
|
|
||||||
{
|
{
|
||||||
setDefaults();
|
setDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
Text::
|
Text::Text(const Text& text,const osg::Cloner& cloner):
|
||||||
Text(Font* font)
|
Drawable(text,cloner),
|
||||||
|
_font(dynamic_cast<Font*>(cloner(text._font.get()))),
|
||||||
|
_init(text._init),
|
||||||
|
_initAlignment(text._initAlignment),
|
||||||
|
_text(text._text),
|
||||||
|
_fontType(text._fontType),
|
||||||
|
_alignment(text._alignment),
|
||||||
|
_drawMode(text._drawMode),
|
||||||
|
_boundingBoxType(text._boundingBoxType),
|
||||||
|
_pos(text._pos),
|
||||||
|
_alignmentPos(text._alignmentPos)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Text::Text(Font* font)
|
||||||
{
|
{
|
||||||
setDefaults();
|
setDefaults();
|
||||||
|
|
||||||
@ -60,8 +73,8 @@ Text(Font* font)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text::
|
|
||||||
~Text()
|
Text::~Text()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,7 +553,12 @@ void Optimizer::RemoveRedundentNodesVisitor::apply(osg::Group& group)
|
|||||||
{
|
{
|
||||||
if (group.getNumParents()>0 && group.getNumChildren()<=1)
|
if (group.getNumParents()>0 && group.getNumChildren()<=1)
|
||||||
{
|
{
|
||||||
_redundentNodeList.insert(&group);
|
if (!group.getUserData() &&
|
||||||
|
!group.getAppCallback() &&
|
||||||
|
!group.getStateSet())
|
||||||
|
{
|
||||||
|
_redundentNodeList.insert(&group);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
traverse(group);
|
traverse(group);
|
||||||
|
@ -29,7 +29,7 @@ RenderBin* RenderBin::createRenderBin(const std::string& binName)
|
|||||||
// cout << "creating RB "<<binName<<std::endl;
|
// cout << "creating RB "<<binName<<std::endl;
|
||||||
|
|
||||||
RenderBinPrototypeList::iterator itr = renderBinPrototypeList()->find(binName);
|
RenderBinPrototypeList::iterator itr = renderBinPrototypeList()->find(binName);
|
||||||
if (itr != renderBinPrototypeList()->end()) return dynamic_cast<RenderBin*>(itr->second->clone());
|
if (itr != renderBinPrototypeList()->end()) return dynamic_cast<RenderBin*>(itr->second->cloneType());
|
||||||
else return NULL;
|
else return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user