More spelling & top fixes.

This commit is contained in:
Robert Osfield 2004-09-15 19:10:15 +00:00
parent 88e2c1b1df
commit b25c08bca4
8 changed files with 232 additions and 218 deletions

View File

@ -20,11 +20,11 @@
namespace osg {
/** General purpose float pair, uses include representation of
texture coordinates.
No support yet added for float * Vec2f - is it necessary?
Need to define a non-member non-friend operator* etc.
BTW: Vec2f * float is okay
/** General purpose float pair. Uses include representation of
* texture coordinates.
* No support yet added for float * Vec2f - is it necessary?
* Need to define a non-member non-friend operator* etc.
* BTW: Vec2f * float is okay
*/
class Vec2f
@ -42,7 +42,7 @@ class Vec2f
inline bool operator != (const Vec2f& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; }
inline bool operator < (const Vec2f& v) const
inline bool operator < (const Vec2f& v) const
{
if (_v[0]<v._v[0]) return true;
else if (_v[0]>v._v[0]) return false;
@ -66,109 +66,110 @@ class Vec2f
inline bool valid() const { return !isNaN(); }
inline bool isNaN() const { return osg::isNaN(_v[0]) || osg::isNaN(_v[1]); }
/// dot product
/** Dot product. */
inline value_type operator * (const Vec2f& rhs) const
{
return _v[0]*rhs._v[0]+_v[1]*rhs._v[1];
}
/// multiply by scalar
/** Multiply by scalar. */
inline const Vec2f operator * (value_type rhs) const
{
return Vec2f(_v[0]*rhs, _v[1]*rhs);
}
/// unary multiply by scalar
/** Unary multiply by scalar. */
inline Vec2f& operator *= (value_type rhs)
{
_v[0]*=rhs;
_v[1]*=rhs;
return *this;
_v[1]*=rhs;
return *this;
}
/// divide by scalar
/** Divide by scalar. */
inline const Vec2f operator / (value_type rhs) const
{
return Vec2f(_v[0]/rhs, _v[1]/rhs);
}
/// unary divide by scalar
/** Unary divide by scalar. */
inline Vec2f& operator /= (value_type rhs)
{
_v[0]/=rhs;
_v[1]/=rhs;
return *this;
_v[1]/=rhs;
return *this;
}
/// binary vector add
/** Binary vector add. */
inline const Vec2f operator + (const Vec2f& rhs) const
{
return Vec2f(_v[0]+rhs._v[0], _v[1]+rhs._v[1]);
}
/** unary vector add. Slightly more efficient because no temporary
intermediate object.*/
/** Unary vector add. Slightly more efficient because no temporary
* intermediate object.
*/
inline Vec2f& operator += (const Vec2f& rhs)
{
_v[0] += rhs._v[0];
_v[1] += rhs._v[1];
return *this;
return *this;
}
/// binary vector subtract
/** Binary vector subtract. */
inline const Vec2f operator - (const Vec2f& rhs) const
{
return Vec2f(_v[0]-rhs._v[0], _v[1]-rhs._v[1]);
}
/// unary vector subtract
/** Unary vector subtract. */
inline Vec2f& operator -= (const Vec2f& rhs)
{
_v[0]-=rhs._v[0];
_v[1]-=rhs._v[1];
return *this;
}
return *this;
}
/// negation operator. Returns the negative of the Vec2f
/** Negation operator. Returns the negative of the Vec2f. */
inline const Vec2f operator - () const
{
return Vec2f (-_v[0], -_v[1]);
}
return Vec2f (-_v[0], -_v[1]);
}
/// Length of the vector = sqrt( vec . vec )
inline value_type length() const
{
return sqrtf( _v[0]*_v[0] + _v[1]*_v[1] );
}
/** Length of the vector = sqrt( vec . vec ) */
inline value_type length() const
{
return sqrtf( _v[0]*_v[0] + _v[1]*_v[1] );
}
/// Length squared of the vector = vec . vec
/** Length squared of the vector = vec . vec */
inline value_type length2( void ) const
{
return _v[0]*_v[0] + _v[1]*_v[1];
}
/** normalize the vector so that it has length unity
returns the previous length of the vector*/
inline value_type normalize()
{
value_type norm = Vec2f::length();
/** Normalize the vector so that it has length unity.
* Returns the previous length of the vector.
*/
inline value_type normalize()
{
value_type norm = Vec2f::length();
if (norm>0.0)
{
value_type inv = 1.0f/norm;
_v[0] *= inv;
_v[1] *= inv;
_v[0] *= inv;
_v[1] *= inv;
}
return( norm );
}
return( norm );
}
friend inline std::ostream& operator << (std::ostream& output, const Vec2f& vec)
friend inline std::ostream& operator << (std::ostream& output, const Vec2f& vec)
{
output << vec._v[0] << " "
<< vec._v[1];
return output; // to enable cascading
}
output << vec._v[0] << " " << vec._v[1];
return output; // to enable cascading
}
}; // end of class Vec2f
}; // end of class Vec2f
} // end of namespace osg
} // end of namespace osg
#endif

