Renamed Byte2,3,4 and Short2,3,4 and UByte4 to use the Vec*b, Vec*s and Vec4ub form

This commit is contained in:
Robert Osfield 2005-07-15 14:41:19 +00:00
parent 0c7f228224
commit d35ea68f3e
28 changed files with 594 additions and 549 deletions

View File

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

View File

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

View File

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

View File

@ -19,13 +19,13 @@
#include <osg/Vec2>
#include <osg/Vec3>
#include <osg/Vec4>
#include <osg/UByte4>
#include <osg/Short2>
#include <osg/Short3>
#include <osg/Short4>
#include <osg/Byte2>
#include <osg/Byte3>
#include <osg/Byte4>
#include <osg/Vec4ub>
#include <osg/Vec2s>
#include <osg/Vec3s>
#include <osg/Vec4s>
#include <osg/Vec2b>
#include <osg/Vec3b>
#include <osg/Vec4b>
#include <osg/Object>
@ -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<GLushort,Array::UShortArrayType,1,GL_UNSIGNED_SHORT>
typedef TemplateIndexArray<GLuint,Array::UIntArrayType,1,GL_UNSIGNED_INT> UIntArray;
typedef TemplateArray<GLfloat,Array::FloatArrayType,1,GL_FLOAT> FloatArray;
typedef TemplateArray<UByte4,Array::UByte4ArrayType,4,GL_UNSIGNED_BYTE> UByte4Array;
typedef TemplateArray<Vec2,Array::Vec2ArrayType,2,GL_FLOAT> Vec2Array;
typedef TemplateArray<Vec3,Array::Vec3ArrayType,3,GL_FLOAT> Vec3Array;
typedef TemplateArray<Vec4,Array::Vec4ArrayType,4,GL_FLOAT> Vec4Array;
typedef TemplateArray<Short2,Array::Short2ArrayType,2,GL_SHORT> Short2Array;
typedef TemplateArray<Short3,Array::Short3ArrayType,3,GL_SHORT> Short3Array;
typedef TemplateArray<Short4,Array::Short4ArrayType,4,GL_SHORT> Short4Array;
typedef TemplateArray<Byte2,Array::Byte2ArrayType,2,GL_BYTE> Byte2Array;
typedef TemplateArray<Byte3,Array::Byte3ArrayType,3,GL_BYTE> Byte3Array;
typedef TemplateArray<Byte4,Array::Byte4ArrayType,4,GL_BYTE> Byte4Array;
typedef TemplateArray<Vec4ub,Array::Vec4ubArrayType,4,GL_UNSIGNED_BYTE> Vec4ubArray;
#ifdef USE_DEPRECATED_API
typedef Vec4ubArray UByte4Array;
#endif
typedef TemplateArray<Vec2s,Array::Vec2sArrayType,2,GL_SHORT> Vec2sArray;
typedef TemplateArray<Vec3s,Array::Vec3sArrayType,3,GL_SHORT> Vec3sArray;
typedef TemplateArray<Vec4s,Array::Vec4sArrayType,4,GL_SHORT> Vec4sArray;
typedef TemplateArray<Vec2b,Array::Vec2bArrayType,2,GL_BYTE> Vec2bArray;
typedef TemplateArray<Vec3b,Array::Vec3bArrayType,3,GL_BYTE> Vec3bArray;
typedef TemplateArray<Vec4b,Array::Vec4bArrayType,4,GL_BYTE> 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<typename T, Array::Type ARRAYTYPE, int DataSize, int DataType>

View File

@ -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&).*/

View File

@ -14,138 +14,13 @@
#ifndef OSG_UBYTE4
#define OSG_UBYTE4 1
#include <osg/Vec3>
#include <osg/Vec4ub>
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 true;
else if (_v[0]>v._v[0]) return false;
else if (_v[1]<v._v[1]) return true;
else if (_v[1]>v._v[1]) return false;
else if (_v[2]<v._v[2]) return true;
else if (_v[2]>v._v[2]) return false;
else return (_v[3]<v._v[3]);
}
inline unsigned char* ptr() { return _v; }
inline const unsigned char* ptr() const { return _v; }
inline void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
_v[0]=r; _v[1]=g; _v[2]=b; _v[3]=a;
}
inline unsigned char& operator [] (unsigned int i) { return _v[i]; }
inline unsigned char operator [] (unsigned int i) const { return _v[i]; }
inline unsigned char& r() { return _v[0]; }
inline unsigned char& g() { return _v[1]; }
inline unsigned char& b() { return _v[2]; }
inline unsigned char& a() { return _v[3]; }
inline unsigned char r() const { return _v[0]; }
inline unsigned char g() const { return _v[1]; }
inline unsigned char b() const { return _v[2]; }
inline unsigned char a() const { return _v[3]; }
/** Multiply by scalar. */
inline UByte4 operator * (float rhs) const
{
UByte4 col(*this);
col *= rhs;
return col;
}
/** Unary multiply by scalar. */
inline UByte4& operator *= (float rhs)
{
_v[0]=(unsigned char)((float)_v[0]*rhs);
_v[1]=(unsigned char)((float)_v[1]*rhs);
_v[2]=(unsigned char)((float)_v[2]*rhs);
_v[3]=(unsigned char)((float)_v[3]*rhs);
return *this;
}
/** Divide by scalar. */
inline UByte4 operator / (float rhs) const
{
UByte4 col(*this);
col /= rhs;
return col;
}
/** Unary divide by scalar. */
inline UByte4& operator /= (float rhs)
{
float div = 1.0f/rhs;
*this *= div;
return *this;
}
/** Binary vector add. */
inline UByte4 operator + (const UByte4& rhs) const
{
return UByte4(_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 UByte4& operator += (const UByte4& rhs)
{
_v[0] += rhs._v[0];
_v[1] += rhs._v[1];
_v[2] += rhs._v[2];
_v[3] += rhs._v[3];
return *this;
}
/** Binary vector subtract. */
inline UByte4 operator - (const UByte4& rhs) const
{
return UByte4(_v[0]-rhs._v[0], _v[1]-rhs._v[1],
_v[2]-rhs._v[2], _v[3]-rhs._v[3] );
}
/** Unary vector subtract. */
inline UByte4& operator -= (const UByte4& rhs)
{
_v[0]-=rhs._v[0];
_v[1]-=rhs._v[1];
_v[2]-=rhs._v[2];
_v[3]-=rhs._v[3];
return *this;
}
}; // end of class UByte4
#ifdef USE_DEPRECATED_API
typedef UByte4 Vec4ub;
#endif
} // end of namespace osg

