29 #ifndef __Ogre_TerrainMaterialGenerator_H__
30 #define __Ogre_TerrainMaterialGenerator_H__
83 return source == e.
source &&
90 source(0), semantic(
TLSS_ALBEDO), elementStart(0), elementCount(0)
95 : source(src), semantic(sem), elementStart(elemStart), elementCount(elemCount)
121 : alias(aliasName), format(fmt)
175 : mParent(parent), mName(name), mDesc(desc) {}
177 : mParent(prof.mParent), mName(prof.mName), mDesc(prof.mDesc) {}
186 virtual bool isVertexCompressionSupported()
const = 0;
192 virtual void setLightmapEnabled(
bool enabled) = 0;
194 virtual uint8 getMaxLayers(
const Terrain* terrain)
const = 0;
196 virtual void updateCompositeMap(
const Terrain* terrain,
const Rect& rect);
201 virtual void updateParamsForCompositeMap(
const MaterialPtr& mat,
const Terrain* terrain) = 0;
204 virtual void requestOptions(
Terrain* terrain) = 0;
221 if (!mActiveProfile || mActiveProfile->getName() != name)
223 for (ProfileList::iterator i = mProfiles.begin(); i != mProfiles.end(); ++i)
225 if ((*i)->getName() == name)
227 setActiveProfile(*i);
238 if (mActiveProfile != p)
248 if (!mActiveProfile && !mProfiles.empty())
249 mActiveProfile = mProfiles[0];
251 return mActiveProfile;
273 return decl == mLayerDecl;
281 return getActiveProfile()->isVertexCompressionSupported();
288 Profile* p = getActiveProfile();
297 Profile* p = getActiveProfile();
307 Profile* p = getActiveProfile();
318 Profile* p = getActiveProfile();
327 Profile* p = getActiveProfile();
342 Profile* p = getActiveProfile();
354 Profile* p = getActiveProfile();
362 Profile* p = getActiveProfile();
377 if (mDebugLevel != dbg)
392 virtual void _renderCompositeMap(
size_t size,
const Rect& rect,
Camera * mCompositeMapCam
A viewpoint from which the scene will be rendered.
TerrainLayerDeclaration mLayerDecl
Texture * _getCompositeMapRTT()
virtual void updateParamsForCompositeMap(const MaterialPtr &mat, const Terrain *terrain)
Update parameters for the given terrain composite map using the active profile.
Class that provides functionality to generate materials for use with a terrain.
The main containing class for a chunk of terrain.
Class providing a much simplified interface to generating manual objects with custom geometry...
Profile(TerrainMaterialGenerator *parent, const String &name, const String &desc)
virtual uint8 getMaxLayers(const Terrain *terrain) const
Get the maximum number of layers supported with the given terrain.
const String & getName() const
Get the name of this profile.
Manages the organisation and rendering of a 'scene' i.e.
Profile * getActiveProfile() const
Get the active profile.
vector< TerrainLayerSampler >::type TerrainLayerSamplerList
Description of a sampler that will be used with each layer.
uint8 elementStart
The colour element at which this element starts.
virtual void requestOptions(Terrain *terrain)
Triggers the generator to request the options that it needs.
TerrainLayerSamplerElement(uint8 src, TerrainLayerSamplerSemantic sem, uint8 elemStart, uint8 elemCount)
virtual void updateParams(const MaterialPtr &mat, const Terrain *terrain)=0
Update params for a terrain.
virtual void setDebugLevel(unsigned int dbg)
Set the debug level of the material.
TerrainLayerSamplerElementList elements
ManualObject * mCompositeMapPlane
void _markChanged()
Internal method - indicates that a change has been made that would require material regeneration...
TerrainMaterialGenerator * getParent() const
Get the generator which owns this profile.
Representation of a dynamic light source in the scene.
TerrainLayerSampler(const String &aliasName, PixelFormat fmt)
virtual MaterialPtr generate(const Terrain *terrain)=0
Generate / reuse a material for the terrain.
vector< TerrainLayerSamplerElement >::type TerrainLayerSamplerElementList
PixelFormat format
The format required of this texture.
vector< Profile * >::type ProfileList
List of profiles - NB should be ordered in descending complexity.
virtual void setLightmapEnabled(bool enabled)=0
Whether to support a light map over the terrain in the shader, if it's present (default true) ...
virtual void setActiveProfile(const String &name)
Set the active profile by name.
SharedPtr< Material > MaterialPtr
Tangent-space normal information from a detail texture.
PixelFormat
The pixel format used for images, textures, and render surfaces.
bool operator==(const TerrainLayerDeclaration &dcl) const
virtual void updateParams(const MaterialPtr &mat, const Terrain *terrain)
Update parameters for the given terrain using the active profile.
TerrainMaterialGenerator * mParent
TerrainLayerSamplerList samplers
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
bool operator==(const TerrainLayerSamplerElement &e) const
virtual MaterialPtr generateForCompositeMap(const Terrain *terrain)=0
Generate / reuse a material for the terrain.
#define _OgreTerrainExport
Albedo colour (diffuse reflectance colour)
virtual void requestOptions(Terrain *terrain)=0
Request the options needed from the terrain.
Light * mCompositeMapLight
Height information for the detail texture.
virtual void updateCompositeMap(const Terrain *terrain, const Rect &rect)
Update the composite map for a terrain.
unsigned long long int getChangeCount() const
Returns the number of times the generator has undergone a change which would require materials to be ...
SceneManager * mCompositeMapSM
virtual MaterialPtr generateForCompositeMap(const Terrain *terrain)
Generate a material for the given composite map of the terrain using the active profile.
Texture * mCompositeMapRTT
The definition of the information each layer will contain in this terrain.
TerrainLayerSamplerSemantic semantic
The semantic this element represents.
virtual void setLightmapEnabled(bool enabled)
Whether to support a light map over the terrain in the shader, if it's present (default true)...
String alias
A descriptive name that is merely used to assist in recognition.
virtual void setActiveProfile(Profile *p)
Set the active Profile.
virtual const ProfileList & getProfiles() const
Get the list of profiles that this generator supports.
virtual MaterialPtr generate(const Terrain *terrain)
Generate a material for the given terrain using the active profile.
virtual unsigned int getDebugLevel() const
Get the debug level of the material.
SharedPtr< TerrainMaterialGenerator > TerrainMaterialGeneratorPtr
virtual void updateCompositeMap(const Terrain *terrain, const Rect &rect)
Update the composite map for a terrain.
virtual void updateParamsForCompositeMap(const MaterialPtr &mat, const Terrain *terrain)=0
Update params for a terrain.
uint8 source
The source sampler index of this element relative to LayerDeclaration's list.
virtual bool isVertexCompressionSupported() const
Return whether this material generator supports using a compressed vertex format. ...
unsigned long long int mChangeCounter
TerrainLayerSamplerElement()
bool operator==(const TerrainLayerSampler &s) const
uint8 elementCount
The number of colour elements this semantic uses (usually standard per semantic)
Inner class which should also be subclassed to provide profile-specific material generation.
Abstract class representing a Texture resource.
const String & getDescription() const
Get the description of this profile.
TerrainLayerSamplerSemantic
Enumeration of types of data that can be read from textures that are specific to a given layer...
Profile(const Profile &prof)
virtual const TerrainLayerDeclaration & getLayerDeclaration() const
Get the layer declaration that this material generator operates with.
virtual bool canGenerateUsingDeclaration(const TerrainLayerDeclaration &decl)
Whether this generator can generate a material for a given declaration.
Information about one element of a sampler / texture within a layer.
virtual uint8 getMaxLayers(const Terrain *terrain) const =0
Get the number of layers supported.