View File

@ -19,10 +19,10 @@
namespace osg {
/** General purpose double triple for use as vertices, vectors and normals.
Provides general maths operations from addition through to cross products.
No support yet added for double * Vec3d - is it necessary?
Need to define a non-member non-friend operator* etc.
Vec3d * double is okay
* Provides general math operations from addition through to cross products.
* No support yet added for double * Vec3d - is it necessary?
* Need to define a non-member non-friend operator* etc.
* Vec3d * double is okay
*/
class Vec3d
@ -40,11 +40,11 @@ class Vec3d
Vec3d(value_type x,value_type y,value_type z) { _v[0]=x; _v[1]=y; _v[2]=z; }
inline bool operator == (const Vec3d& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; }
inline bool operator == (const Vec3d& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; }
inline bool operator != (const Vec3d& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2]; }
inline bool operator < (const Vec3d& v) const
inline bool operator < (const Vec3d& v) const
{
if (_v[0]<v._v[0]) return true;
else if (_v[0]>v._v[0]) return false;
@ -80,27 +80,27 @@ class Vec3d
inline bool valid() const { return !isNaN(); }
inline bool isNaN() const { return osg::isNaN(_v[0]) || osg::isNaN(_v[1]) || osg::isNaN(_v[2]); }
/// dot product
/** Dot product. */
inline value_type operator * (const Vec3d& rhs) const
{
return _v[0]*rhs._v[0]+_v[1]*rhs._v[1]+_v[2]*rhs._v[2];
}
/// cross product
/** Cross product. */
inline const Vec3d operator ^ (const Vec3d& rhs) const
{
return Vec3d(_v[1]*rhs._v[2]-_v[2]*rhs._v[1],
_v[2]*rhs._v[0]-_v[0]*rhs._v[2] ,
_v[0]*rhs._v[1]-_v[1]*rhs._v[0]);
_v[2]*rhs._v[0]-_v[0]*rhs._v[2] ,
_v[0]*rhs._v[1]-_v[1]*rhs._v[0]);
}
/// multiply by scalar
/** Multiply by scalar. */
inline const Vec3d operator * (value_type rhs) const
{
return Vec3d(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs);
}
/// unary multiply by scalar
/** Unary multiply by scalar. */
inline Vec3d& operator *= (value_type rhs)
{
_v[0]*=rhs;
@ -109,13 +109,13 @@ class Vec3d
return *this;
}
/// divide by scalar
/** Divide by scalar. */
inline const Vec3d operator / (value_type rhs) const
{
return Vec3d(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs);
}
/// unary divide by scalar
/** Unary divide by scalar. */
inline Vec3d& operator /= (value_type rhs)
{
_v[0]/=rhs;
@ -124,14 +124,15 @@ class Vec3d
return *this;
}
/// binary vector add
/** Binary vector add. */
inline const Vec3d operator + (const Vec3d& rhs) const
{
return Vec3d(_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*/
/** Unary vector add. Slightly more efficient because no temporary
* intermediate object.
*/
inline Vec3d& operator += (const Vec3d& rhs)
{
_v[0] += rhs._v[0];
@ -140,13 +141,13 @@ class Vec3d
return *this;
}
/// binary vector subtract
/** Binary vector subtract. */
inline const Vec3d operator - (const Vec3d& rhs) const
{
return Vec3d(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2]);
}
/// unary vector subtract
/** Unary vector subtract. */
inline Vec3d& operator -= (const Vec3d& rhs)
{
_v[0]-=rhs._v[0];
@ -155,26 +156,27 @@ class Vec3d
return *this;
}
/// negation operator. Returns the negative of the Vec3d
/** Negation operator. Returns the negative of the Vec3d. */
inline const Vec3d operator - () const
{
return Vec3d (-_v[0], -_v[1], -_v[2]);
}
/// Length of the vector = sqrt( vec . vec )
/** Length of the vector = sqrt( vec . vec ) */
inline value_type length() const
{
return sqrt( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] );
}
/// Length squared of the vector = vec . vec
/** Length squared of the vector = vec . vec */
inline value_type length2() const
{
return _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2];
}
/** normalize the vector so that it has length unity
returns the previous length of the vector*/
/** Normalize the vector so that it has length unity.
* Returns the previous length of the vector.
*/
inline value_type normalize()
{
value_type norm = Vec3d::length();
@ -188,18 +190,18 @@ class Vec3d
return( norm );
}
friend inline std::ostream& operator << (std::ostream& output, const Vec3d& vec);
friend inline std::ostream& operator << (std::ostream& output, const Vec3d& vec);
}; // end of class Vec3d
}; // end of class Vec3d
inline std::ostream& operator << (std::ostream& output, const Vec3d& vec)
{
output << vec._v[0] << " "
<< vec._v[1] << " "
<< vec._v[2];
return output; // to enable cascading
return output; // to enable cascading
}
} // end of namespace osg
} // end of namespace osg
#endif