View File

@ -11,37 +11,37 @@
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_BYTE2
#define OSG_BYTE2 1
#ifndef OSG_VEC2B
#define OSG_VEC2B 1
namespace osg {
/** General purpose float triple.
* Uses include representation of color coordinates.
* No support yet added for float * Byte2 - is it necessary?
* No support yet added for float * Vec2b - is it necessary?
* Need to define a non-member non-friend operator* etc.
* Byte2 * float is okay
* Vec2b * float is okay
*/
class Byte2
class Vec2b
{
public:
// Methods are defined here so that they are implicitly inlined
Byte2() { _v[0]=0; _v[1]=0; }
Vec2b() { _v[0]=0; _v[1]=0; }
Byte2(char r, char g)
Vec2b(char r, char g)
{
_v[0]=r; _v[1]=g;
}
char _v[2];
inline bool operator == (const Byte2& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; }
inline bool operator == (const Vec2b& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; }
inline bool operator != (const Byte2& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; }
inline bool operator != (const Vec2b& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; }
inline bool operator < (const Byte2& v) const
inline bool operator < (const Vec2b& v) const
{
if (_v[0]<v._v[0]) return true;
else if (_v[0]>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

View File

@ -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 true;
else if (_v[0]>v._v[0]) return false;
else return (_v[1]<v._v[1]);
}
inline Short2 operator * (value_type rhs) const
inline Vec2s operator * (value_type rhs) const
{
return Short2(_v[0]*rhs, _v[1]*rhs);
return Vec2s(_v[0]*rhs, _v[1]*rhs);
}
inline Short2 operator / (value_type rhs) const
inline Vec2s operator / (value_type rhs) const
{
return Short2(_v[0]/rhs, _v[1]/rhs);
return Vec2s(_v[0]/rhs, _v[1]/rhs);
}
inline Short2 operator + (value_type rhs) const
inline Vec2s operator + (value_type rhs) const
{
return Short2(_v[0]+rhs, _v[1]+rhs);
return Vec2s(_v[0]+rhs, _v[1]+rhs);
}
inline Short2 operator - (value_type rhs) const
inline Vec2s operator - (value_type rhs) const
{
return Short2(_v[0]-rhs, _v[1]-rhs);
return Vec2s(_v[0]-rhs, _v[1]-rhs);
}
inline Short2 operator + (const Short2& rhs) const
inline Vec2s operator + (const Vec2s& rhs) const
{
return Short2(_v[0]+rhs._v[0], _v[1]+rhs._v[1]);
return Vec2s(_v[0]+rhs._v[0], _v[1]+rhs._v[1]);
}
inline Short2 operator - (const Short2& rhs) const
inline Vec2s operator - (const Vec2s& rhs) const
{
return Short2(_v[0]-rhs._v[0], _v[1]-rhs._v[1]);
return Vec2s(_v[0]-rhs._v[0], _v[1]-rhs._v[1]);
}
inline Short2 operator * (const Short2& rhs) const
inline Vec2s operator * (const Vec2s& rhs) const
{
return Short2(_v[0]*rhs._v[0], _v[1]*rhs._v[1]);
return Vec2s(_v[0]*rhs._v[0], _v[1]*rhs._v[1]);
}
};

View File

@ -11,37 +11,37 @@
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_BYTE3
#define OSG_BYTE3 1
#ifndef OSG_VEC3B
#define OSG_VEC3B 1
namespace osg {
/** General purpose float triple.
* Uses include representation of color coordinates.
* No support yet added for float * Byte3 - is it necessary?
* No support yet added for float * Vec3b - is it necessary?
* Need to define a non-member non-friend operator* etc.
* Byte3 * float is okay
* Vec3b * float is okay
*/
class Byte3
class Vec3b
{
public:
// Methods are defined here so that they are implicitly inlined
Byte3() { _v[0]=0; _v[1]=0; _v[2]=0; }
Vec3b() { _v[0]=0; _v[1]=0; _v[2]=0; }
Byte3(char r, char g, char b)
Vec3b(char r, char g, char b)
{
_v[0]=r; _v[1]=g; _v[2]=b;
}
char _v[3];
inline bool operator == (const Byte3& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; }
inline bool operator == (const Vec3b& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; }
inline bool operator != (const Byte3& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2]; }
inline bool operator != (const Vec3b& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2]; }
inline bool operator < (const Byte3& v) const
inline bool operator < (const Vec3b& v) const
{
if (_v[0]<v._v[0]) return true;
else if (_v[0]>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

View File

@ -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 true;
else if (_v[0]>v._v[0]) return false;
@ -46,39 +46,39 @@ public:
else return (_v[2]<v._v[2]);
}
inline Short3 operator * (value_type rhs) const
inline Vec3s operator * (value_type rhs) const
{
return Short3(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs);
return Vec3s(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs);
}
inline Short3 operator / (value_type rhs) const
inline Vec3s operator / (value_type rhs) const
{
return Short3(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs);
return Vec3s(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs);
}
inline Short3 operator + (value_type rhs) const
inline Vec3s operator + (value_type rhs) const
{
return Short3(_v[0]+rhs, _v[1]+rhs, _v[2]+rhs);
return Vec3s(_v[0]+rhs, _v[1]+rhs, _v[2]+rhs);
}
inline Short3 operator - (value_type rhs) const
inline Vec3s operator - (value_type rhs) const
{
return Short3(_v[0]-rhs, _v[1]-rhs, _v[2]-rhs);
return Vec3s(_v[0]-rhs, _v[1]-rhs, _v[2]-rhs);
}
inline Short3 operator + (const Short3& rhs) const
inline Vec3s operator + (const Vec3s& rhs) const
{
return Short3(_v[0]+rhs._v[0], _v[1]+rhs._v[1], _v[2]+rhs._v[2]);
return Vec3s(_v[0]+rhs._v[0], _v[1]+rhs._v[1], _v[2]+rhs._v[2]);
}
inline Short3 operator - (const Short3& rhs) const
inline Vec3s operator - (const Vec3s& rhs) const
{
return Short3(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2]);
return Vec3s(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2]);
}
inline Short3 operator * (const Short3& rhs) const
inline Vec3s operator * (const Vec3s& rhs) const
{
return Short3(_v[0]*rhs._v[0], _v[1]*rhs._v[1], _v[2]*rhs._v[2]);
return Vec3s(_v[0]*rhs._v[0], _v[1]*rhs._v[1], _v[2]*rhs._v[2]);
}
};

