Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::Color4< ValueTypeT > Class Template Reference
[Colors]

#include <OSGColor.h>

List of all members.

Public Types

typedef ValueTypeT ValueType

Public Member Functions

Constructors
Color4 (void)
 Color4 (const Color4 &source)
 Color4 (const ValueType red, const ValueType green, const ValueType blue, const ValueType alpha)
Destructors
~Color4 (void)
Set
*void clear (void)
void setValuesRGBA (const ValueType red, const ValueType green, const ValueType blue, const ValueType alpha)
void setValuesHSV (const Real32 h, const Real32 s, const Real32 v)
void setRandom (void)
void setRGBA (UInt32 rgbPack)
void setValue (const Char8 *szString)
void setValue (Char8 *szString)
Get
*UInt32 getRGBA (void) const
void getValuesRGBA (ValueType &red, ValueType &green, ValueType &blue, ValueType &alpha) const
void getValuesHSV (Real32 &h, Real32 &s, Real32 &v) const
ValueType red (void) const
ValueType green (void) const
ValueType blue (void) const
ValueType alpha (void) const
ValueTypegetValuesRGBA (void)
const ValueTypegetValuesRGBA (void) const
Operators
*Color4 operator * (const ValueType val)
ValueTypeoperator[] (const UInt32 uiIndex)
const ValueTypeoperator[] (const UInt32 uiIndex) const
Color4operator= (const Color4 &source)
bool equals (const Color4 &other, const ValueType tolerance) const
bool operator== (const Color4 &other) const
bool operator!= (const Color4 &other) const

Static Public Attributes

static const Color4 Null

Protected Attributes

ValueType _rgba [4]


Detailed Description

template<class ValueTypeT>
class osg::Color4< ValueTypeT >

Definition at line 175 of file OSGColor.h.


Member Typedef Documentation

template<class ValueTypeT>
typedef ValueTypeT osg::Color4< ValueTypeT >::ValueType
 

Definition at line 180 of file OSGColor.h.


Constructor & Destructor Documentation

template<class ValueTypeT>
osg::Color4< ValueTypeT >::Color4 void   )  [inline]
 

Definition at line 518 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00519 {
00520     _rgba[0] = TypeTraits<ValueTypeT>::getZeroElement();
00521     _rgba[1] = TypeTraits<ValueTypeT>::getZeroElement();
00522     _rgba[2] = TypeTraits<ValueTypeT>::getZeroElement();
00523     _rgba[3] = TypeTraits<ValueTypeT>::getZeroElement();
00524 }

template<class ValueTypeT>
osg::Color4< ValueTypeT >::Color4 const Color4< ValueTypeT > &  source  )  [inline]
 

Definition at line 528 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00529 {
00530     _rgba[0] = source._rgba[0];
00531     _rgba[1] = source._rgba[1];
00532     _rgba[2] = source._rgba[2];
00533     _rgba[3] = source._rgba[3];
00534 }

template<class ValueTypeT>
osg::Color4< ValueTypeT >::Color4 const ValueType  red,
const ValueType  green,
const ValueType  blue,
const ValueType  alpha
[inline]
 

Definition at line 538 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00542 {
00543     _rgba[0] = red;
00544     _rgba[1] = green;
00545     _rgba[2] = blue;
00546     _rgba[3] = alpha;
00547 }

template<class ValueTypeT>
osg::Color4< ValueTypeT >::~Color4 void   )  [inline]
 

Definition at line 551 of file OSGColor.inl.

00552 {
00553 }


Member Function Documentation

template<class ValueTypeT>
void osg::Color4< ValueTypeT >::clear void   )  [inline]
 

Definition at line 557 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

Referenced by osg::DVRIsoShader::getLightSources().

00558 {
00559     _rgba[0] = TypeTraits<ValueTypeT>::getZeroElement();
00560     _rgba[1] = TypeTraits<ValueTypeT>::getZeroElement();
00561     _rgba[2] = TypeTraits<ValueTypeT>::getZeroElement();
00562     _rgba[3] = TypeTraits<ValueTypeT>::getZeroElement();
00563 }