View File

@ -21,10 +21,10 @@
namespace osg {
/** General purpose float triple for use as vertices, vectors and normals.
Provides general maths operations from addition through to cross products.
No support yet added for float * Vec3f - is it necessary?
Need to define a non-member non-friend operator* etc.
Vec3f * float is okay
* Provides general math operations from addition through to cross products.
* No support yet added for float * Vec3f - is it necessary?
* Need to define a non-member non-friend operator* etc.
* Vec3f * float is okay
*/
class Vec3f
{
@ -37,11 +37,11 @@ class Vec3f
Vec3f(value_type x,value_type y,value_type z) { _v[0]=x; _v[1]=y; _v[2]=z; }
inline bool operator == (const Vec3f& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; }
inline bool operator == (const Vec3f& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; }
inline bool operator != (const Vec3f& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2]; }
inline bool operator < (const Vec3f& v) const
inline bool operator < (const Vec3f& v) const
{
if (_v[0]<v._v[0]) return true;
else if (_v[0]>v._v[0]) return false;
@ -77,27 +77,27 @@ class Vec3f
inline bool valid() const { return !isNaN(); }
inline bool isNaN() const { return osg::isNaN(_v[0]) || osg::isNaN(_v[1]) || osg::isNaN(_v[2]); }
/// dot product
/** Dot product. */
inline value_type operator * (const Vec3f& rhs) const
{
return _v[0]*rhs._v[0]+_v[1]*rhs._v[1]+_v[2]*rhs._v[2];
}
/// cross product
/** Cross product. */
inline const Vec3f operator ^ (const Vec3f& rhs) const
{
return Vec3f(_v[1]*rhs._v[2]-_v[2]*rhs._v[1],
_v[2]*rhs._v[0]-_v[0]*rhs._v[2] ,
_v[0]*rhs._v[1]-_v[1]*rhs._v[0]);
_v[2]*rhs._v[0]-_v[0]*rhs._v[2] ,
_v[0]*rhs._v[1]-_v[1]*rhs._v[0]);
}
/// multiply by scalar
/** Multiply by scalar. */
inline const Vec3f operator * (value_type rhs) const
{
return Vec3f(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs);
}
/// unary multiply by scalar
/** Unary multiply by scalar. */
inline Vec3f& operator *= (value_type rhs)
{
_v[0]*=rhs;
@ -106,13 +106,13 @@ class Vec3f
return *this;
}
/// divide by scalar
/** Divide by scalar. */
inline const Vec3f operator / (value_type rhs) const
{
return Vec3f(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs);
}
/// unary divide by scalar
/** Unary divide by scalar. */
inline Vec3f& operator /= (value_type rhs)
{
_v[0]/=rhs;
@ -121,14 +121,15 @@ class Vec3f
return *this;
}
/// binary vector add
/** Binary vector add. */
inline const Vec3f operator + (const Vec3f& rhs) const
{
return Vec3f(_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*/
/** Unary vector add. Slightly more efficient because no temporary
* intermediate object.
*/
inline Vec3f& operator += (const Vec3f& rhs)
{
_v[0] += rhs._v[0];
@ -137,13 +138,13 @@ class Vec3f
return *this;
}
/// binary vector subtract
/** Binary vector subtract. */
inline const Vec3f operator - (const Vec3f& rhs) const
{
return Vec3f(_v[0]-rhs._v[0], _v[1]-rhs._v[1], _v[2]-rhs._v[2]);
}
/// unary vector subtract
/** Unary vector subtract. */
inline Vec3f& operator -= (const Vec3f& rhs)
{
_v[0]-=rhs._v[0];
@ -152,26 +153,27 @@ class Vec3f
return *this;
}
/// negation operator. Returns the negative of the Vec3f
/** Negation operator. Returns the negative of the Vec3f. */
inline const Vec3f operator - () const
{
return Vec3f (-_v[0], -_v[1], -_v[2]);
}
/// Length of the vector = sqrt( vec . vec )
/** Length of the vector = sqrt( vec . vec ) */
inline value_type length() const
{
return sqrtf( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] );
}
/// Length squared of the vector = vec . vec
/** Length squared of the vector = vec . vec */
inline value_type length2() const
{
return _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2];
}
/** normalize the vector so that it has length unity
returns the previous length of the vector*/
/** Normalize the vector so that it has length unity.
* Returns the previous length of the vector.
*/
inline value_type normalize()
{
value_type norm = Vec3f::length();
@ -185,22 +187,22 @@ class Vec3f
return( norm );
}
friend inline std::ostream& operator << (std::ostream& output, const Vec3f& vec);
friend inline std::ostream& operator << (std::ostream& output, const Vec3f& vec);
}; // end of class Vec3f
}; // end of class Vec3f
inline std::ostream& operator << (std::ostream& output, const Vec3f& vec)
{
output << vec._v[0] << " "
<< vec._v[1] << " "
<< vec._v[2];
return output; // to enable cascading
return output; // to enable cascading
}
const Vec3f X_AXIS(1.0,0.0,0.0);
const Vec3f Y_AXIS(0.0,1.0,0.0);
const Vec3f Z_AXIS(0.0,0.0,1.0);
} // end of namespace osg
} // end of namespace osg
#endif