View File

@ -11,37 +11,37 @@
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_BYTE4
#define OSG_BYTE4 1
#ifndef OSG_VEC4B
#define OSG_VEC4B 1
namespace osg {
/** General purpose float triple.
* Uses include representation of color coordinates.
* No support yet added for float * Byte4 - is it necessary?
* No support yet added for float * Vec4b - is it necessary?
* Need to define a non-member non-friend operator* etc.
* Byte4 * float is okay
* Vec4b * float is okay
*/
class Byte4
class Vec4b
{
public:
// Methods are defined here so that they are implicitly inlined
Byte4() { _v[0]=0; _v[1]=0; _v[2]=0; _v[3]=0; }
Vec4b() { _v[0]=0; _v[1]=0; _v[2]=0; _v[3]=0; }
Byte4(char r, char g, char b, char a)
Vec4b(char r, char g, char b, char a)
{
_v[0]=r; _v[1]=g; _v[2]=b; _v[3]=a;
}
char _v[4];
inline bool operator == (const Byte4& 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 Vec4b& 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 Byte4& 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 Vec4b& 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 Byte4& v) const
inline bool operator < (const Vec4b& v) const
{
if (_v[0]<v._v[0]) return true;
else if (_v[0]>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

View File

@ -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 true;
else if (_v[0]>v._v[0]) return false;
@ -48,39 +48,39 @@ public:
else return (_v[3]<v._v[3]);
}
inline Short4 operator * (value_type rhs) const
inline Vec4s operator * (value_type rhs) const
{
return Short4(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs, _v[3]*rhs);
return Vec4s(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs, _v[3]*rhs);
}
inline Short4 operator / (value_type rhs) const
inline Vec4s operator / (value_type rhs) const
{
return Short4(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs, _v[3]/rhs);
return Vec4s(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs, _v[3]/rhs);
}
inline Short4 operator + (value_type rhs) const
inline Vec4s operator + (value_type rhs) const
{
return Short4(_v[0]+rhs, _v[1]+rhs, _v[2]+rhs, _v[3]+rhs);
return Vec4s(_v[0]+rhs, _v[1]+rhs, _v[2]+rhs, _v[3]+rhs);
}
inline Short4 operator - (value_type rhs) const
inline Vec4s operator - (value_type rhs) const
{
return Short4(_v[0]-rhs, _v[1]-rhs, _v[2]-rhs, _v[3]-rhs);
return Vec4s(_v[0]-rhs, _v[1]-rhs, _v[2]-rhs, _v[3]-rhs);
}
inline Short4 operator + (const Short4& rhs) const
inline Vec4s operator + (const Vec4s& rhs) const
{
return Short4(_v[0]+rhs._v[0], _v[1]+rhs._v[1], _v[2]+rhs._v[2], _v[3]+rhs._v[3]);
return Vec4s(_v[0]+rhs._v[0], _v[1]+rhs._v[1], _v[2]+rhs._v[2], _v[3]+rhs._v[3]);
}
inline Short4 operator - (const Short4& rhs) const
inline Vec4s operator - (const Vec4s& rhs) const
{
return Short4(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2], _v[3]-rhs._v[3]);
return Vec4s(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2], _v[3]-rhs._v[3]);
}
inline Short4 operator * (const Short4& rhs) const
inline Vec4s operator * (const Vec4s& rhs) const
{
return Short4(_v[0]*rhs._v[0], _v[1]*rhs._v[1], _v[2]*rhs._v[2], _v[3]*rhs._v[3]);
return Vec4s(_v[0]*rhs._v[0], _v[1]*rhs._v[1], _v[2]*rhs._v[2], _v[3]*rhs._v[3]);
}
};

