LibCarna Version 3.4.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
LibCarna::presets::TransparentRenderingStage Class Reference

Implements rendering stage that renders transparent meshes. More...

#include <TransparentRenderingStage.hpp>

+ Inheritance diagram for LibCarna::presets::TransparentRenderingStage:
+ Collaboration diagram for LibCarna::presets::TransparentRenderingStage:

Public Member Functions

 TransparentRenderingStage (unsigned int geometryType)
 Instantiates.
 
virtual void renderPass (const base::math::Matrix4f &viewTransform, base::RenderTask &rt, const base::Viewport &vp) override
 Renders transparent geometries with enabled blending and disabled depth writing.
 
- Public Member Functions inherited from LibCarna::base::MeshRenderingStage< base::Renderable::BackToFront >
 MeshRenderingStage (unsigned int geometryType)
 Instantiates.
 
- Public Member Functions inherited from LibCarna::base::GeometryStage< RenderableCompare >
 GeometryStage (unsigned int geometryType, unsigned int geometryTypeMask=RenderQueue< RenderableCompare >::EXACT_MATCH_GEOMETRY_TYPE_MASK)
 Instantiates s.t. the predefined rendering queue enqueues such LibCarna::base::Geometry scene graph nodes, whose geometry type AND-linked with geometryTypeMask equals the geometryType specified here.
 
virtual ~GeometryStage ()
 Releases acquired video resources.
 
virtual void prepareFrame (Node &root) override
 Called once before each frame.
 
std::size_t renderedPassesCount () const
 Tells the number of passes rendered so far since the beginning of the current frame.
 
template<typename GeometryFeatureType >
GeometryFeatureType::ManagedInterface & videoResource (GeometryFeatureType &geometryFeature) const
 Interfaces the geometryFeature video resources that were acquired by this rendering stage.
 
template<typename GeometryFeatureType >
const GeometryFeatureType::ManagedInterface & videoResource (const GeometryFeatureType &geometryFeature) const
 
- Public Member Functions inherited from LibCarna::base::RenderStage
 RenderStage ()
 Instantiates in enabled-state.
 
virtual ~RenderStage ()
 Deletes.
 
void setViewTransformFixed (bool viewTransformFixed)
 Sets whether the view transform is pass-invariant for the duration of a single frame.
 
bool isViewTransformFixed () const
 Tells whether the view transform is pass-invariant for the duration of a single frame.
 
virtual void reshape (FrameRenderer &fr, unsigned int width, unsigned int height)
 Orders this stage to reshape its buffers according to the specified width and height.
 
bool isInitialized () const
 Tells whether this stage is ready for rendering.
 
bool isEnabled () const
 Tells whether this stage is enabled. Disabled stages are not rendered by render tasks.
 
void setEnabled (bool)
 Sets whether this stage is enabled. Disabled stages are not rendered by render tasks.
 
base::FrameRendererrenderer ()
 References the renderer this stage belongs to.
 
const base::FrameRendererrenderer () const
 
void addRenderStageListener (RenderStageListener &listener)
 Adds listener to the set of listeners this instance notifies in \(\mathcal O\left(\log n\right)\).
 
void removeRenderStageListener (RenderStageListener &listener)
 Removes listener from the set of listeners this instance notifies in \(\mathcal O\left(\log n\right)\).
 
- Public Member Functions inherited from LibCarna::base::MeshRenderingMixin
 MeshRenderingMixin (unsigned int geometryType)
 Instantiates.
 
virtual ~MeshRenderingMixin ()
 Does nothing.
 

Additional Inherited Members

- Public Attributes inherited from LibCarna::base::GeometryStage< RenderableCompare >
const unsigned int geometryType
 Renders such geometries whose type AND-linked with geometryTypeMask equals this.
 
const unsigned int geometryTypeMask
 Renders such geometries whose type AND-linked with this equals geometryType.
 
- Public Attributes inherited from LibCarna::base::MeshRenderingMixin
const unsigned int geometryType
 Holds the geometry type rendered by this MeshRenderingStage.
 
- Static Public Attributes inherited from LibCarna::base::MeshRenderingMixin
static const unsigned int DEFAULT_ROLE_MESH = 0
 Identifies the Mesh object that MeshRenderingStage uses for rendering.
 
static const unsigned int DEFAULT_ROLE_MATERIAL = 1
 Identifies the Material object that MeshRenderingStage uses for rendering.
 
- Protected Member Functions inherited from LibCarna::base::MeshRenderingStage< base::Renderable::BackToFront >
virtual void render (const Renderable &renderable) override
 Renders the renderable.
 