template<class ValueTypeT>
void osg::Color4< ValueTypeT >::setValuesRGBA const ValueType  red,
const ValueType  green,
const ValueType  blue,
const ValueType  alpha
[inline]
 

Definition at line 567 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

Referenced by osg::VRMLMaterialDesc::endNode(), osg::VRMLMaterialDesc::endProtoInterface(), osg::SimpleMaterial::makeState(), osg::PhongMaterial::makeState(), osg::FresnelMaterial::makeState(), osg::OFFSceneFileType::read(), osg::SimpleMaterial::rebuildState(), osg::PhongMaterial::rebuildState(), osg::FresnelMaterial::rebuildState(), and osg::Color4< ValueTypeT >::setRandom().

00571 {
00572     _rgba[0] = red;
00573     _rgba[1] = green;
00574     _rgba[2] = blue;
00575     _rgba[3] = alpha;
00576 }

template<class ValueTypeT>
void osg::Color4< ValueTypeT >::setValuesHSV const Real32  h,
const Real32  s,
const Real32  v
[inline]
 

Definition at line 579 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00582 {
00583     Color3<ValueType>::convertFromHSV(_rgba, h, s, v);
00584 
00585     _rgba[3] = TypeTraits<ValueTypeT>::getOneElement();
00586 }

template<class ValueTypeT>
void osg::Color4< ValueTypeT >::setRandom void   )  [inline]
 

Definition at line 590 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::setValuesRGBA().

00591 {
00592     Real32 rf = 1.0 / Real32(RAND_MAX);
00593 
00594     setValuesRGBA(TypeTraits<ValueTypeT>::getPortion(rf * rand()),
00595                   TypeTraits<ValueTypeT>::getPortion(rf * rand()),
00596                   TypeTraits<ValueTypeT>::getPortion(rf * rand()),
00597                   TypeTraits<ValueTypeT>::getPortion(rf * rand()));
00598 }

template<class ValueTypeT>
void osg::Color4< ValueTypeT >::setRGBA UInt32  rgbPack  )  [inline]
 

method to set the rgb values (ABGGRR)

Definition at line 604 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00605 {
00606     for(Int32 i = 0; i < 4; ++i)
00607     {
00608         Real32 rTmp = Real32(rgbPack & 255) / 255.0f;
00609 
00610         _rgba[i] = TypeTraits<ValueTypeT>::getPortion(rTmp);
00611 
00612         rgbPack >>= 8;
00613     }
00614 }

template<class ValueTypeT>
void osg::Color4< ValueTypeT >::setValue const Char8 szString  )  [inline]
 

Definition at line 618 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba, and osg::PointInterface< ValueTypeT, StorageInterfaceT >::setValueFromCString().

Referenced by osg::FieldDataTraits< Color4ub >::getFromString(), osg::FieldDataTraits< Color4f >::getFromString(), and osg::Color4< ValueTypeT >::setValue().

00619 {
00620     // this is the easiest way, not the most efficient...
00621     Vec4f v;
00622 
00623     v.setValueFromCString(szString);
00624 
00625     _rgba[0] = ValueTypeT(v[0]);
00626     _rgba[1] = ValueTypeT(v[1]);
00627     _rgba[2] = ValueTypeT(v[2]);
00628     _rgba[3] = ValueTypeT(v[3]);
00629 }

template<class ValueTypeT>
void osg::Color4< ValueTypeT >::setValue Char8 szString  )  [inline]
 

Definition at line 633 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::setValue().

00634 {
00635     setValue(static_cast<const Char8 *>(szString));
00636 }

template<class ValueTypeT>
UInt32 osg::Color4< ValueTypeT >::getRGBA void   )  const [inline]
 

method to get a packed rgb value (ABGGRR)

Definition at line 642 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00643 {
00644     UInt32 pack = 0;
00645 
00646     for(Int32 i = 3; i >= 0; --i)
00647     {
00648         pack = (pack << 8) | 
00649             Int32(TypeTraits<ValueTypeT>::getFraction(_rgba[i]) *
00650                   255.0f                                        +
00651                   0.5f                                           );
00652     }
00653 
00654     return pack;
00655 }

