11#ifndef __GrassLoader_H__
12#define __GrassLoader_H__
18#include "OgrePrerequisites.h"
19#include "OgreMaterial.h"
20#include "OgrePixelFormat.h"
21#include "OgreStringConverter.h"
214 return "GrassLDR" + Ogre::StringConverter::toString(++
GUID);
272 if (maxSlopeAngle > Ogre::Degree(89.99f))
273 maxSlopeAngle = Ogre::Degree(89.99f);
274 if (maxSlopeAngle < Ogre::Degree(0))
275 maxSlopeAngle = Ogre::Degree(0);
277 maxSlope = Ogre::Math::Tan(maxSlopeAngle);
554 void addEntity(Ogre::Entity *ent,
const Ogre::Vector3 &position,
const Ogre::Quaternion &rotation,
const Ogre::Vector3 &scale,
const Ogre::ColourValue &color);
556 void setFade(
bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist) {}
568 return "GrassPage" + Ogre::StringConverter::toString(++
GUID);
A 2D greyscale image that is assigned to a certain region of your world to represent color levels.
A 2D greyscale image that is assigned to a certain region of your world to represent density levels.
This base-class can be extended to provide different ways of representing entities.
A data structure giving you full control over grass properties.
void setColorMapFilter(MapFilter filter)
Sets the filtering mode used for color maps.
GrassTechnique renderTechnique
ColorMap * getColorMap() const
Gets a pointer to the color map being used.
DensityMap * getDensityMap() const
Gets a pointer to the density map being used.
const TBounds & getMapBounds() const
Gets the map bounds.
void setMaxSlope(const float maxSlopeRatio)
Set the maximum slope a grass of blade can be placed on.
void setMaximumSize(float width, float height)
Sets the maximum size that grass quads/billboards will be.
Ogre::MaterialPtr material
void setMaxSlope(Ogre::Radian maxSlopeAngle)
void setDensityMapFilter(MapFilter filter)
Sets the filtering mode used for density maps.
void setColorMap(const Ogre::String &mapFile, MapChannel channel=CHANNEL_COLOR)
Sets the color map used for this grass layer.
bool getBlendValue() const
Gives back the value of blending.
void setSwayDistribution(Ogre::Real freq)
Sets the smooth distribution (positional phase shift) of the grass swaying animation.
MapFilter densityMapFilter
Ogre::Real getMaxSlope() const
Get the maximum slope a grass blade can be placed on (as set by setMaxSlope()).
void setLightingEnabled(bool enabled)
Enables/disables lighting on this layer.
void setRenderTechnique(GrassTechnique style, bool blendBase=false)
Sets the technique used to render this grass layer.
unsigned int _populateGrassList_BilinearDM(PageInfo page, float *posBuff, unsigned int grassCount)
void setSwaySpeed(Ogre::Real speed)
Sets the sway speed of the grass (measured in "sways-per-second")
void setMapBounds(const TBounds &bounds)
Sets the boundaries of the density/color maps.
unsigned int _populateGrassList_UnfilteredDM(PageInfo page, float *posBuff, unsigned int grassCount)
void setMinimumSize(float width, float height)
Sets the minimum size that grass quads/billboards will be.
~GrassLayer()
Do not delete a GrassLayer yourself - the GrassLoader will do this automatically when it's deleted.
void setDensity(float density)
Sets the maximum density (measured in grass quads/billboards per square unit) of grass.
void setFadeTechnique(FadeTechnique style)
Sets the technique used when fading out distant grass.
FadeTechnique fadeTechnique
GrassLoader * getParentGrassLoader() const
Gets the parent grassLoader of this layer.
void setHeightRange(float minHeight, float maxHeight=0)
Sets a minimum / maximum height where grass may appear.
void setAnimationEnabled(bool enabled)
Enables/disables animation on this layer.
void setDensityMap(const Ogre::String &mapFile, MapChannel channel=CHANNEL_COLOR)
Sets the density map used for this grass layer.
unsigned int _populateGrassList_Uniform(PageInfo page, float *posBuff, unsigned int grassCount)
void setColorMap(Ogre::TexturePtr map, MapChannel channel=CHANNEL_COLOR)
Sets the color map used for this grass layer.
bool getLightingEnabled() const
Gives back if lighting is enabled for grass.
void setDensityMap(Ogre::TexturePtr map, MapChannel channel=CHANNEL_COLOR)
Sets the density map used for this grass layer.
void setMaterialName(const Ogre::String &matName)
Sets the material that is applied to all grass billboards/quads.
void setSwayLength(Ogre::Real mag)
Sets how far grass should sway back and forth.
A PageLoader-derived object you can use with PagedGeometry to produce realistic grass.
static unsigned long GUID
void setWindDirection(Ogre::Vector3 &dir)
Sets the global wind direction for this GrassLoader.
void deleteLayer(GrassLayer *layer)
Removes and deletes a grass layer from the scene.
void * heightFunctionUserData
static Ogre::String getUniqueID()
Ogre::Real(* heightFunction)(Ogre::Real x, Ogre::Real z, void *userData)
void setRenderQueueGroup(Ogre::uint8 queueID)
Sets the render queue group the grass will be rendered through.
void setDensityFactor(float density)
Sets the global density factor for this GrassLoader.
Ogre::Vector3 & getWindDirection()
Returns the global wind direction for this GrassLoader.
void frameUpdate()
INTERNAL FUNCTION - DO NOT USE.
Ogre::Mesh * generateGrass_QUAD(PageInfo &page, GrassLayer *layer, const float *grassPositions, unsigned int grassCount)
Ogre::Mesh * generateGrass_CROSSQUADS(PageInfo &page, GrassLayer *layer, const float *grassPositions, unsigned int grassCount)
Ogre::Mesh * generateGrass_SPRITE(PageInfo &page, GrassLayer *layer, const float *grassPositions, unsigned int grassCount)
std::list< GrassLayer * > & getLayerList()
Returns a list of added grass layers.
static float getRangeRandom(float start, float end)
void unloadPage(PageInfo &page)
INTERNAL FUNCTION - DO NOT USE.
void loadPage(PageInfo &page)
INTERNAL FUNCTION - DO NOT USE.
void setHeightFunction(Ogre::Real(*heightFunction)(Ogre::Real x, Ogre::Real z, void *userData), void *userData=NULL)
Sets the height function used to calculate grass Y coordinates.
GrassLayer * addLayer(const Ogre::String &material)
Adds a grass layer to the scene.
std::list< GrassLayer * > layerList
float getDensityFactor()
Returns the global density factor for this GrassLoader.
A custom page type designed specifically for use with GrassLoader.
Ogre::SceneNode * rootNode
void addEntity(Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale, const Ogre::ColourValue &color)
Add an entity to the page, at the specified position, rotation, and scale.
void setFade(bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist)
Sets fade behavior for this page.
std::list< Ogre::SceneNode * > nodeList
Ogre::SceneManager * sceneMgr
void removeEntities()
Remove all geometry/entities from the page completely.
void init(PagedGeometry *geom, const Ogre::Any &data)
Prepare a geometry page for use.
void setVisible(bool visible)
Toggle the entire page's visibility.
static Ogre::String getUniqueID()
static unsigned long GUID
A class which you extend to provide a callback function for loading entities.
A class providing highly optimized methods for rendering massive amounts of geometry.
MapFilter
Specifies the filtering method used to interpret property maps.
GrassTechnique
A technique used to render grass.
Ogre::TRect< Ogre::Real > TBounds
Define TBounds as a TRect using Real numeric units.
FadeTechnique
A technique used to fade grass into the distance.
MapChannel
Specifies which color channel(s) to extract from an image.
@ CHANNEL_COLOR
Use the image's full RGB color information.
Useful page information supplied to a pageloader.