proland::EditElevationProducer Class Reference
[edit]

An ElevationProducer whose tiles can be edited at runtime. More...

#include <EditElevationProducer.h>

Inheritance diagram for proland::EditElevationProducer:
proland::Editor

List of all members.

Public Member Functions

 EditElevationProducer (ptr< TileCache > cache, ptr< TileProducer > residualTiles, ptr< Texture2D > demTexture, ptr< Texture2D > layerTexture, ptr< Texture2D > residualTexture, ptr< Program > upsample, ptr< Program > blend, ptr< Module > edit, ptr< Program > brush, int gridMeshSize, ptr< ResourceManager > manager, const string &terrain, vector< float > &noiseAmp, bool flipDiagonals=false)
 Creates a new EditElevationProducer.
virtual ~EditElevationProducer ()
 Deletes this EditElevationProducer.
virtual SceneNode * getTerrain ()
 Returns the SceneNode defining the position of the terrain edited by this Editor.
virtual TerrainNode * getTerrainNode ()
 Returns the TerrainNode defining the terrain edited by this Editor.
virtual void setPencil (const vec4f &pencil, const vec4f &brushColor, bool paint)
 Notifies this Editor of a new position of the paint brush.
virtual vec4f getBrushColor ()
 Returns the current brush color.
virtual void setEditMode (BlendEquation editMode)
 Sets the edition mode.
virtual BlendEquation getEditMode ()
 Returns the edition mode.
virtual void edit (const vector< vec4d > &strokes)
 Notifies this Editor that a new stroke has been added to the shape being painted on the terrain.
virtual void update ()
 Notifies this Editor that the user has finished painting a shape on the terrain.
virtual void reset ()
 Cancels all editing operations performed on this producer.

Static Public Member Functions

static ptr< EditorHandlergetEditorHandler ()
 Returns the EditorHandler shared by all the EditElevationProducer instances.

Protected Member Functions

 EditElevationProducer ()
 Creates an uninitialized EditElevationProducer.
void init (ptr< ResourceManager > manager, ptr< Module > edit, ptr< Program > brush, const string &terrain)
 Initializes this EditElevationProducer from a Resource.

Private Member Functions

void edit (ptr< TerrainQuad > q, const vector< vec4d > &strokes, const vector< box2f > &strokeBounds, int newStrokes)
 Edits the elevation tile corresponding to the given terrain quad, and so on recursively for all sub quads of this quad.

Private Attributes

set< TileCache::Tile::Id > editedTileIds
 The Tile ids of the tiles that have been edited since the last call to update.
set< TileCache::Tile * > editedTiles
 The tiles that have been edited since the last call to update.
vector< box2f > strokeBounds
 The bounding boxes of the edit strokes in terrain physical coordinates.
ResourceManager * manager
 The resource manager used to load the SceneNode defining the terrain that uses the elevations produced by this producer.
string terrainName
 The name of the SceneNode defining the terrain that uses the elevations produced by this producer.
SceneNode * terrain
 The SceneNode defining the terrain that uses the elevations produced by this producer.
TerrainNode * terrainNode
 The TerrainNode that uses the elevations produced by this producer.
ptr< Module > editShader
 The shader containing a 'pencil' uniform.
ptr< Program > initProg
 Program used to copy an original tile to a temporary texture to edit it.
ptr< UniformSampler > initSamplerU
 Sampler used in initProg to access an original tile content.
ptr< Uniform4f > initOffsetU
 Texture coordinates used in initProg to access an original tile content.
ptr< Uniform4f > strokeU
 The start of a stroke segment (position and radius in world coordinates).
ptr< Uniform4f > strokeEndU
 The end of a stroke segment (position and radius in world coordinates).
ptr< Uniform1f > brushElevationU
 Altitude written by the brush.
ptr< Program > brushProg
 Program used to draw a stroke mask in an edited tile (in alpha channel).
ptr< Program > composeProg
 Program used to compose the stroke mask with the original elevations (in rgb channels) to produce modified elevations.
float brushElevation
 Altitude written by the brush.
int tileWidth
 The size of elevation tiles, including borders.
BlendEquation editMode
 Determines how to edit the elevations.

Static Private Attributes

static static_ptr< EditorHandlerHANDLER
 The EditorHandler shared by all the EditElevationProducer instances.

Detailed Description

An ElevationProducer whose tiles can be edited at runtime.

The residual producer used by this producer must be an EditResidualProducer. The edition is performed by drawing a mask in the alpha channel of the edited tiles, and then by composing this mask with the elevations values in the rgb channels, to get new elevations.

Authors:
Eric Bruneton, Antoine Begault, Guillaume Piolat

Constructor & Destructor Documentation

proland::EditElevationProducer::EditElevationProducer ( ptr< TileCache >  cache,
ptr< TileProducer >  residualTiles,
ptr< Texture2D >  demTexture,
ptr< Texture2D >  layerTexture,
ptr< Texture2D >  residualTexture,
ptr< Program >  upsample,
ptr< Program >  blend,
ptr< Module >  edit,
ptr< Program >  brush,
int  gridMeshSize,
ptr< ResourceManager >  manager,
const string &  terrain,
vector< float > &  noiseAmp,
bool  flipDiagonals = false 
)