template<class ValueTypeT>
void osg::Color4< ValueTypeT >::getValuesRGBA ValueType red,
ValueType green,
ValueType blue,
ValueType alpha
const [inline]
 

method to get a packed rgb value (ABGGRR)

Definition at line 659 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

Referenced by osg::SkyBackground::clear(), osg::DVRIsoShader::setupCombinerParametersDiffuse(), and osg::DVRIsoShader::setupCombinerParametersSpecular().

00663 {
00664     red   = _rgba[0];
00665     green = _rgba[1];
00666     blue  = _rgba[2];
00667     alpha = _rgba[3];
00668 }

template<class ValueTypeT>
void osg::Color4< ValueTypeT >::getValuesHSV Real32 h,
Real32 s,
Real32 v
const [inline]
 

method to get a packed rgb value (ABGGRR)

Definition at line 672 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00675 {
00676     Color3<ValueType>::convertToHSV(_rgba, h, s, v);
00677 }

template<class ValueTypeT>
Color4< ValueTypeT >::ValueType osg::Color4< ValueTypeT >::red void   )  const [inline]
 

method to get a packed rgb value (ABGGRR)

Definition at line 682 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

Referenced by cToV(), osg::operator<<(), osg::FieldDataTraits< Color4ub >::putToString(), and osg::FieldDataTraits< Color4f >::putToString().

00683 {
00684     return _rgba[0];
00685 }

template<class ValueTypeT>
Color4< ValueTypeT >::ValueType osg::Color4< ValueTypeT >::green void   )  const [inline]
 

method to get a packed rgb value (ABGGRR)

Definition at line 690 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

Referenced by cToV(), osg::operator<<(), osg::FieldDataTraits< Color4ub >::putToString(), and osg::FieldDataTraits< Color4f >::putToString().

00691 {
00692     return _rgba[1];
00693 }

template<class ValueTypeT>
Color4< ValueTypeT >::ValueType osg::Color4< ValueTypeT >::blue void   )  const [inline]
 

method to get a packed rgb value (ABGGRR)

Definition at line 698 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

Referenced by cToV(), osg::operator<<(), osg::FieldDataTraits< Color4ub >::putToString(), and osg::FieldDataTraits< Color4f >::putToString().

00699 {
00700     return _rgba[2];
00701 }

template<class ValueTypeT>
Color4< ValueTypeT >::ValueType osg::Color4< ValueTypeT >::alpha void   )  const [inline]
 

method to get a packed rgb value (ABGGRR)

Definition at line 706 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

Referenced by cToV(), osg::operator<<(), osg::FieldDataTraits< Color4ub >::putToString(), and osg::FieldDataTraits< Color4f >::putToString().

00707 {
00708     return _rgba[3];
00709 }

template<class ValueTypeT>
Color4< ValueTypeT >::ValueType * osg::Color4< ValueTypeT >::getValuesRGBA void   )  [inline]
 

method to get a packed rgb value (ABGGRR)

Definition at line 714 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00715 {
00716     return _rgba;
00717 }

template<class ValueTypeT>
const Color4< ValueTypeT >::ValueType * osg::Color4< ValueTypeT >::getValuesRGBA void   )  const [inline]
 

method to get a packed rgb value (ABGGRR)

Definition at line 722 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00723 {
00724     return _rgba;
00725 }

template<class ValueTypeT>
Color4< ValueTypeT > osg::Color4< ValueTypeT >::operator * const ValueType  val  )  [inline]
 

Definition at line 729 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00730 {
00731     Color4<ValueTypeT> returnValue;
00732 
00733     returnValue._rgba[0] = _rgba[0] * val;
00734     returnValue._rgba[1] = _rgba[1] * val;
00735     returnValue._rgba[2] = _rgba[2] * val;
00736     returnValue._rgba[3] = _rgba[3] * val;
00737 
00738     return returnValue;
00739 }

