From a0ba625cb0cd5395d7f018f783fe7242e45e1535 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 17 Dec 2004 01:06:33 +0000 Subject: [PATCH] Property API clean to smooth the task of generating wrappers. --- examples/osgreflect/osgreflect.cpp | 2 +- include/osg/AnimationPath | 21 +++++++-- include/osg/ClipNode | 9 ++-- include/osg/ClipPlane | 30 ++++++------ include/osg/ColorMask | 4 ++ include/osg/ConvexPlanarOccluder | 8 ++-- include/osg/ConvexPlanarPolygon | 2 + include/osg/CullingSet | 1 + include/osg/Depth | 9 ++-- include/osg/DrawPixels | 9 ++-- include/osg/FragmentProgram | 4 +- include/osg/FrontFace | 2 +- include/osg/Image | 30 +++++++----- include/osg/Impostor | 11 ++--- include/osg/ImpostorSprite | 2 +- include/osg/LOD | 3 ++ include/osg/Multisample | 4 ++ include/osg/Node | 3 ++ include/osg/NodeCallback | 1 + include/osg/PolygonMode | 30 ++++++------ include/osg/Shape | 10 ++-- include/osg/StateSet | 27 +++++++++-- include/osg/Switch | 21 +-------- include/osg/VertexProgram | 4 +- src/osg/AnimationPath.cpp | 12 ++--- src/osg/ClipPlane.cpp | 62 +------------------------ src/osg/PolygonMode.cpp | 6 +-- src/osg/ShapeDrawable.cpp | 28 +++++------ src/osgPlugins/dds/ReaderWriterDDS.cpp | 14 +++--- src/osgPlugins/ive/AnimationPath.cpp | 6 +-- src/osgPlugins/ive/ClipPlane.cpp | 21 +-------- src/osgPlugins/ive/DataInputStream.cpp | 33 +++++++++++++ src/osgPlugins/ive/DataInputStream.h | 6 +++ src/osgPlugins/ive/DataOutputStream.cpp | 24 ++++++++++ src/osgPlugins/ive/DataOutputStream.h | 3 ++ src/osgPlugins/osg/AnimationPath.cpp | 8 +--- src/osgPlugins/osg/ClipPlane.cpp | 6 +-- src/osgPlugins/txp/TXPParser.cpp | 4 +- src/osgUtil/CullVisitor.cpp | 2 +- 39 files changed, 253 insertions(+), 229 deletions(-) diff --git a/examples/osgreflect/osgreflect.cpp b/examples/osgreflect/osgreflect.cpp index df961b824..5f61749ce 100644 --- a/examples/osgreflect/osgreflect.cpp +++ b/examples/osgreflect/osgreflect.cpp @@ -243,7 +243,7 @@ osg::Node* createMirroredScene(osg::Node* model) // poke through the mirror. However, this clip plane should really // flip sides once the eye point goes to the back of the mirror... osg::ClipPlane* clipplane = new osg::ClipPlane; - clipplane->setClipPlane(osg::Vec4(0.0f,0.0f,-1.0f,z)); + clipplane->setClipPlane(0.0,0.0,-1.0,z); clipplane->setClipPlaneNum(0); osg::ClipNode* clipNode = new osg::ClipNode; diff --git a/include/osg/AnimationPath b/include/osg/AnimationPath index 852c4a8b3..eb777369f 100644 --- a/include/osg/AnimationPath +++ b/include/osg/AnimationPath @@ -43,8 +43,9 @@ class SG_EXPORT AnimationPath : public virtual osg::Object META_Object(osg,AnimationPath); - struct ControlPoint + class ControlPoint { + public: ControlPoint(): _scale(1.0,1.0,1.0) {} @@ -63,10 +64,14 @@ class SG_EXPORT AnimationPath : public virtual osg::Object _rotation(rotation), _scale(scale) {} - osg::Vec3d _position; - osg::Quat _rotation; - osg::Vec3d _scale; + void setPosition(const osg::Vec3d& position) { _position = position; } + const osg::Vec3d& getPosition() const { return _position; } + void setRotation(const osg::Quat& rotation) { _rotation = rotation; } + const osg::Quat& getRotation() const { return _rotation; } + + void setScale(const osg::Vec3d& scale) { _scale = scale; } + const osg::Vec3d& getScale() const { return _scale; } inline void interpolate(float ratio,const ControlPoint& first, const ControlPoint& second) { @@ -103,6 +108,14 @@ class SG_EXPORT AnimationPath : public virtual osg::Object matrix.preMult(osg::Matrixd::rotate(_rotation.inverse())); matrix.preMult(osg::Matrixd::translate(-_position)); } + + #ifdef USE_DEPRECATED_API + protected: +#endif + osg::Vec3d _position; + osg::Quat _rotation; + osg::Vec3d _scale; + }; diff --git a/include/osg/ClipNode b/include/osg/ClipNode index 6de0156c7..e214c98da 100644 --- a/include/osg/ClipNode +++ b/include/osg/ClipNode @@ -39,15 +39,15 @@ class SG_EXPORT ClipNode : public Group /** Adds the clipplane. Returns true on success, and false if the plane - * has already been added, or if clipplane is NULL. */ + * has already been added, or if clipplane is NULL. */ bool addClipPlane(ClipPlane* clipplane); /** Removes the clipplane. Returns true on success, false if clipplane - * isn't in this ClipNode.*/ + * isn't in this ClipNode.*/ bool removeClipPlane(ClipPlane* clipplane); /** Remove the ClipPlane with the given index. Returns true on success, - * false if pos is not a valid plane index. */ + * false if pos is not a valid plane index. */ bool removeClipPlane(unsigned int pos); /** Returns the number of ClipPlanes. */ @@ -60,6 +60,9 @@ class SG_EXPORT ClipNode : public Group /** Get const ClipPlane at the given index position. */ inline const ClipPlane* getClipPlane(unsigned int pos) const { return _planes[pos].get(); } + /** Set the ClipPlaneList. */ + inline void getClipPlaneList(const ClipPlaneList& cpl) { _planes=cpl; } + /** Get the ClipPlaneList. */ inline ClipPlaneList& getClipPlaneList() { return _planes; } diff --git a/include/osg/ClipPlane b/include/osg/ClipPlane index a943bcdf9..c7d96524d 100644 --- a/include/osg/ClipPlane +++ b/include/osg/ClipPlane @@ -14,6 +14,7 @@ #ifndef OSG_CLIPPLANE #define OSG_CLIPPLANE 1 +#include #include #include @@ -26,7 +27,7 @@ class SG_EXPORT ClipPlane : public StateAttribute public : ClipPlane(); - inline ClipPlane(unsigned int no,const Vec4& plane) { setClipPlaneNum(no); setClipPlane(plane); } + inline ClipPlane(unsigned int no,const Vec4d& plane) { setClipPlaneNum(no); setClipPlane(plane); } inline ClipPlane(unsigned int no,const Plane& plane) { setClipPlaneNum(no); setClipPlane(plane); } inline ClipPlane(unsigned int no,double a,double b,double c,double d) { setClipPlaneNum(no); setClipPlane(a,b,c,d); } @@ -69,29 +70,24 @@ class SG_EXPORT ClipPlane : public StateAttribute } - /** Defines the clip plane with the given Vec4. */ - void setClipPlane(const Vec4& plane); - - /** Defines this plane with the given Plane. */ - void setClipPlane(const Plane& plane); - - /** Defines the clip plane with the given double[4]. */ - void setClipPlane(const double* plane); + /** Set the clip plane with the given Plane. */ + void setClipPlane(const Plane& plane) + { + _clipPlane.set(plane[0],plane[1],plane[2],plane[3]); + } /** Defines the plane as [ a b c d ]. */ void setClipPlane(double a,double b,double c,double d) { - _clipPlane[0]=a;_clipPlane[1]=b;_clipPlane[2]=c;_clipPlane[3]=d; + _clipPlane.set(a,b,c,d); } - /** Gets the clip plane as a Vec4. */ - void getClipPlane(Vec4& plane) const; + /** Set the clip plane with the given Vec4. */ + inline void setClipPlane(const Vec4d& plane) { _clipPlane = plane; } - /** Gets the clip plane as a Plane. */ - void getClipPlane(Plane& plane) const; + /** Gets the clip plane as a Vec4d. */ + const Vec4d& getClipPlane() const { return _clipPlane; } - /** Gets the clip plane as an array of doubles. */ - void getClipPlane(double* plane) const; /** Sets the clip plane number. */ void setClipPlaneNum(unsigned int num); @@ -106,7 +102,7 @@ class SG_EXPORT ClipPlane : public StateAttribute virtual ~ClipPlane(); - double _clipPlane[4]; + Vec4d _clipPlane; unsigned int _clipPlaneNum; }; diff --git a/include/osg/ColorMask b/include/osg/ColorMask index b1d7130a1..9b9fa8631 100644 --- a/include/osg/ColorMask +++ b/include/osg/ColorMask @@ -70,12 +70,16 @@ class SG_EXPORT ColorMask : public StateAttribute } + inline void getRedMask(bool mask) { _red=mask; } inline bool getRedMask() const { return _red; } + inline void setGreenMask(bool mask) { _green=mask; } inline bool getGreenMask() const { return _green; } + inline void setBlueMask(bool mask) { _blue=mask; } inline bool getBlueMask() const { return _blue; } + inline void setAlphaMask(bool mask) { _alpha=mask; } inline bool getAlphaMask() const { return _alpha; } virtual void apply(State& state) const; diff --git a/include/osg/ConvexPlanarOccluder b/include/osg/ConvexPlanarOccluder index e09e910e6..f0db47fb3 100644 --- a/include/osg/ConvexPlanarOccluder +++ b/include/osg/ConvexPlanarOccluder @@ -39,7 +39,7 @@ class SG_EXPORT ConvexPlanarOccluder : public Object void setOccluder(const ConvexPlanarPolygon& cpp) { _occluder = cpp; } ConvexPlanarPolygon& getOccluder() { return _occluder; } - + const ConvexPlanarPolygon& getOccluder() const { return _occluder; } @@ -48,9 +48,11 @@ class SG_EXPORT ConvexPlanarOccluder : public Object void addHole(const ConvexPlanarPolygon& cpp) { _holeList.push_back(cpp); } - HoleList& getHoleList() { return _holeList; } + void setHoleList(const HoleList& holeList) { _holeList=holeList; } - const HoleList& getHoleList() const { return _holeList; } + HoleList& getHoleList() { return _holeList; } + + const HoleList& getHoleList() const { return _holeList; } protected: diff --git a/include/osg/ConvexPlanarPolygon b/include/osg/ConvexPlanarPolygon index 89a1e3d4b..dc0a56d25 100644 --- a/include/osg/ConvexPlanarPolygon +++ b/include/osg/ConvexPlanarPolygon @@ -36,6 +36,8 @@ class SG_EXPORT ConvexPlanarPolygon void add(const Vec3& v) { _vertexList.push_back(v); } + void setVertexList(const VertexList& vertexList) { _vertexList=vertexList; } + VertexList& getVertexList() { return _vertexList; } const VertexList& getVertexList() const { return _vertexList; } diff --git a/include/osg/CullingSet b/include/osg/CullingSet index 076aec3b0..a226133ed 100644 --- a/include/osg/CullingSet +++ b/include/osg/CullingSet @@ -123,6 +123,7 @@ class SG_EXPORT CullingSet : public Referenced }; void setCullingMask(Mask mask) { _mask = mask; } + Mask getCullingMask() const { return _mask; } void setFrustum(Polytope& cv) { _frustum = cv; } diff --git a/include/osg/Depth b/include/osg/Depth index 60035e334..5304416fa 100644 --- a/include/osg/Depth +++ b/include/osg/Depth @@ -73,8 +73,7 @@ class SG_EXPORT Depth : public StateAttribute return true; } - inline void setFunction(Function func) { _func = func; } - + inline void setFunction(Function func) { _func = func; } inline Function getFunction() const { return _func; } @@ -84,11 +83,13 @@ class SG_EXPORT Depth : public StateAttribute _zFar = zFar; } + inline void setZNear(double zNear) { _zNear=zNear; } inline double getZNear() const { return _zNear; } + + inline void setZFar(double zFar) { _zFar=zFar; } inline double getZFar() const { return _zFar; } - inline void setWriteMask(bool mask) { _depthWriteMask = mask; } - + inline void setWriteMask(bool mask) { _depthWriteMask = mask; } inline bool getWriteMask() const { return _depthWriteMask; } diff --git a/include/osg/DrawPixels b/include/osg/DrawPixels index c5463e86b..110d95ea1 100644 --- a/include/osg/DrawPixels +++ b/include/osg/DrawPixels @@ -51,14 +51,11 @@ class SG_EXPORT DrawPixels : public Drawable osg::Image* getImage() { return _image.get(); } const osg::Image* getImage() const { return _image.get(); } - void setUseCompleteImage() { _useSubImage = false; } - - void setSubImageDimensions(unsigned int offsetX,unsigned int offsetY,unsigned int width,unsigned int height); - - void getSubImageDimensions(unsigned int& offsetX,unsigned int& offsetY,unsigned int& width,unsigned int& height) const; - + void setUseSubImage(bool useSubImage) { _useSubImage=useSubImage; } bool getUseSubImage() const { return _useSubImage; } + void setSubImageDimensions(unsigned int offsetX,unsigned int offsetY,unsigned int width,unsigned int height); + void getSubImageDimensions(unsigned int& offsetX,unsigned int& offsetY,unsigned int& width,unsigned int& height) const; virtual void drawImplementation(State& state) const; diff --git a/include/osg/FragmentProgram b/include/osg/FragmentProgram index 299faf711..f5e6a4e5a 100644 --- a/include/osg/FragmentProgram +++ b/include/osg/FragmentProgram @@ -177,7 +177,7 @@ class SG_EXPORT FragmentProgram : public StateAttribute typedef std::map LocalParamList; /** Set list of Program Parameters */ - inline void setLocalParameters(LocalParamList& lpl) { _programLocalParameters = lpl; } + inline void setLocalParameters(const LocalParamList& lpl) { _programLocalParameters = lpl; } /** Get list of Program Parameters */ inline LocalParamList& getLocalParameters() { return _programLocalParameters; } @@ -194,7 +194,7 @@ class SG_EXPORT FragmentProgram : public StateAttribute typedef std::map MatrixList; /** Set list of Matrices */ - inline void setMatrices(MatrixList& matrices) { _matrixList = matrices; } + inline void setMatrices(const MatrixList& matrices) { _matrixList = matrices; } /** Get list of Matrices */ inline MatrixList& getMatrices() { return _matrixList; } diff --git a/include/osg/FrontFace b/include/osg/FrontFace index 3f5789a72..ba2c1b739 100644 --- a/include/osg/FrontFace +++ b/include/osg/FrontFace @@ -53,7 +53,7 @@ class SG_EXPORT FrontFace : public StateAttribute }; inline void setMode(Mode mode) { _mode = mode; } - inline const Mode getMode() const { return _mode; } + inline Mode getMode() const { return _mode; } virtual void apply(State& state) const; diff --git a/include/osg/Image b/include/osg/Image index 820a3c0e1..45472f075 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -224,20 +224,28 @@ class SG_EXPORT Image : public Object }; /** Send offsets into data. It is assumed that first mipmap offset (index 0) is 0.*/ - inline void setMipmapData(const MipmapDataType& mipmapDataVector) + inline void setMipmapLevels(const MipmapDataType& mipmapDataVector) { _mipmapData = mipmapDataVector; } + + inline const MipmapDataType& getMipmapLevels() const { return _mipmapData; } + + inline unsigned int getMipmapOffset(unsigned int mipmapLevel) const { - _mipmapData = mipmapDataVector; - }; - - inline unsigned char* getMipmapData(unsigned int mipmapNumber) const - { - if(mipmapNumber == 0) - return _data; - else if(mipmapNumber < getNumMipmapLevels()) - return _data + _mipmapData[mipmapNumber-1]; - return 0L; + if(mipmapLevel == 0) + return 0; + else if (mipmapLevel < getNumMipmapLevels()) + return _mipmapData[mipmapLevel-1]; + return 0; }; + inline unsigned char* getMipmapData(unsigned int mipmapLevel) + { + return _data+getMipmapOffset(mipmapLevel); + } + + inline const unsigned char* getMipmapData(unsigned int mipmapLevel) const + { + return _data+getMipmapOffset(mipmapLevel); + } /** Return true if this image is translucent - i.e. it has alpha values that are less 1.0 (when normalized). */ bool isImageTranslucent() const; diff --git a/include/osg/Impostor b/include/osg/Impostor index 516a1d0c6..5f17ba50d 100644 --- a/include/osg/Impostor +++ b/include/osg/Impostor @@ -77,16 +77,13 @@ class SG_EXPORT Impostor : public LOD */ inline void setImpostorThreshold(float distance) { _impostorThreshold = distance; } - /** Set the Impostor threshold distance relative to the node's bounding - * sphere's radius. - */ - inline void setImpostorThresholdToBound(float ratio=1.0f) { _impostorThreshold = getBound().radius()*ratio; } - /* Get the Impostor threshold distance. */ inline float getImpostorThreshold() const { return _impostorThreshold; } - /* Get the Impostor threshold distance squared. */ - inline float getImpostorThreshold2() const { return _impostorThreshold*_impostorThreshold; } + /** Set the Impostor threshold distance relative to the node's bounding + * sphere's radius. + */ + inline void setImpostorThresholdToBound(float ratio=1.0f) { _impostorThreshold = getBound().radius()*ratio; } /** Find the ImposterSprite which fits the current eye point best. */ ImpostorSprite* findBestImpostorSprite(unsigned int contextID, const osg::Vec3& currLocalEyePoint) const; diff --git a/include/osg/ImpostorSprite b/include/osg/ImpostorSprite index 6ca3d6524..28e80718b 100644 --- a/include/osg/ImpostorSprite +++ b/include/osg/ImpostorSprite @@ -117,9 +117,9 @@ class SG_EXPORT ImpostorSprite : public Drawable float calcPixelError(const Matrix& MVPW) const; void setTexture(Texture2D* tex,int s,int t); - Texture2D* getTexture() { return _texture; } const Texture2D* getTexture() const { return _texture; } + int s() const { return _s; } int t() const { return _t; } diff --git a/include/osg/LOD b/include/osg/LOD index f9c7fa296..97d50c732 100644 --- a/include/osg/LOD +++ b/include/osg/LOD @@ -113,6 +113,9 @@ class SG_EXPORT LOD : public Group * An LOD which has been fully set up will have getNumChildren()==getNumRanges(). */ inline unsigned int getNumRanges() const { return _rangeList.size(); } + /** set the list of MinMax ranges for each child.*/ + inline void setRangeList(const RangeList& rangeList) { _rangeList=rangeList; } + /** return the list of MinMax ranges for each child.*/ inline const RangeList& getRangeList() const { return _rangeList; } diff --git a/include/osg/Multisample b/include/osg/Multisample index 5de751387..0768774d5 100644 --- a/include/osg/Multisample +++ b/include/osg/Multisample @@ -81,10 +81,14 @@ class SG_EXPORT Multisample : public StateAttribute _coverage = coverage; _invert = invert; } + inline void setCoverage(float coverage) { _coverage=coverage; } inline float getCoverage() const { return _coverage; } + + inline void setInvert(bool invert) { _invert=invert; } inline bool getInvert() const { return _invert; } inline void setHint(Mode mode) { _mode = mode; } + inline Mode getHint() const { return _mode; } virtual void apply(State& state) const; diff --git a/include/osg/Node b/include/osg/Node index 24f7d1b55..dd1886276 100644 --- a/include/osg/Node +++ b/include/osg/Node @@ -198,10 +198,13 @@ class SG_EXPORT Node : public Object /** A vector of std::string's which are used to describe the object.*/ typedef std::vector DescriptionList; + /** Set the description list of the const node.*/ + inline void setDescriptions(const DescriptionList& descriptions) { _descriptions=descriptions; } /** Get the description list of the const node.*/ inline const DescriptionList& getDescriptions() const { return _descriptions; } /** Get the description list of the const node.*/ inline DescriptionList& getDescriptions() { return _descriptions; } + /** Get a single const description of the const node.*/ inline const std::string& getDescription(unsigned int i) const { return _descriptions[i]; } /** Get a single description of the node.*/ diff --git a/include/osg/NodeCallback b/include/osg/NodeCallback index 93f4ef8c5..fdc286471 100644 --- a/include/osg/NodeCallback +++ b/include/osg/NodeCallback @@ -50,6 +50,7 @@ class SG_EXPORT NodeCallback : public virtual Object { void setNestedCallback(NodeCallback* nc) { _nestedCallback = nc; } NodeCallback* getNestedCallback() { return _nestedCallback.get(); } + const NodeCallback* getNestedCallback() const { return _nestedCallback.get(); } inline void addNestedCallback(NodeCallback* nc) { diff --git a/include/osg/PolygonMode b/include/osg/PolygonMode index f5eb43995..1991e08e0 100644 --- a/include/osg/PolygonMode +++ b/include/osg/PolygonMode @@ -30,7 +30,6 @@ class SG_EXPORT PolygonMode : public StateAttribute /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ PolygonMode(const PolygonMode& pm,const CopyOp& copyop=CopyOp::SHALLOW_COPY): StateAttribute(pm,copyop), - _frontAndBack(pm._frontAndBack), _modeFront(pm._modeFront), _modeBack(pm._modeBack) {} @@ -44,30 +43,36 @@ class SG_EXPORT PolygonMode : public StateAttribute 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 macros, must be equal. } - enum Face { - FRONT, - BACK, - FRONT_AND_BACK - }; - enum Mode { POINT = GL_POINT, LINE = GL_LINE, FILL = GL_FILL }; +/* + void setFrontAndBackFaceMode(Mode mode) { _modeFront = _modeBack = mode; } + + void setFrontFaceMode(Mode mode) { _modeFront = mode; } + Mode getFrontFaceMode() const { return _modeFront; } - void setMode(Face face,Mode mode); - - Mode getMode(Face face) const; + void setBackFaceMode(Mode mode) { _modeFront = mode; } + Mode getBackFaceMode() const { return _modeBack; } +*/ + enum Face { + FRONT_AND_BACK, + FRONT, + BACK, + }; - inline bool getFrontAndBack() const { return _frontAndBack; } + void setMode(Face face,Mode mode); + Mode getMode(Face face) const; + + inline bool getFrontAndBack() const { return _modeFront==_modeBack; } virtual void apply(State& state) const; @@ -75,7 +80,6 @@ class SG_EXPORT PolygonMode : public StateAttribute virtual ~PolygonMode(); - bool _frontAndBack; Mode _modeFront; Mode _modeBack; diff --git a/include/osg/Shape b/include/osg/Shape index 077b03821..efdfc7046 100644 --- a/include/osg/Shape +++ b/include/osg/Shape @@ -221,7 +221,7 @@ class Box : public Shape inline void setRotation(const Quat& quat) { _rotation = quat; } inline const Quat& getRotation() const { return _rotation; } - inline Matrix getRotationMatrix() const { return Matrix(_rotation); } + inline Matrix computeRotationMatrix() const { return Matrix(_rotation); } inline bool zeroRotation() const { return _rotation.zeroRotation(); } protected: @@ -279,7 +279,7 @@ class Cone : public Shape inline void setRotation(const Quat& quat) { _rotation = quat; } inline const Quat& getRotation() const { return _rotation; } - inline Matrix getRotationMatrix() const { return Matrix(_rotation); } + inline Matrix computeRotationMatrix() const { return Matrix(_rotation); } inline bool zeroRotation() const { return _rotation.zeroRotation(); } inline float getBaseOffsetFactor() const { return 0.25f; } @@ -339,7 +339,7 @@ class Cylinder : public Shape inline void setRotation(const Quat& quat) { _rotation = quat; } inline const Quat& getRotation() const { return _rotation; } - inline Matrix getRotationMatrix() const { return Matrix(_rotation); } + inline Matrix computeRotationMatrix() const { return Matrix(_rotation); } bool zeroRotation() const { return _rotation.zeroRotation(); } protected: @@ -396,7 +396,7 @@ class Capsule : public Shape inline void setRotation(const Quat& quat) { _rotation = quat; } inline const Quat& getRotation() const { return _rotation; } - inline Matrix getRotationMatrix() const { return Matrix(_rotation); } + inline Matrix computeRotationMatrix() const { return Matrix(_rotation); } bool zeroRotation() const { return _rotation.zeroRotation(); } protected: @@ -538,7 +538,7 @@ class SG_EXPORT HeightField : public Shape inline void setRotation(const Quat& quat) { _rotation = quat; } inline const Quat& getRotation() const { return _rotation; } - inline Matrix getRotationMatrix() const { return Matrix(_rotation); } + inline Matrix computeRotationMatrix() const { return Matrix(_rotation); } inline bool zeroRotation() const { return _rotation.zeroRotation(); } /* set a single height point in the height field */ diff --git a/include/osg/StateSet b/include/osg/StateSet index b7b2d1833..34aaba9d0 100644 --- a/include/osg/StateSet +++ b/include/osg/StateSet @@ -92,6 +92,9 @@ class SG_EXPORT StateSet : public Object * returns INHERIT if no GLModeValue is contained within StateSet.*/ StateAttribute::GLModeValue getMode(StateAttribute::GLMode mode) const; + /** set the list of all GLModes contained in this StateSet.*/ + inline void setModeList(ModeList& ml) { _modeList=ml; } + /** return the list of all GLModes contained in this StateSet.*/ inline ModeList& getModeList() { return _modeList; } @@ -135,6 +138,9 @@ class SG_EXPORT StateSet : public Object * Returns NULL if no type is contained within StateSet.*/ const RefAttributePair* getAttributePair(StateAttribute::Type type, unsigned int member = 0) const; + /** set the list of all StateAttributes contained in this StateSet.*/ + inline void setAttributeList(AttributeList& al) { _attributeList=al; } + /** return the list of all StateAttributes contained in this StateSet.*/ inline AttributeList& getAttributeList() { return _attributeList; } @@ -160,6 +166,9 @@ class SG_EXPORT StateSet : public Object * returns INHERIT if no GLModeValue is contained within StateSet.*/ StateAttribute::GLModeValue getTextureMode(unsigned int unit,StateAttribute::GLMode mode) const; + /** set the list of all Texture related GLModes contained in this StateSet.*/ + inline void setTextureModeList(TextureModeList& tml) { _textureModeList=tml; } + /** return the list of all Texture related GLModes contained in this StateSet.*/ inline TextureModeList& getTextureModeList() { return _textureModeList; } @@ -198,6 +207,9 @@ class SG_EXPORT StateSet : public Object * Returns NULL if no type is contained within StateSet.*/ const RefAttributePair* getTextureAttributePair(unsigned int unit,StateAttribute::Type type) const; + /** Set the list of all Texture related StateAttributes contained in this StateSet.*/ + inline void setTextureAttributeList(TextureAttributeList& tal) { _textureAttributeList=tal; } + /** Return the list of all Texture related StateAttributes contained in this StateSet.*/ inline TextureAttributeList& getTextureAttributeList() { return _textureAttributeList; } @@ -240,15 +252,24 @@ class SG_EXPORT StateSet : public Object /** Set the render bin details to inherit.*/ void setRenderBinToInherit(); - /** Get the render bin mode.*/ - inline RenderBinMode getRenderBinMode() const { return _binMode; } - /** Get whether the render bin details are set and should be used.*/ inline bool useRenderBinDetails() const { return _binMode!=INHERIT_RENDERBIN_DETAILS; } + /** Set the render bin mode.*/ + inline void setRenderBinMode(RenderBinMode mode) { _binMode=mode; } + + /** Get the render bin mode.*/ + inline RenderBinMode getRenderBinMode() const { return _binMode; } + + /** Set the render bin number.*/ + inline void setBinNumber(int num) { _binNum=num; } + /** Get the render bin number.*/ inline int getBinNumber() const { return _binNum; } + /** Set the render bin name.*/ + inline void setBinName(const std::string& name) { _binName=name; } + /** Get the render bin name.*/ inline const std::string& getBinName() const { return _binName; } diff --git a/include/osg/Switch b/include/osg/Switch index 0a2a05945..6f9a1c0f8 100644 --- a/include/osg/Switch +++ b/include/osg/Switch @@ -70,28 +70,11 @@ class SG_EXPORT Switch : public Group /** Set a single child on, switch off all other children. */ bool setSingleChildOn(unsigned int pos); -#ifdef USE_DEPRECATED_API - /** Special values for the Switch. Use these if you want to - * turn on/off all child nodes. */ - enum Values { - /** All children turned on. */ - ALL_CHILDREN_ON=-1, - /** All children off. */ - ALL_CHILDREN_OFF=-2, - /** Multiple children turned on.*/ - MULTIPLE_CHILDREN_ON=-3 - }; - - /** Selects the active child Node or enables a special SwitchType mode. - * @param value the number of the active child (first child == number - * 0) or SwitchType. Invalid values will be ignored. */ - void setValue(int value); - - int getValue() const; -#endif typedef std::vector ValueList; + void setValueList(const ValueList& values) { _values=values; } + const ValueList& getValueList() const { return _values; } protected : diff --git a/include/osg/VertexProgram b/include/osg/VertexProgram index b6c90f73e..d6ceef634 100644 --- a/include/osg/VertexProgram +++ b/include/osg/VertexProgram @@ -177,7 +177,7 @@ class SG_EXPORT VertexProgram : public StateAttribute typedef std::map LocalParamList; /** Set list of Program Parameters */ - inline void setLocalParameters(LocalParamList& lpl) { _programLocalParameters = lpl; } + inline void setLocalParameters(const LocalParamList& lpl) { _programLocalParameters = lpl; } /** Get list of Program Parameters */ inline LocalParamList& getLocalParameters() { return _programLocalParameters; } @@ -194,7 +194,7 @@ class SG_EXPORT VertexProgram : public StateAttribute typedef std::map MatrixList; /** Set list of Matrices */ - inline void setMatrices(MatrixList& matrices) { _matrixList = matrices; } + inline void setMatrices(const MatrixList& matrices) { _matrixList = matrices; } /** Get list of Matrices */ inline MatrixList& getMatrices() { return _matrixList; } diff --git a/src/osg/AnimationPath.cpp b/src/osg/AnimationPath.cpp index e7ef6e09f..4b71dd0bb 100644 --- a/src/osg/AnimationPath.cpp +++ b/src/osg/AnimationPath.cpp @@ -106,7 +106,7 @@ void AnimationPath::write(std::ostream& fout) const ++tcpmitr) { const ControlPoint& cp = tcpmitr->second; - fout<first<<" "<first<<" "<setImage(s,t,r, internalFormat, pixelFormat, dataType, 0, osg::Image::USE_NEW_DELETE); - if (mipmaps.size()>0) osgImage->setMipmapData(mipmaps); + if (mipmaps.size()>0) osgImage->setMipmapLevels(mipmaps); unsigned int size = osgImage->getTotalSizeInBytesIncludingMipmaps(); if(size <= 0) @@ -428,7 +428,7 @@ osg::Image* ReadDDSFile(std::istream& _istream) _istream.read((char*)imageData, size); osgImage->setImage(s,t,r, internalFormat, pixelFormat, dataType, imageData, osg::Image::USE_NEW_DELETE); - if (mipmaps.size()>0) osgImage->setMipmapData(mipmaps); + if (mipmaps.size()>0) osgImage->setMipmapLevels(mipmaps); @@ -463,10 +463,10 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout) // Initialize ddsd structure and its members DDSURFACEDESC2 ddsd; DDPIXELFORMAT ddpf; - DDCOLORKEY ddckCKDestOverlay; - DDCOLORKEY ddckCKDestBlt; - DDCOLORKEY ddckCKSrcOverlay; - DDCOLORKEY ddckCKSrcBlt; + //DDCOLORKEY ddckCKDestOverlay; + //DDCOLORKEY ddckCKDestBlt; + //DDCOLORKEY ddckCKSrcOverlay; + //DDCOLORKEY ddckCKSrcBlt; DDSCAPS2 ddsCaps; ddsd.dwSize = sizeof(ddsd); @@ -647,7 +647,7 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout) if(img->isMipmap()) { dataPtr += imageSize; - unsigned char *mmdPtr, *next_mmdPtr; + const unsigned char *mmdPtr, *next_mmdPtr; int offset; unsigned int mipmaps = img->getNumMipmapLevels(); unsigned int blockSize; diff --git a/src/osgPlugins/ive/AnimationPath.cpp b/src/osgPlugins/ive/AnimationPath.cpp index 1ff14dab8..a8a798927 100644 --- a/src/osgPlugins/ive/AnimationPath.cpp +++ b/src/osgPlugins/ive/AnimationPath.cpp @@ -37,9 +37,9 @@ void AnimationPath::write(DataOutputStream* out){ out->writeInt(tcpm.size()); for(AnimationPath::TimeControlPointMap::iterator itr=tcpm.begin(); itr!=tcpm.end(); ++itr){ out->writeFloat(itr->first); - out->writeVec3(itr->second._position); - out->writeQuat(itr->second._rotation); - out->writeVec3(itr->second._scale); + out->writeVec3(itr->second.getPosition()); + out->writeQuat(itr->second.getRotation()); + out->writeVec3(itr->second.getScale()); } } diff --git a/src/osgPlugins/ive/ClipPlane.cpp b/src/osgPlugins/ive/ClipPlane.cpp index 45ab63e53..f3375e43b 100644 --- a/src/osgPlugins/ive/ClipPlane.cpp +++ b/src/osgPlugins/ive/ClipPlane.cpp @@ -31,16 +31,7 @@ void ClipPlane::write(DataOutputStream* out){ // write ClipPlane's properties - - - - double plane[4]; - getClipPlane(plane); - - out->writeDouble(plane[0]); - out->writeDouble(plane[1]); - out->writeDouble(plane[2]); - out->writeDouble(plane[3]); + out->writeVec4d(getClipPlane()); out->writeUInt(getClipPlaneNum()); @@ -62,15 +53,7 @@ void ClipPlane::read(DataInputStream* in){ else throw Exception("ClipPlane::read(): Could not cast this osg::ClipPlane to an osg::Object."); - // Read ClipPlane's properties - double plane[4]; - - plane[0] = in->readDouble(); - plane[1] = in->readDouble(); - plane[2] = in->readDouble(); - plane[3] = in->readDouble(); - - setClipPlane(plane); + setClipPlane(in->readVec4d()); setClipPlaneNum(in->readUInt()); } diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp index ce7d987f9..b99c1cd20 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -313,6 +313,39 @@ osg::Vec4 DataInputStream::readVec4(){ return v; } +osg::Vec2d DataInputStream::readVec2d() +{ + osg::Vec2d v; + v.x()=readDouble(); + v.y()=readDouble(); + + if (_verboseOutput) std::cout<<"read/writeVec2d() ["< #include #include +#include +#include +#include #include #include #include @@ -54,6 +57,9 @@ public: osg::Vec2 readVec2(); osg::Vec3 readVec3(); osg::Vec4 readVec4(); + osg::Vec2d readVec2d(); + osg::Vec3d readVec3d(); + osg::Vec4d readVec4d(); osg::Plane readPlane(); osg::UByte4 readUByte4(); osg::Quat readQuat(); diff --git a/src/osgPlugins/ive/DataOutputStream.cpp b/src/osgPlugins/ive/DataOutputStream.cpp index ecbdbe0eb..b2e0430ae 100644 --- a/src/osgPlugins/ive/DataOutputStream.cpp +++ b/src/osgPlugins/ive/DataOutputStream.cpp @@ -182,6 +182,30 @@ void DataOutputStream::writeVec4(const osg::Vec4& v){ if (_verboseOutput) std::cout<<"read/writeVec4() ["<insert(time, ctrlPoint); fr+=11; @@ -138,7 +134,7 @@ bool AnimationPath_writeLocalData(const osg::Object &obj, osgDB::Output &fw) itr!=tcpm.end(); ++itr) { - fw.indent() << itr->first << " " << itr->second._position << " " << itr->second._rotation << " " << itr->second._scale << std::endl; + fw.indent() << itr->first << " " << itr->second.getPosition() << " " << itr->second.getRotation() << " " <second.getScale() << std::endl; } diff --git a/src/osgPlugins/osg/ClipPlane.cpp b/src/osgPlugins/osg/ClipPlane.cpp index 5e23ec8cd..9055cba97 100644 --- a/src/osgPlugins/osg/ClipPlane.cpp +++ b/src/osgPlugins/osg/ClipPlane.cpp @@ -50,7 +50,7 @@ bool ClipPlane_readLocalData(Object& obj, Input& fr) fr[2].getFloat(plane[1]); fr[3].getFloat(plane[2]); fr[4].getFloat(plane[3]); - clipplane.setClipPlane(plane); + clipplane.setClipPlane(plane[0],plane[1],plane[2],plane[3]); fr+=5; iteratorAdvanced = true; @@ -66,9 +66,7 @@ bool ClipPlane_writeLocalData(const Object& obj,Output& fw) fw.indent() << "clipPlaneNum " << clipplane.getClipPlaneNum() <MipLevelOffset(k); } - image->setMipmapData(mipmaps); + image->setMipmapLevels(mipmaps); } @@ -1601,7 +1601,7 @@ osg::Texture2D* txp::getTemplateTexture(trpgrImageHelper& image_helper, trpgLoca { mipmaps[k-1] = tmp_tex->MipLevelOffset(k); } - image->setMipmapData(mipmaps); + image->setMipmapLevels(mipmaps); } diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 7a196f801..d8126d217 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -1083,7 +1083,7 @@ void CullVisitor::apply(Impostor& node) float distance2 = (eyeLocal-bs.center()).length2(); if (!_impostorActive || - distance2*_LODScale*_LODScale