View File

@ -19,11 +19,11 @@
namespace osg {
/** General purpose double quad, uses include representation
of colour coordinates.
No support yet added for double * Vec4d - is it necessary?
Need to define a non-member non-friend operator* etc.
Vec4d * double is okay
/** General purpose double quad. Uses include representation
* of color coordinates.
* No support yet added for double * Vec4d - is it necessary?
* Need to define a non-member non-friend operator* etc.
* Vec4d * double is okay
*/
class Vec4d
{
@ -33,7 +33,7 @@ class Vec4d
value_type _v[4];
// Methods are defined here so that they are implicitly inlined
// Methods are defined here so that they are implicitly inlined
Vec4d() { _v[0]=0.0; _v[1]=0.0; _v[2]=0.0; _v[3]=0.0;}
@ -113,22 +113,22 @@ class Vec4d
inline bool valid() const { return !isNaN(); }
inline bool isNaN() const { return osg::isNaN(_v[0]) || osg::isNaN(_v[1]) || osg::isNaN(_v[2]) || osg::isNaN(_v[3]); }
/// dot product
/** Dot product. */
inline value_type operator * (const Vec4d& rhs) const
{
return _v[0]*rhs._v[0]+
_v[1]*rhs._v[1]+
_v[2]*rhs._v[2]+
_v[3]*rhs._v[3] ;
_v[1]*rhs._v[1]+
_v[2]*rhs._v[2]+
_v[3]*rhs._v[3] ;
}
/// multiply by scalar
/** Multiply by scalar. */
inline Vec4d operator * (value_type rhs) const
{
return Vec4d(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs, _v[3]*rhs);
}
/// unary multiply by scalar
/** Unary multiply by scalar. */
inline Vec4d& operator *= (value_type rhs)
{
_v[0]*=rhs;
@ -138,13 +138,13 @@ class Vec4d
return *this;
}
/// divide by scalar
/** Divide by scalar. */
inline Vec4d operator / (value_type rhs) const
{
return Vec4d(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs, _v[3]/rhs);
}
/// unary divide by scalar
/** Unary divide by scalar. */
inline Vec4d& operator /= (value_type rhs)
{
_v[0]/=rhs;
@ -154,15 +154,16 @@ class Vec4d
return *this;
}
/// binary vector add
/** Binary vector add. */
inline Vec4d operator + (const Vec4d& rhs) const
{
return Vec4d(_v[0]+rhs._v[0], _v[1]+rhs._v[1],
_v[2]+rhs._v[2], _v[3]+rhs._v[3]);
_v[2]+rhs._v[2], _v[3]+rhs._v[3]);
}
/** unary vector add. Slightly more efficient because no temporary
intermediate object*/
/** Unary vector add. Slightly more efficient because no temporary
* intermediate object.
*/
inline Vec4d& operator += (const Vec4d& rhs)
{
_v[0] += rhs._v[0];
@ -172,14 +173,14 @@ class Vec4d
return *this;
}
/// binary vector subtract
/** Binary vector subtract. */
inline Vec4d operator - (const Vec4d& rhs) const
{
return Vec4d(_v[0]-rhs._v[0], _v[1]-rhs._v[1],
_v[2]-rhs._v[2], _v[3]-rhs._v[3] );
_v[2]-rhs._v[2], _v[3]-rhs._v[3] );
}
/// unary vector subtract
/** Unary vector subtract. */
inline Vec4d& operator -= (const Vec4d& rhs)
{
_v[0]-=rhs._v[0];
@ -189,26 +190,27 @@ class Vec4d
return *this;
}
/// negation operator. Returns the negative of the Vec4d
/** Negation operator. Returns the negative of the Vec4d. */
inline const Vec4d operator - () const
{
return Vec4d (-_v[0], -_v[1], -_v[2], -_v[3]);
}
/// Length of the vector = sqrt( vec . vec )
/** Length of the vector = sqrt( vec . vec ) */
inline value_type length() const
{
return sqrt( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] + _v[3]*_v[3]);
}
/// Length squared of the vector = vec . vec
/** Length squared of the vector = vec . vec */
inline value_type length2() const
{
return _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] + _v[3]*_v[3];
}
/** normalize the vector so that it has length unity
returns the previous length of the vector*/
/** Normalize the vector so that it has length unity.
* Returns the previous length of the vector.
*/
inline value_type normalize()
{
value_type norm = Vec4d::length();
@ -225,28 +227,28 @@ class Vec4d
friend inline std::ostream& operator << (std::ostream& output, const Vec4d& vec)
{
output << vec._v[0] << " "
output << vec._v[0] << " "
<< vec._v[1] << " "
<< vec._v[2] << " "
<< vec._v[3];
return output; // to enable cascading
}
return output; // to enable cascading
}
}; // end of class Vec4d
}; // end of class Vec4d
/** Compute the dot product of a (Vec3,1.0) and a Vec4d.*/
/** Compute the dot product of a (Vec3,1.0) and a Vec4d. */
inline Vec4d::value_type operator * (const Vec3d& lhs,const Vec4d& rhs)
{
return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+rhs[3];
}
/** Compute the dot product of a Vec4d and a (Vec3,1.0).*/
/** Compute the dot product of a Vec4d and a (Vec3,1.0). */
inline Vec4d::value_type operator * (const Vec4d& lhs,const Vec3d& rhs)
{
return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+lhs[3];
}
} // end of namespace osg
} // end of namespace osg
#endif

