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

osg::PolygonBackground Class Reference

PolygonBackground class. See PageSystemPolygonBackground for a description. More...

#include <OSGPolygonBackground.h>

Inheritance diagram for osg::PolygonBackground:

osg::PolygonBackgroundBase osg::Background osg::BackgroundBase osg::AttachmentContainer osg::FieldContainer List of all members.

Public Types

typedef PolygonBackgroundPtr Ptr
enum  {
  MaterialFieldId = Inherited::NextFieldId, TexCoordsFieldId = MaterialFieldId + 1, PositionsFieldId = TexCoordsFieldId + 1, NormalizedXFieldId = PositionsFieldId + 1,
  NormalizedYFieldId = NormalizedXFieldId + 1, NextFieldId = NormalizedYFieldId + 1
}

Public Member Functions

Handle Attachments
*void addAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
void subAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
AttachmentPtr findAttachment (UInt32 groupId, UInt16 binding=0)
AttachmentPtr findAttachment (const FieldContainerType &type, UInt16 binding=0)
Field Access *SFAttachmentMapgetSFAttachments (void)
Handle Attachments
*void addAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
void subAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
AttachmentPtr findAttachment (UInt32 groupId, UInt16 binding=0)
AttachmentPtr findAttachment (const FieldContainerType &type, UInt16 binding=0)
Field Access *SFAttachmentMapgetSFAttachments (void)
Handle Attachments
*void addAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
void subAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
AttachmentPtr findAttachment (UInt32 groupId, UInt16 binding=0)
AttachmentPtr findAttachment (const FieldContainerType &type, UInt16 binding=0)
Field Access *SFAttachmentMapgetSFAttachments (void)
Handle Attachments
*void addAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
void subAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
AttachmentPtr findAttachment (UInt32 groupId, UInt16 binding=0)
AttachmentPtr findAttachment (const FieldContainerType &type, UInt16 binding=0)
Field Access *SFAttachmentMapgetSFAttachments (void)
Handle Attachments
*void addAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
void subAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
AttachmentPtr findAttachment (UInt32 groupId, UInt16 binding=0)
AttachmentPtr findAttachment (const FieldContainerType &type, UInt16 binding=0)
Field Access *SFAttachmentMapgetSFAttachments (void)
Handle Attachments
*void addAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
void subAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
AttachmentPtr findAttachment (UInt32 groupId, UInt16 binding=0)
AttachmentPtr findAttachment (const FieldContainerType &type, UInt16 binding=0)
Field Access *SFAttachmentMapgetSFAttachments (void)
Handle Attachments
*void addAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
void subAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
AttachmentPtr findAttachment (UInt32 groupId, UInt16 binding=0)
AttachmentPtr findAttachment (const FieldContainerType &type, UInt16 binding=0)
Field Access *SFAttachmentMapgetSFAttachments (void)
Clear
*virtual void clear (DrawActionBase *act, Viewport *port)
Sync
*virtual void changed (BitVector whichField, UInt32 origin)
Output
*virtual void dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const
Helpers
*Real32 mapCoordinate (Real32 val, Real32 max, bool norm)
FieldContainer Get
*virtual FieldContainerTypegetType (void)
virtual const FieldContainerTypegetType (void) const
virtual UInt32 getContainerSize (void) const
Field Get
*SFMaterialPtrgetSFMaterial (void)
 Get the PolygonBackground::_sfMaterial field.
MFVec3fgetMFTexCoords (void)
 Get the PolygonBackground::_mfTexCoords field.
MFPnt2fgetMFPositions (void)
 Get the PolygonBackground::_mfPositions field.
SFBoolgetSFNormalizedX (void)
 Get the PolygonBackground::_sfNormalizedX field.
SFBoolgetSFNormalizedY (void)
 Get the PolygonBackground::_sfNormalizedY field.
MaterialPtrgetMaterial (void)
 Get the value of the PolygonBackground::_sfMaterial field.
const MaterialPtrgetMaterial (void) const
 Get the value of the PolygonBackground::_sfMaterial field.
bool & getNormalizedX (void)
 Get the value of the PolygonBackground::_sfNormalizedX field.
const bool & getNormalizedX (void) const
 Get the value of the PolygonBackground::_sfNormalizedX field.
bool & getNormalizedY (void)
 Get the value of the PolygonBackground::_sfNormalizedY field.
const bool & getNormalizedY (void) const
 Get the value of the PolygonBackground::_sfNormalizedY field.