Creates a new EditElevationProducer.

See ElevationProducer.

Parameters:
manager the resource manager to load the SceneNode defining the terrain that uses the elevations produced by this producer.
edit the shader containing a 'pencil' uniform. This uniform is set to the current pencil position and radius in world frame at each frame.
terrain the name of the SceneNode defining the terrain that uses the elevations produced by this producer.
virtual proland::EditElevationProducer::~EditElevationProducer (  )  [virtual]

Deletes this EditElevationProducer.

proland::EditElevationProducer::EditElevationProducer (  )  [protected]

Creates an uninitialized EditElevationProducer.


Member Function Documentation

void proland::EditElevationProducer::edit ( ptr< TerrainQuad >  q,
const vector< vec4d > &  strokes,
const vector< box2f > &  strokeBounds,
int  newStrokes 
) [private]

Edits the elevation tile corresponding to the given terrain quad, and so on recursively for all sub quads of this quad.

Parameters:
q a terrain quad.
strokes the edition strokes (position and radius in world space).
strokeBounds the bounding boxes of these strokes (in terrain physical coordinates).
newStrokes how many strokes have been added to 'strokes' since the last call to this method.
virtual void proland::EditElevationProducer::edit ( const vector< vec4d > &  strokes  )  [virtual]

Notifies this Editor that a new stroke has been added to the shape being painted on the terrain.

Parameters:
strokes the samples that have been taken along the shape that the user is currently painting on the terrain. Each sample contains a position and a radius (in world space).

Implements proland::Editor.

virtual vec4f proland::EditElevationProducer::getBrushColor (  )  [virtual]

Returns the current brush color.

Implements proland::Editor.

virtual BlendEquation proland::EditElevationProducer::getEditMode (  )  [virtual]

Returns the edition mode.

see editMode.

static ptr<EditorHandler> proland::EditElevationProducer::getEditorHandler (  )  [static]

Returns the EditorHandler shared by all the EditElevationProducer instances.

virtual SceneNode* proland::EditElevationProducer::getTerrain (  )  [virtual]

Returns the SceneNode defining the position of the terrain edited by this Editor.

Implements proland::Editor.

virtual TerrainNode* proland::EditElevationProducer::getTerrainNode (  )  [virtual]

Returns the TerrainNode defining the terrain edited by this Editor.

Implements proland::Editor.

void proland::EditElevationProducer::init ( ptr< ResourceManager >  manager,
ptr< Module >  edit,
ptr< Program >  brush,
const string &  terrain 
) [protected]

Initializes this EditElevationProducer from a Resource.

See EditElevationProducer.

virtual void proland::EditElevationProducer::reset (  )  [virtual]

Cancels all editing operations performed on this producer.

Implements proland::Editor.

virtual void proland::EditElevationProducer::setEditMode ( BlendEquation  editMode  )  [virtual]

Sets the edition mode.

see editMode.

virtual void proland::EditElevationProducer::setPencil ( const vec4f &  pencil,
const vec4f &  brushColor,
bool  paint 
) [virtual]

Notifies this Editor of a new position of the paint brush.

Parameters:
pencil a position in world space, and a radius (in world space).
brushColor value that will be written by the brush.
paint true if the user is currently painting.

Implements proland::Editor.

virtual void proland::EditElevationProducer::update (  )  [virtual]

Notifies this Editor that the user has finished painting a shape on the terrain.

Implements proland::Editor.


Member Data Documentation

Altitude written by the brush.

Altitude written by the brush.

Program used to draw a stroke mask in an edited tile (in alpha channel).

Program used to compose the stroke mask with the original elevations (in rgb channels) to produce modified elevations.

set<TileCache::Tile::Id> proland::EditElevationProducer::editedTileIds [private]

The Tile ids of the tiles that have been edited since the last call to update.

set<TileCache::Tile*> proland::EditElevationProducer::editedTiles [private]

The tiles that have been edited since the last call to update.

Determines how to edit the elevations.

Can be either ADD or MAX.

The shader containing a 'pencil' uniform.

This uniform is set to the current pencil position and radius in world frame at each frame.

The EditorHandler shared by all the EditElevationProducer instances.

Texture coordinates used in initProg to access an original tile content.

Program used to copy an original tile to a temporary texture to edit it.

ptr<UniformSampler> proland::EditElevationProducer::initSamplerU [private]

Sampler used in initProg to access an original tile content.

ResourceManager* proland::EditElevationProducer::manager [private]

The resource manager used to load the SceneNode defining the terrain that uses the elevations produced by this producer.

The bounding boxes of the edit strokes in terrain physical coordinates.

The end of a stroke segment (position and radius in world coordinates).

ptr<Uniform4f> proland::EditElevationProducer::strokeU [private]

The start of a stroke segment (position and radius in world coordinates).

The SceneNode defining the terrain that uses the elevations produced by this producer.

The name of the SceneNode defining the terrain that uses the elevations produced by this producer.

The TerrainNode that uses the elevations produced by this producer.

The size of elevation tiles, including borders.


Generated on Sat May 12 09:43:14 2012 for proland by  doxygen 1.6.1