class RED::LayerSet
Use this class to build sets of layers. Layers are visibility masks that can be used to filter some parts of a scene from rendering. More...
#include <REDLayerSet.h>
Inherits: IChunkSaver and Object.
Public functions:
LayerSet ( ) | |
~LayerSet ( ) | |
RED_RC | AddAllLayers ( ) |
RED_RC | AddLayer ( unsigned int iLayer ) |
virtual const void * | As ( const RED::CID & iCID ) const |
template< class T_As > const T_As * | As ( ) const |
virtual void * | As ( const RED::CID & iCID ) |
template< class T_As > T_As * | As ( ) |
void | ClearLayers ( ) |
RED_RC | GetLayers ( RED::Vector< unsigned int > & oLayers ) const |
RED::uint64 | GetMemorySize ( ) const |
IMPLEMENT_CHUNKINTERPRETER ( ) | |
bool | Intersects ( const RED::LayerSet & iOther ) const |
bool | IsAllLayers ( ) const |
bool | IsEmpty ( ) const |
bool | operator< ( const RED::LayerSet & iOther ) const |
RED_RC | operator= ( const RED::LayerSet & iSrc ) |
bool | operator== ( const RED::LayerSet & iOther ) const |
bool | operator> ( const RED::LayerSet & iOther ) const |
void | RemoveLayer ( unsigned int iLayer ) |
virtual RED_RC | Save ( RED::IStream * iStream, StreamingPolicy & iPolicy, int iState = -1 ) const |
Public static functions:
static RED::CID | GetClassID ( ) |
Public static variables:
static const RED::LayerSet | ALL_LAYERS |
Protected functions:
LayerSet ( int iSize ) |
Protected variables:
RED::Vector< unsigned int > | _layermask |
int | _size |
Detailed description:
Use this class to build sets of layers. Layers are visibility masks that can be used to filter some parts of a scene from rendering.
A RED::LayerSet is a mask of bits. Each bit corresponds to a layer. During the rendering of a scene, the engine checks the layer set that is set on each rendered viewpoint, and based on this value and on the layer set values of the scene geometries and transforms, filtering may occur for the rendering.
Layer sets are inherited in a DAG in the same way materials are inherited: The last layer found on the path to access a shape instance is the layer set for that shape instance.
For RED::IShape instances, a shape is discarded from the rendering whenever its own layer set does not match any valid layer bit set in the viewpoint's layer set. Children are also discarded but if they overload their ancestor's layer set.
For RED::IMaterial instances, rules differ. A material is defined per layer configuration. A material always have a RED::LayerSet::ALL_LAYERS rendering configuration and may have alternative rendering configurations defined. These configurations are selected during the rendering only if the rendered viewpoint layer set exactly matches one of them, which differs from the shape's rule. Note that the RED::OPTIONS_MATERIAL_LAYER_INTERSECT may affect this behavior.
RED::LayerSet objects are also used by lights for the selection of light receivers, shadow casting geometries and shadow receiving geometries.
Functions documentation
public RED::LayerSet::LayerSet | ( | ) |
LayerSet construction method.
The created layers set is empty.
public RED::LayerSet::~LayerSet | ( | ) |
LayerSet destruction method.
protected RED::LayerSet::LayerSet | ( | int | iSize | ) |
Internal construction method.
Parameters:
iSize: | Initial size. Used to setup ALL_LAYERS. |
public static RED::CID RED::LayerSet::GetClassID | ( | ) |
Reimplements: RED::IChunkSaver::GetClassID.
public RED_RC RED::LayerSet::AddAllLayers | ( | ) |
Adds all known layers in the cluster explicitly to the mask.
This method generates a layerset whose contents are set to the explicit list of layers that are known to exist inside the cluster at the time of the call.
The value of a layerset setup using this method is NOT identical to RED::LayerSet::ALL_LAYERS. If a new layer is created after this call, then the layerset won't contain it whereas RED::LayerSet::ALL_LAYERS is always containing all layers. After a call to this method, it's possible to use the RED::LayerSet::RemoveLayer method, as we contain the list of all existing layers in our mask.
Returns:
public RED_RC RED::LayerSet::AddLayer | ( | unsigned int | iLayer | ) |
Adds a layer to the set.
Adding a layer to a RED::LayerSet whose value is ALL_LAYERS has no effect. Adding a layer to a layer set is an operation that can cause a memory allocation and therefore, there's a multi-threading securization mutex that takes place during the operation, so this may cost a bit of time, specially if several threads create layersets in parallel.
Parameters:
iLayer: | Index of the layer to add. |
Returns:
public virtual const void * RED::LayerSet::As | ( | const RED::CID & | iCID | ) const |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Object::As.
template< class T_As > public const T_As * RED::LayerSet::As | ( | ) const |
Template version of the as const method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Object::As.
public virtual void * RED::LayerSet::As | ( | const RED::CID & | iCID | ) |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Object::As.
template< class T_As > public T_As * RED::LayerSet::As | ( | ) |
Template version of the as method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Object::As.
public void RED::LayerSet::ClearLayers | ( | ) |
Clears all layers from the layer set.
public RED_RC RED::LayerSet::GetLayers | ( | RED::Vector< unsigned int > & | oLayers | ) const |
public RED::uint64 RED::LayerSet::GetMemorySize | ( | ) const |
Gets the memory size used by the class.
Returns:
public bool RED::LayerSet::Intersects | ( | const RED::LayerSet & | iOther | ) const |
Layer inclusion test.
Layer interference tests are:
- If this is empty, then it does not interfere with iOther.
- If this is RED::LayerSet::ALL_LAYERS:
- if iOther is empty, then intersection does not exist.
- Otherwise intersection exists.
- For all other cases, the intersection exists if iOther has at least one layer bit that matches a layer bit in this.
Returns:
public bool RED::LayerSet::IsAllLayers | ( | ) const |
Tests whether the layerset is set to ALL_LAYERS or not.
Returns:
public bool RED::LayerSet::IsEmpty | ( | ) const |
Gets the fill state of the layer set.
Returns:
public bool RED::LayerSet::operator< | ( | const RED::LayerSet & | iOther | ) const |
Sorting operator.
Parameters:
iOther: | reference to another RED::LayerSet. |
Returns:
public RED_RC RED::LayerSet::operator= | ( | const RED::LayerSet & | iSrc | ) |
Assignment operator.
Parameters:
iSrc: | Source of our contents. |
Returns:
public bool RED::LayerSet::operator== | ( | const RED::LayerSet & | iOther | ) const |
public bool RED::LayerSet::operator> | ( | const RED::LayerSet & | iOther | ) const |
Sorting operator.
Parameters:
iOther: | reference to another RED::LayerSet. |
Returns:
public void RED::LayerSet::RemoveLayer | ( | unsigned int | iLayer | ) |
Removes a layer from the set.
Removing a layer from a layer whose value is RED::LayerSet::ALL_LAYERS is ignored.
Parameters:
iLayer: | Index of the layer to remove. |
public virtual RED_RC RED::LayerSet::Save | ( | RED::IStream * | iStream, |
StreamingPolicy & | iPolicy, | ||
int | iState = -1 | ||
) | const |
Saves the object content as one or more chunks in the given stream.
Parameters:
iStream: | Pointer to the stream where the data must be saved. |
iPolicy: | Reference to the streaming policy to be used. |
iState: | Optional state number parameter at which the data to be saved must be retrieved. Default is set to 0 (for current state). |
Returns:
RED_FILE_WRITE_ERROR on a file write error (if iStream is a file stream),
RED_ALLOC_FAILURE on a memory allocation error,
RED_FAIL otherwise.
Implements: RED::IChunkSaver::Save.
Variables documentation
Built-in layer set: include every layer.
Layer bits field. Each bit corresponds to a layer: if set to 1 the shape belongs to the layer, if set to 0 it does not.
Number of layers into the set: -1: ALL_LAYERS. >= 0: Number of layer bits in the layerset.