Vec3fgetTexCoords (const UInt32 index)
 Get the value of the index element the PolygonBackground::_mfTexCoords field.
MFVec3fgetTexCoords (void)
 Get the PolygonBackground::_mfTexCoords field.
const MFVec3fgetTexCoords (void) const
 Get the PolygonBackground::_mfTexCoords field.
Pnt2fgetPositions (const UInt32 index)
 Get the value of the index element the PolygonBackground::_mfPositions field.
MFPnt2fgetPositions (void)
 Get the PolygonBackground::_mfPositions field.
const MFPnt2fgetPositions (void) const
 Get the PolygonBackground::_mfPositions field.
Field Set
*void setMaterial (const MaterialPtr &value)
 Set the value of the PolygonBackground::_sfMaterial field.
void setNormalizedX (const bool &value)
 Set the value of the PolygonBackground::_sfNormalizedX field.
void setNormalizedY (const bool &value)
 Set the value of the PolygonBackground::_sfNormalizedY field.
Binary Access
*virtual UInt32 getBinSize (const BitVector &whichField)
virtual void copyToBin (BinaryDataHandler &pMem, const BitVector &whichField)
virtual void copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField)
Copy
*virtual FieldContainerPtr shallowCopy (void) const
Handle Attachments
*void addAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
void subAttachment (const AttachmentPtr &fieldContainerP, UInt16 binding=0)
AttachmentPtr findAttachment (UInt32 groupId, UInt16 binding=0)
AttachmentPtr findAttachment (const FieldContainerType &type, UInt16 binding=0)
Field Access *SFAttachmentMapgetSFAttachments (void)

Static Public Member Functions

Class Get
*static FieldContainerTypegetClassType (void)
 access the type of the class
static UInt32 getClassTypeId (void)
 access the numerical type of the class
Construction
*static PolygonBackgroundPtr create (void)
 create a new instance of the class
static PolygonBackgroundPtr createEmpty (void)
 create an empty new instance of the class, do not copy the prototype
Class Get
*static const Char8getClassname (void)

Static Public Attributes

static const osg::BitVector MaterialFieldMask
static const osg::BitVector TexCoordsFieldMask
static const osg::BitVector PositionsFieldMask
static const osg::BitVector NormalizedXFieldMask
static const osg::BitVector NormalizedYFieldMask
static const osg::BitVector MTInfluenceMask
static const BitVector AttachmentsFieldMask
static const BitVector NextFieldMask

Protected Member Functions

Sync
void executeSyncImpl (AttachmentContainer *pOther, const BitVector &whichField)
Pointer
*AttachmentContainerPtr getPtr (void)
Sync
void executeSyncImpl (AttachmentContainer *pOther, const BitVector &whichField)
Pointer
*AttachmentContainerPtr getPtr (void)
Sync
void executeSyncImpl (AttachmentContainer *pOther, const BitVector &whichField)
Pointer
*AttachmentContainerPtr getPtr (void)
Sync
void executeSyncImpl (AttachmentContainer *pOther, const BitVector &whichField)
Pointer
*AttachmentContainerPtr getPtr (void)
Sync
void executeSyncImpl (AttachmentContainer *pOther, const BitVector &whichField)
Pointer
*AttachmentContainerPtr getPtr (void)
Sync
void executeSyncImpl (AttachmentContainer *pOther, const BitVector &whichField)
Pointer
*AttachmentContainerPtr getPtr (void)
Sync
void executeSyncImpl (AttachmentContainer *pOther, const BitVector &whichField)
Pointer
*AttachmentContainerPtr getPtr (void)
Constructors
PolygonBackground (void)
 PolygonBackground (const PolygonBackground &source)
Destructors
*virtual ~PolygonBackground (void)
Sync
*void executeSyncImpl (PolygonBackgroundBase *pOther, const BitVector &whichField)
virtual void executeSync (FieldContainer &other, const BitVector &whichField)
Sync
*void executeSyncImpl (BackgroundBase *pOther, const BitVector &whichField)
Sync
void executeSyncImpl (AttachmentContainer *pOther, const BitVector &whichField)
Pointer
*AttachmentContainerPtr getPtr (void)

Protected Attributes

