Carna Version 3.3.3
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Carna::presets::ParallaxStage Class Reference

Produces stereoscopic renderings. More...

#include <ParallaxStage.h>

+ Inheritance diagram for Carna::presets::ParallaxStage:
+ Collaboration diagram for Carna::presets::ParallaxStage:

Public Member Functions

 ParallaxStage (CompositionMode compositionMode)
 Sets the eye distance to DEFAULT_EYE_DISTANCE.
 
ParallaxStageclone () const override
 Returns same RenderStage implementation with same configuration.
 
virtual ~ParallaxStage ()
 Deletes.
 
void setEyeDistance (float)
 Sets the double of the distance that the camera is offset to left/right.
 
float eyeDistance () const
 Tells the double of the distance that the camera is offset to left/right.
 
- Public Member Functions inherited from Carna::presets::CompositionStage
 CompositionStage (CompositionMode compositionMode)
 Instantiates.
 
virtual ~CompositionStage ()
 Deletes.
 
void setCompositionMode (CompositionMode compositionMode)
 Sets how the two renderings obtained through renderPass(const base::math::Matrix4f&,base::RenderTask&,const base::Viewport&,bool,bool) shall be combined.
 
CompositionMode compositionMode () const
 Tells how the two renderings obtained through renderPass(const base::math::Matrix4f&,base::RenderTask&,const base::Viewport&,bool,bool) are combined.
 
void setCompositionSwap (bool)
 Swaps the two renderings obtained through renderPass(const base::math::Matrix4f&,base::RenderTask&,const base::Viewport&,bool,bool) when combining.
 
bool isCompositionSwapped () const
 Tells whether the two renderings obtained through renderPass(const base::math::Matrix4f&,base::RenderTask&,const base::Viewport&,bool,bool) are swapped when combined.
 
virtual void reshape (base::FrameRenderer &fr, unsigned int width, unsigned int height) override
 Orders this stage to reshape its buffers according to the specified dimensions.
 
virtual void prepareFrame (base::Node &root) override
 Called once before each frame.
 
virtual void renderPass (const base::math::Matrix4f &viewTransform, base::RenderTask &rt, const base::Viewport &vp) override
 Invokes renderPass(const base::math::Matrix4f&,base::RenderTask&,const base::Viewport&,bool,bool) twice and combines the results like specified.
 
- Public Member Functions inherited from Carna::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.
 
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)\).
 

Static Public Attributes

static const float DEFAULT_EYE_DISTANCE
 Holds the default double distance that the camera is offset to left/right.
 

Protected Member Functions

virtual void renderPass (const base::math::Matrix4f &viewTransform, base::RenderTask &rt, const base::Viewport &vp, bool isFirstInvocation, bool isFirstSource) override
 Renders one of the two renderings that are to be combined per invocation.
 

Additional Inherited Members

- Public Types inherited from Carna::presets::CompositionStage
enum  CompositionMode { interleave , aside }
 Defines how two renderings are to be combined. More...
 

Detailed Description

Produces stereoscopic renderings.

Example

The instantiation of the ParallaxStage takes a parameter that decides how the composition of the two images should be done:

/* Create parallax rendering stage.
*/
parallax->setEyeDistance( presets::ParallaxStage::DEFAULT_EYE_DISTANCE * 3 );
renderer->appendStage( parallax );
void appendStage(RenderStage *stage)
Appends stage to the rendering stages sequence.
base::FrameRenderer & renderer()
References the renderer this stage belongs to.
Produces stereoscopic renderings.
static const float DEFAULT_EYE_DISTANCE
Holds the default double distance that the camera is offset to left/right.

We also enlarge the eye distance for demonstration purposes. For same reason, lets also add a few other rendering stages:

/* Create opaque rendering stage.
*/
presets::OpaqueRenderingStage* const opaque = new presets::OpaqueRenderingStage( GEOMETRY_TYPE_OPAQUE );
renderer->appendStage( opaque );
/* Create volumetric rendering stage.
*/
presets::DRRStage* const drr = new presets::DRRStage( GEOMETRY_TYPE_VOLUMETRIC );
drr->setSampleRate( 100 );
drr->setWaterAttenuation( 5e-3f );
drr->setBaseIntensity( 1.f );
drr->setUpperMultiplier( 1.5f );
Represents an association.
Definition Association.h:45
Renders digital radiograph reconstructs of volume geometries in the scene.
Definition DRRStage.h:107
void setUpperMultiplier(float multiplier)
Sets to multiplier. The parameters are described here.
void setWaterAttenuation(float muWater)
Sets to muWater. The parameters are described here.
void setUpperThreshold(base::HUV upper)
Sets to upper. The parameters are described here.
void setLowerThreshold(base::HUV lower)
Sets to lower. The parameters are described here.
void setBaseIntensity(float baseIntensity)
Sets to baseIntensity. The parameters are described here.
void setSampleRate(unsigned int sampleRate)
Sets number of slices to be rendered per segment.
base::MeshRenderingStage< base::Renderable::VideoResourcesOrder< base::MeshRenderingStageBase::ROLE_DEFAULT_MATERIAL > > OpaqueRenderingStage
Implements rendering stage that renders opaque meshes.
static HUV abs(T value)
Wraps an absolute HU value.
Definition HUV.h:134

The concept of geometry types is explained here.

The last step is to setup the scene, e.g.:

base::Material& material = base::Material::create( "unshaded" );
material.setParameter( "color", base::Color::RED );
base::Geometry* const box = new base::Geometry( GEOMETRY_TYPE_OPAQUE );
box->putFeature( presets::OpaqueRenderingStage::ROLE_DEFAULT_MESH, boxMesh );
box->putFeature( presets::OpaqueRenderingStage::ROLE_DEFAULT_MATERIAL, material );
scene->root->attachChild( box );
boxMesh.release();
material.release();
static const Color RED
Holds Color(255, 0, 0, 255).
Definition Color.h:50
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.h:60
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...
Definition ManagedMesh.h:57
Specifies the shader and it's configuration that are to be used for rendering a Geometry node with a ...
Definition Material.h:175
void setParameter(const std::string &name, const ParameterType &value)
Definition Material.h:306
static Material & create(const std::string &shaderName)
Instantiates. Call release when you do not need the object any longer.
static ManagedMesh< VertexType, uint8_t > & createBox(float width, float height, float depth)
Creates box with width, height and depth. The box is centered in .

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

exemplary rendering in aside-mode from code above
Author
Leonid Kostrykin
Date
22.2.15 - 11.3.15

Definition at line 62 of file ParallaxStage.h.

Member Function Documentation

◆ clone()

ParallaxStage * Carna::presets::ParallaxStage::clone ( ) const
overridevirtual

Returns same RenderStage implementation with same configuration.

The listeners and the rendering state are not copied.

Deprecated:
Do not use this method. It will be removed shortly.

Implements Carna::base::RenderStage.

◆ renderPass()

virtual void Carna::presets::ParallaxStage::renderPass ( const base::math::Matrix4f viewTransform,
base::RenderTask rt,
const base::Viewport vp,
bool  isFirstInvocation,
bool  isFirstSource 
)
overrideprotectedvirtual

Renders one of the two renderings that are to be combined per invocation.

Parameters
viewTransformtransforms world space to view space.
rtreferences the rendering task.
vpreferences the viewport.
isFirstInvocationindicates whether this is the first rendering invocation of the current rendering pass.
isFirstSourceindicates whether this rendering should be done using the "first" method/source/algorithm.

Note that isFirstInvocation == isFirstSource is true when swapping was disabled and isFirstInvocation != isFirstSource is true if it was enabled.

Implements Carna::presets::CompositionStage.

Member Data Documentation

◆ DEFAULT_EYE_DISTANCE

const float Carna::presets::ParallaxStage::DEFAULT_EYE_DISTANCE
static

Holds the default double distance that the camera is offset to left/right.

Definition at line 73 of file ParallaxStage.h.


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