An OrthoProducer whose tiles can be edited at runtime. More...
#include <EditOrthoProducer.h>
Public Member Functions | |
EditOrthoProducer (ptr< TileCache > cache, ptr< TileProducer > residualTiles, ptr< Texture2D > orthoTexture, ptr< Texture2D > residualTexture, ptr< Texture2D > layerTexture, ptr< Program > upsample, vec4f rootNoiseColor, vec4f noiseColor, vector< float > &noiseAmp, bool noiseHsv, float scale, int maxLevel, ptr< Module > edit, ptr< Program > brush, ptr< Program > compose, ptr< ResourceManager > manager, const string &terrain) | |
Creates a new EditOrthoProducer. | |
virtual | ~EditOrthoProducer () |
Deletes this EditOrthoProducer. | |
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 | 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 EditOrthoProducer instances. | |
Protected Member Functions | |
EditOrthoProducer () | |
Creates an uninitialized EditOrthoProducer. | |
void | init (ptr< ResourceManager > manager, ptr< Texture2D > layerTexture, ptr< Module > edit, ptr< Program > brush, ptr< Program > compose, const string &terrain) |
Initializes this EditOrthoProducer from a Resource. | |
Private Member Functions | |
void | edit (ptr< TerrainQuad > q, const vector< vec4d > &strokes, const vector< box2f > &strokeBounds, int newStrokes) |
Edits the color tile corresponding to the given terrain quad, and so on recursively for all sub quads of this quad. | |
void | backupTile (GPUTileStorage::GPUSlot *s) |
Makes a copy of the given tile in backupTiles and in residualTexture. | |
Private Attributes | |
ptr< Texture2D > | layerTexture |
A temporary texture used to draw a stroke mask, before compositing it with tile colors. | |
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 colors produced by this producer. | |
string | terrainName |
The name of the SceneNode defining the terrain that uses the colors produced by this producer. | |
SceneNode * | terrain |
The SceneNode defining the terrain that uses the colors produced by this producer. | |
TerrainNode * | terrainNode |
The TerrainNode that uses the colors 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 CPU buffer to edit it. | |
ptr< Program > | brushProg |
Program used to draw a stroke mask layerTexture. | |
ptr< UniformSampler > | initSamplerU |
The GLSL sampler that contains the copied texture. | |
ptr< Uniform4f > | initOffsetU |
Texture coordinates used in initProg to access an original tile content. | |
ptr< Uniform4f > | brushOffsetU |
Brush coordinates used in brushProg. | |
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< Uniform4f > | pencilU |
Pencil informations (position & size) used in brushProg. | |
ptr< Uniform4f > | pencilColorU |
Pencil color used in brushProg. | |
ptr< UniformSampler > | composeSourceSamplerU |
Sampler used in backupProg and composeProg to access an original tile content. | |
ptr< UniformSampler > | composeBrushSamplerU |
Sampler used in composeProg to access the stroke mask to be composed with the original tile colors. | |
ptr< Uniform4f > | composeColorU |
Color of the added strokes. | |
vec4f | brushColor |
color of the added strokes. | |
ptr< Program > | composeProg |
Program used to compose the stroke mask with original colors to produce modified colors. | |
int | tileWidth |
The size of the ortho tiles, including borders. | |
TextureFormat | format |
The texture format of the ortho tiles. | |
map< GPUTileStorage::GPUSlot *, unsigned char * > | backupedTiles |
A copy of the original colors of the edited tiles in CPU buffers. | |
Static Private Attributes | |
static static_ptr< EditorHandler > | HANDLER |
The EditorHandler shared by all the EditOrthoProducer instances. |
An OrthoProducer whose tiles can be edited at runtime.
The residual producer used by this producer must be an EditOrthoCPUProducer. The edition is performed by drawing a mask in a temporary texture, and then by composing this mask with the oringinal tile colors, to get new colors.
proland::EditOrthoProducer::EditOrthoProducer | ( | ptr< TileCache > | cache, | |
ptr< TileProducer > | residualTiles, | |||
ptr< Texture2D > | orthoTexture, | |||
ptr< Texture2D > | residualTexture, | |||
ptr< Texture2D > | layerTexture, | |||
ptr< Program > | upsample, | |||
vec4f | rootNoiseColor, | |||
vec4f | noiseColor, | |||
vector< float > & | noiseAmp, | |||
bool | noiseHsv, | |||
float | scale, | |||
int | maxLevel, | |||
ptr< Module > | edit, | |||
ptr< Program > | brush, | |||
ptr< Program > | compose, | |||
ptr< ResourceManager > | manager, | |||
const string & | terrain | |||
) |
Creates a new EditOrthoProducer.
See OrthoProducer.
manager | the resource manager to load the SceneNode defining the terrain that uses the colors produced by this producer. | |
layerTexture | a temporary texture used to draw a stroke mask, before compositing it with tile colors. | |
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 colors produced by this producer. |
virtual proland::EditOrthoProducer::~EditOrthoProducer | ( | ) | [virtual] |
Deletes this EditOrthoProducer.
proland::EditOrthoProducer::EditOrthoProducer | ( | ) | [protected] |
Creates an uninitialized EditOrthoProducer.
void proland::EditOrthoProducer::backupTile | ( | GPUTileStorage::GPUSlot * | s | ) | [private] |
Makes a copy of the given tile in backupTiles and in residualTexture.
void proland::EditOrthoProducer::edit | ( | ptr< TerrainQuad > | q, | |
const vector< vec4d > & | strokes, | |||
const vector< box2f > & | strokeBounds, | |||
int | newStrokes | |||
) | [private] |
Edits the color tile corresponding to the given terrain quad, and so on recursively for all sub quads of this quad.
q | 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::EditOrthoProducer::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::EditOrthoProducer::getBrushColor | ( | ) | [virtual] |
Returns the current brush color.
Implements proland::Editor.
static ptr<EditorHandler> proland::EditOrthoProducer::getEditorHandler | ( | ) | [static] |
Returns the EditorHandler shared by all the EditOrthoProducer instances.
virtual SceneNode* proland::EditOrthoProducer::getTerrain | ( | ) | [virtual] |
Returns the SceneNode defining the position of the terrain edited by this Editor.
Implements proland::Editor.
virtual TerrainNode* proland::EditOrthoProducer::getTerrainNode | ( | ) | [virtual] |
Returns the TerrainNode defining the terrain edited by this Editor.
Implements proland::Editor.
void proland::EditOrthoProducer::init | ( | ptr< ResourceManager > | manager, | |
ptr< Texture2D > | layerTexture, | |||
ptr< Module > | edit, | |||
ptr< Program > | brush, | |||
ptr< Program > | compose, | |||
const string & | terrain | |||
) | [protected] |
Initializes this EditOrthoProducer from a Resource.
See EditOrthoProducer.
virtual void proland::EditOrthoProducer::reset | ( | ) | [virtual] |
Cancels all editing operations performed on this producer.
Implements proland::Editor.
virtual void proland::EditOrthoProducer::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::EditOrthoProducer::update | ( | ) | [virtual] |
Notifies this Editor that the user has finished painting a shape on the terrain.
Implements proland::Editor.
map<GPUTileStorage::GPUSlot*, unsigned char*> proland::EditOrthoProducer::backupedTiles [private] |
A copy of the original colors of the edited tiles in CPU buffers.
vec4f proland::EditOrthoProducer::brushColor [private] |
color of the added strokes.
ptr<Uniform4f> proland::EditOrthoProducer::brushOffsetU [private] |
Brush coordinates used in brushProg.
ptr<Program> proland::EditOrthoProducer::brushProg [private] |
Program used to draw a stroke mask layerTexture.
ptr<UniformSampler> proland::EditOrthoProducer::composeBrushSamplerU [private] |
Sampler used in composeProg to access the stroke mask to be composed with the original tile colors.
ptr<Uniform4f> proland::EditOrthoProducer::composeColorU [private] |
Color of the added strokes.
ptr<Program> proland::EditOrthoProducer::composeProg [private] |
Program used to compose the stroke mask with original colors to produce modified colors.
ptr<UniformSampler> proland::EditOrthoProducer::composeSourceSamplerU [private] |
Sampler used in backupProg and composeProg to access an original tile content.
set<TileCache::Tile::Id> proland::EditOrthoProducer::editedTileIds [private] |
The Tile ids of the tiles that have been edited since the last call to update.
set<TileCache::Tile*> proland::EditOrthoProducer::editedTiles [private] |
The tiles that have been edited since the last call to update.
ptr<Module> proland::EditOrthoProducer::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.
TextureFormat proland::EditOrthoProducer::format [private] |
The texture format of the ortho tiles.
static_ptr<EditorHandler> proland::EditOrthoProducer::HANDLER [static, private] |
The EditorHandler shared by all the EditOrthoProducer instances.
ptr<Uniform4f> proland::EditOrthoProducer::initOffsetU [private] |
Texture coordinates used in initProg to access an original tile content.
ptr<Program> proland::EditOrthoProducer::initProg [private] |
Program used to copy an original tile to a temporary CPU buffer to edit it.
ptr<UniformSampler> proland::EditOrthoProducer::initSamplerU [private] |
The GLSL sampler that contains the copied texture.
ptr<Texture2D> proland::EditOrthoProducer::layerTexture [private] |
A temporary texture used to draw a stroke mask, before compositing it with tile colors.
ResourceManager* proland::EditOrthoProducer::manager [private] |
The resource manager used to load the SceneNode defining the terrain that uses the colors produced by this producer.
ptr<Uniform4f> proland::EditOrthoProducer::pencilColorU [private] |
Pencil color used in brushProg.
ptr<Uniform4f> proland::EditOrthoProducer::pencilU [private] |
Pencil informations (position & size) used in brushProg.
vector<box2f> proland::EditOrthoProducer::strokeBounds [private] |
The bounding boxes of the edit strokes in terrain physical coordinates.
ptr<Uniform4f> proland::EditOrthoProducer::strokeEndU [private] |
The end of a stroke segment (position and radius in world coordinates).
ptr<Uniform4f> proland::EditOrthoProducer::strokeU [private] |
The start of a stroke segment (position and radius in world coordinates).
SceneNode* proland::EditOrthoProducer::terrain [private] |
The SceneNode defining the terrain that uses the colors produced by this producer.
string proland::EditOrthoProducer::terrainName [private] |
The name of the SceneNode defining the terrain that uses the colors produced by this producer.
TerrainNode* proland::EditOrthoProducer::terrainNode [private] |
The TerrainNode that uses the colors produced by this producer.
int proland::EditOrthoProducer::tileWidth [private] |
The size of the ortho tiles, including borders.