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);
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);
762 bool debugRenderables =
false);
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
MovableObject()
Constructor.
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.
Manages the organisation and rendering of a 'scene' i.e.
Class representing a node in the scene graph.
VectorIterator< ShadowRenderableList > ShadowRenderableListIterator
static void extrudeVertices(const HardwareVertexBufferSharedPtr &vertexBuffer, size_t originalVertexCount, const Vector4 &lightPos, Real extrudeDist)
Utility method for extruding vertices based on a light.
vector< ShadowRenderable * >::type ShadowRenderableList
ShadowRenderable()
Used only if isLightCapSeparate == true.
void build(bool stencilShadows)
Build.
VertexData * mVertexData
Vertex information, includes current number of vertices committed to be a part of this bucket.
const IndexData * getIndexData(void) const
Get the index data for this geometry.
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.
const LightList & getLights(void) const
Gets a list of lights, ordered relative to how close they are to this renderable.
const MaterialPtr & getMaterial(void) const
Retrieves a weak reference to the material this renderable object uses.
Real getSquaredViewDepth(const Camera *cam) const
Returns the camera-relative squared depth of this renderable.
HardwareIndexBuffer::IndexType mIndexType
Size of indexes.
Technique * getTechnique(void) const
Retrieves a pointer to the Material Technique this renderable object uses.
bool getCastsShadows(void) const
Method which reports whether this renderable would normally cast a shadow.
String mFormatString
String identifying the vertex / index format.
MaterialBucket * getParent(void)
IndexData * mIndexData
Index information, includes index type which limits the max number of vertices which are allowed in o...
const VertexData * getVertexData(void) const
Get the vertex data for this geometry.
virtual ~GeometryBucket()
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)
void getWorldTransforms(Matrix4 *xform) const
Gets the world transform matrix / matrices for this renderable object.
MaterialBucket * mParent
Pointer to parent bucket.
size_t mMaxVertexIndex
Maximum vertex indexable.
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?
ShadowCaster::ShadowRenderableList & getShadowRenderableList()
void dump(std::ofstream &of) const
Dump contents for diagnostics.
map< String, MaterialBucket * >::type MaterialBucketMap
Lookup of Material Buckets in this region.
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
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)
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.
map< String, GeometryBucket * >::type CurrentGeometryMap
Technique * getCurrentTechnique(void) const
Get the current Technique.
Technique * mTechnique
Active technique.
const String & getMaterialName(void) const
Get the material name.
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.
VectorIterator< GeometryBucketList > GeometryIterator
Iterator over geometry.
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.
const MaterialPtr & getMaterial(void) const
Get the material for this bucket.
void addRenderables(RenderQueue *queue, uint8 group, Real lodValue)
Add children to the render queue.
virtual ~MaterialBucket()
String mMaterialName
Material being used.
LODBucket * getParent(void)
MaterialBucket(LODBucket *parent, const String &materialName)
GeometryIterator getGeometryIterator(void)
Get an iterator over the contained geometry.
~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.
ushort mCurrentLod
The current LOD level, as determined from the last camera.
friend class GeometryBucket
vector< LODBucket * >::type LODBucketList
list of LOD Buckets in this region
friend class MaterialBucket
LODBucketList mLodBucketList
List of LOD buckets.
EdgeData * getEdgeList(void)
Overridden from MovableObject.
const String & getMovableType(void) const
Returns the type name of this object.
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
uint32 mRegionID
Unique identifier for the region.
QueuedSubMeshList mQueuedSubMeshes
Local list of queued meshes (not used for deallocation)
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.
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.
StaticGeometry * getParent(void) const
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 Vector3 & getCentre(void) const
Get the centre point of the region.
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 ...
const AxisAlignedBox & getBoundingBox(void) const
Retrieves the local axis-aligned bounding box for this object.
void build(bool stencilShadows)
Build this region.
uint32 getID(void) const
Get the region ID of this region.
Real mBoundingRadius
Local bounding radius.
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.
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(const Vector3 &point, bool autoCreate)
Get the region within which a point lies.
void remapIndexes(T *src, T *dst, const IndexRemap &remap, size_t numIndexes)
Method for altering indexes based on a remap.
SubMeshLodGeometryLinkList * determineGeometry(SubMesh *sm)
Look up or calculate the geometry data to use for this SubMesh.
virtual const Vector3 & getOrigin(void) const
Gets the origin of this geometry.
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?
virtual const Vector3 & getRegionDimensions(void) const
Gets the size of a single batch of geometry.
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.
RegionIterator getRegionIterator(void)
Get an iterator over the regions in this geometry.
map< uint32, Region * >::type RegionMap
Indexed region map based on packed x/y/z region index, 10 bits for each axis.
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.
const String & getName(void) const
Get the name of this object.
virtual uint32 packIndex(ushort x, ushort y, ushort z)
Pack 3 indexes into a single index value.
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.
map< SubMesh *, SubMeshLodGeometryLinkList * >::type SubMeshGeometryLookup
virtual void setOrigin(const Vector3 &origin)
Sets the origin of the geometry.
QueuedSubMeshList mQueuedSubMeshes
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.
map< size_t, size_t >::type IndexRemap
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.
virtual Region * getRegion(const AxisAlignedBox &bounds, bool autoCreate)
Virtual method for getting a region most suitable for the passed in bounds.
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 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.
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 Region * getRegion(uint32 index)
Get the region using a packed index, returns null if it doesn't exist.
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.
virtual Region * getRegion(ushort x, ushort y, ushort z, bool autoCreate)
Get the region using indexes.
list< OptimisedSubMeshGeometry * >::type OptimisedSubMeshGeometryList
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.
HashedVector< Light * > LightList
SharedPtr< Material > MaterialPtr
GeometryAllocatedObject BatchedGeometryAlloc
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