16#ifndef __ImpostorPage_H__
17#define __ImpostorPage_H__
22#include <OgrePrerequisites.h>
23#include <OgreTextureManager.h>
24#include <OgreRenderTexture.h>
26#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
32#define IMPOSTOR_YAW_ANGLES 8
35#define IMPOSTOR_PITCH_ANGLES 4
42#define IMPOSTOR_RENDER_ABOVE_ONLY
47#define IMPOSTOR_FILE_SAVE
53 class ImpostorTexture;
94 void setRegion(Ogre::Real left, Ogre::Real top, Ogre::Real right, Ogre::Real bottom);
95 void addEntity(Ogre::Entity *ent,
const Ogre::Vector3 &position,
const Ogre::Quaternion &rotation,
96 const Ogre::Vector3 &scale,
const Ogre::ColourValue &color);
101 void setFade(
bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist);
118 return injectedBatch ?
183 if (origin != Ogre::BBO_CENTER && origin != Ogre::BBO_BOTTOM_CENTER)
185 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
186 "Invalid origin - only BBO_CENTER and BBO_BOTTOM_CENTER is supported",
187 "ImpostorPage::setImpostorPivot()");
270 inline void setFade(
bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist)
278 void addBillboard(
const Ogre::Vector3 &position,
const Ogre::Quaternion &rotation,
279 const Ogre::Vector3 &scale,
const Ogre::ColourValue &color = Ogre::ColourValue::White);
281 void setAngle(Ogre::Real pitchDeg, Ogre::Real yawDeg);
298 static inline Ogre::String
getUniqueID(
const Ogre::String &prefix)
300 return prefix + Ogre::StringConverter::toString(++
GUID);
359 static std::map<Ogre::String, ImpostorTexture *>
selfList;
374 static inline Ogre::String
getUniqueID(
const Ogre::String &prefix)
376 return prefix + Ogre::StringConverter::toString(++
GUID);
380 std::auto_ptr<ImpostorTextureResourceLoader>
loader;
389 const Ogre::Vector3 &scale,
const Ogre::ColourValue &color)
392 const Ogre::Vector3 zVector = rotation * Ogre::Vector3::UNIT_Z;
393 float degrees = (float)Ogre::Math::ATan2(zVector.x, zVector.z).valueDegrees();
403 color, texCoordIndx);
#define IMPOSTOR_PITCH_ANGLES
#define IMPOSTOR_YAW_ANGLES
This base-class can be extended to provide different ways of representing entities.
void setVisible(bool visible)
static Ogre::String generateEntityKey(Ogre::Entity *entity)
static unsigned long GUID
void addBillboard(const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale, const Ogre::ColourValue &color=Ogre::ColourValue::White)
StaticBillboardSet * bbset
void setBillboardOrigin(Ogre::BillboardOrigin origin)
static Ogre::String getUniqueID(const Ogre::String &prefix)
ImpostorTexture * m_pTexture
void setFade(bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist)
void setAngle(Ogre::Real pitchDeg, Ogre::Real yawDeg)
static ImpostorBatch * getBatch(ImpostorPage *group, Ogre::Entity *entity)
Ogre::Vector3 entityBBCenter
The ImpostorPage class renders entities as impostors (billboard images that look just like the real e...
static void setImpostorBackgroundColor(const Ogre::ColourValue &color)
Sets the background color used when rendering impostor images.
void update()
Do whatever needs to be done to keep the page geometry up-to-date.
static Ogre::uint s_nImpostorResolution
void build()
Perform any final steps to make added entities appear in the scene.
void setBlendMode(ImpostorBlendMode blendMode)
ImpostorBlendMode m_blendMode
PagedGeometry * m_pPagedGeom
static void setImpostorPivot(Ogre::BillboardOrigin origin)
Sets the billboard pivot point used when rendering camera-facing impostors.
static void regenerate(Ogre::Entity *ent)
Regenerates the impostor texture for the specified entity.
static void regenerateAll()
Regenerates all impostor textures currently being used in the scene.
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.
TImpostorBatchs m_mapImpostorBatches
void setRegion(Ogre::Real left, Ogre::Real top, Ogre::Real right, Ogre::Real bottom)
Prepare a geometry page for entities.
std::map< Ogre::String, ImpostorBatch * > TImpostorBatchs
static Ogre::uint s_nSelfInstances
static void setImpostorResolution(Ogre::uint pixels)
Sets the resolution for single impostor images.
static Ogre::uint getImpostorResolution()
ImpostorBlendMode getBlendMode() const
Ogre::Vector3 m_vecCenter
void setFade(bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist)
Sets fade behavior for this page.
Ogre::SceneManager * m_pSceneMgr
~ImpostorPage()
Destructor.
ImpostorBatch * getImpostorBatch(const Ogre::String &key) const
static Ogre::BillboardOrigin getImpostorPivot()
static Ogre::uint s_nUpdateInstanceID
void setVisible(bool visible)
Toggle the entire page's visibility.
Ogre::Timer m_timerUpdate
static Ogre::BillboardOrigin s_impostorPivot
bool injectImpostorBatch(const Ogre::String &key, ImpostorBatch *injectedBatch)
ImpostorPage()
Default constructor.
void removeEntities()
Remove all geometry/entities from the page completely.
static Ogre::ColourValue s_clrImpostorBackground
static const Ogre::ColourValue & getImpostorBackgroundColor()
void init(PagedGeometry *geom, const Ogre::Any &data)
Prepare a geometry page for use.
PagedGeometry * getParentPagedGeometry() const
Ogre::ResourceHandle sourceMesh
Ogre::MaterialPtr material[IMPOSTOR_PITCH_ANGLES][IMPOSTOR_YAW_ANGLES]
static void regenerateAll()
Ogre::Real entityDiameter
static Ogre::String getUniqueID(const Ogre::String &prefix)
static ImpostorTexture * getTexture(ImpostorPage *group, Ogre::Entity *entity)
Returns a pointer to an ImpostorTexture for the specified entity.
static unsigned long GUID
static std::map< Ogre::String, ImpostorTexture * > selfList
static void removeTexture(ImpostorTexture *Texture)
remove created texture, note that all of the ImposterTextures must be deleted at once,...
Ogre::SceneManager * sceneMgr
void renderTextures(bool force)
std::auto_ptr< ImpostorTextureResourceLoader > loader
Ogre::AxisAlignedBox boundingBox
Ogre::Vector3 entityCenter
Responsible for making sure that the texture is rerendered when the texture resource needs to be relo...
ImpostorTexture & texture
virtual void loadResource(Ogre::Resource *resource)
At load time the texture will be rerendered.
A class providing highly optimized methods for rendering massive amounts of geometry.
A faster alternative to Ogre's built-in BillboardSet class.
void setFade(bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist)
Enables/disables distance fade-out for this billboard set.
void build()
Performs final steps required for the created billboards to appear in the scene.
void setVisible(bool visible)
Sets whether or not this StaticBillboardSet will be rendered.
void createBillboard(const Ogre::Vector3 &position, float xScale=1.0f, float yScale=1.0f, const Ogre::ColourValue &color=Ogre::ColourValue::White, Ogre::uint16 texcoordIndexU=0, Ogre::uint16 texcoordIndexV=0)
Adds a billboard to the StaticBillboardSet at the specified position.
void clear()
Deletes all billboards from the scene.
ImpostorBlendMode
Blend modes used by ImpostorPage::setBlendMode()