Public Member Functions | Private Member Functions | Private Attributes | List of all members
asv::WavefieldVisualPlugin Class Reference

A Gazebo visual plugin to synchronise and control a vertex shader rendering Gerstner waves. It also renders reflections and refractions onto the water. More...

#include <WavefieldVisualPlugin.hh>

Inheritance diagram for asv::WavefieldVisualPlugin:
Inheritance graph
[legend]

Public Member Functions

virtual void Init ()
 Initialize the plugin. More...
 
virtual void Load (gazebo::rendering::VisualPtr _visual, sdf::ElementPtr _sdf)
 Load the plugin. More...
 
virtual void Reset ()
 Reset the plugin. More...
 
 WavefieldVisualPlugin ()
 Constructor. More...
 
virtual ~WavefieldVisualPlugin ()
 Destructor. More...
 

Private Member Functions

void AddNewCamerasForReflectionRefraction ()
 Check for new cameras, setup rtts for them. More...
 
void CreateRtts (Ogre::Camera *_camera)
 Create reflection refraction rtts for a given camera Stores the render target and given camera. More...
 
std::vector< gazebo::rendering::CameraPtr > NewCameras ()
 Get new cameras not already contained in this->data->cameras. More...
 
void OnCameraPreRender (const std::string &_camera)
 Update rtts before cameras. More...
 
void OnPreRender ()
 Called every PreRender event. More...
 
void OnStatsMsg (ConstWorldStatisticsPtr &_msg)
 Callback for gztopic "~/world_stats". More...
 
virtual void postRenderTargetUpdate (const Ogre::RenderTargetEvent &rte)
 
virtual void preRenderTargetUpdate (const Ogre::RenderTargetEvent &rte)
 Hide/Show objects for reflection/refraction render eg. hide objects above water for refraction hide objects below water for reflection unhide all objects after texture is rendered. More...
 
void SetShaderParams ()
 Update the vertex shader parameters. More...
 
void SetupReflectionRefraction ()
 Setup Ogre objects for reflection/refraction. More...
 
void UpdateClipPlanes ()
 Move and rotate clip planes to match ocean pose. More...
 

Private Attributes

std::shared_ptr< WavefieldVisualPluginPrivatedata
 

Detailed Description

A Gazebo visual plugin to synchronise and control a vertex shader rendering Gerstner waves. It also renders reflections and refractions onto the water.

Usage

Add the SDF for the plugin to the <visual> element of your wave model.

The SDF parameters specifying the wave are all optional, and normal use will be overridden.

If this visual is loaded as part of a wave model that also contains the plugin libWavefieldModelPlugin.so, then it will receive a response to its request for ~/wave_param and set the wave parameters to be consistent with the wave generator operating on the physics server.

<plugin name="wavefield_visual" filename="libWavefieldVisualPlugin.so">
<enableRtt>true</enableRtt>
<rttNoise>0.1</rttNoise>
<refractOpacity>0.1</refractOpacity>
<reflectOpacity>0.5</reflectOpacity>
<static>false</static>
<wave>
<number>3</number>
<scale>1.5</scale>
<angle>0.4</angle>
<steepness>1.0</steepness>
<amplitude>0.4</amplitude>
<period>8.0</period>
<direction>1 1</direction>
</wave>
</plugin>

Subscribed Topics

  1. ~/reponse (gazebo::msgs::Response)
  2. ~/wave (gazebo::msgs::Param_V)
  3. ~/world_stats (gazebo::msgs::WorldStatistics)
  4. /marker (ignition::msgs::Marker)

Published Topics

  1. ~/request (gazebo::msgs::Request)