View File

@ -18,11 +18,11 @@
namespace osg {
/** General purpose float quad, uses include representation
of colour coordinates.
No support yet added for float * Vec4f - is it necessary?
Need to define a non-member non-friend operator* etc.
Vec4f * float is okay
/** General purpose float quad. Uses include representation
* of color coordinates.
* No support yet added for float * Vec4f - is it necessary?
* Need to define a non-member non-friend operator* etc.
* Vec4f * float is okay
*/
class Vec4f
{
@ -32,7 +32,7 @@ class Vec4f
value_type _v[4];
// Methods are defined here so that they are implicitly inlined
// Methods are defined here so that they are implicitly inlined
Vec4f() { _v[0]=0.0; _v[1]=0.0; _v[2]=0.0; _v[3]=0.0;}
@ -107,22 +107,22 @@ class Vec4f
inline bool valid() const { return !isNaN(); }
inline bool isNaN() const { return osg::isNaN(_v[0]) || osg::isNaN(_v[1]) || osg::isNaN(_v[2]) || osg::isNaN(_v[3]); }
/// dot product
/** Dot product. */
inline value_type operator * (const Vec4f& rhs) const
{
return _v[0]*rhs._v[0]+
_v[1]*rhs._v[1]+
_v[2]*rhs._v[2]+
_v[3]*rhs._v[3] ;
_v[1]*rhs._v[1]+
_v[2]*rhs._v[2]+
_v[3]*rhs._v[3] ;
}
/// multiply by scalar
/** Multiply by scalar. */
inline Vec4f operator * (value_type rhs) const
{
return Vec4f(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs, _v[3]*rhs);
}
/// unary multiply by scalar
/** Unary multiply by scalar. */
inline Vec4f& operator *= (value_type rhs)
{
_v[0]*=rhs;
@ -132,13 +132,13 @@ class Vec4f
return *this;
}
/// divide by scalar
/** Divide by scalar. */
inline Vec4f operator / (value_type rhs) const
{
return Vec4f(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs, _v[3]/rhs);
}
/// unary divide by scalar
/** Unary divide by scalar. */
inline Vec4f& operator /= (value_type rhs)
{
_v[0]/=rhs;
@ -148,15 +148,16 @@ class Vec4f
return *this;
}
/// binary vector add
/** Binary vector add. */
inline Vec4f operator + (const Vec4f& rhs) const
{
return Vec4f(_v[0]+rhs._v[0], _v[1]+rhs._v[1],
_v[2]+rhs._v[2], _v[3]+rhs._v[3]);
_v[2]+rhs._v[2], _v[3]+rhs._v[3]);
}
/** unary vector add. Slightly more efficient because no temporary
intermediate object*/
/** Unary vector add. Slightly more efficient because no temporary
* intermediate object.
*/
inline Vec4f& operator += (const Vec4f& rhs)
{
_v[0] += rhs._v[0];
@ -166,14 +167,14 @@ class Vec4f
return *this;
}
/// binary vector subtract
/** Binary vector subtract. */
inline Vec4f operator - (const Vec4f& rhs) const
{
return Vec4f(_v[0]-rhs._v[0], _v[1]-rhs._v[1],
_v[2]-rhs._v[2], _v[3]-rhs._v[3] );
_v[2]-rhs._v[2], _v[3]-rhs._v[3] );
}
/// unary vector subtract
/** Unary vector subtract. */
inline Vec4f& operator -= (const Vec4f& rhs)
{
_v[0]-=rhs._v[0];
@ -183,26 +184,27 @@ class Vec4f
return *this;
}
/// negation operator. Returns the negative of the Vec4f
/** Negation operator. Returns the negative of the Vec4f. */
inline const Vec4f operator - () const
{
return Vec4f (-_v[0], -_v[1], -_v[2], -_v[3]);
}
/// Length of the vector = sqrt( vec . vec )
/** Length of the vector = sqrt( vec . vec ) */
inline value_type length() const
{
return sqrtf( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] + _v[3]*_v[3]);
}
/// Length squared of the vector = vec . vec
/** Length squared of the vector = vec . vec */
inline value_type length2() const
{
return _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] + _v[3]*_v[3];
}
/** normalize the vector so that it has length unity
returns the previous length of the vector*/
/** Normalize the vector so that it has length unity.
* Returns the previous length of the vector.
*/
inline value_type normalize()
{
value_type norm = Vec4f::length();
@ -219,28 +221,28 @@ class Vec4f
friend inline std::ostream& operator << (std::ostream& output, const Vec4f& vec)
{
output << vec._v[0] << " "
output << vec._v[0] << " "
<< vec._v[1] << " "
<< vec._v[2] << " "
<< vec._v[3];
return output; // to enable cascading
}
return output; // to enable cascading
}
}; // end of class Vec4f
}; // end of class Vec4f
/** Compute the dot product of a (Vec3,1.0) and a Vec4f.*/
/** Compute the dot product of a (Vec3,1.0) and a Vec4f. */
inline Vec4f::value_type operator * (const Vec3f& lhs,const Vec4f& rhs)
{
return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+rhs[3];
}
/** Compute the dot product of a Vec4f and a (Vec3,1.0).*/
/** Compute the dot product of a Vec4f and a (Vec3,1.0). */
inline Vec4f::value_type operator * (const Vec4f& lhs,const Vec3f& rhs)
{
return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+lhs[3];
}
} // end of namespace osg
} // end of namespace osg
#endif

