diff --git a/VisualStudio/osg/osg.dsp b/VisualStudio/osg/osg.dsp index 44bde1dc5..8ef0e8c39 100755 --- a/VisualStudio/osg/osg.dsp +++ b/VisualStudio/osg/osg.dsp @@ -1000,31 +1000,31 @@ SOURCE=..\..\Include\Osg\UnitTestFramework # End Source File # Begin Source File -SOURCE=..\..\Include\Osg\Byte2 +SOURCE=..\..\Include\Osg\Vec2b # End Source File # Begin Source File -SOURCE=..\..\Include\Osg\Byte3 +SOURCE=..\..\Include\Osg\Vec3b # End Source File # Begin Source File -SOURCE=..\..\Include\Osg\Byte4 +SOURCE=..\..\Include\Osg\Vec4b # End Source File # Begin Source File -SOURCE=..\..\Include\Osg\Short2 +SOURCE=..\..\Include\Osg\Vec2s # End Source File # Begin Source File -SOURCE=..\..\Include\Osg\Short3 +SOURCE=..\..\Include\Osg\Vec3s # End Source File # Begin Source File -SOURCE=..\..\Include\Osg\Short4 +SOURCE=..\..\Include\Osg\Vec4s # End Source File # Begin Source File -SOURCE=..\..\Include\Osg\UByte4 +SOURCE=..\..\Include\Osg\Vec4ub # End Source File # Begin Source File diff --git a/examples/osgbluemarble/osgbluemarble.cpp b/examples/osgbluemarble/osgbluemarble.cpp index 26b577412..700503190 100644 --- a/examples/osgbluemarble/osgbluemarble.cpp +++ b/examples/osgbluemarble/osgbluemarble.cpp @@ -124,7 +124,7 @@ osg::Node* createTile(const std::string& filename, bool leftHemisphere, double x osg::Vec3Array& v = *(new osg::Vec3Array(numColumns*numRows)); osg::Vec3Array& n = *(new osg::Vec3Array(numColumns*numRows)); osg::Vec2Array& t = *(new osg::Vec2Array(numColumns*numRows)); - osg::UByte4Array& color = *(new osg::UByte4Array(1)); + osg::Vec4ubArray& color = *(new osg::Vec4ubArray(1)); color[0].set(255,255,255,255); diff --git a/examples/osgforest/osgforest.cpp b/examples/osgforest/osgforest.cpp index 8b7e242da..6363e7a8d 100644 --- a/examples/osgforest/osgforest.cpp +++ b/examples/osgforest/osgforest.cpp @@ -43,7 +43,7 @@ public: _height(1.0f), _type(0) {} - Tree(const osg::Vec3& position, const osg::UByte4& color, float width, float height, unsigned int type): + Tree(const osg::Vec3& position, const osg::Vec4ub& color, float width, float height, unsigned int type): _position(position), _color(color), _width(width), @@ -51,7 +51,7 @@ public: _type(type) {} osg::Vec3 _position; - osg::UByte4 _color; + osg::Vec4ub _color; float _width; float _height; unsigned int _type; @@ -98,9 +98,9 @@ public: void createTreeList(osg::Node* terrain,const osg::Vec3& origin, const osg::Vec3& size,unsigned int numTreesToCreate,TreeList& trees); - osg::Geometry* createSprite( float w, float h, osg::UByte4 color ); + osg::Geometry* createSprite( float w, float h, osg::Vec4ub color ); - osg::Geometry* createOrthogonalQuads( const osg::Vec3& pos, float w, float h, osg::UByte4 color ); + osg::Geometry* createOrthogonalQuads( const osg::Vec3& pos, float w, float h, osg::Vec4ub color ); osg::Geometry* createOrthogonalQuadsNoColor( const osg::Vec3& pos, float w, float h ); osg::Node* createBillboardGraph(Cell* cell,osg::StateSet* stateset); @@ -409,7 +409,7 @@ osg::Geode* ForestTechniqueManager::createTerrain(const osg::Vec3& origin, const osg::Vec3Array& v = *(new osg::Vec3Array(numColumns*numRows)); osg::Vec2Array& t = *(new osg::Vec2Array(numColumns*numRows)); - osg::UByte4Array& color = *(new osg::UByte4Array(1)); + osg::Vec4ubArray& color = *(new osg::Vec4ubArray(1)); color[0].set(255,255,255,255); @@ -511,12 +511,12 @@ void ForestTechniqueManager::createTreeList(osg::Node* terrain,const osg::Vec3& } } -osg::Geometry* ForestTechniqueManager::createSprite( float w, float h, osg::UByte4 color ) +osg::Geometry* ForestTechniqueManager::createSprite( float w, float h, osg::Vec4ub color ) { // set up the coords osg::Vec3Array& v = *(new osg::Vec3Array(4)); osg::Vec2Array& t = *(new osg::Vec2Array(4)); - osg::UByte4Array& c = *(new osg::UByte4Array(1)); + osg::Vec4ubArray& c = *(new osg::Vec4ubArray(1)); v[0].set(-w*0.5f,0.0f,0.0f); v[1].set( w*0.5f,0.0f,0.0f); @@ -544,12 +544,12 @@ osg::Geometry* ForestTechniqueManager::createSprite( float w, float h, osg::UByt return geom; } -osg::Geometry* ForestTechniqueManager::createOrthogonalQuads( const osg::Vec3& pos, float w, float h, osg::UByte4 color ) +osg::Geometry* ForestTechniqueManager::createOrthogonalQuads( const osg::Vec3& pos, float w, float h, osg::Vec4ub color ) { // set up the coords osg::Vec3Array& v = *(new osg::Vec3Array(8)); osg::Vec2Array& t = *(new osg::Vec2Array(8)); - osg::UByte4Array& c = *(new osg::UByte4Array(1)); + osg::Vec4ubArray& c = *(new osg::Vec4ubArray(1)); float rotation = random(0.0f,osg::PI/2.0f); float sw = sinf(rotation)*w*0.5f; @@ -680,7 +680,7 @@ osg::Node* ForestTechniqueManager::createTransformGraph(Cell* cell,osg::StateSet { transform_group = new osg::Group; - osg::Geometry* geometry = createOrthogonalQuads(osg::Vec3(0.0f,0.0f,0.0f),1.0f,1.0f,osg::UByte4(255,255,255,255)); + osg::Geometry* geometry = createOrthogonalQuads(osg::Vec3(0.0f,0.0f,0.0f),1.0f,1.0f,osg::Vec4ub(255,255,255,255)); for(TreeList::iterator itr=cell->_trees.begin(); itr!=cell->_trees.end(); diff --git a/include/osg/Array b/include/osg/Array index 28352dc33..55d18b4b6 100644 --- a/include/osg/Array +++ b/include/osg/Array @@ -19,13 +19,13 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include @@ -53,17 +53,17 @@ class OSG_EXPORT Array : public Object UByteArrayType = 4, UShortArrayType = 5, UIntArrayType = 6, - UByte4ArrayType = 7, + Vec4ubArrayType = 7, FloatArrayType = 8, Vec2ArrayType = 9, Vec3ArrayType = 10, Vec4ArrayType = 11, - Short2ArrayType = 12, - Short3ArrayType = 13, - Short4ArrayType = 14, - Byte2ArrayType = 15, - Byte3ArrayType = 16, - Byte4ArrayType = 17 + Vec2sArrayType = 12, + Vec3sArrayType = 13, + Vec4sArrayType = 14, + Vec2bArrayType = 15, + Vec3bArrayType = 16, + Vec4bArrayType = 17 }; @@ -266,17 +266,24 @@ typedef TemplateIndexArray typedef TemplateIndexArray UIntArray; typedef TemplateArray FloatArray; -typedef TemplateArray UByte4Array; + typedef TemplateArray Vec2Array; typedef TemplateArray Vec3Array; typedef TemplateArray Vec4Array; -typedef TemplateArray Short2Array; -typedef TemplateArray Short3Array; -typedef TemplateArray Short4Array; -typedef TemplateArray Byte2Array; -typedef TemplateArray Byte3Array; -typedef TemplateArray Byte4Array; +typedef TemplateArray Vec4ubArray; + +#ifdef USE_DEPRECATED_API +typedef Vec4ubArray UByte4Array; +#endif + +typedef TemplateArray Vec2sArray; +typedef TemplateArray Vec3sArray; +typedef TemplateArray Vec4sArray; + +typedef TemplateArray Vec2bArray; +typedef TemplateArray Vec3bArray; +typedef TemplateArray Vec4bArray; class ArrayVisitor @@ -291,18 +298,21 @@ class ArrayVisitor virtual void apply(UByteArray&) {} virtual void apply(UShortArray&) {} virtual void apply(UIntArray&) {} - virtual void apply(UByte4Array&) {} virtual void apply(FloatArray&) {} + virtual void apply(Vec2Array&) {} virtual void apply(Vec3Array&) {} virtual void apply(Vec4Array&) {} - virtual void apply(Short2Array&) {} - virtual void apply(Short3Array&) {} - virtual void apply(Short4Array&) {} - virtual void apply(Byte2Array&) {} - virtual void apply(Byte3Array&) {} - virtual void apply(Byte4Array&) {} + virtual void apply(Vec2sArray&) {} + virtual void apply(Vec3sArray&) {} + virtual void apply(Vec4sArray&) {} + + virtual void apply(Vec2bArray&) {} + virtual void apply(Vec3bArray&) {} + virtual void apply(Vec4bArray&) {} + + virtual void apply(Vec4ubArray&) {} }; class ConstArrayVisitor @@ -317,18 +327,21 @@ class ConstArrayVisitor virtual void apply(const UByteArray&) {} virtual void apply(const UShortArray&) {} virtual void apply(const UIntArray&) {} - virtual void apply(const UByte4Array&) {} virtual void apply(const FloatArray&) {} + virtual void apply(const Vec2Array&) {} virtual void apply(const Vec3Array&) {} virtual void apply(const Vec4Array&) {} - - virtual void apply(const Short2Array&) {} - virtual void apply(const Short3Array&) {} - virtual void apply(const Short4Array&) {} - virtual void apply(const Byte2Array&) {} - virtual void apply(const Byte3Array&) {} - virtual void apply(const Byte4Array&) {} + + virtual void apply(const Vec4ubArray&) {} + + virtual void apply(const Vec2bArray&) {} + virtual void apply(const Vec3bArray&) {} + virtual void apply(const Vec4bArray&) {} + + virtual void apply(const Vec2sArray&) {} + virtual void apply(const Vec3sArray&) {} + virtual void apply(const Vec4sArray&) {} }; @@ -344,17 +357,20 @@ class ValueVisitor virtual void apply(GLubyte&) {} virtual void apply(GLuint&) {} virtual void apply(GLfloat&) {} - virtual void apply(UByte4&) {} + + virtual void apply(Vec4ub&) {} + virtual void apply(Vec2&) {} virtual void apply(Vec3&) {} virtual void apply(Vec4&) {} - virtual void apply(Short2&) {} - virtual void apply(Short3&) {} - virtual void apply(Short4&) {} - virtual void apply(Byte2&) {} - virtual void apply(Byte3&) {} - virtual void apply(Byte4&) {} + virtual void apply(Vec2s&) {} + virtual void apply(Vec3s&) {} + virtual void apply(Vec4s&) {} + + virtual void apply(Vec2b&) {} + virtual void apply(Vec3b&) {} + virtual void apply(Vec4b&) {} }; class ConstValueVisitor @@ -369,17 +385,19 @@ class ConstValueVisitor virtual void apply(const GLubyte&) {} virtual void apply(const GLuint&) {} virtual void apply(const GLfloat&) {} - virtual void apply(const UByte4&) {} + + virtual void apply(const Vec4ub&) {} + virtual void apply(const Vec2&) {} virtual void apply(const Vec3&) {} virtual void apply(const Vec4&) {} - virtual void apply(const Short2&) {} - virtual void apply(const Short3&) {} - virtual void apply(const Short4&) {} - virtual void apply(const Byte2&) {} - virtual void apply(const Byte3&) {} - virtual void apply(const Byte4&) {} + virtual void apply(const Vec2s&) {} + virtual void apply(const Vec3s&) {} + virtual void apply(const Vec4s&) {} + virtual void apply(const Vec2b&) {} + virtual void apply(const Vec3b&) {} + virtual void apply(const Vec4b&) {} }; template diff --git a/include/osg/Drawable b/include/osg/Drawable index 701e13f09..bb778519b 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -49,7 +49,7 @@ namespace osg { class Vec2f; class Vec3f; class Vec4f; -class UByte4; +class Vec4ub; class Geometry; class NodeVisitor; @@ -467,7 +467,7 @@ class OSG_EXPORT Drawable : public Object virtual void apply(AttributeType,unsigned int,Vec2*) {} virtual void apply(AttributeType,unsigned int,Vec3*) {} virtual void apply(AttributeType,unsigned int,Vec4*) {} - virtual void apply(AttributeType,unsigned int,UByte4*) {} + virtual void apply(AttributeType,unsigned int,Vec4ub*) {} }; @@ -498,7 +498,7 @@ class OSG_EXPORT Drawable : public Object virtual void apply(AttributeType,const unsigned int,const Vec2*) {} virtual void apply(AttributeType,const unsigned int,const Vec3*) {} virtual void apply(AttributeType,const unsigned int,const Vec4*) {} - virtual void apply(AttributeType,const unsigned int,const UByte4*) {} + virtual void apply(AttributeType,const unsigned int,const Vec4ub*) {} }; /** Return true if the Drawable subclass supports accept(ConstAttributeFunctor&).*/ diff --git a/include/osg/UByte4 b/include/osg/UByte4 index 931da05a2..19295ae9c 100644 --- a/include/osg/UByte4 +++ b/include/osg/UByte4 @@ -14,138 +14,13 @@ #ifndef OSG_UBYTE4 #define OSG_UBYTE4 1 -#include +#include namespace osg { -/** General purpose float quad. - * Uses include representation of color coordinates. - * No support yet added for float * UByte4 - is it necessary? - * Need to define a non-member non-friend operator* etc. - * UByte4 * float is okay -*/ -class UByte4 -{ - public: - - // Methods are defined here so that they are implicitly inlined - - UByte4() { _v[0]=0; _v[1]=0; _v[2]=0; _v[3]=0;} - - UByte4(unsigned char r, unsigned char g, unsigned char b, unsigned char a) - { - _v[0]=r; _v[1]=g; _v[2]=b; _v[3]=a; - } - - unsigned char _v[4]; - - inline bool operator == (const UByte4& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2] && _v[3]==v._v[3]; } - - inline bool operator != (const UByte4& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2] || _v[3]!=v._v[3]; } - - inline bool operator < (const UByte4& v) const - { - if (_v[0]v._v[0]) return false; - else if (_v[1]v._v[1]) return false; - else if (_v[2]v._v[2]) return false; - else return (_v[3]v._v[0]) return false; @@ -66,15 +66,15 @@ class Byte2 inline char g() const { return _v[1]; } /** Multiply by scalar. */ - inline Byte2 operator * (float rhs) const + inline Vec2b operator * (float rhs) const { - Byte2 col(*this); + Vec2b col(*this); col *= rhs; return col; } /** Unary multiply by scalar. */ - inline Byte2& operator *= (float rhs) + inline Vec2b& operator *= (float rhs) { _v[0]=(char)((float)_v[0]*rhs); _v[1]=(char)((float)_v[1]*rhs); @@ -82,15 +82,15 @@ class Byte2 } /** Divide by scalar. */ - inline Byte2 operator / (float rhs) const + inline Vec2b operator / (float rhs) const { - Byte2 col(*this); + Vec2b col(*this); col /= rhs; return col; } /** Unary divide by scalar. */ - inline Byte2& operator /= (float rhs) + inline Vec2b& operator /= (float rhs) { float div = 1.0f/rhs; *this *= div; @@ -98,15 +98,15 @@ class Byte2 } /** Binary vector add. */ - inline Byte2 operator + (const Byte2& rhs) const + inline Vec2b operator + (const Vec2b& rhs) const { - return Byte2(_v[0]+rhs._v[0], _v[1]+rhs._v[1]); + return Vec2b(_v[0]+rhs._v[0], _v[1]+rhs._v[1]); } /** Unary vector add. Slightly more efficient because no temporary * intermediate object. */ - inline Byte2& operator += (const Byte2& rhs) + inline Vec2b& operator += (const Vec2b& rhs) { _v[0] += rhs._v[0]; _v[1] += rhs._v[1]; @@ -114,20 +114,20 @@ class Byte2 } /** Binary vector subtract. */ - inline Byte2 operator - (const Byte2& rhs) const + inline Vec2b operator - (const Vec2b& rhs) const { - return Byte2(_v[0]-rhs._v[0], _v[1]-rhs._v[1]); + return Vec2b(_v[0]-rhs._v[0], _v[1]-rhs._v[1]); } /** Unary vector subtract. */ - inline Byte2& operator -= (const Byte2& rhs) + inline Vec2b& operator -= (const Vec2b& rhs) { _v[0]-=rhs._v[0]; _v[1]-=rhs._v[1]; return *this; } -}; // end of class Byte2 +}; // end of class Vec2b diff --git a/include/osg/Short2 b/include/osg/Vec2s similarity index 52% rename from include/osg/Short2 rename to include/osg/Vec2s index 17d50db2c..abbbb8ba3 100644 --- a/include/osg/Short2 +++ b/include/osg/Vec2s @@ -11,12 +11,12 @@ * OpenSceneGraph Public License for more details. */ -#ifndef OSG_SHORT_2 -#define OSG_SHORT_2 1 +#ifndef OSG_VEC2S +#define OSG_VEC2S 1 namespace osg { -class Short2 +class Vec2s { public: @@ -27,55 +27,55 @@ public: struct {value_type x,y;}; value_type _v[2]; }; - Short2() {} - Short2(value_type xx, value_type yy) + Vec2s() {} + Vec2s(value_type xx, value_type yy) { x = xx; y = yy; } inline value_type* ptr() { return _v; } inline const value_type* ptr() const { return _v; } - inline bool operator == (const Short2& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; } - inline bool operator != (const Short2& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; } - inline bool operator < (const Short2& v) const + inline bool operator == (const Vec2s& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; } + inline bool operator != (const Vec2s& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; } + inline bool operator < (const Vec2s& v) const { if (_v[0]v._v[0]) return false; else return (_v[1]v._v[0]) return false; @@ -70,15 +70,15 @@ class Byte3 inline char b() const { return _v[2]; } /** Multiply by scalar. */ - inline Byte3 operator * (float rhs) const + inline Vec3b operator * (float rhs) const { - Byte3 col(*this); + Vec3b col(*this); col *= rhs; return col; } /** Unary multiply by scalar. */ - inline Byte3& operator *= (float rhs) + inline Vec3b& operator *= (float rhs) { _v[0]=(char)((float)_v[0]*rhs); _v[1]=(char)((float)_v[1]*rhs); @@ -87,15 +87,15 @@ class Byte3 } /** Divide by scalar. */ - inline Byte3 operator / (float rhs) const + inline Vec3b operator / (float rhs) const { - Byte3 col(*this); + Vec3b col(*this); col /= rhs; return col; } /** Unary divide by scalar. */ - inline Byte3& operator /= (float rhs) + inline Vec3b& operator /= (float rhs) { float div = 1.0f/rhs; *this *= div; @@ -103,16 +103,16 @@ class Byte3 } /** Binary vector add. */ - inline Byte3 operator + (const Byte3& rhs) const + inline Vec3b operator + (const Vec3b& rhs) const { - return Byte3(_v[0]+rhs._v[0], _v[1]+rhs._v[1], + return Vec3b(_v[0]+rhs._v[0], _v[1]+rhs._v[1], _v[2]+rhs._v[2]); } /** Unary vector add. Slightly more efficient because no temporary * intermediate object. */ - inline Byte3& operator += (const Byte3& rhs) + inline Vec3b& operator += (const Vec3b& rhs) { _v[0] += rhs._v[0]; _v[1] += rhs._v[1]; @@ -121,14 +121,14 @@ class Byte3 } /** Binary vector subtract. */ - inline Byte3 operator - (const Byte3& rhs) const + inline Vec3b operator - (const Vec3b& rhs) const { - return Byte3(_v[0]-rhs._v[0], _v[1]-rhs._v[1], + return Vec3b(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2]); } /** Unary vector subtract. */ - inline Byte3& operator -= (const Byte3& rhs) + inline Vec3b& operator -= (const Vec3b& rhs) { _v[0]-=rhs._v[0]; _v[1]-=rhs._v[1]; @@ -136,7 +136,7 @@ class Byte3 return *this; } -}; // end of class Byte3 +}; // end of class Vec3b diff --git a/include/osg/Short3 b/include/osg/Vec3s similarity index 51% rename from include/osg/Short3 rename to include/osg/Vec3s index 1529c05bb..6a870df1d 100644 --- a/include/osg/Short3 +++ b/include/osg/Vec3s @@ -11,12 +11,12 @@ * OpenSceneGraph Public License for more details. */ -#ifndef OSG_SHORT_3 -#define OSG_SHORT_3 1 +#ifndef OSG_VEC3S +#define OSG_VEC3S 1 namespace osg { -class Short3 +class Vec3s { public: @@ -28,16 +28,16 @@ public: value_type _v[3]; }; - Short3 (){} - Short3 (value_type xx, value_type yy, value_type zz) + Vec3s (){} + Vec3s (value_type xx, value_type yy, value_type zz) { x = xx; y = yy; z = zz;} inline value_type* ptr() { return _v; } inline const value_type* ptr() const { return _v; } - inline bool operator == (const Short3& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; } - inline bool operator != (const Short3& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2]; } - inline bool operator < (const Short3& v) const + inline bool operator == (const Vec3s& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; } + inline bool operator != (const Vec3s& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2]; } + inline bool operator < (const Vec3s& v) const { if (_v[0]v._v[0]) return false; @@ -46,39 +46,39 @@ public: else return (_v[2]v._v[0]) return false; @@ -74,15 +74,15 @@ class Byte4 inline char a() const { return _v[3]; } /** Multiply by scalar. */ - inline Byte4 operator * (float rhs) const + inline Vec4b operator * (float rhs) const { - Byte4 col(*this); + Vec4b col(*this); col *= rhs; return col; } /** Unary multiply by scalar. */ - inline Byte4& operator *= (float rhs) + inline Vec4b& operator *= (float rhs) { _v[0]=(char)((float)_v[0]*rhs); _v[1]=(char)((float)_v[1]*rhs); @@ -92,15 +92,15 @@ class Byte4 } /** Divide by scalar. */ - inline Byte4 operator / (float rhs) const + inline Vec4b operator / (float rhs) const { - Byte4 col(*this); + Vec4b col(*this); col /= rhs; return col; } /** Unary divide by scalar. */ - inline Byte4& operator /= (float rhs) + inline Vec4b& operator /= (float rhs) { float div = 1.0f/rhs; *this *= div; @@ -108,16 +108,16 @@ class Byte4 } /** Binary vector add. */ - inline Byte4 operator + (const Byte4& rhs) const + inline Vec4b operator + (const Vec4b& rhs) const { - return Byte4(_v[0]+rhs._v[0], _v[1]+rhs._v[1], + return Vec4b(_v[0]+rhs._v[0], _v[1]+rhs._v[1], _v[2]+rhs._v[2], _v[3]+rhs._v[3]); } /** Unary vector add. Slightly more efficient because no temporary * intermediate object. */ - inline Byte4& operator += (const Byte4& rhs) + inline Vec4b& operator += (const Vec4b& rhs) { _v[0] += rhs._v[0]; _v[1] += rhs._v[1]; @@ -127,14 +127,14 @@ class Byte4 } /** Binary vector subtract. */ - inline Byte4 operator - (const Byte4& rhs) const + inline Vec4b operator - (const Vec4b& rhs) const { - return Byte4(_v[0]-rhs._v[0], _v[1]-rhs._v[1], + return Vec4b(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2], _v[3]-rhs._v[3]); } /** Unary vector subtract. */ - inline Byte4& operator -= (const Byte4& rhs) + inline Vec4b& operator -= (const Vec4b& rhs) { _v[0]-=rhs._v[0]; _v[1]-=rhs._v[1]; @@ -143,7 +143,7 @@ class Byte4 return *this; } -}; // end of class Byte4 +}; // end of class Vec4b diff --git a/include/osg/Short4 b/include/osg/Vec4s similarity index 50% rename from include/osg/Short4 rename to include/osg/Vec4s index d991edad9..c1fc0982d 100644 --- a/include/osg/Short4 +++ b/include/osg/Vec4s @@ -11,12 +11,12 @@ * OpenSceneGraph Public License for more details. */ -#ifndef OSG_SHORT_4 -#define OSG_SHORT_4 1 +#ifndef OSG_VEC4S +#define OSG_VEC4S 1 namespace osg { -class Short4 +class Vec4s { public: @@ -28,16 +28,16 @@ public: value_type _v[4]; }; - Short4 (){} - Short4 (value_type xx, value_type yy, value_type zz, value_type ww) + Vec4s (){} + Vec4s (value_type xx, value_type yy, value_type zz, value_type ww) {x = xx; y = yy; z = zz; w = ww;} inline value_type* ptr() { return _v; } inline const value_type* ptr() const { return _v; } - inline bool operator == (const Short4& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2] && _v[3]==v._v[3]; } - inline bool operator != (const Short4& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2] || _v[3]!=v._v[3]; } - inline bool operator < (const Short4& v) const + inline bool operator == (const Vec4s& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2] && _v[3]==v._v[3]; } + inline bool operator != (const Vec4s& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2] || _v[3]!=v._v[3]; } + inline bool operator < (const Vec4s& v) const { if (_v[0]v._v[0]) return false; @@ -48,39 +48,39 @@ public: else return (_v[3] + +namespace osg { + +/** General purpose float quad. + * Uses include representation of color coordinates. + * No support yet added for float * Vec4ub - is it necessary? + * Need to define a non-member non-friend operator* etc. + * Vec4ub * float is okay +*/ +class Vec4ub +{ + public: + + // Methods are defined here so that they are implicitly inlined + + Vec4ub() { _v[0]=0; _v[1]=0; _v[2]=0; _v[3]=0;} + + Vec4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a) + { + _v[0]=r; _v[1]=g; _v[2]=b; _v[3]=a; + } + + unsigned char _v[4]; + + inline bool operator == (const Vec4ub& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2] && _v[3]==v._v[3]; } + + inline bool operator != (const Vec4ub& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2] || _v[3]!=v._v[3]; } + + inline bool operator < (const Vec4ub& v) const + { + if (_v[0]v._v[0]) return false; + else if (_v[1]v._v[1]) return false; + else if (_v[2]v._v[2]) return false; + else return (_v[3] #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -131,23 +131,23 @@ inline std::istream& operator >> (std::istream& input, Vec4d& vec) ////////////////////////////////////////////////////////////////////////// -// Byte2 steaming operators. -inline std::ostream& operator << (std::ostream& output, const Byte2& vec) +// Vec2b steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec2b& vec) { output << (int)vec._v[0] << " " << (int)vec._v[1]; return output; // to enable cascading } -inline std::istream& operator >> (std::istream& input, Byte2& vec) +inline std::istream& operator >> (std::istream& input, Vec2b& vec) { input >> vec._v[0] >> vec._v[1]; return input; } ////////////////////////////////////////////////////////////////////////// -// Byte3 steaming operators. -inline std::ostream& operator << (std::ostream& output, const Byte3& vec) +// Vec3b steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec3b& vec) { output << (int)vec._v[0] << " " << (int)vec._v[1] << " " @@ -155,15 +155,15 @@ inline std::ostream& operator << (std::ostream& output, const Byte3& vec) return output; // to enable cascading } -inline std::istream& operator >> (std::istream& input, Byte3& vec) +inline std::istream& operator >> (std::istream& input, Vec3b& vec) { input >> vec._v[0] >> vec._v[1] >> vec._v[2]; return input; } ////////////////////////////////////////////////////////////////////////// -// Byte4 steaming operators. -inline std::ostream& operator << (std::ostream& output, const Byte4& vec) +// Vec4b steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec4b& vec) { output << (int)vec._v[0] << " " << (int)vec._v[1] << " " @@ -172,7 +172,7 @@ inline std::ostream& operator << (std::ostream& output, const Byte4& vec) return output; // to enable cascading } -inline std::istream& operator >> (std::istream& input, Byte4& vec) +inline std::istream& operator >> (std::istream& input, Vec4b& vec) { input >> vec._v[0] >> vec._v[1] >> vec._v[2] >> vec._v[3]; return input; @@ -180,23 +180,23 @@ inline std::istream& operator >> (std::istream& input, Byte4& vec) ////////////////////////////////////////////////////////////////////////// -// Short2 steaming operators. -inline std::ostream& operator << (std::ostream& output, const Short2& vec) +// Vec2s steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec2s& vec) { output << (int)vec._v[0] << " " << (int)vec._v[1]; return output; // to enable cascading } -inline std::istream& operator >> (std::istream& input, Short2& vec) +inline std::istream& operator >> (std::istream& input, Vec2s& vec) { input >> vec._v[0] >> vec._v[1]; return input; } ////////////////////////////////////////////////////////////////////////// -// Short3 steaming operators. -inline std::ostream& operator << (std::ostream& output, const Short3& vec) +// Vec3s steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec3s& vec) { output << (int)vec._v[0] << " " << (int)vec._v[1] << " " @@ -204,15 +204,15 @@ inline std::ostream& operator << (std::ostream& output, const Short3& vec) return output; // to enable cascading } -inline std::istream& operator >> (std::istream& input, Short3& vec) +inline std::istream& operator >> (std::istream& input, Vec3s& vec) { input >> vec._v[0] >> vec._v[1] >> vec._v[2]; return input; } ////////////////////////////////////////////////////////////////////////// -// Short4 steaming operators. -inline std::ostream& operator << (std::ostream& output, const Short4& vec) +// Vec4s steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec4s& vec) { output << (int)vec._v[0] << " " << (int)vec._v[1] << " " @@ -221,7 +221,7 @@ inline std::ostream& operator << (std::ostream& output, const Short4& vec) return output; // to enable cascading } -inline std::istream& operator >> (std::istream& input, Short4& vec) +inline std::istream& operator >> (std::istream& input, Vec4s& vec) { input >> vec._v[0] >> vec._v[1] >> vec._v[2] >> vec._v[3]; return input; @@ -260,8 +260,8 @@ inline std::ostream& operator<< (std::ostream& os, const Matrixd& m ) } ////////////////////////////////////////////////////////////////////////// -// UByte4 steaming operators. -inline std::ostream& operator << (std::ostream& output, const UByte4& vec) +// Vec4ub steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec4ub& vec) { output << (int)vec._v[0] << " " << (int)vec._v[1] << " " @@ -270,7 +270,7 @@ inline std::ostream& operator << (std::ostream& output, const UByte4& vec) return output; // to enable cascading } -inline std::istream& operator >> (std::istream& input, UByte4& vec) +inline std::istream& operator >> (std::istream& input, Vec4ub& vec) { input >> vec._v[0] >> vec._v[1] >> vec._v[2] >> vec._v[3]; return input; diff --git a/src/osg/Array.cpp b/src/osg/Array.cpp index 51fb14638..de9ed3384 100644 --- a/src/osg/Array.cpp +++ b/src/osg/Array.cpp @@ -24,25 +24,25 @@ static char* s_ArrayNames[] = "UByteArray", // 4 "UShortArray", // 5 "UIntArray", // 6 - "UByte4Array", // 7 + "Vec4ubArray", // 7 "FloatArray", // 8 "Vec2Array", // 9 "Vec3Array", // 10 - "Vec4Array", // 11 + "Vec4Array", // 11 - "Short2Array", // 12 - "Short3Array", // 13 - "Short4Array", // 14 + "Vec2sArray", // 12 + "Vec3sArray", // 13 + "Vec4sArray", // 14 - "Byte2Array", // 15 - "Byte3Array", // 16 - "Byte4Array", // 17 + "Vec2bArray", // 15 + "Vec3bArray", // 16 + "Vec4bArray", // 17 }; const char* Array::className() const { - if (_arrayType>=ArrayType && _arrayType<=Byte4ArrayType) + if (_arrayType>=ArrayType && _arrayType<=Vec4bArrayType) return s_ArrayNames[_arrayType]; else return "UnkownArray"; diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index abfaeabfb..ef71f8045 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -120,30 +120,30 @@ class DrawNormal else glNormal3fv(normals[pos].ptr()); } break; - case (Array::Short3ArrayType): + case (Array::Vec3sArrayType): { - const Short3Array& normals = *static_cast(_normals); + const Vec3sArray& normals = *static_cast(_normals); if (_indices) glNormal3sv(normals[_indices->index(pos)].ptr()); else glNormal3sv(normals[pos].ptr()); } break; - case (Array::Short4ArrayType): + case (Array::Vec4sArrayType): { - const Short4Array& normals = *static_cast(_normals); + const Vec4sArray& normals = *static_cast(_normals); if (_indices) glNormal3sv(normals[_indices->index(pos)].ptr()); else glNormal3sv(normals[pos].ptr()); } break; - case (Array::Byte3ArrayType): + case (Array::Vec3bArrayType): { - const Byte3Array& normals = *static_cast(_normals); + const Vec3bArray& normals = *static_cast(_normals); if (_indices) glNormal3bv((const GLbyte*)normals[_indices->index(pos)].ptr()); else glNormal3bv((const GLbyte*)normals[pos].ptr()); } break; - case (Array::Byte4ArrayType): + case (Array::Vec4bArrayType): { - const Byte4Array& normals = *static_cast(_normals); + const Vec4bArray& normals = *static_cast(_normals); if (_indices) glNormal3bv((const GLbyte*)normals[_indices->index(pos)].ptr()); else glNormal3bv((const GLbyte*)normals[pos].ptr()); } @@ -195,8 +195,8 @@ class DrawColor case(Array::Vec4ArrayType): apply((*static_cast(_colors))[pos]); break; - case(Array::UByte4ArrayType): - apply((*static_cast(_colors))[pos]); + case(Array::Vec4ubArrayType): + apply((*static_cast(_colors))[pos]); break; case(Array::Vec3ArrayType): apply((*static_cast(_colors))[pos]); @@ -206,7 +206,7 @@ class DrawColor } } - inline void apply(const UByte4& v) { glColor4ubv(v.ptr()); } + inline void apply(const Vec4ub& v) { glColor4ubv(v.ptr()); } inline void apply(const Vec3& v) { glColor3fv(v.ptr()); } inline void apply(const Vec4& v) { glColor4fv(v.ptr()); } @@ -230,7 +230,7 @@ class DrawColor : public osg::ConstValueVisitor else _colors->accept(pos,*this); } - virtual void apply(const UByte4& v) { glColor4ubv(v.ptr()); } + virtual void apply(const UVec4b& v) { glColor4ubv(v.ptr()); } virtual void apply(const Vec3& v) { glColor3fv(v.ptr()); } virtual void apply(const Vec4& v) { glColor4fv(v.ptr()); } @@ -266,7 +266,7 @@ public: { _extensions->glVertexAttrib1f( _vertAttribIndex, f ); } - virtual void apply(const UByte4& v) + virtual void apply(const Vec4ub& v) { if( _normalized ) { @@ -368,7 +368,7 @@ class DrawSecondaryColor : public osg::ConstValueVisitor else _colors->accept(pos,*this); } - virtual void apply(const UByte4& v) { _extensions->glSecondaryColor3ubv(v.ptr()); } + virtual void apply(const Vec4ub& v) { _extensions->glSecondaryColor3ubv(v.ptr()); } virtual void apply(const Vec3& v) { _extensions->glSecondaryColor3fv(v.ptr()); } virtual void apply(const Vec4& v) { _extensions->glSecondaryColor3fv(v.ptr()); } @@ -1775,7 +1775,7 @@ class AttributeFunctorArrayVisitor : public ArrayVisitor virtual void apply(UByteArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(UShortArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(UIntArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } - virtual void apply(UByte4Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } + virtual void apply(Vec4ubArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(FloatArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(Vec2Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(Vec3Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } @@ -1824,7 +1824,7 @@ class ConstAttributeFunctorArrayVisitor : public ConstArrayVisitor virtual void apply(const UByteArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(const UShortArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(const UIntArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } - virtual void apply(const UByte4Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } + virtual void apply(const Vec4ubArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(const FloatArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(const Vec2Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } virtual void apply(const Vec3Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); } @@ -2544,7 +2544,7 @@ class ExpandIndexedArray : public osg::ConstArrayVisitor virtual void apply(const osg::UByteArray& array) { _targetArray = create(array); } virtual void apply(const osg::UShortArray& array) { _targetArray = create(array); } virtual void apply(const osg::UIntArray& array) { _targetArray = create(array); } - virtual void apply(const osg::UByte4Array& array) { _targetArray = create(array); } + virtual void apply(const osg::Vec4ubArray& array) { _targetArray = create(array); } virtual void apply(const osg::FloatArray& array) { _targetArray = create(array); } virtual void apply(const osg::Vec2Array& array) { _targetArray = create(array); } virtual void apply(const osg::Vec3Array& array) { _targetArray = create(array); } diff --git a/src/osgPlugins/3dc/ReaderWriter3DC.cpp b/src/osgPlugins/3dc/ReaderWriter3DC.cpp index c299d5413..bf244e42b 100644 --- a/src/osgPlugins/3dc/ReaderWriter3DC.cpp +++ b/src/osgPlugins/3dc/ReaderWriter3DC.cpp @@ -65,7 +65,7 @@ class ReaderWriter3DC : public osgDB::ReaderWriter osg::Vec3Array* vertices = new osg::Vec3Array; osg::Vec3Array* normals = new osg::Vec3Array; - osg::UByte4Array* colours = new osg::UByte4Array; + osg::Vec4ubArray* colours = new osg::Vec4ubArray; vertices->reserve(targetNumVertices); normals->reserve(targetNumVertices); @@ -117,7 +117,7 @@ class ReaderWriter3DC : public osgDB::ReaderWriter vertices = new osg::Vec3Array; normals = new osg::Vec3Array; - colours = new osg::UByte4Array; + colours = new osg::Vec4ubArray; vertices->reserve(targetNumVertices); normals->reserve(targetNumVertices); @@ -127,7 +127,7 @@ class ReaderWriter3DC : public osgDB::ReaderWriter vertices->push_back(pos); normals->push_back(normal); - colours->push_back(osg::UByte4(r,g,b,255)); + colours->push_back(osg::Vec4ub(r,g,b,255)); } } diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp index 8c6906477..d6d469baa 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -383,14 +383,14 @@ osg::Plane DataInputStream::readPlane(){ return v; } -osg::UByte4 DataInputStream::readUByte4(){ - osg::UByte4 v; +osg::Vec4ub DataInputStream::readVec4ub(){ + osg::Vec4ub v; v.r()=readChar(); v.g()=readChar(); v.b()=readChar(); v.a()=readChar(); - if (_verboseOutput) std::cout<<"read/writeUByte4() ["<read((char*)&((*a)[0]), INTSIZE*size); if (_istream->rdstate() & _istream->failbit) - throw Exception("DataInputStream::readUbyte4Array(): Failed to read UByte4 array."); + throw Exception("DataInputStream::readVec4ubArray(): Failed to read Vec4ub array."); - if (_verboseOutput) std::cout<<"read/writeUByte4Array() ["<read((char*)&((*a)[0]), CHARSIZE * 2 * size); if (_istream->rdstate() & _istream->failbit) - throw Exception("DataInputStream::readByte2Array(): Failed to read Byte2 array."); + throw Exception("DataInputStream::readVec2bArray(): Failed to read Vec2b array."); - if (_verboseOutput) std::cout<<"read/writeByte2Array() ["<read((char*)&((*a)[0]), CHARSIZE * 3 * size); if (_istream->rdstate() & _istream->failbit) - throw Exception("DataInputStream::readByte3Array(): Failed to read Byte3 array."); + throw Exception("DataInputStream::readVec3bArray(): Failed to read Vec3b array."); - if (_verboseOutput) std::cout<<"read/writeByte3Array() ["<read((char*)&((*a)[0]), CHARSIZE * 4 * size); if (_istream->rdstate() & _istream->failbit) - throw Exception("DataInputStream::readByte4Array(): Failed to read Byte4 array."); + throw Exception("DataInputStream::readVec4bArray(): Failed to read Vec4b array."); - if (_verboseOutput) std::cout<<"read/writeByte4Array() ["<read((char*)&((*a)[0]), SHORTSIZE * 2 * size); if (_istream->rdstate() & _istream->failbit) - throw Exception("DataInputStream::readShort2Array(): Failed to read Short2 array."); + throw Exception("DataInputStream::readVec2sArray(): Failed to read Vec2s array."); - if (_verboseOutput) std::cout<<"read/writeShort2Array() ["<read((char*)&((*a)[0]), SHORTSIZE * 3 * size); if (_istream->rdstate() & _istream->failbit) - throw Exception("DataInputStream::readShort3Array(): Failed to read Short3 array."); + throw Exception("DataInputStream::readVec3sArray(): Failed to read Vec3s array."); - if (_verboseOutput) std::cout<<"read/writeShort3Array() ["<read((char*)&((*a)[0]), SHORTSIZE * 4 * size); if (_istream->rdstate() & _istream->failbit) - throw Exception("DataInputStream::readShort4Array(): Failed to read Short4 array."); + throw Exception("DataInputStream::readVec4sArray(): Failed to read Vec4s array."); - if (_verboseOutput) std::cout<<"read/writeShort4Array() ["<(a)); break; - case osg::Array::UByte4ArrayType: + case osg::Array::Vec4ubArrayType: writeChar((char)4); - writeUByte4Array(static_cast(a)); + writeVec4ubArray(static_cast(a)); break; case osg::Array::FloatArrayType: writeChar((char)5); @@ -354,29 +354,29 @@ void DataOutputStream::writeArray(const osg::Array* a){ writeChar((char)8); writeVec4Array(static_cast(a)); break; - case osg::Array::Short2ArrayType: + case osg::Array::Vec2sArrayType: writeChar((char)9); - writeShort2Array(static_cast(a)); + writeVec2sArray(static_cast(a)); break; - case osg::Array::Short3ArrayType: + case osg::Array::Vec3sArrayType: writeChar((char)10); - writeShort3Array(static_cast(a)); + writeVec3sArray(static_cast(a)); break; - case osg::Array::Short4ArrayType: + case osg::Array::Vec4sArrayType: writeChar((char)11); - writeShort4Array(static_cast(a)); + writeVec4sArray(static_cast(a)); break; - case osg::Array::Byte2ArrayType: + case osg::Array::Vec2bArrayType: writeChar((char)12); - writeByte2Array(static_cast(a)); + writeVec2bArray(static_cast(a)); break; - case osg::Array::Byte3ArrayType: + case osg::Array::Vec3bArrayType: writeChar((char)13); - writeByte3Array(static_cast(a)); + writeVec3bArray(static_cast(a)); break; - case osg::Array::Byte4ArrayType: + case osg::Array::Vec4bArrayType: writeChar((char)14); - writeByte4Array(static_cast(a)); + writeVec4bArray(static_cast(a)); break; default: throw Exception("Unknown array type in DataOutputStream::writeArray()"); } @@ -427,15 +427,15 @@ void DataOutputStream::writeUIntArray(const osg::UIntArray* a) if (_verboseOutput) std::cout<<"read/writeUIntArray() ["<getNumElements(); writeInt(size); for(int i =0; igetNumElements(); writeInt(size); @@ -492,10 +492,10 @@ void DataOutputStream::writeShort2Array(const osg::Short2Array* a) writeShort((*a)[i].y); } - if (_verboseOutput) std::cout<<"read/writeShort2Array() ["<getNumElements(); writeInt(size); @@ -505,10 +505,10 @@ void DataOutputStream::writeShort3Array(const osg::Short3Array* a) writeShort((*a)[i].z); } - if (_verboseOutput) std::cout<<"read/writeShort3Array() ["<getNumElements(); writeInt(size); @@ -519,40 +519,40 @@ void DataOutputStream::writeShort4Array(const osg::Short4Array* a) writeShort((*a)[i].w); } - if (_verboseOutput) std::cout<<"read/writeShort4Array() ["<getNumElements(); writeInt(size); for(int i =0; igetNumElements(); writeInt(size); for(int i =0; igetNumElements(); writeInt(size); for(int i =0; isetNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE); } - osg::UByte4Array* osg_colors = new osg::UByte4Array(1); + osg::Vec4ubArray* osg_colors = new osg::Vec4ubArray(1); (*osg_colors)[0].set(255,255,255,255); geom->setColorArray(osg_colors); geom->setColorBinding(osg::Geometry::BIND_OVERALL); diff --git a/src/osgPlugins/osg/Geometry.cpp b/src/osgPlugins/osg/Geometry.cpp index ef304de5c..4fd729726 100644 --- a/src/osgPlugins/osg/Geometry.cpp +++ b/src/osgPlugins/osg/Geometry.cpp @@ -513,9 +513,9 @@ Array* Array_readLocalData(Input& fr) ++fr; return_array = array; } - else if (strcmp(arrayName,"UByte4Array")==0) + else if (strcmp(arrayName,"UVec4bArray")==0 || strcmp(arrayName,"Vec4ubArray")==0) { - UByte4Array* array = new UByte4Array; + Vec4ubArray* array = new Vec4ubArray; array->reserve(capacity); while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { @@ -526,7 +526,7 @@ Array* Array_readLocalData(Input& fr) fr[3].getUInt(a)) { fr+=4; - array->push_back(osg::UByte4(r,g,b,a)); + array->push_back(osg::Vec4ub(r,g,b,a)); } else ++fr; } @@ -601,9 +601,9 @@ Array* Array_readLocalData(Input& fr) ++fr; return_array = array; } - else if (strcmp(arrayName,"Byte2Array")==0) + else if (strcmp(arrayName,"Vec2bArray")==0) { - Byte2Array* array = new Byte2Array; + Vec2bArray* array = new Vec2bArray; array->reserve(capacity); while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { @@ -612,16 +612,16 @@ Array* Array_readLocalData(Input& fr) fr[1].getUInt(g)) { fr+=2; - array->push_back(osg::Byte2(r,g)); + array->push_back(osg::Vec2b(r,g)); } else ++fr; } ++fr; return_array = array; } - else if (strcmp(arrayName,"Byte3Array")==0) + else if (strcmp(arrayName,"Vec3bArray")==0) { - Byte3Array* array = new Byte3Array; + Vec3bArray* array = new Vec3bArray; array->reserve(capacity); while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { @@ -631,16 +631,16 @@ Array* Array_readLocalData(Input& fr) fr[2].getUInt(b)) { fr+=3; - array->push_back(osg::Byte3(r,g,b)); + array->push_back(osg::Vec3b(r,g,b)); } else ++fr; } ++fr; return_array = array; } - else if (strcmp(arrayName,"Byte4Array")==0) + else if (strcmp(arrayName,"Vec4bArray")==0) { - Byte4Array* array = new Byte4Array; + Vec4bArray* array = new Vec4bArray; array->reserve(capacity); while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { @@ -651,16 +651,16 @@ Array* Array_readLocalData(Input& fr) fr[3].getUInt(a)) { fr+=4; - array->push_back(osg::Byte4(r,g,b,a)); + array->push_back(osg::Vec4b(r,g,b,a)); } else ++fr; } ++fr; return_array = array; } - else if (strcmp(arrayName,"Short2Array")==0) + else if (strcmp(arrayName,"Vec2sArray")==0) { - Short2Array* array = new Short2Array; + Vec2sArray* array = new Vec2sArray; array->reserve(capacity); while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { @@ -669,16 +669,16 @@ Array* Array_readLocalData(Input& fr) fr[1].getUInt(g)) { fr+=2; - array->push_back(osg::Short2(r,g)); + array->push_back(osg::Vec2s(r,g)); } else ++fr; } ++fr; return_array = array; } - else if (strcmp(arrayName,"Short3Array")==0) + else if (strcmp(arrayName,"Vec3sArray")==0) { - Short3Array* array = new Short3Array; + Vec3sArray* array = new Vec3sArray; array->reserve(capacity); while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { @@ -688,16 +688,16 @@ Array* Array_readLocalData(Input& fr) fr[2].getUInt(b)) { fr+=3; - array->push_back(osg::Short3(r,g,b)); + array->push_back(osg::Vec3s(r,g,b)); } else ++fr; } ++fr; return_array = array; } - else if (strcmp(arrayName,"Short4Array")==0) + else if (strcmp(arrayName,"Vec4sArray")==0) { - Short4Array* array = new Short4Array; + Vec4sArray* array = new Vec4sArray; array->reserve(capacity); while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { @@ -708,7 +708,7 @@ Array* Array_readLocalData(Input& fr) fr[3].getUInt(a)) { fr+=4; - array->push_back(osg::Short4(r,g,b,a)); + array->push_back(osg::Vec4s(r,g,b,a)); } else ++fr; } @@ -795,9 +795,9 @@ bool Array_writeLocalData(const Array& array,Output& fw) return true; } break; - case(Array::UByte4ArrayType): + case(Array::Vec4ubArrayType): { - const UByte4Array& carray = static_cast(array); + const Vec4ubArray& carray = static_cast(array); fw<(array); + const Vec2sArray& carray = static_cast(array); fw<(array); + const Vec3sArray& carray = static_cast(array); fw<(array); + const Vec4sArray& carray = static_cast(array); fw<(array); + const Vec2bArray& carray = static_cast(array); fw<(array); + const Vec3bArray& carray = static_cast(array); fw<(array); + const Vec4bArray& carray = static_cast(array); fw<getType()getType()) return false; switch(lhs_normalArray->getType()) { - case(osg::Array::Byte3ArrayType): - if ((*static_cast(lhs_normalArray))[0]<(*static_cast(rhs_normalArray))[0]) return true; - if ((*static_cast(rhs_normalArray))[0]<(*static_cast(lhs_normalArray))[0]) return false; + case(osg::Array::Vec3bArrayType): + if ((*static_cast(lhs_normalArray))[0]<(*static_cast(rhs_normalArray))[0]) return true; + if ((*static_cast(rhs_normalArray))[0]<(*static_cast(lhs_normalArray))[0]) return false; break; - case(osg::Array::Short3ArrayType): - if ((*static_cast(lhs_normalArray))[0]<(*static_cast(rhs_normalArray))[0]) return true; - if ((*static_cast(rhs_normalArray))[0]<(*static_cast(lhs_normalArray))[0]) return false; + case(osg::Array::Vec3sArrayType): + if ((*static_cast(lhs_normalArray))[0]<(*static_cast(rhs_normalArray))[0]) return true; + if ((*static_cast(rhs_normalArray))[0]<(*static_cast(lhs_normalArray))[0]) return false; break; case(osg::Array::Vec3ArrayType): if ((*static_cast(lhs_normalArray))[0]<(*static_cast(rhs_normalArray))[0]) return true; @@ -1593,9 +1593,9 @@ struct LessGeometry if (rhs_colorArray->getType()getType()) return false; switch(lhs_colorArray->getType()) { - case(osg::Array::UByte4ArrayType): - if ((*static_cast(lhs_colorArray))[0]<(*static_cast(rhs_colorArray))[0]) return true; - if ((*static_cast(rhs_colorArray))[0]<(*static_cast(lhs_colorArray))[0]) return false; + case(osg::Array::Vec4ubArrayType): + if ((*static_cast(lhs_colorArray))[0]<(*static_cast(rhs_colorArray))[0]) return true; + if ((*static_cast(rhs_colorArray))[0]<(*static_cast(lhs_colorArray))[0]) return false; break; case(osg::Array::Vec3ArrayType): if ((*static_cast(lhs_colorArray))[0]<(*static_cast(rhs_colorArray))[0]) return true; @@ -1901,18 +1901,18 @@ class MergeArrayVisitor : public osg::ArrayVisitor virtual void apply(osg::UByteArray& rhs) { _merge(rhs); } virtual void apply(osg::UShortArray& rhs) { _merge(rhs); } virtual void apply(osg::UIntArray& rhs) { _merge(rhs); } - virtual void apply(osg::UByte4Array& rhs) { _merge(rhs); } + virtual void apply(osg::Vec4ubArray& rhs) { _merge(rhs); } virtual void apply(osg::FloatArray& rhs) { _merge(rhs); } virtual void apply(osg::Vec2Array& rhs) { _merge(rhs); } virtual void apply(osg::Vec3Array& rhs) { _merge(rhs); } virtual void apply(osg::Vec4Array& rhs) { _merge(rhs); } - virtual void apply(osg::Byte2Array& rhs) { _merge(rhs); } - virtual void apply(osg::Byte3Array& rhs) { _merge(rhs); } - virtual void apply(osg::Byte4Array& rhs) { _merge(rhs); } - virtual void apply(osg::Short2Array& rhs) { _merge(rhs); } - virtual void apply(osg::Short3Array& rhs) { _merge(rhs); } - virtual void apply(osg::Short4Array& rhs) { _merge(rhs); } + virtual void apply(osg::Vec2bArray& rhs) { _merge(rhs); } + virtual void apply(osg::Vec3bArray& rhs) { _merge(rhs); } + virtual void apply(osg::Vec4bArray& rhs) { _merge(rhs); } + virtual void apply(osg::Vec2sArray& rhs) { _merge(rhs); } + virtual void apply(osg::Vec3sArray& rhs) { _merge(rhs); } + virtual void apply(osg::Vec4sArray& rhs) { _merge(rhs); } }; bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geometry& rhs) diff --git a/src/osgUtil/Simplifier.cpp b/src/osgUtil/Simplifier.cpp index 4e41aca53..a91a44cce 100644 --- a/src/osgUtil/Simplifier.cpp +++ b/src/osgUtil/Simplifier.cpp @@ -1075,13 +1075,13 @@ class CopyArrayToPointsVisitor : public osg::ArrayVisitor virtual void apply(osg::UIntArray& array) { copy(array); } virtual void apply(osg::FloatArray& array) { copy(array); } - virtual void apply(osg::UByte4Array& array) + virtual void apply(osg::Vec4ubArray& array) { if (_pointList.size()!=array.size()) return; for(unsigned int i=0;i<_pointList.size();++i) { - osg::UByte4& value = array[i]; + osg::Vec4ub& value = array[i]; EdgeCollapse::FloatList& attributes = _pointList[i]->_attributes; attributes.push_back((float)value.r()); attributes.push_back((float)value.g()); @@ -1291,7 +1291,7 @@ class CopyPointsToArrayVisitor : public osg::ArrayVisitor virtual void apply(osg::UIntArray& array) { copy(array, dummy_uint()); } virtual void apply(osg::FloatArray& array) { copy(array, float()); } - virtual void apply(osg::UByte4Array& array) + virtual void apply(osg::Vec4ubArray& array) { array.resize(_pointList.size()); diff --git a/src/osgUtil/Tesselator.cpp b/src/osgUtil/Tesselator.cpp index 40e25b7b9..63fa06a9a 100644 --- a/src/osgUtil/Tesselator.cpp +++ b/src/osgUtil/Tesselator.cpp @@ -145,7 +145,7 @@ class InsertNewVertices : public osg::ArrayVisitor virtual void apply(osg::UByteArray& ba) { apply_imp(ba,GLubyte(0)); } virtual void apply(osg::UShortArray& ba) { apply_imp(ba,GLushort(0)); } virtual void apply(osg::UIntArray& ba) { apply_imp(ba,GLuint(0)); } - virtual void apply(osg::UByte4Array& ba) { apply_imp(ba,UByte4()); } + virtual void apply(osg::Vec4ubArray& ba) { apply_imp(ba,Vec4ub()); } virtual void apply(osg::FloatArray& ba) { apply_imp(ba,float(0)); } virtual void apply(osg::Vec2Array& ba) { apply_imp(ba,Vec2()); } virtual void apply(osg::Vec3Array& ba) { apply_imp(ba,Vec3()); } @@ -591,7 +591,7 @@ void Tesselator::reduceArray(osg::Array * cold, const unsigned int nnu) } break; default: // should also handle:ArrayType' ByteArrayType' ShortArrayType' IntArrayType' - // `UShortArrayType' `UIntArrayType' `UByte4ArrayType' `FloatArrayType' + // `UShortArrayType' `UIntArrayType' `Vec4ubArrayType' `FloatArrayType' break; } } diff --git a/src/osgUtil/TriStripVisitor.cpp b/src/osgUtil/TriStripVisitor.cpp index 9025dba7d..ec6facc77 100644 --- a/src/osgUtil/TriStripVisitor.cpp +++ b/src/osgUtil/TriStripVisitor.cpp @@ -42,7 +42,7 @@ class WriteValue : public osg::ConstValueVisitor virtual void apply(const GLubyte& v) { _o << v; } virtual void apply(const GLuint& v) { _o << v; } virtual void apply(const GLfloat& v) { _o << v; } - virtual void apply(const UByte4& v) { _o << v; } + virtual void apply(const Vec4ub& v) { _o << v; } virtual void apply(const Vec2& v) { _o << v; } virtual void apply(const Vec3& v) { _o << v; } virtual void apply(const Vec4& v) { _o << v; } @@ -158,7 +158,7 @@ class RemapArray : public osg::ArrayVisitor virtual void apply(osg::UByteArray& array) { remap(array); } virtual void apply(osg::UShortArray& array) { remap(array); } virtual void apply(osg::UIntArray& array) { remap(array); } - virtual void apply(osg::UByte4Array& array) { remap(array); } + virtual void apply(osg::Vec4ubArray& array) { remap(array); } virtual void apply(osg::FloatArray& array) { remap(array); } virtual void apply(osg::Vec2Array& array) { remap(array); } virtual void apply(osg::Vec3Array& array) { remap(array); }