Parameters

  1. <static> (bool, default: false) Display a static wave field if set to true.
  2. <enableRtt> (bool, default: true) Display reflection and reflections if set to true.
  3. <rttNoise> (double, default: 0.1) Amount of distortion in reflection/refraction.
  4. <refractOpacity> (double, default: 0.2) Ratio between shallow water color and refraction color to use In [0, 1], where 0 is no refraction and 1 is maximum refraction
  5. <reflectOpacity> (double, default: 0.2) Ratio between environment color and reflection color to use In [0, 1], where 0 is no reflection and 1 is maximum reflection
  6. <number> (int, default: 1) The number of component waves.
  7. <scale> (double, default: 2.0) The scale between the mean and largest / smallest component waves.
  8. <angle> (double, default: 2*pi/10) The angle between the mean wave direction and the largest / smallest component waves.
  9. <steepness> (double, default: 1.0) A parameter in [0, 1] controlling the wave steepness with 1 being steepest.
  10. <amplitude> (double, default: 0.0) The amplitude of the mean wave in [m].

11.<period> (double, default: 1.0) The period of the mean wave in [s].

12.<phase> (double, default: 0.0) The phase of the mean wave.

13.<direction> (Vector2D, default: (1 0)) A two component vector specifiying the direction of the mean wave.

Definition at line 138 of file WavefieldVisualPlugin.hh.

Constructor & Destructor Documentation

asv::WavefieldVisualPlugin::~WavefieldVisualPlugin ( )
virtual

Destructor.

Definition at line 229 of file WavefieldVisualPlugin.cc.

asv::WavefieldVisualPlugin::WavefieldVisualPlugin ( )

Constructor.

Definition at line 239 of file WavefieldVisualPlugin.cc.

Member Function Documentation

void asv::WavefieldVisualPlugin::AddNewCamerasForReflectionRefraction ( )
private

Check for new cameras, setup rtts for them.

internal

Definition at line 475 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::CreateRtts ( Ogre::Camera *  _camera)
private

Create reflection refraction rtts for a given camera Stores the render target and given camera.

internal

Definition at line 503 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::Init ( )
virtual

Initialize the plugin.

Definition at line 331 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::Load ( gazebo::rendering::VisualPtr  _visual,
sdf::ElementPtr  _sdf 
)
virtual

Load the plugin.

Definition at line 247 of file WavefieldVisualPlugin.cc.

std::vector< rendering::CameraPtr > asv::WavefieldVisualPlugin::NewCameras ( )
private

Get new cameras not already contained in this->data->cameras.

internal

Definition at line 573 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::OnCameraPreRender ( const std::string &  _camera)
private

Update rtts before cameras.

internal

Definition at line 661 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::OnPreRender ( )
private

Called every PreRender event.

internal

Definition at line 361 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::OnStatsMsg ( ConstWorldStatisticsPtr &  _msg)
private

Callback for gztopic "~/world_stats".

internal

Parameters
[in]_msgWorld statistics message.
void asv::WavefieldVisualPlugin::postRenderTargetUpdate ( const Ogre::RenderTargetEvent &  rte)
privatevirtual

Definition at line 722 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::preRenderTargetUpdate ( const Ogre::RenderTargetEvent &  rte)
privatevirtual

Hide/Show objects for reflection/refraction render eg. hide objects above water for refraction hide objects below water for reflection unhide all objects after texture is rendered.

internal

Definition at line 685 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::Reset ( )
virtual

Reset the plugin.

Definition at line 355 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::SetShaderParams ( )
private

Update the vertex shader parameters.

internal

Definition at line 599 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::SetupReflectionRefraction ( )
private

Setup Ogre objects for reflection/refraction.

internal

Definition at line 390 of file WavefieldVisualPlugin.cc.

void asv::WavefieldVisualPlugin::UpdateClipPlanes ( )
private

Move and rotate clip planes to match ocean pose.

internal

Definition at line 447 of file WavefieldVisualPlugin.cc.

Member Data Documentation

std::shared_ptr<WavefieldVisualPluginPrivate> asv::WavefieldVisualPlugin::data
private

Definition at line 210 of file WavefieldVisualPlugin.hh.


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


wave_gazebo_plugins
Author(s): Rhys Mainwaring
autogenerated on Thu May 7 2020 03:54:44