Carna  Version 3.3.2
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

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 = new presets::ParallaxStage( presets::ParallaxStage::aside );
parallax->setEyeDistance( presets::ParallaxStage::DEFAULT_EYE_DISTANCE * 3 );
renderer->appendStage( parallax );

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->setLowerThreshold( base::HUV::abs( -400 ) );
drr->setUpperThreshold( base::HUV::abs( +400 ) );
drr->setUpperMultiplier( 1.5f );

The concept of geometry types is explained here.

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

base::ManagedMeshBase& boxMesh = base::MeshFactory< base::PVertex >::createBox( 40, 40, 40 );
base::Material& material = base::Material::create( "unshaded" );
material.setParameter( "color", base::Color::RED );
base::Geometry* const box = new base::Geometry( GEOMETRY_TYPE_OPAQUE );
scene->root->attachChild( box );
boxMesh.release();
material.release();

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

aside.png
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.


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