Fields
*SFAttachmentMap _attachmentMap
Fields
*SFAttachmentMap _attachmentMap
Fields
*SFAttachmentMap _attachmentMap
Fields
*SFAttachmentMap _attachmentMap
Fields
*SFAttachmentMap _attachmentMap
Fields
*SFAttachmentMap _attachmentMap
Fields
*SFAttachmentMap _attachmentMap
Fields
*SFMaterialPtr _sfMaterial
MFVec3f _mfTexCoords
MFPnt2f _mfPositions
SFBool _sfNormalizedX
SFBool _sfNormalizedY
Fields
*SFAttachmentMap _attachmentMap

Private Types

typedef PolygonBackgroundBase Inherited

Private Member Functions

void operator= (const PolygonBackground &source)

Static Private Member Functions

static void initMethod (void)

Friends

class FieldContainer
class PolygonBackgroundBase

Detailed Description

A Background that renders a single polygon using the specified material.

Definition at line 56 of file OSGPolygonBackground.h.


Member Typedef Documentation

typedef PolygonBackgroundBase osg::PolygonBackground::Inherited [private]
 

Reimplemented from osg::PolygonBackgroundBase.

Definition at line 60 of file OSGPolygonBackground.h.

typedef PolygonBackgroundPtr osg::PolygonBackgroundBase::Ptr [inherited]
 

Reimplemented from osg::BackgroundBase.

Definition at line 94 of file OSGPolygonBackgroundBase.h.


Member Enumeration Documentation

anonymous enum [inherited]
 

Enumerator:
MaterialFieldId 
TexCoordsFieldId 
PositionsFieldId 
NormalizedXFieldId 
NormalizedYFieldId 
NextFieldId 

Reimplemented from osg::AttachmentContainer.

Definition at line 96 of file OSGPolygonBackgroundBase.h.

00097     {
00098         MaterialFieldId    = Inherited::NextFieldId,
00099         TexCoordsFieldId   = MaterialFieldId    + 1,
00100         PositionsFieldId   = TexCoordsFieldId   + 1,
00101         NormalizedXFieldId = PositionsFieldId   + 1,
00102         NormalizedYFieldId = NormalizedXFieldId + 1,
00103         NextFieldId        = NormalizedYFieldId + 1
00104     };


Constructor & Destructor Documentation

PolygonBackground::PolygonBackground void   )  [protected]
 

Definition at line 84 of file OSGPolygonBackground.cpp.

00084                                          :
00085     Inherited()
00086 {
00087 }

PolygonBackground::PolygonBackground const PolygonBackground source  )  [protected]
 

Definition at line 89 of file OSGPolygonBackground.cpp.

00089                                                                     :
00090     Inherited(source)
00091 {
00092 }

PolygonBackground::~PolygonBackground void   )  [protected, virtual]
 

Definition at line 94 of file OSGPolygonBackground.cpp.

00095 {
00096 }


Member Function Documentation

void PolygonBackground::clear DrawActionBase act,
Viewport port
[virtual]
 

Implements osg::Background.

Definition at line 120 of file OSGPolygonBackground.cpp.

References FWARNING, osg::PolygonBackgroundBase::getMaterial(), osg::PolygonBackgroundBase::getNormalizedX(), osg::PolygonBackgroundBase::getNormalizedY(), osg::Viewport::getPixelHeight(), osg::Viewport::getPixelWidth(), osg::PolygonBackgroundBase::getPositions(), osg::PolygonBackgroundBase::getTexCoords(), GLboolean, and mapCoordinate().

