version 3.3

VRS::TexturedBatchTreeGL Class Reference

#include <vrs/opengl/texturedbatchtreegl.h>

Inheritance diagram for VRS::TexturedBatchTreeGL:

VRS::Shape VRS::RenderObj VRS::SharedObj VRS::Visitable

List of all members.

Public Types

enum  TextureHint { TH_DISABLE_ATLAS, TH_ENABLE_ATLAS, TH_UNKNOWN }
 The TextureHint indicates whether it is allowed to combine a certain texture with other textures to a texture atlas. More...
typedef Iterator< SO< RenderObj > > StateSet
 A state set is a set of render objects that modify the appearance of a shape.

Public Member Functions

 TexturedBatchTreeGL ()
int insertShape (SO< PolygonSet > shape, SO< ImageTexture2DGL > texture=NULL, TextureHint hint=TH_UNKNOWN, int stateSetID=-1)
 Inserts a new shape.
SO< Iterator< int > > insertShapes (SO< Iterator< SO< PolygonSet > > > shapes, SO< ImageTexture2DGL > texture=NULL, TextureHint hint=TH_UNKNOWN, int stateSetID=-1)
 The same as above for multiple shapes sharing a single texture.
SO< Iterator< int > > insertShapes (SO< Iterator< SO< PolygonSet > > > shapes, SO< Iterator< SO< ImageTexture2DGL > > > textures, SO< Iterator< TextureHint > > hints, SO< Iterator< int > > stateSetIDs)
 The second variant allows for inserting multiple shapes with different textures and states.
bool removeShape (int id)
 Removes a previously inserted shape from the tree.
bool removeShapes (SO< Iterator< int > > ids)
 Removes multiple previously inserted shapes from the tree.
SO< PolygonSetextractShape (int index) const
 Creates a PolygonSet that contains the previously inserted data.
SO< Iterator< int > > shapeIDs () const
 Iterator of all currently registered ShapeIDs.
SO< ImageTexture2DGLgetTexture (int index) const
 Returns the texture for a previously inserted shape.
virtual Bounds boundingBox () const
 Returns the summed bounding box of all shapes.
void setShapeVisibility (int index, bool visible)
 Allows to hide certain shapes temporarily without removing them, so that the change does not involve any reconfiguration of textures.
bool getShapeVisibility (int index) const
void optimize (int maxAtlasSize=1024)
 Combines several separately stored textures into texture atlases.
unsigned int getMaximumBatchSize () const
 See batchtreegl.h.
void setMaximumBatchSize (unsigned int size=0xffff)
int registerStateSet (SO< StateSet > stateSet, bool doNotUnify=false)
 Registers a StateSet that can be assigned to one or more shapes.
SO< StateSetgetStateSet (int stateSetID) const
 Returns/Removes the StateSet for a given StateSet index.
bool unregisterStateSet (int stateSetID)
void cleanUpStateSets ()
 removes all state sets that are no more referenced by any registered shape.
int getShapeStateSet (int shapeID) const
 Returns the associated StateSetID for a given shape id.
SO< Iterator< int > > getStateSetIDs () const
 Returns an iterator of all currently registered state set ids.
void changeStateSet (int shapeID, int newStateSetID, SO< ImageTexture2DGL > tex)
 Assigns a different StateSet to one or more previously added shapes.
void changeStateSets (SO< Iterator< int > > shapeIDs, SO< Iterator< int > > newStateSetIDs, SO< Iterator< SO< ImageTexture2DGL > > > textures=NULL)
bool replaceStateSet (int stateSetIndex, SO< StateSet > stateSet)
 Allows to change an already registered stateSet.
 VRS_TYPEINFO (TexturedBatchTreeGL, Shape)
 VRS_SERIALIZABLE (TexturedBatchTreeGL)

Friends

class TexturedBatchTreeSimplifierGL
class TexturedBatchTreeRayIntersectorGL

Classes

struct  AtlasImage
struct  ShapeInfo


Member Typedef Documentation

A state set is a set of render objects that modify the appearance of a shape.

Only Attributes and Transforms will be considered. All other kinds of RenderObj cause a warning and are ignored.


