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