- Protected Member Functions inherited from LibCarna::base::GeometryStage< RenderableCompare >
void activateGLContext () const
 Ensures that the OpenGL context of the hosting LibCarna::base::FrameRenderer is the current one.
 
virtual void buildRenderQueues (Node &root, const math::Matrix4f &viewTransform)
 Builds the rendering queues of this stage.
 
virtual void rewindRenderQueues ()
 Rewinds the rendering queues of this stage.
 
virtual void updateRenderQueues (const math::Matrix4f &viewTransform)
 Recomputes the model-view transforms of the renderables enqueued by this stage.
 
- Protected Attributes inherited from LibCarna::base::GeometryStage< RenderableCompare >
RenderQueue< RenderableComparerq
 Holds the predefined rendering queue of this rendering stage.
 

Detailed Description

Implements rendering stage that renders transparent meshes.

The TransparentRenderingStage constructor takes a geometry type parameter:

transparent = new presets::TransparentRenderingStage( GEOMETRY_TYPE_TRANSPARENT );
renderer->appendStage( transparent );
void appendStage(RenderStage *stage)
Appends stage to the rendering stages sequence.
base::FrameRenderer & renderer()
References the renderer this stage belongs to.
Implements rendering stage that renders transparent meshes.

The concept of geometry types is explained here.

Note
In the rendering process this stage will usually be inserted after such stages that render opaque geometry, like CuttingPlanesStage and OpaqueRenderingStage.

The following example code configures the scene s.t. it produces the rendering presented further below:

base::Material& redMaterial = base::Material::create( "unshaded" );
base::Material& greenMaterial = base::Material::create( "unshaded" );
redMaterial .setParameter( "color", base::math::Vector4f( 1, 0, 0, 0.5f ) );
greenMaterial.setParameter( "color", base::math::Vector4f( 0, 1, 0, 0.5f ) );
base::Geometry* const box1 = new base::Geometry( GEOMETRY_TYPE_TRANSPARENT );
base::Geometry* const box2 = new base::Geometry( GEOMETRY_TYPE_TRANSPARENT );
boxMesh.release();
redMaterial.release();
greenMaterial.release();
scene->root->attachChild( box1 );
scene->root->attachChild( box2 );
box1->localTransform = base::math::translation4f( -10, -10, -40 );
box2->localTransform = base::math::translation4f( +10, +10, +40 );
void release()
Denotes that this object is no longer required and may be deleted as soon as it is valid to delete it...
Defines scene graph leafs. Instances of this class represent visible geometry that can be rendered....
Definition Geometry.hpp:63
void putFeature(unsigned int role, GeometryFeature &feature)
Adds the feature to this geometry node using role in . The concept of geometry features and roles is ...
Represents MeshBase object whose lifetime is managed by instances of this class. This is a format-ind...
Specifies the shader and it's configuration that are to be used for rendering a Geometry node with a ...
Definition Material.hpp:176
static Material & create(const std::string &shaderName)
Instantiates. Call release when you do not need the object any longer.
void setParameter(const std::string &name, const ParameterType &value)
Definition Material.hpp:310
static ManagedMesh< VertexType, uint8_t > & createBox(float width, float height, float depth)
Creates box with width, height and depth. The box is centered in .
static const unsigned int DEFAULT_ROLE_MATERIAL
Identifies the Material object that MeshRenderingStage uses for rendering.
static const unsigned int DEFAULT_ROLE_MESH
Identifies the Mesh object that MeshRenderingStage uses for rendering.
math::Matrix4f localTransform
Defines the location, rotation and scale of this spatial in relation to it's parent....
Definition Spatial.hpp:135
Eigen::Matrix< float, 4, 1 > Vector4f
Defines vector.
Definition math.hpp:199
Matrix4f translation4f(float x, float y, float z)
Returns matrix that translates homogeneous coordinates.
Definition math.hpp:275

The concept of materials, meshes and other geometry feature is explained here.

exemplary rendering of two box meshes from code above
Author
Leonid Kostrykin

Definition at line 63 of file TransparentRenderingStage.hpp.

Constructor & Destructor Documentation

◆ TransparentRenderingStage()

LibCarna::presets::TransparentRenderingStage::TransparentRenderingStage ( unsigned int  geometryType)
explicit

Instantiates.

Parameters
geometryTypeis the geometry type rendered by this stage.

Member Function Documentation

◆ renderPass()

virtual void LibCarna::presets::TransparentRenderingStage::renderPass ( const base::math::Matrix4f viewTransform,
base::RenderTask rt,
const base::Viewport vp 
)
overridevirtual

Renders transparent geometries with enabled blending and disabled depth writing.

Reimplemented from LibCarna::base::MeshRenderingStage< base::Renderable::BackToFront >.


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