template<class ValueTypeT>
Color4< ValueTypeT >::ValueType & osg::Color4< ValueTypeT >::operator[] const UInt32  uiIndex  )  [inline]
 

Definition at line 743 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00745 {
00746     return _rgba[uiIndex];
00747 }

template<class ValueTypeT>
const Color4< ValueTypeT >::ValueType & osg::Color4< ValueTypeT >::operator[] const UInt32  uiIndex  )  const [inline]
 

Definition at line 751 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00753 {
00754     return _rgba[uiIndex];
00755 }

template<class ValueTypeT>
Color4< ValueTypeT > & osg::Color4< ValueTypeT >::operator= const Color4< ValueTypeT > &  source  )  [inline]
 

Definition at line 760 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

00762 {
00763     if (this == &other)
00764         return *this;
00765 
00766     _rgba[0] = other._rgba[0];
00767     _rgba[1] = other._rgba[1];
00768     _rgba[2] = other._rgba[2];
00769     _rgba[3] = other._rgba[3];
00770 
00771     return *this;
00772 }

template<class ValueTypeT>
bool osg::Color4< ValueTypeT >::equals const Color4< ValueTypeT > &  other,
const ValueType  tolerance
const [inline]
 

equal within tolerance

Definition at line 779 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba.

Referenced by osg::MaterialChunk::operator==(), and osg::LightChunk::operator==().

00781 {
00782     bool returnValue = true;
00783 
00784     for(UInt32 i = 0; i < 4; i++)
00785     {
00786         returnValue &= ( (      _rgba[i] - other._rgba[i] <= tolerance) &&
00787                          (other._rgba[i] -       _rgba[i] <= tolerance));
00788     }
00789 
00790     return returnValue;
00791 }

template<class ValueTypeT>
bool osg::Color4< ValueTypeT >::operator== const Color4< ValueTypeT > &  other  )  const [inline]
 

Definition at line 795 of file OSGColor.inl.

References osg::Color4< ValueTypeT >::_rgba, and osg::Eps.

00796 {
00797     bool returnValue = true;
00798 
00799     for(UInt32 i = 0; i < 4; i++)
00800     {
00801         returnValue &= ( (      _rgba[i] - other._rgba[i] <= Eps) &&
00802                          (other._rgba[i] -       _rgba[i] <= Eps));
00803     }
00804 
00805     return returnValue;
00806 }

template<class ValueTypeT>
bool osg::Color4< ValueTypeT >::operator!= const Color4< ValueTypeT > &  other  )  const [inline]
 

Definition at line 810 of file OSGColor.inl.

00811 {
00812     return ! (*this == other);
00813 }


Member Data Documentation

template<class ValueTypeT>
const Color4< ValueTypeT > osg::Color4< ValueTypeT >::Null [static]
 

Definition at line 513 of file OSGColor.inl.

template<class ValueTypeT>
ValueType osg::Color4< ValueTypeT >::_rgba[4] [protected]
 

Definition at line 272 of file OSGColor.h.

Referenced by osg::Color4< ValueTypeT >::alpha(), osg::Color4< ValueTypeT >::blue(), osg::Color4< ValueTypeT >::clear(), osg::Color4< ValueTypeT >::Color4(), osg::Color4< ValueTypeT >::equals(), osg::Color4< ValueTypeT >::getRGBA(), osg::Color4< ValueTypeT >::getValuesHSV(), osg::Color4< ValueTypeT >::getValuesRGBA(), osg::Color4< ValueTypeT >::green(), osg::Color4< ValueTypeT >::operator *(), osg::Color4< ValueTypeT >::operator=(), osg::Color4< ValueTypeT >::operator==(), osg::Color4< ValueTypeT >::operator[](), osg::Color4< ValueTypeT >::red(), osg::Color4< ValueTypeT >::setRGBA(), osg::Color4< ValueTypeT >::setValue(), osg::Color4< ValueTypeT >::setValuesHSV(), and osg::Color4< ValueTypeT >::setValuesRGBA().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:12:33 2005 for OpenSG by  doxygen 1.4.3