View File

@ -19,13 +19,13 @@
extern "C" {
/**
* osgGetVersion() returns the library version number.
* Numbering convention : OpenSceneGraph-0.8-31 will return 0.8.31 from osgGetVersion.
*
* This C function can be also used to check for the existence of the OpenSceneGraph
* library using autoconf and its m4 macro AC_CHECK_LIB.
*
* Here is the code to add to your configure.in:
* osgGetVersion() returns the library version number.
* Numbering convention : OpenSceneGraph-0.8-31 will return 0.8.31 from osgGetVersion.
*
* This C function can be also used to check for the existence of the OpenSceneGraph
* library using autoconf and its m4 macro AC_CHECK_LIB.
*
* Here is the code to add to your configure.in:
\verbatim
#
# Check for the OpenSceneGraph (OSG) library
@ -36,9 +36,7 @@ extern "C" {
*/
extern SG_EXPORT const char* osgGetVersion();
/**
* osgGetLibraryName() returns the library name in human friendly form.
*/
/** The osgGetLibraryName() method returns the library name in human-friendly form. */
extern SG_EXPORT const char* osgGetLibraryName();
}

View File

@ -111,19 +111,19 @@ namespace osg {
/** VertexProgram - encapsulates the OpenGL ARB vertex program state.*/
/** VertexProgram - encapsulates the OpenGL ARB vertex program state. */
class SG_EXPORT VertexProgram : public StateAttribute
{
public:
VertexProgram();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
VertexProgram(const VertexProgram& vp,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, VertexProgram, VERTEXPROGRAM);
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
virtual int compare(const osg::StateAttribute& sa) const
{
// check the types are equal and then create the rhs variable
@ -133,7 +133,7 @@ class SG_EXPORT VertexProgram : public StateAttribute
// compare each paramter in turn against the rhs.
COMPARE_StateAttribute_Parameter(_vertexProgram)
return 0; // passed all the above comparison macro's, must be equal.
return 0; // passed all the above comparison macros, must be equal.
}
virtual bool getModeUsage(ModeUsage& usage) const
@ -144,65 +144,69 @@ class SG_EXPORT VertexProgram : public StateAttribute
// data access methods.
/** Get the handle to the vertex program id for the current context.*/
/** Get the handle to the vertex program ID for the current context. */
inline GLuint& getVertexProgramID(unsigned int contextID) const
{
return _vertexProgramIDList[contextID];
}
/** Set the vertex program using C++ style string.*/
/** Set the vertex program using C++ style string. */
inline void setVertexProgram( const std::string& program )
{
_vertexProgram = program;
dirtyVertexProgramObject();
}
/** Set the vertex program using a C style string.*/
/** Set the vertex program using a C style string. */
inline void setVertexProgram( const char* program )
{
_vertexProgram = program;
dirtyVertexProgramObject();
}
/** Get the vertex program.*/
/** Get the vertex program. */
inline const std::string& getVertexProgram() const { return _vertexProgram; }
/** Program Parameters */
/** Set program parameters. */
inline void setProgramLocalParameter(const GLuint index, const Vec4& p)
{
_programLocalParameters[index] = p;
}
/** Matrix */
/** Set matrix. */
inline void setMatrix(const GLenum mode, const Matrix& matrix)
{
_matrixList[mode] = matrix;
}
/** Force a recompile on next apply() of associated OpenGL vertex program objects.*/
/** Force a recompile on next apply() of associated OpenGL vertex program objects. */
void dirtyVertexProgramObject();
/** use deleteVertexProgramObject instead of glDeletePrograms to allow
/** Use deleteVertexProgramObject instead of glDeletePrograms to allow
* OpenGL Vertex Program objects to cached until they can be deleted
* by the OpenGL context in which they were created, specified
* by contextID.*/
* by contextID.
*/
static void deleteVertexProgramObject(unsigned int contextID,GLuint handle);
/** flush all the cached vertex programs which need to be deleted
* in the OpenGL context related to contextID.*/
/** Flush all the cached vertex programs which need to be deleted
* in the OpenGL context related to contextID.
*/
static void flushDeletedVertexProgramObjects(unsigned int contextID,double currentTime, double& availableTime);
virtual void apply(State& state) const;
virtual void compileGLObjects(State& state) const { apply(state); }
/** release an OpenGL objects in specified graphics context if State
object is passed, otherwise release OpenGL objexts for all graphics context if
State object pointer NULL.*/
/** Release any OpenGL objects in specified graphics context if State
* object is passed, otherwise release OpenGL objexts for all graphics contexts if
* State object pointer is NULL.
*/
virtual void releaseGLObjects(State* state=0) const;
/** Extensions class which encapsulates the querring of extensions and
* associated function pointers, and provide convinience wrappers to
* check for the extensions or use the associated functions.*/
/** Extensions class which encapsulates the querying of extensions and
* associated function pointers, and provide convenience wrappers to
* check for the extensions or use the associated functions.
*/
class SG_EXPORT Extensions : public osg::Referenced
{
public:
@ -238,16 +242,18 @@ class SG_EXPORT VertexProgram : public StateAttribute
};
/** Function to call to get the extension of a specified context.
* If the Exentsion object for that context has not yet been created then
* If the Exentsion object for that context has not yet been created
* and the 'createIfNotInitalized' flag been set to false then returns NULL.
* If 'createIfNotInitalized' is true then the Extensions object is
* automatically created. However, in this case the extension object
* only be created with the graphics context associated with ContextID..*/
* If 'createIfNotInitalized' is true then the Extensions object is
* automatically created. However, in this case the extension object
* will only be created with the graphics context associated with ContextID.
*/
static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
/** setExtensions allows users to override the extensions across graphics contexts.
* typically used when you have different extensions supported across graphics pipes
* but need to ensure that they all use the same low common denominator extensions.*/
/** The setExtensions method allows users to override the extensions across graphics contexts.
* Typically used when you have different extensions supported across graphics pipes
* but need to ensure that they all use the same low common denominator extensions.
*/
static void setExtensions(unsigned int contextID,Extensions* extensions);

View File

@ -19,8 +19,7 @@
namespace osg {
/** Encapsulte OpenGL glViewport.
*/
/** Encapsulate OpenGL glViewport. */
class SG_EXPORT Viewport : public StateAttribute
{
public :
@ -35,7 +34,7 @@ class SG_EXPORT Viewport : public StateAttribute
_height(height) {}
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
Viewport(const Viewport& vp,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
StateAttribute(vp,copyop),
_x(vp._x),
@ -45,7 +44,7 @@ class SG_EXPORT Viewport : public StateAttribute
META_StateAttribute(osg, Viewport,VIEWPORT);
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
virtual int compare(const StateAttribute& sa) const
{
// check the types are equal and then create the rhs variable
@ -84,15 +83,17 @@ class SG_EXPORT Viewport : public StateAttribute
inline bool valid() const { return _width!=0 && _height!=0; }
/** Return the aspcetRatio of the viewport, which is equal to width/height.
* If height is zero, the potental division by zero is avoid by simply returning 1.0f.*/
/** Return the aspectRatio of the viewport, which is equal to width/height.
* If height is zero, the potental division by zero is avoided by simply returning 1.0f.
*/
inline float aspectRatio() const { if (_height!=0) return (float)_width/(float)_height; else return 1.0f; }
/** Compute the Window Matrix which takes projected coords into Window coordinates.
* To converted local coodinates into window coordinates use v_window = v_local * MVPW matrix,
* where the MVPW matrix is ModelViewMatrix * ProjectionMatrix * WindowMatrix, the later supplied by
* viewport::computeWindowMatrix(), the ModelView and Projection Matrix can either be sourced from the
* current osg::State object, via osgUtil::SceneView or CullVisitor.*/
* To convert local coordinates into window coordinates use v_window = v_local * MVPW matrix,
* where the MVPW matrix is ModelViewMatrix * ProjectionMatrix * WindowMatrix, the latter supplied by
* Viewport::computeWindowMatrix(), the ModelView and Projection Matrix can either be sourced from the
* current osg::State object, via osgUtil::SceneView or CullVisitor.
*/
inline const osg::Matrix computeWindowMatrix() const
{
return osg::Matrix::translate(1.0f,1.0f,1.0f)*osg::Matrix::scale(0.5f*width(),0.5f*height(),0.5f);