152
include/osg/Vec4ub Normal file
View File

@ -0,0 +1,152 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_VEC4UB
#define OSG_VEC4UB 1
#include <osg/Vec3>
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 true;
else if (_v[0]>v._v[0]) return false;
else if (_v[1]<v._v[1]) return true;
else if (_v[1]>v._v[1]) return false;
else if (_v[2]<v._v[2]) return true;
else if (_v[2]>v._v[2]) return false;
else return (_v[3]<v._v[3]);
}
inline unsigned char* ptr() { return _v; }
inline const unsigned char* ptr() const { return _v; }
inline void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
_v[0]=r; _v[1]=g; _v[2]=b; _v[3]=a;
}
inline unsigned char& operator [] (unsigned int i) { return _v[i]; }
inline unsigned char operator [] (unsigned int i) const { return _v[i]; }
inline unsigned char& r() { return _v[0]; }
inline unsigned char& g() { return _v[1]; }
inline unsigned char& b() { return _v[2]; }
inline unsigned char& a() { return _v[3]; }
inline unsigned char r() const { return _v[0]; }
inline unsigned char g() const { return _v[1]; }
inline unsigned char b() const { return _v[2]; }
inline unsigned char a() const { return _v[3]; }
/** Multiply by scalar. */
inline Vec4ub operator * (float rhs) const
{
Vec4ub col(*this);
col *= rhs;
return col;
}
/** Unary multiply by scalar. */
inline Vec4ub& operator *= (float rhs)
{
_v[0]=(unsigned char)((float)_v[0]*rhs);
_v[1]=(unsigned char)((float)_v[1]*rhs);
_v[2]=(unsigned char)((float)_v[2]*rhs);
_v[3]=(unsigned char)((float)_v[3]*rhs);
return *this;
}
/** Divide by scalar. */
inline Vec4ub operator / (float rhs) const
{
Vec4ub col(*this);
col /= rhs;
return col;
}
/** Unary divide by scalar. */
inline Vec4ub& operator /= (float rhs)
{
float div = 1.0f/rhs;
*this *= div;
return *this;
}
/** Binary vector add. */
inline Vec4ub operator + (const Vec4ub& rhs) const
{
return Vec4ub(_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 Vec4ub& operator += (const Vec4ub& rhs)
{
_v[0] += rhs._v[0];
_v[1] += rhs._v[1];
_v[2] += rhs._v[2];
_v[3] += rhs._v[3];
return *this;
}
/** Binary vector subtract. */
inline Vec4ub operator - (const Vec4ub& rhs) const
{
return Vec4ub(_v[0]-rhs._v[0], _v[1]-rhs._v[1],
_v[2]-rhs._v[2], _v[3]-rhs._v[3] );
}
/** Unary vector subtract. */
inline Vec4ub& operator -= (const Vec4ub& rhs)
{
_v[0]-=rhs._v[0];
_v[1]-=rhs._v[1];
_v[2]-=rhs._v[2];
_v[3]-=rhs._v[3];
return *this;
}
}; // end of class Vec4ub
} // end of namespace osg
#endif

View File

@ -18,13 +18,13 @@
#include <istream>
#include <osg/Vec4d>
#include <osg/UByte4>
#include <osg/Byte2>
#include <osg/Byte3>
#include <osg/Byte4>
#include <osg/Short2>
#include <osg/Short3>
#include <osg/Short4>
#include <osg/Vec4ub>
#include <osg/Vec2b>
#include <osg/Vec3b>
#include <osg/Vec4b>
#include <osg/Vec2s>
#include <osg/Vec3s>
#include <osg/Vec4s>
#include <osg/Matrixf>
#include <osg/Matrixd>
#include <osg/Plane>
@ -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;

View File

@ -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";

View File

