An ElevationProducer whose tiles can be edited at runtime. More...
#include <EditElevationProducer.h>
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< EditorHandler > | getEditorHandler () |
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< EditorHandler > | HANDLER |
The EditorHandler shared by all the EditElevationProducer instances. |
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.
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.
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.
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.
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.
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.
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.
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.
float proland::EditElevationProducer::brushElevation [private] |
Altitude written by the brush.
ptr<Uniform1f> proland::EditElevationProducer::brushElevationU [private] |
Altitude written by the brush.
ptr<Program> proland::EditElevationProducer::brushProg [private] |
Program used to draw a stroke mask in an edited tile (in alpha channel).
ptr<Program> proland::EditElevationProducer::composeProg [private] |
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.
BlendEquation proland::EditElevationProducer::editMode [private] |
Determines how to edit the elevations.
Can be either ADD or MAX.
ptr<Module> proland::EditElevationProducer::editShader [private] |
The shader containing a 'pencil' uniform.
This uniform is set to the current pencil position and radius in world frame at each frame.
static_ptr<EditorHandler> proland::EditElevationProducer::HANDLER [static, private] |
The EditorHandler shared by all the EditElevationProducer instances.
ptr<Uniform4f> proland::EditElevationProducer::initOffsetU [private] |
Texture coordinates used in initProg to access an original tile content.
ptr<Program> proland::EditElevationProducer::initProg [private] |
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.
vector<box2f> proland::EditElevationProducer::strokeBounds [private] |
The bounding boxes of the edit strokes in terrain physical coordinates.
ptr<Uniform4f> proland::EditElevationProducer::strokeEndU [private] |
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).
SceneNode* proland::EditElevationProducer::terrain [private] |
The SceneNode defining the terrain that uses the elevations produced by this producer.
string proland::EditElevationProducer::terrainName [private] |
The name of the SceneNode defining the terrain that uses the elevations produced by this producer.
TerrainNode* proland::EditElevationProducer::terrainNode [private] |
The TerrainNode that uses the elevations produced by this producer.
int proland::EditElevationProducer::tileWidth [private] |
The size of elevation tiles, including borders.