00121 {
00122     if (port->getPixelWidth()  == 0 ||
00123         port->getPixelHeight() == 0 ) 
00124     {   
00125         FWARNING(("Port has zero size: nothing to render to!\n"));
00126         return;
00127     }
00128         
00129     if (getPositions().getSize() == 0 ||
00130         getPositions().getSize() != getTexCoords().getSize())
00131     {
00132         FWARNING(("PolygonBackground::clear: positions and texcoords have "
00133                   "different/ invalid sizes (%d vs. %d)!\n", 
00134                   getPositions().getSize(), getTexCoords().getSize()));
00135         return;
00136     }
00137        
00138     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00139 
00140     glPushAttrib(GL_ALL_ATTRIB_BITS);
00141 
00142     GLboolean depth = glIsEnabled(GL_DEPTH_TEST);
00143     glDisable(GL_DEPTH_TEST);
00144 
00145     GLint depthFunc;
00146     glGetIntegerv(GL_DEPTH_FUNC, &depthFunc);
00147     glDepthFunc(GL_ALWAYS);
00148 
00149     glDepthMask(GL_FALSE);
00150  
00151     glMatrixMode(GL_MODELVIEW);
00152     glPushMatrix();
00153     glLoadIdentity();
00154 
00155     glMatrixMode(GL_PROJECTION);
00156     glPushMatrix();
00157     glLoadIdentity();
00158     glOrtho(0, port->getPixelWidth(), 0, port->getPixelHeight(), 0, 1);
00159     
00160     getMaterial()->getState()->activate(act);
00161     
00162     Vec3f *tc  = &getTexCoords()[0];
00163     Pnt2f *pos = &getPositions()[0];
00164     
00165     glBegin(GL_POLYGON);
00166     
00167     for (UInt16 i=0; i<getPositions().size(); i++)
00168     {
00169         glTexCoord3fv( tc[i].getValues() );
00170         glVertex2f( mapCoordinate(pos[i][0], Real32(port->getPixelWidth()),
00171                                              getNormalizedX()),
00172                     mapCoordinate(pos[i][1], Real32(port->getPixelHeight()),
00173                                              getNormalizedY()) );
00174     }
00175 
00176     glEnd();
00177     
00178     getMaterial()->getState()->deactivate(act);
00179 
00180     glClear(GL_DEPTH_BUFFER_BIT);
00181     
00182     glDepthMask(GL_TRUE);
00183 
00184     if (depth)    
00185         glEnable(GL_DEPTH_TEST);
00186     glDepthFunc(depthFunc);
00187     
00188     glPopMatrix();
00189     glMatrixMode(GL_MODELVIEW);
00190     glPopMatrix();
00191 
00192     glPopAttrib();
00193 }

void PolygonBackground::changed BitVector  whichField,
UInt32  origin
[virtual]
 

Reimplemented from osg::Background.

Definition at line 195 of file OSGPolygonBackground.cpp.

References osg::Background::changed().

00196 {
00197     Inherited::changed(whichField, origin);
00198 }

void PolygonBackground::dump UInt32  uiIndent = 0,
const BitVector  bvFlags = 0
const [virtual]
 

Reimplemented from osg::Background.

Definition at line 200 of file OSGPolygonBackground.cpp.

References SLOG.

00202 {
00203     SLOG << "Dump PolygonBackground NI" << std::endl;
00204 }

Real32 PolygonBackground::mapCoordinate Real32  val,
Real32  max,
bool  norm
 

Definition at line 100 of file OSGPolygonBackground.cpp.

Referenced by clear().

00101 {
00102     if(val >= 0)
00103     {
00104         if (norm)
00105             val *= max;
00106     }
00107     else
00108     {
00109         val += 1;
00110         
00111         if (norm)
00112             val *= max;
00113         
00114         val = max + val;
00115     }
00116    
00117     return val;
00118 }

void PolygonBackground::initMethod void   )  [static, private]
 

Reimplemented from osg::Background.

Definition at line 69 of file OSGPolygonBackground.cpp.

00070 {
00071 }

void osg::PolygonBackground::operator= const PolygonBackground source  )  [private]
 

osg::FieldContainerType & osg::PolygonBackgroundBase::getClassType void   )  [inline, static, inherited]
 

Reimplemented from osg::BackgroundBase.

Definition at line 58 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_type.

Referenced by osg::PolygonBackgroundBase::create().

00059 {
00060     return _type; 
00061 } 

osg::UInt32 osg::PolygonBackgroundBase::getClassTypeId void   )  [inline, static, inherited]
 

Reimplemented from osg::BackgroundBase.

Definition at line 65 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_type, and osg::TypeBase::getId().

00066 {
00067     return _type.getId(); 
00068 } 

FieldContainerType & PolygonBackgroundBase::getType void   )  [virtual, inherited]
 

Reimplemented from osg::BackgroundBase.

Definition at line 150 of file OSGPolygonBackgroundBase.cpp.

References osg::PolygonBackgroundBase::_type.

00151 {
00152     return _type; 
00153 } 

const FieldContainerType & PolygonBackgroundBase::getType void   )  const [virtual, inherited]
 

Reimplemented from osg::BackgroundBase.

Definition at line 155 of file OSGPolygonBackgroundBase.cpp.

References osg::PolygonBackgroundBase::_type.

00156 {
00157     return _type;
00158 } 

UInt32 PolygonBackgroundBase::getContainerSize void   )  const [virtual, inherited]
 

Reimplemented from osg::BackgroundBase.

