28 #ifndef __StaticGeometry_H__
29 #define __StaticGeometry_H__
212 void copyIndexes(
const T* src, T* dst,
size_t count,
size_t indexOffset)
214 if (indexOffset == 0)
216 memcpy(dst, src,
sizeof(T) * count);
222 *dst++ =
static_cast<T
>(*src++ + indexOffset);
251 void dump(std::ofstream& of)
const;
300 void dump(std::ofstream& of)
const;
327 bool createSeparateLightCap,
bool isLightCap =
false);
373 void dump(std::ofstream& of)
const;
381 bool extrudeVertices,
Real extrusionDistance,
unsigned long flags = 0 );
456 bool debugRenderables =
false);
467 bool extrudeVertices,
Real extrusionDistance,
unsigned long flags = 0 );
474 void dump(std::ofstream& of)
const;
561 template <
typename T>
565 for (
size_t i = 0; i < numIndexes; ++i)
568 remap.insert(IndexRemap::value_type(*pBuffer++, remap.size()));
574 template <
typename T>
578 for (
size_t i = 0; i < numIndexes; ++i)
581 IndexRemap::const_iterator ix = remap.find(*src++);
582 assert(ix != remap.end());
583 *dst++ =
static_cast<T
>(ix->second);
671 mUpperDistance = dist;
672 mSquaredUpperDistance = mUpperDistance * mUpperDistance;
680 {
return mSquaredUpperDistance; }
720 mRegionDimensions = size;
721 mHalfRegionDimensions = size * 0.5;
762 bool debugRenderables =
false);
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
A 3D box aligned with the x/y/z axes.
A viewpoint from which the scene will be rendered.
This class contains the information required to describe the edge connectivity of a given set of vert...
Defines an instance of a discrete, movable object based on a Mesh.
Shared pointer implementation used to share index buffers.
Shared pointer implementation used to share vertex buffers.
Summary class collecting together index data source information.
Representation of a dynamic light source in the scene.
Strategy for determining level of detail.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Class encapsulating a standard 4x4 homogeneous matrix.
vector< Real >::type LodValueList
Abstract class defining a movable object in a scene.
Implementation of a Quaternion, i.e.
static const Quaternion IDENTITY
'New' rendering operation using vertex buffers.
Class to manage the scene object rendering queue.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly.
Abstract class defining the interface all renderable objects must implement.
Manages the organisation and rendering of a 'scene' i.e.
Class representing a node in the scene graph.
vector< ShadowRenderable * >::type ShadowRenderableList
Class which represents the renderable aspects of a set of shadow volume faces.
A GeometryBucket is a the lowest level bucket where geometry with the same vertex & index format is s...
const MaterialPtr & getMaterial(void) const
Retrieves a weak reference to the material this renderable object uses.
void build(bool stencilShadows)
Build.
MaterialBucket * getParent(void)
VertexData * mVertexData
Vertex information, includes current number of vertices committed to be a part of this bucket.
QueuedGeometryList mQueuedGeometry
Geometry which has been queued up pre-build (not for deallocation)
bool assign(QueuedGeometry *qsm)
Try to assign geometry to this bucket.
void dump(std::ofstream &of) const
Dump contents for diagnostics.
void getRenderOperation(RenderOperation &op)
Gets the render operation required to send this object to the frame buffer.
Real getSquaredViewDepth(const Camera *cam) const
Returns the camera-relative squared depth of this renderable.
HardwareIndexBuffer::IndexType mIndexType
Size of indexes.
bool getCastsShadows(void) const
Method which reports whether this renderable would normally cast a shadow.
String mFormatString
String identifying the vertex / index format.
IndexData * mIndexData
Index information, includes index type which limits the max number of vertices which are allowed in o...
virtual ~GeometryBucket()
const LightList & getLights(void) const
Gets a list of lights, ordered relative to how close they are to this renderable.
GeometryBucket(MaterialBucket *parent, const String &formatString, const VertexData *vData, const IndexData *iData)
void copyIndexes(const T *src, T *dst, size_t count, size_t indexOffset)
const VertexData * getVertexData(void) const
Get the vertex data for this geometry.
void getWorldTransforms(Matrix4 *xform) const
Gets the world transform matrix / matrices for this renderable object.
Technique * getTechnique(void) const
Retrieves a pointer to the Material Technique this renderable object uses.
const IndexData * getIndexData(void) const
Get the index data for this geometry.
MaterialBucket * mParent
Pointer to parent bucket.
size_t mMaxVertexIndex
Maximum vertex indexable.
Nested class to allow shadows.
virtual void rebindIndexBuffer(const HardwareIndexBufferSharedPtr &indexBuffer)
Overridden from ShadowRenderable.
LODShadowRenderable(LODBucket *parent, HardwareIndexBufferSharedPtr *indexBuffer, const VertexData *vertexData, bool createSeparateLightCap, bool isLightCap=false)
HardwareVertexBufferSharedPtr getPositionBuffer(void)
HardwareVertexBufferSharedPtr getWBuffer(void)
HardwareVertexBufferSharedPtr mPositionBuffer
HardwareVertexBufferSharedPtr mWBuffer
void getWorldTransforms(Matrix4 *xform) const
Overridden from ShadowRenderable.
A LODBucket is a collection of smaller buckets with the same LOD.
LODBucket(Region *parent, unsigned short lod, Real lodValue)
QueuedGeometryList mQueuedGeometryList
Geometry queued for a single LOD (deallocated here)
Region * mParent
Pointer to parent region.
bool mVertexProgramInUse
Is a vertex program in use somewhere in this group?
void dump(std::ofstream &of) const
Dump contents for diagnostics.
void assign(QueuedSubMesh *qsm, ushort atLod)
Assign a queued submesh to this bucket, using specified mesh LOD.
MapIterator< MaterialBucketMap > MaterialIterator
Iterator over the materials in this LOD.
void addRenderables(RenderQueue *queue, uint8 group, Real lodValue)
Add children to the render queue.
unsigned short mLod
LOD level (0 == full LOD)
EdgeData * mEdgeList
Edge list, used if stencil shadow casting is enabled.
ushort getLod(void) const
Get the LOD index.
EdgeData * getEdgeList() const
ShadowCaster::ShadowRenderableList & getShadowRenderableList()
bool isVertexProgramInUse() const
ShadowCaster::ShadowRenderableList mShadowRenderables
List of shadow renderables.
Real mLodValue
LOD value at which this LOD starts to apply (squared)
void updateShadowRenderables(ShadowTechnique shadowTechnique, const Vector4 &lightPos, HardwareIndexBufferSharedPtr *indexBuffer, bool extrudeVertices, Real extrusionDistance, unsigned long flags=0)
void build(bool stencilShadows)
Build.
MaterialIterator getMaterialIterator(void)
Get an iterator over the materials in this LOD.
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables)
map< String, MaterialBucket * >::type MaterialBucketMap
Lookup of Material Buckets in this region.
Real getLodValue(void) const
Get the LOD value.
MaterialBucketMap mMaterialBucketMap
Lookup of Material Buckets in this region.
A MaterialBucket is a collection of smaller buckets with the same Material (and implicitly the same L...
void dump(std::ofstream &of) const
Dump contents for diagnostics.
Technique * getCurrentTechnique(void) const
Get the current Technique.
Technique * mTechnique
Active technique.
map< String, GeometryBucket * >::type CurrentGeometryMap
void assign(QueuedGeometry *qsm)
Assign geometry to this bucket.
LODBucket * mParent
Pointer to parent LODBucket.
CurrentGeometryMap mCurrentGeometryMap
GeometryBucketList mGeometryBucketList
list of Geometry Buckets in this region
MaterialPtr mMaterial
Pointer to material being used.
void build(bool stencilShadows)
Build.
const String & getMaterialName(void) const
Get the material name.
const MaterialPtr & getMaterial(void) const
Get the material for this bucket.
VectorIterator< GeometryBucketList > GeometryIterator
Iterator over geometry.
LODBucket * getParent(void)
vector< GeometryBucket * >::type GeometryBucketList
list of Geometry Buckets in this region
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables)
String getGeometryFormatString(SubMeshLodGeometryLink *geom)
Get a packed string identifying the geometry format.
void addRenderables(RenderQueue *queue, uint8 group, Real lodValue)
Add children to the render queue.
virtual ~MaterialBucket()
String mMaterialName
Material being used.
MaterialBucket(LODBucket *parent, const String &materialName)
GeometryIterator getGeometryIterator(void)
Get an iterator over the contained geometry.
Struct holding geometry optimised per SubMesh / LOD level, ready for copying to instances.
~OptimisedSubMeshGeometry()
OptimisedSubMeshGeometry()
The details of a topological region which is the highest level of partitioning for this class.
Real mSquaredViewDepth
Cached squared view depth value to avoid recalculation by GeometryBucket.
bool isVisible(void) const
Returns whether or not this object is supposed to be visible or not.
AxisAlignedBox mAABB
Local AABB relative to region centre.
EdgeData * getEdgeList(void)
Overridden from MovableObject.
ushort mCurrentLod
The current LOD level, as determined from the last camera.
vector< LODBucket * >::type LODBucketList
list of LOD Buckets in this region
LODBucketList mLodBucketList
List of LOD buckets
SceneNode * mNode
Scene node.
void _updateRenderQueue(RenderQueue *queue)
Internal method by which the movable object must add Renderable subclass instances to the rendering q...
Vector3 mCentre
Center of the region.
ulong mLightListUpdated
The last frame that this light list was updated in.
SceneManager * mSceneMgr
Scene manager link.
LODIterator getLODIterator(void)
Get an iterator over the LODs in this region.
StaticGeometry * mParent
Parent static geometry.
void dump(std::ofstream &of) const
Dump contents for diagnostics.
bool hasEdgeList(void)
Overridden member from ShadowCaster.
Real getBoundingRadius(void) const
Retrieves the radius of the origin-centered bounding sphere for this object.
VectorIterator< LODBucketList > LODIterator
const Vector3 & getCentre(void) const
Get the centre point of the region.
uint32 mRegionID
Unique identifier for the region.
QueuedSubMeshList mQueuedSubMeshes
Local list of queued meshes (not used for deallocation)
const String & getMovableType(void) const
Returns the type name of this object.
ShadowRenderableListIterator getShadowVolumeRenderableIterator(ShadowTechnique shadowTechnique, const Light *light, HardwareIndexBufferSharedPtr *indexBuffer, size_t *indexBufferUsedSize, bool extrudeVertices, Real extrusionDistance, unsigned long flags=0)
Gets an iterator over the renderables required to render the shadow volume.
const AxisAlignedBox & getBoundingBox(void) const
Retrieves the local axis-aligned bounding box for this object.
Camera * mCamera
Current camera.
void _notifyCurrentCamera(Camera *cam)
Internal method to notify the object of the camera to be used for the next rendering operation.
LightList mLightList
List of lights for this region.
void assign(QueuedSubMesh *qmesh)
Assign a queued mesh to this region, read for final build.
Real mLodValue
Current LOD value, passed on to do material LOD later.
Region(StaticGeometry *parent, const String &name, SceneManager *mgr, uint32 regionID, const Vector3 ¢re)
const LodStrategy * mLodStrategy
LOD strategy reference.
uint32 getTypeFlags(void) const
Get the 'type flags' for this MovableObject.
Mesh::LodValueList mLodValues
LOD values as built up - use the max at each level.
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
void build(bool stencilShadows)
Build this region.
uint32 getID(void) const
Get the region ID of this region.
StaticGeometry * getParent(void) const
Real mBoundingRadius
Local bounding radius.
Pre-transforms and batches up meshes for efficient use as static geometry in a scene.
map< size_t, size_t >::type IndexRemap
void setVisibilityFlags(uint32 flags)
Sets the visibility flags of all the regions at once.
virtual void build(void)
Build the geometry.
StaticGeometry(SceneManager *owner, const String &name)
Constructor; do not use directly (.
RegionMap mRegionMap
Map of regions.
virtual void reset(void)
Clears any of the entities / nodes added to this geometry and destroys anything which has already bee...
bool mRenderQueueIDSet
Flags whether the RenderQueue's default should be used.
SubMeshLodGeometryLinkList * determineGeometry(SubMesh *sm)
Look up or calculate the geometry data to use for this SubMesh.
uint32 mVisibilityFlags
Stores the visibility flags for the regions.
virtual uint8 getRenderQueueGroup(void) const
Gets the queue group for this entity, see setRenderQueueGroup for full details.
virtual Region * getRegion(uint32 index)
Get the region using a packed index, returns null if it doesn't exist.
void remapIndexes(T *src, T *dst, const IndexRemap &remap, size_t numIndexes)
Method for altering indexes based on a remap.
virtual void setRenderingDistance(Real dist)
Sets the distance at which batches are no longer rendered.
virtual bool getCastShadows(void)
Will the geometry from this object cast shadows?
uint8 mRenderQueueID
The render queue to use when rendering this object.
Vector3 mRegionDimensions
virtual void getRegionIndexes(const Vector3 &point, ushort &x, ushort &y, ushort &z)
Get the region indexes for a point.
map< SubMesh *, SubMeshLodGeometryLinkList * >::type SubMeshGeometryLookup
RegionIterator getRegionIterator(void)
Get an iterator over the regions in this geometry.
virtual void destroy(void)
Destroys all the built geometry state (reverse of build).
virtual Real getVolumeIntersection(const AxisAlignedBox &box, ushort x, ushort y, ushort z)
Get the volume intersection for an indexed region with some bounds.
uint32 getVisibilityFlags() const
Returns the visibility flags of the regions.
virtual uint32 packIndex(ushort x, ushort y, ushort z)
Pack 3 indexes into a single index value.
virtual Region * getRegion(ushort x, ushort y, ushort z, bool autoCreate)
Get the region using indexes.
OptimisedSubMeshGeometryList mOptimisedSubMeshGeometryList
List of geometry which has been optimised for SubMesh use This is the primary storage used for cleani...
virtual ~StaticGeometry()
Destructor.
virtual void setCastShadows(bool castShadows)
Sets whether this geometry should cast shadows.
virtual void setOrigin(const Vector3 &origin)
Sets the origin of the geometry.
QueuedSubMeshList mQueuedSubMeshes
virtual const Vector3 & getOrigin(void) const
Gets the origin of this geometry.
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
virtual void setRenderQueueGroup(uint8 queueID)
Sets the render queue group this object will be rendered through.
virtual void setRegionDimensions(const Vector3 &size)
Sets the size of a single region of geometry.
virtual void addEntity(Entity *ent, const Vector3 &position, const Quaternion &orientation=Quaternion::IDENTITY, const Vector3 &scale=Vector3::UNIT_SCALE)
Adds an Entity to the static geometry.
vector< QueuedGeometry * >::type QueuedGeometryList
virtual void addSceneNode(const SceneNode *node)
Adds all the Entity objects attached to a SceneNode and all it's children to the static geometry.
virtual Region * getRegion(const Vector3 &point, bool autoCreate)
Get the region within which a point lies.
virtual void setVisible(bool visible)
Hides or shows all the batches.
virtual Real getSquaredRenderingDistance(void) const
Gets the squared distance at which batches are no longer rendered.
virtual AxisAlignedBox calculateBounds(VertexData *vertexData, const Vector3 &position, const Quaternion &orientation, const Vector3 &scale)
Calculate world bounds from a set of vertex data.
MapIterator< RegionMap > RegionIterator
Iterator for iterating over contained regions.
virtual Region * getRegion(const AxisAlignedBox &bounds, bool autoCreate)
Virtual method for getting a region most suitable for the passed in bounds.
void buildIndexRemap(T *pBuffer, size_t numIndexes, IndexRemap &remap)
Method for figuring out which vertices are used by an index buffer and calculating a remap lookup for...
void splitGeometry(VertexData *vd, IndexData *id, SubMeshLodGeometryLink *targetGeomLink)
Split some shared geometry into dedicated geometry.
Vector3 mHalfRegionDimensions
virtual void dump(const String &filename) const
Dump the contents of this StaticGeometry to a file for diagnostic purposes.
vector< QueuedSubMesh * >::type QueuedSubMeshList
Real mSquaredUpperDistance
virtual bool isVisible(void) const
Are the batches visible?
virtual AxisAlignedBox getRegionBounds(ushort x, ushort y, ushort z)
Get the bounds of an indexed region.
SubMeshGeometryLookup mSubMeshGeometryLookup
Cached links from SubMeshes to (potentially optimised) geometry This is not used for deletion since t...
virtual Real getRenderingDistance(void) const
Gets the distance at which batches are no longer rendered.
vector< SubMeshLodGeometryLink >::type SubMeshLodGeometryLinkList
virtual Vector3 getRegionCentre(ushort x, ushort y, ushort z)
Get the centre of an indexed region.
list< OptimisedSubMeshGeometry * >::type OptimisedSubMeshGeometryList
const String & getName(void) const
Get the name of this object.
virtual const Vector3 & getRegionDimensions(void) const
Gets the size of a single batch of geometry.
map< uint32, Region * >::type RegionMap
Indexed region map based on packed x/y/z region index, 10 bits for each axis.
Defines a part of a complete mesh.
Class representing an approach to rendering this particular Material.
Standard 3-dimensional vector.
static const Vector3 UNIT_SCALE
4-dimensional homogeneous vector.
Concrete IteratorWrapper for nonconst access to the underlying container.
Summary class collecting together vertex source information.
ShadowTechnique
An enumeration of broad shadow techniques.
float Real
Software floating point type.
Structure recording a queued geometry for low level builds.
SubMeshLodGeometryLink * geometry
Structure recording a queued submesh for the build.
SubMeshLodGeometryLinkList * geometryLodList
Link to LOD list of geometry, potentially optimised.
AxisAlignedBox worldBounds
Pre-transformed world AABB.
Saved link between SubMesh at a LOD and vertex/index data May point to original or optimised geometry...
std::map< K, V, P, A > type