@ -120,30 +120,30 @@ class DrawNormal
else glNormal3fv(normals[pos].ptr());
}
break;
case (Array::Short3ArrayType):
case (Array::Vec3sArrayType):
{
const Short3Array& normals = *static_cast<const Short3Array*>(_normals);
const Vec3sArray& normals = *static_cast<const Vec3sArray*>(_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<const Short4Array*>(_normals);
const Vec4sArray& normals = *static_cast<const Vec4sArray*>(_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<const Byte3Array*>(_normals);
const Vec3bArray& normals = *static_cast<const Vec3bArray*>(_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<const Byte4Array*>(_normals);
const Vec4bArray& normals = *static_cast<const Vec4bArray*>(_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<const Vec4Array*>(_colors))[pos]);
break;
case(Array::UByte4ArrayType):
apply((*static_cast<const UByte4Array*>(_colors))[pos]);
case(Array::Vec4ubArrayType):
apply((*static_cast<const Vec4ubArray*>(_colors))[pos]);
break;
case(Array::Vec3ArrayType):
apply((*static_cast<const Vec3Array*>(_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); }

View File

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

View File

@ -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() ["<<v<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec4ub() ["<<v<<"]"<<std::endl;
return v;
}
@ -433,17 +433,17 @@ osg::Array* DataInputStream::readArray(){
case 1: return readUByteArray();
case 2: return readUShortArray();
case 3: return readUIntArray();
case 4: return readUByte4Array();
case 4: return readVec4ubArray();
case 5: return readFloatArray();
case 6: return readVec2Array();
case 7: return readVec3Array();
case 8: return readVec4Array();
case 9: return readShort2Array();
case 10: return readShort3Array();
case 11: return readShort4Array();
case 12: return readByte2Array();
case 13: return readByte3Array();
case 14: return readByte4Array();
case 9: return readVec2sArray();
case 10: return readVec3sArray();
case 11: return readVec4sArray();
case 12: return readVec2bArray();
case 13: return readVec3bArray();
case 14: return readVec4bArray();
default: throw Exception("Unknown array type in DataInputStream::readArray()");
}
}
@ -517,17 +517,17 @@ osg::UIntArray* DataInputStream::readUIntArray()
return a;
}
osg::UByte4Array* DataInputStream::readUByte4Array()
osg::Vec4ubArray* DataInputStream::readVec4ubArray()
{
int size = readInt();
osg::UByte4Array* a = new osg::UByte4Array(size);
osg::Vec4ubArray* a = new osg::Vec4ubArray(size);
_istream->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() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec4ubArray() ["<<size<<"]"<<std::endl;
return a;
}
@ -618,92 +618,92 @@ osg::Vec4Array* DataInputStream::readVec4Array(){
return a;
}
osg::Byte2Array* DataInputStream::readByte2Array()
osg::Vec2bArray* DataInputStream::readVec2bArray()
{
int size = readInt();
osg::Byte2Array* a = new osg::Byte2Array(size);
osg::Vec2bArray* a = new osg::Vec2bArray(size);
_istream->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() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec2bArray() ["<<size<<"]"<<std::endl;
return a;
}
osg::Byte3Array* DataInputStream::readByte3Array()
osg::Vec3bArray* DataInputStream::readVec3bArray()
{
int size = readInt();
osg::Byte3Array* a = new osg::Byte3Array(size);
osg::Vec3bArray* a = new osg::Vec3bArray(size);
_istream->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() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec3bArray() ["<<size<<"]"<<std::endl;
return a;
}
osg::Byte4Array* DataInputStream::readByte4Array()
osg::Vec4bArray* DataInputStream::readVec4bArray()
{
int size = readInt();
osg::Byte4Array* a = new osg::Byte4Array(size);
osg::Vec4bArray* a = new osg::Vec4bArray(size);
_istream->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() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec4bArray() ["<<size<<"]"<<std::endl;
return a;
}
osg::Short2Array* DataInputStream::readShort2Array()
osg::Vec2sArray* DataInputStream::readVec2sArray()
{
int size = readInt();
osg::Short2Array* a = new osg::Short2Array(size);
osg::Vec2sArray* a = new osg::Vec2sArray(size);
_istream->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() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec2sArray() ["<<size<<"]"<<std::endl;
return a;
}
osg::Short3Array* DataInputStream::readShort3Array()
osg::Vec3sArray* DataInputStream::readVec3sArray()
{
int size = readInt();
osg::Short3Array* a = new osg::Short3Array(size);
osg::Vec3sArray* a = new osg::Vec3sArray(size);
_istream->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() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec3sArray() ["<<size<<"]"<<std::endl;
return a;
}
osg::Short4Array* DataInputStream::readShort4Array()
osg::Vec4sArray* DataInputStream::readVec4sArray()
{
int size = readInt();
osg::Short4Array* a = new osg::Short4Array(size);
osg::Vec4sArray* a = new osg::Vec4sArray(size);
_istream->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() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec4sArray() ["<<size<<"]"<<std::endl;
return a;
}

View File

@ -62,7 +62,7 @@ public:
osg::Vec3d readVec3d();
osg::Vec4d readVec4d();
osg::Plane readPlane();
osg::UByte4 readUByte4();
osg::Vec4ub readVec4ub();
osg::Quat readQuat();
osg::Matrixf readMatrixf();
osg::Matrixd readMatrixd();
@ -72,17 +72,17 @@ public:
osg::UByteArray* readUByteArray();
osg::UShortArray* readUShortArray();
osg::UIntArray* readUIntArray();
osg::UByte4Array* readUByte4Array();
osg::Vec4ubArray* readVec4ubArray();
osg::FloatArray* readFloatArray();
osg::Vec2Array* readVec2Array();
osg::Vec3Array* readVec3Array();
osg::Vec4Array* readVec4Array();
osg::Byte2Array* readByte2Array();
osg::Byte3Array* readByte3Array();
osg::Byte4Array* readByte4Array();
osg::Short2Array* readShort2Array();
osg::Short3Array* readShort3Array();
osg::Short4Array* readShort4Array();
osg::Vec2bArray* readVec2bArray();
osg::Vec3bArray* readVec3bArray();
osg::Vec4bArray* readVec4bArray();
osg::Vec2sArray* readVec2sArray();
osg::Vec3sArray* readVec3sArray();
osg::Vec4sArray* readVec4sArray();
osg::Image* readImage(std::string s);
osg::StateSet* readStateSet();

View File

@ -261,37 +261,37 @@ void DataOutputStream::writePlane(const osg::Plane& v)
if (_verboseOutput) std::cout<<"read/writePlane() ["<<v<<"]"<<std::endl;
}
void DataOutputStream::writeUByte4(const osg::UByte4& v){
void DataOutputStream::writeVec4ub(const osg::Vec4ub& v){
writeChar(v.r());
writeChar(v.g());
writeChar(v.b());
writeChar(v.a());
if (_verboseOutput) std::cout<<"read/writeUByte4() ["<<v<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec4ub() ["<<v<<"]"<<std::endl;
}
void DataOutputStream::writeByte2(const osg::Byte2& v){
void DataOutputStream::writeVec2b(const osg::Vec2b& v){
writeChar(v.r());
writeChar(v.g());
if (_verboseOutput) std::cout<<"read/writeByte2() ["<<v<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec2b() ["<<v<<"]"<<std::endl;
}
void DataOutputStream::writeByte3(const osg::Byte3& v){
void DataOutputStream::writeVec3b(const osg::Vec3b& v){
writeChar(v.r());
writeChar(v.g());
writeChar(v.b());
if (_verboseOutput) std::cout<<"read/writeByte3() ["<<v<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec3b() ["<<v<<"]"<<std::endl;
}
void DataOutputStream::writeByte4(const osg::Byte4& v){
void DataOutputStream::writeVec4b(const osg::Vec4b& v){
writeChar(v.r());
writeChar(v.g());
writeChar(v.b());
writeChar(v.a());
if (_verboseOutput) std::cout<<"read/writeByte4() ["<<v<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec4b() ["<<v<<"]"<<std::endl;
}
void DataOutputStream::writeQuat(const osg::Quat& q){
@ -334,9 +334,9 @@ void DataOutputStream::writeArray(const osg::Array* a){
writeChar((char)3);
writeUIntArray(static_cast<const osg::UIntArray*>(a));
break;
case osg::Array::UByte4ArrayType:
case osg::Array::Vec4ubArrayType:
writeChar((char)4);
writeUByte4Array(static_cast<const osg::UByte4Array*>(a));
writeVec4ubArray(static_cast<const osg::Vec4ubArray*>(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<const osg::Vec4Array*>(a));
break;
case osg::Array::Short2ArrayType:
case osg::Array::Vec2sArrayType:
writeChar((char)9);
writeShort2Array(static_cast<const osg::Short2Array*>(a));
writeVec2sArray(static_cast<const osg::Vec2sArray*>(a));
break;
case osg::Array::Short3ArrayType:
case osg::Array::Vec3sArrayType:
writeChar((char)10);
writeShort3Array(static_cast<const osg::Short3Array*>(a));
writeVec3sArray(static_cast<const osg::Vec3sArray*>(a));
break;
case osg::Array::Short4ArrayType:
case osg::Array::Vec4sArrayType:
writeChar((char)11);
writeShort4Array(static_cast<const osg::Short4Array*>(a));
writeVec4sArray(static_cast<const osg::Vec4sArray*>(a));
break;
case osg::Array::Byte2ArrayType:
case osg::Array::Vec2bArrayType:
writeChar((char)12);
writeByte2Array(static_cast<const osg::Byte2Array*>(a));
writeVec2bArray(static_cast<const osg::Vec2bArray*>(a));
break;
case osg::Array::Byte3ArrayType:
case osg::Array::Vec3bArrayType:
writeChar((char)13);
writeByte3Array(static_cast<const osg::Byte3Array*>(a));
writeVec3bArray(static_cast<const osg::Vec3bArray*>(a));
break;
case osg::Array::Byte4ArrayType:
case osg::Array::Vec4bArrayType:
writeChar((char)14);
writeByte4Array(static_cast<const osg::Byte4Array*>(a));
writeVec4bArray(static_cast<const osg::Vec4bArray*>(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() ["<<size<<"]"<<std::endl;
}
void DataOutputStream::writeUByte4Array(const osg::UByte4Array* a)
void DataOutputStream::writeVec4ubArray(const osg::Vec4ubArray* a)
{
int size = a->getNumElements();
writeInt(size);
for(int i =0; i<size ;i++){
writeUByte4((*a)[i]);
writeVec4ub((*a)[i]);
}
if (_verboseOutput) std::cout<<"read/writeUByte4Array() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec4ubArray() ["<<size<<"]"<<std::endl;
}
void DataOutputStream::writeFloatArray(const osg::FloatArray* a)
@ -483,7 +483,7 @@ void DataOutputStream::writeVec4Array(const osg::Vec4Array* a)
if (_verboseOutput) std::cout<<"read/writeVec4Array() ["<<size<<"]"<<std::endl;
}
void DataOutputStream::writeShort2Array(const osg::Short2Array* a)
void DataOutputStream::writeVec2sArray(const osg::Vec2sArray* a)
{
int size = a->getNumElements();
writeInt(size);
@ -492,10 +492,10 @@ void DataOutputStream::writeShort2Array(const osg::Short2Array* a)
writeShort((*a)[i].y);
}
if (_verboseOutput) std::cout<<"read/writeShort2Array() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec2sArray() ["<<size<<"]"<<std::endl;
}
void DataOutputStream::writeShort3Array(const osg::Short3Array* a)
void DataOutputStream::writeVec3sArray(const osg::Vec3sArray* a)
{
int size = a->getNumElements();
writeInt(size);
@ -505,10 +505,10 @@ void DataOutputStream::writeShort3Array(const osg::Short3Array* a)
writeShort((*a)[i].z);
}
if (_verboseOutput) std::cout<<"read/writeShort3Array() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec3sArray() ["<<size<<"]"<<std::endl;
}
void DataOutputStream::writeShort4Array(const osg::Short4Array* a)
void DataOutputStream::writeVec4sArray(const osg::Vec4sArray* a)
{
int size = a->getNumElements();
writeInt(size);
@ -519,40 +519,40 @@ void DataOutputStream::writeShort4Array(const osg::Short4Array* a)
writeShort((*a)[i].w);
}
if (_verboseOutput) std::cout<<"read/writeShort4Array() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec4sArray() ["<<size<<"]"<<std::endl;
}
void DataOutputStream::writeByte2Array(const osg::Byte2Array* a)
void DataOutputStream::writeVec2bArray(const osg::Vec2bArray* a)
{
int size = a->getNumElements();
writeInt(size);
for(int i =0; i<size ;i++){
writeByte2((*a)[i]);
writeVec2b((*a)[i]);
}
if (_verboseOutput) std::cout<<"read/writeByte2Array() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec2bArray() ["<<size<<"]"<<std::endl;
}
void DataOutputStream::writeByte3Array(const osg::Byte3Array* a)
void DataOutputStream::writeVec3bArray(const osg::Vec3bArray* a)
{
int size = a->getNumElements();
writeInt(size);
for(int i =0; i<size ;i++){
writeByte3((*a)[i]);
writeVec3b((*a)[i]);
}
if (_verboseOutput) std::cout<<"read/writeByte3Array() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec3bArray() ["<<size<<"]"<<std::endl;
}
void DataOutputStream::writeByte4Array(const osg::Byte4Array* a)
void DataOutputStream::writeVec4bArray(const osg::Vec4bArray* a)
{
int size = a->getNumElements();
writeInt(size);
for(int i =0; i<size ;i++){
writeByte4((*a)[i]);
writeVec4b((*a)[i]);
}
if (_verboseOutput) std::cout<<"read/writeByte4Array() ["<<size<<"]"<<std::endl;
if (_verboseOutput) std::cout<<"read/writeVec4bArray() ["<<size<<"]"<<std::endl;
}
void DataOutputStream::writeMatrixf(const osg::Matrixf& mat)

View File

@ -56,7 +56,7 @@ public:
void writeVec3d(const osg::Vec3d& v);
void writeVec4d(const osg::Vec4d& v);
void writePlane(const osg::Plane& v);
void writeUByte4(const osg::UByte4& v);
void writeVec4ub(const osg::Vec4ub& v);
void writeQuat(const osg::Quat& q);
void writeBinding(osg::Geometry::AttributeBinding b);
void writeArray(const osg::Array* a);
@ -64,20 +64,20 @@ public:
void writeUByteArray(const osg::UByteArray* a);
void writeUShortArray(const osg::UShortArray* a);
void writeUIntArray(const osg::UIntArray* a);
void writeUByte4Array(const osg::UByte4Array* a);
void writeByte2(const osg::Byte2& v);
void writeByte3(const osg::Byte3& v);
void writeByte4(const osg::Byte4& v);
void writeVec4ubArray(const osg::Vec4ubArray* a);
void writeVec2b(const osg::Vec2b& v);
void writeVec3b(const osg::Vec3b& v);
void writeVec4b(const osg::Vec4b& v);
void writeFloatArray(const osg::FloatArray* a);
void writeVec2Array(const osg::Vec2Array* a);
void writeVec3Array(const osg::Vec3Array* a);
void writeVec4Array(const osg::Vec4Array* a);
void writeShort2Array(const osg::Short2Array* a);
void writeShort3Array(const osg::Short3Array* a);
void writeShort4Array(const osg::Short4Array* a);
void writeByte2Array(const osg::Byte2Array* a);
void writeByte3Array(const osg::Byte3Array* a);
void writeByte4Array(const osg::Byte4Array* a);
void writeVec2sArray(const osg::Vec2sArray* a);
void writeVec3sArray(const osg::Vec3sArray* a);
void writeVec4sArray(const osg::Vec4sArray* a);
void writeVec2bArray(const osg::Vec2bArray* a);
void writeVec3bArray(const osg::Vec3bArray* a);
void writeVec4bArray(const osg::Vec4bArray* a);
void writeMatrixf(const osg::Matrixf& mat);
void writeMatrixd(const osg::Matrixd& mat);

View File

@ -615,7 +615,7 @@ osg::Drawable* ReaderWriter3DS::ReaderObject::createDrawable(Lib3dsMesh *m,Fac
geom->setNormalBinding(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);

View File

@ -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<const UByte4Array&>(array);
const Vec4ubArray& carray = static_cast<const Vec4ubArray&>(array);
fw<<array.className()<<" "<<carray.size()<<" ";
writeArray(fw,carray.begin(),carray.end(),1);
return true;
@ -835,49 +835,49 @@ bool Array_writeLocalData(const Array& array,Output& fw)
return true;
}
break;
case(Array::Short2ArrayType):
case(Array::Vec2sArrayType):
{
const Short2Array& carray = static_cast<const Short2Array&>(array);
const Vec2sArray& carray = static_cast<const Vec2sArray&>(array);
fw<<array.className()<<" "<<carray.size()<<std::endl;
writeArray(fw,carray.begin(),carray.end(), 3);
return true;
}
break;
case(Array::Short3ArrayType):
case(Array::Vec3sArrayType):
{
const Short3Array& carray = static_cast<const Short3Array&>(array);
const Vec3sArray& carray = static_cast<const Vec3sArray&>(array);
fw<<array.className()<<" "<<carray.size()<<std::endl;
writeArray(fw,carray.begin(),carray.end(), 2);
return true;
}
break;
case(Array::Short4ArrayType):
case(Array::Vec4sArrayType):
{
const Short4Array& carray = static_cast<const Short4Array&>(array);
const Vec4sArray& carray = static_cast<const Vec4sArray&>(array);
fw<<array.className()<<" "<<carray.size()<<std::endl;
writeArray(fw,carray.begin(),carray.end(), 1);
return true;
}
break;
case(Array::Byte2ArrayType):
case(Array::Vec2bArrayType):
{
const Byte2Array& carray = static_cast<const Byte2Array&>(array);
const Vec2bArray& carray = static_cast<const Vec2bArray&>(array);
fw<<array.className()<<" "<<carray.size()<<" ";
writeArray(fw,carray.begin(),carray.end(),1);
return true;
}
break;
case(Array::Byte3ArrayType):
case(Array::Vec3bArrayType):
{
const Byte3Array& carray = static_cast<const Byte3Array&>(array);
const Vec3bArray& carray = static_cast<const Vec3bArray&>(array);
fw<<array.className()<<" "<<carray.size()<<" ";
writeArray(fw,carray.begin(),carray.end(),1);
return true;
}
break;
case(Array::Byte4ArrayType):
case(Array::Vec4bArrayType):
{
const Byte4Array& carray = static_cast<const Byte4Array&>(array);
const Vec4bArray& carray = static_cast<const Vec4bArray&>(array);
fw<<array.className()<<" "<<carray.size()<<" ";
writeArray(fw,carray.begin(),carray.end(),1);
return true;

View File

@ -2482,7 +2482,7 @@ osg::Node* DataSet::DestinationTile::createPolygonal()
osg::Vec3Array& v = *(new osg::Vec3Array(numVertices));
osg::Vec2Array& t = *(new osg::Vec2Array(numVertices));
osg::UByte4Array& color = *(new osg::UByte4Array(1));
osg::Vec4ubArray& color = *(new osg::Vec4ubArray(1));
color[0].set(255,255,255,255);

View File

@ -1568,13 +1568,13 @@ struct LessGeometry
if (rhs_normalArray->getType()<lhs_normalArray->getType()) return false;
switch(lhs_normalArray->getType())
{
case(osg::Array::Byte3ArrayType):
if ((*static_cast<const osg::Byte3Array*>(lhs_normalArray))[0]<(*static_cast<const osg::Byte3Array*>(rhs_normalArray))[0]) return true;
if ((*static_cast<const osg::Byte3Array*>(rhs_normalArray))[0]<(*static_cast<const osg::Byte3Array*>(lhs_normalArray))[0]) return false;
case(osg::Array::Vec3bArrayType):
if ((*static_cast<const osg::Vec3bArray*>(lhs_normalArray))[0]<(*static_cast<const osg::Vec3bArray*>(rhs_normalArray))[0]) return true;
if ((*static_cast<const osg::Vec3bArray*>(rhs_normalArray))[0]<(*static_cast<const osg::Vec3bArray*>(lhs_normalArray))[0]) return false;
break;
case(osg::Array::Short3ArrayType):
if ((*static_cast<const osg::Short3Array*>(lhs_normalArray))[0]<(*static_cast<const osg::Short3Array*>(rhs_normalArray))[0]) return true;
if ((*static_cast<const osg::Short3Array*>(rhs_normalArray))[0]<(*static_cast<const osg::Short3Array*>(lhs_normalArray))[0]) return false;
case(osg::Array::Vec3sArrayType):
if ((*static_cast<const osg::Vec3sArray*>(lhs_normalArray))[0]<(*static_cast<const osg::Vec3sArray*>(rhs_normalArray))[0]) return true;
if ((*static_cast<const osg::Vec3sArray*>(rhs_normalArray))[0]<(*static_cast<const osg::Vec3sArray*>(lhs_normalArray))[0]) return false;
break;
case(osg::Array::Vec3ArrayType):
if ((*static_cast<const osg::Vec3Array*>(lhs_normalArray))[0]<(*static_cast<const osg::Vec3Array*>(rhs_normalArray))[0]) return true;
@ -1593,9 +1593,9 @@ struct LessGeometry
if (rhs_colorArray->getType()<lhs_colorArray->getType()) return false;
switch(lhs_colorArray->getType())
{
case(osg::Array::UByte4ArrayType):
if ((*static_cast<const osg::UByte4Array*>(lhs_colorArray))[0]<(*static_cast<const osg::UByte4Array*>(rhs_colorArray))[0]) return true;
if ((*static_cast<const osg::UByte4Array*>(rhs_colorArray))[0]<(*static_cast<const osg::UByte4Array*>(lhs_colorArray))[0]) return false;
case(osg::Array::Vec4ubArrayType):
if ((*static_cast<const osg::Vec4ubArray*>(lhs_colorArray))[0]<(*static_cast<const osg::Vec4ubArray*>(rhs_colorArray))[0]) return true;
if ((*static_cast<const osg::Vec4ubArray*>(rhs_colorArray))[0]<(*static_cast<const osg::Vec4ubArray*>(lhs_colorArray))[0]) return false;
break;
case(osg::Array::Vec3ArrayType):
if ((*static_cast<const osg::Vec3Array*>(lhs_colorArray))[0]<(*static_cast<const osg::Vec3Array*>(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)

View File

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

View File

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

View File

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