Definition at line 170 of file OSGPolygonBackgroundBase.cpp.

00171 { 
00172     return sizeof(PolygonBackground); 
00173 }

SFMaterialPtr * osg::PolygonBackgroundBase::getSFMaterial void   )  [inline, inherited]
 

Definition at line 101 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_sfMaterial.

00102 {
00103     return &_sfMaterial;
00104 }

MFVec3f * osg::PolygonBackgroundBase::getMFTexCoords void   )  [inline, inherited]
 

Definition at line 108 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_mfTexCoords.

00109 {
00110     return &_mfTexCoords;
00111 }

MFPnt2f * osg::PolygonBackgroundBase::getMFPositions void   )  [inline, inherited]
 

Definition at line 115 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_mfPositions.

00116 {
00117     return &_mfPositions;
00118 }

SFBool * osg::PolygonBackgroundBase::getSFNormalizedX void   )  [inline, inherited]
 

Definition at line 122 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_sfNormalizedX.

00123 {
00124     return &_sfNormalizedX;
00125 }

SFBool * osg::PolygonBackgroundBase::getSFNormalizedY void   )  [inline, inherited]
 

Definition at line 129 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_sfNormalizedY.

00130 {
00131     return &_sfNormalizedY;
00132 }

MaterialPtr & osg::PolygonBackgroundBase::getMaterial void   )  [inline, inherited]
 

Definition at line 137 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_sfMaterial, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

Referenced by clear().

00138 {
00139     return _sfMaterial.getValue();
00140 }

const MaterialPtr & osg::PolygonBackgroundBase::getMaterial void   )  const [inline, inherited]
 

Definition at line 144 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_sfMaterial, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

00145 {
00146     return _sfMaterial.getValue();
00147 }

bool & osg::PolygonBackgroundBase::getNormalizedX void   )  [inline, inherited]
 

Definition at line 158 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_sfNormalizedX, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

Referenced by clear().

00159 {
00160     return _sfNormalizedX.getValue();
00161 }

const bool & osg::PolygonBackgroundBase::getNormalizedX void   )  const [inline, inherited]
 

Definition at line 165 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_sfNormalizedX, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

00166 {
00167     return _sfNormalizedX.getValue();
00168 }

bool & osg::PolygonBackgroundBase::getNormalizedY void   )  [inline, inherited]
 

Definition at line 179 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_sfNormalizedY, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

Referenced by clear().

00180 {
00181     return _sfNormalizedY.getValue();
00182 }

const bool & osg::PolygonBackgroundBase::getNormalizedY void   )  const [inline, inherited]
 

Definition at line 186 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_sfNormalizedY, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

00187 {
00188     return _sfNormalizedY.getValue();
00189 }

Vec3f & osg::PolygonBackgroundBase::getTexCoords const UInt32  index  )  [inline, inherited]
 

Definition at line 201 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_mfTexCoords.

00202 {
00203     return _mfTexCoords[index];
00204 }

MFVec3f & osg::PolygonBackgroundBase::getTexCoords void   )  [inline, inherited]
 

Definition at line 208 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_mfTexCoords.

Referenced by clear().

00209 {
00210     return _mfTexCoords;
00211 }

const MFVec3f & osg::PolygonBackgroundBase::getTexCoords void   )  const [inline, inherited]
 

Definition at line 215 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_mfTexCoords.

00216 {
00217     return _mfTexCoords;
00218 }

Pnt2f & osg::PolygonBackgroundBase::getPositions const UInt32  index  )  [inline, inherited]
 

Definition at line 222 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_mfPositions.

00223 {
00224     return _mfPositions[index];
00225 }

MFPnt2f & osg::PolygonBackgroundBase::getPositions void   )  [inline, inherited]
 

Definition at line 229 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_mfPositions.

Referenced by clear().

00230 {
00231     return _mfPositions;
00232 }

const MFPnt2f & osg::PolygonBackgroundBase::getPositions void   )  const [inline, inherited]
 

Definition at line 236 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_mfPositions.

00237 {
00238     return _mfPositions;
00239 }

void osg::PolygonBackgroundBase::setMaterial const MaterialPtr value  )  [inline, inherited]
 

Definition at line 151 of file OSGPolygonBackgroundBase.inl.

References osg::PolygonBackgroundBase::_sfMaterial, and osg::SField< FieldTypeT, fieldNameSpace >::setValue().

00152 {
00153