Member Enumeration Documentation

The TextureHint indicates whether it is allowed to combine a certain texture with other textures to a texture atlas.

For textures that are used repeatedly, i.e., with tex coords outside [0,1], texture atlases should be disabled. If TH_UNKNOWN is used, the right choice is automatically detected (increases insertion time).

Enumerator:
TH_DISABLE_ATLAS 
TH_ENABLE_ATLAS 
TH_UNKNOWN 


Constructor & Destructor Documentation

VRS::TexturedBatchTreeGL::TexturedBatchTreeGL (  ) 


Member Function Documentation

int VRS::TexturedBatchTreeGL::insertShape ( SO< PolygonSet shape,
SO< ImageTexture2DGL texture = NULL,
TextureHint  hint = TH_UNKNOWN,
int  stateSetID = -1 
)

Inserts a new shape.

The return value is a unique index that can be used to delete the shape later. Passing a NULL pointers or invalid shapes causes a warning and returns -1 as index. If texture is not NULL it must contain a valid image. 'stateSetIndex' must be either -1 or the index of any previously registered StateSet (see below). If 'stateSetID' is -1, the shape is inserted without additional appearance attributes.

SO<Iterator<int> > VRS::TexturedBatchTreeGL::insertShapes ( SO< Iterator< SO< PolygonSet > > >  shapes,
SO< ImageTexture2DGL texture = NULL,
TextureHint  hint = TH_UNKNOWN,
int  stateSetID = -1 
)

The same as above for multiple shapes sharing a single texture.

NULL pointers or invalid shapes cause a warning, and their corresponding int-index is set to -1. The first version assigns the same stateset number to all shapes

SO<Iterator<int> > VRS::TexturedBatchTreeGL::insertShapes ( SO< Iterator< SO< PolygonSet > > >  shapes,
SO< Iterator< SO< ImageTexture2DGL > > >  textures,
SO< Iterator< TextureHint > >  hints,
SO< Iterator< int > >  stateSetIDs 
)

The second variant allows for inserting multiple shapes with different textures and states.

'textures', 'hints', and stateSetIndices may be NULL, may contain NULL pointers or may be shorter than 'shapes'. Any missing values will be interpreted as default values:

  • Shapes do not need a texture
  • Missing texture hints are interpreted as TH_UNKNOWN
  • Missing stateSetIndices are interpreted as -1, i.e., "no stateset". The cooresponding shapes will be rendered without additional appearance attributes.

bool VRS::TexturedBatchTreeGL::removeShape ( int  id  ) 

Removes a previously inserted shape from the tree.

If the index is invalid, the return value is 'false' and a warning is caused. Textures are automatically removed as soon as they are not used any longer.

bool VRS::TexturedBatchTreeGL::removeShapes ( SO< Iterator< int > >  ids  ) 

Removes multiple previously inserted shapes from the tree.

If the iterator contains one or more invalid indices, the return value is 'false'.

SO<PolygonSet> VRS::TexturedBatchTreeGL::extractShape ( int  index  )  const

Creates a PolygonSet that contains the previously inserted data.

Since the inserted PolygonSets are not explicitly stored (due to memory efficiency reasons), the return value is extracted from the internal combined shapes. 'index' must be an index obtained from a previous shape insertion and must not have been used in a removeShape call since.

SO<Iterator<int> > VRS::TexturedBatchTreeGL::shapeIDs (  )  const

Iterator of all currently registered ShapeIDs.

SO<ImageTexture2DGL> VRS::TexturedBatchTreeGL::getTexture ( int  index  )  const

Returns the texture for a previously inserted shape.

virtual Bounds VRS::TexturedBatchTreeGL::boundingBox (  )  const [virtual]

Returns the summed bounding box of all shapes.

Implements VRS::Shape.

void VRS::TexturedBatchTreeGL::setShapeVisibility ( int  index,
bool  visible 
)

Allows to hide certain shapes temporarily without removing them, so that the change does not involve any reconfiguration of textures.

'index' must be a valid index obtained by an insertion method.

