1
/*-------------------------------------------------------------------------------------
2
Copyright (c) 2006 John Judnich
4
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
5
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
6
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
7
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
8
3. This notice may not be removed or altered from any source distribution.
9
-------------------------------------------------------------------------------------*/
12
//BatchPage is an extension to PagedGeometry which displays entities as static geometry.
13
//-------------------------------------------------------------------------------------
15
#ifndef __BatchPage_H__
16
#define __BatchPage_H__
18
#include "PagedGeometry.h"
19
#include "BatchedGeometry.h"
21
#include <OgrePrerequisites.h>
22
#include <OgreStringConverter.h>
24
namespace PagedGeometry {
27
\brief The BatchPage class renders entities as StaticGeometry.
29
This is one of the geometry page types included in the StaticGeometry engine. These
30
page types should be added to a PagedGeometry object with PagedGeometry::addDetailLevel()
31
so the PagedGeometry will know how you want your geometry displayed.
33
To use this page type, use:
35
PagedGeometry::addDetailLevel<BatchPage>(farRange);
38
This page type uses batched geometry (Ogre::StaticGeometry) to represent the entities.
39
Batched geometry is generally much faster than plain entities, since video card state
40
changes and transform calculations can be minimized. Batched geometry can be anywhere
41
from 2 to 20 times faster than plain entities.
43
class BatchPage: public GeometryPage
46
void init(PagedGeometry *geom);
49
void addEntity(Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale, const Ogre::ColourValue &color);
51
void removeEntities();
53
void setVisible(bool visible);
54
void setFade(bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist);
56
void addEntityToBoundingBox() {}
57
void clearBoundingBox() {}
58
const Ogre::AxisAlignedBox &getBoundingBox() { return batch->getBoundingBox(); }
61
void _updateShaders();
63
bool fadeEnabled, shadersSupported;
64
Ogre::Real visibleDist, invisibleDist;
65
std::vector<Ogre::MaterialPtr> unfadedMaterials;
67
Ogre::SceneManager *sceneMgr;
68
BatchedGeometry *batch;
70
static unsigned long refCount;
71
static unsigned long GUID;
72
static inline Ogre::String getUniqueID(const Ogre::String &prefix)
74
return prefix + Ogre::StringConverter::toString(++GUID);