bool VRS::TexturedBatchTreeGL::getShapeVisibility ( int  index  )  const

void VRS::TexturedBatchTreeGL::optimize ( int  maxAtlasSize = 1024  ) 

Combines several separately stored textures into texture atlases.

unsigned int VRS::TexturedBatchTreeGL::getMaximumBatchSize (  )  const

void VRS::TexturedBatchTreeGL::setMaximumBatchSize ( unsigned int  size = 0xffff  ) 

int VRS::TexturedBatchTreeGL::registerStateSet ( SO< StateSet stateSet,
bool  doNotUnify = false 
)

Registers a StateSet that can be assigned to one or more shapes.

The return value is an index that can later be used to identify a registered StateSet, e.g., to assign it to one or more shapes.

Per default, equal statesets will be avoided, i.e., if a new StateSet S1 equals a previously inserted StateSet S2 one, the index of S2 will be returned and S1 will not be stored. If 'doNotUnify' is true, a StateSet will never be unified with another StateSet even if they are equal. Use this if you want to ensure that later changes of a certain StateSet affect only a certain set of shapes.

The objects contained in StateSets will not be copied, i.e., later changes will affect all shapes that use the StateSet. If stateSet is NULL or empty and 'doNotModify' is false, the return value is -1. Otherwise, an empty StateSet will be stored and a new index will be returned.

SO<StateSet> VRS::TexturedBatchTreeGL::getStateSet ( int  stateSetID  )  const

Returns/Removes the StateSet for a given StateSet index.

If 'stateSetID' is invalid, the return value is NULL. A StateSet can only be removed if it is not referenced by any shapes anymore. If 'unregisterStateSet' returns false, the stateSetIndex was either invalid or there were still referring shapes.

bool VRS::TexturedBatchTreeGL::unregisterStateSet ( int  stateSetID  ) 

void VRS::TexturedBatchTreeGL::cleanUpStateSets (  ) 

removes all state sets that are no more referenced by any registered shape.

Note that this might cause externally stored state set IDs to become invalid.

int VRS::TexturedBatchTreeGL::getShapeStateSet ( int  shapeID  )  const

Returns the associated StateSetID for a given shape id.

If shapeID is not registered, the return value is -1 and a warning is caused.

SO<Iterator<int> > VRS::TexturedBatchTreeGL::getStateSetIDs (  )  const

Returns an iterator of all currently registered state set ids.

void VRS::TexturedBatchTreeGL::changeStateSet ( int  shapeID,
int  newStateSetID,
SO< ImageTexture2DGL tex 
)

Assigns a different StateSet to one or more previously added shapes.

If one of the ids is invalid, a warning is caused. Otherwise, the shape(s) will appear with the new appearance attributes. If 'textures' is NULL, the shapes are assigned to the same textures as before. The 'textureHint' (see insertShapes) is left unchanged for previously inserted textures and is assumed as 'TH_UNKNOWN' for new textures.

void VRS::TexturedBatchTreeGL::changeStateSets ( SO< Iterator< int > >  shapeIDs,
SO< Iterator< int > >  newStateSetIDs,
SO< Iterator< SO< ImageTexture2DGL > > >  textures = NULL 
)

bool VRS::TexturedBatchTreeGL::replaceStateSet ( int  stateSetIndex,
SO< StateSet stateSet 
)

Allows to change an already registered stateSet.

Note: If multiple identical stateSets are registered with 'doNotUnify'==false, this change will affect all shapes that have been inserted with equal StateSets. If the index is invalid, the return value is false.

VRS::TexturedBatchTreeGL::VRS_TYPEINFO ( TexturedBatchTreeGL  ,
Shape   
)

VRS::TexturedBatchTreeGL::VRS_SERIALIZABLE ( TexturedBatchTreeGL   ) 


Friends And Related Function Documentation

friend class TexturedBatchTreeSimplifierGL [friend]

friend class TexturedBatchTreeRayIntersectorGL [friend]


The documentation for this class was generated from the following file:

Generated on Sat May 25 06:00:28 2013 by Doxygen 1.5.6
© 2001-2010 Hasso-Plattner-Institut | Impressum | Contact