28#ifndef __InstancedGeometry_H__
29#define __InstancedGeometry_H__
206 void copyIndexes(
const T* src, T* dst,
size_t count,
size_t indexOffset)
208 if (indexOffset == 0)
210 memcpy(dst, src,
sizeof(T) * count);
216 *dst++ =
static_cast<T
>(*src++ + indexOffset);
254 void dump(std::ofstream& of)
const;
366 void dump(std::ofstream& of)
const;
420 void dump(std::ofstream& of)
const;
502 bool debugRenderables =
false);
516 void dump(std::ofstream& of)
const;
631 template <
typename T>
635 for (
size_t i = 0; i < numIndexes; ++i)
638 remap.insert(IndexRemap::value_type(*pBuffer++, remap.size()));
644 template <
typename T>
648 for (
size_t i = 0; i < numIndexes; ++i)
651 IndexRemap::const_iterator ix = remap.find(*src++);
652 assert(ix != remap.end());
653 *dst++ =
static_cast<T
>(ix->second);
843 bool debugRenderables =
false);
Class encapsulating a set of AnimationState objects.
Represents the state of an animation and the weight of its influence.
A 3D box aligned with the x/y/z axes.
A viewpoint from which the scene will be rendered.
Defines an instance of a discrete, movable object based on a Mesh.
Summary class collecting together index data source information.
The details of a topological BatchInstance which is the highest level of partitioning for this class.
SceneNode * mNode
Scene node.
void attachToScene()
attach the BatchInstance to the scene
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
void setBoundingBox(AxisAlignedBox &box)
bool isVisible(void) const
Returns whether or not this object is supposed to be visible or not.
InstancedObjectIterator getObjectIterator()
friend class MaterialBucket
uint32 mBatchInstanceID
Unique identifier for the BatchInstance.
void assign(QueuedSubMesh *qmesh)
Assign a queued mesh to this BatchInstance, read for final build.
SceneManager * mSceneMgr
Scene manager link.
const String & getMovableType(void) const
Get the centre point of the BatchInstance.
vector< LODBucket * >::type LODBucketList
list of LOD Buckets in this BatchInstance
const LodStrategy * mLodStrategy
LOD strategy reference.
InstancedObject * isInstancedObjectPresent(unsigned short index)
void addInstancedObject(unsigned short index, InstancedObject *object)
InstancedGeometry * mParent
Parent static geometry.
void updateBoundingBox()
update the bounding box of the BatchInstance according to the positions of the objects
Real getBoundingRadius(void) const
Retrieves the radius of the origin-centered bounding sphere for this object.
ushort mCurrentLod
The current LOD level, as determined from the last camera.
AxisAlignedBox mAABB
Local AABB relative to BatchInstance centre.
uint32 getID(void) const
Get the BatchInstance ID of this BatchInstance.
Real mSquaredViewDepth
Cached squared view depth value to avoid recalculation by GeometryBucket.
void build()
Build this BatchInstance.
const AxisAlignedBox & getBoundingBox(void) const
Retrieves the local axis-aligned bounding box for this object.
VectorIterator< LODBucketList > LODIterator
ObjectsMap & getInstancesMap(void)
QueuedSubMeshList mQueuedSubMeshes
Local list of queued meshes (not used for deallocation)
void dump(std::ofstream &of) const
Dump contents for diagnostics.
InstancedGeometry * getParent(void) const
void _updateRenderQueue(RenderQueue *queue)
Internal method by which the movable object must add Renderable subclass instances to the rendering q...
LODBucketList mLodBucketList
List of LOD buckets.
map< unsignedshort, InstancedObject * >::type ObjectsMap
Real mBoundingRadius
Local bounding radius.
Mesh::LodValueList mLodValues
LOD values as built up - use the max at each level.
BatchInstance(InstancedGeometry *parent, const String &name, SceneManager *mgr, uint32 BatchInstanceID)
void _notifyCurrentCamera(Camera *cam)
Internal method to notify the object of the camera to be used for the next rendering operation.
Real mLodValue
Current LOD value, passed on to do material LOD later.
const LightList & getLights(void) const
Shared set of lights for all GeometryBuckets.
SceneNode * getSceneNode(void)
LODIterator getLODIterator(void)
Get an iterator over the LODs in this BatchInstance.
MapIterator< ObjectsMap > InstancedObjectIterator
Camera * mCamera
Current camera, passed on to do material LOD later.
void updateContainers(LODBucket *bucket)
fill in the list
A GeometryBucket is a the lowest level bucket where geometry with the same vertex & index format is s...
MaterialBucket * getParent(void)
void _initGeometryBucket(GeometryBucket *bucket)
GeometryBucket(const String &name, MaterialBucket *parent, const String &formatString, GeometryBucket *bucket)
const IndexData * getIndexData(void) const
Get the index data for this geometry.
Real getBoundingRadius(void) const
Retrieves the radius of the origin-centered bounding sphere for this object.
void _initGeometryBucket(const VertexData *vData, const IndexData *iData)
InstancedGeometry * mBatch
Pointer to the Batch.
AxisAlignedBox & getAABB(void)
Return the BoundingBox information. Useful when cloning the batch instance.
bool assign(QueuedGeometry *qsm)
Try to assign geometry to this bucket.
size_t mMaxVertexIndex
Maximum vertex indexable.
GeometryBucket(const String &name, MaterialBucket *parent, const String &formatString, const VertexData *vData, const IndexData *iData)
IndexData * mIndexData
Index information, includes index type which limits the max number of vertices which are allowed in o...
unsigned short mTexCoordIndex
Index of the Texcoord where the index is stored.
String mFormatString
String identifying the vertex / index format.
Real getSquaredViewDepth(const Camera *cam) const
Returns the camera-relative squared depth of this renderable.
GeometryBucket(MaterialBucket *parent, const String &formatString, GeometryBucket *bucket)
Technique * getTechnique(void) const
Retrieves a pointer to the Material Technique this renderable object uses.
void getWorldTransforms(Matrix4 *xform) const
Gets the world transform matrix / matrices for this renderable object.
HardwareIndexBuffer::IndexType mIndexType
Size of indexes.
String getFormatString(void) const
const MaterialPtr & getMaterial(void) const
Retrieves a weak reference to the material this renderable object uses.
const VertexData * getVertexData(void) const
Get the vertex data for this geometry.
MaterialBucket * mParent
Pointer to parent bucket.
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)
virtual unsigned short getNumWorldTransforms(void) const
Returns the number of world transform matrices this renderable requires.
void copyIndexes(const T *src, T *dst, size_t count, size_t indexOffset)
virtual ~GeometryBucket()
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
void dump(std::ofstream &of) const
Dump contents for diagnostics.
const LightList & getLights(void) const
Gets a list of lights, ordered relative to how close they are to this renderable.
bool getCastsShadows(void) const
Method which reports whether this renderable would normally cast a shadow.
GeometryBucket(MaterialBucket *parent, const String &formatString, const VertexData *vData, const IndexData *iData)
const Vector3 & getScale() const
friend class GeometryBucket
void updateAnimation(void)
void setScale(const Vector3 &scale)
GeometryBucketList & getGeometryBucketList(void)
Matrix3 getLocalAxes(void) const
AnimationStateSet * mAnimationState
State of animation for animable meshes.
AnimationState * getAnimationState(const String &name) const
void setPositionAndOrientation(Vector3 p, const Quaternion &q)
@ TS_PARENT
Transform is relative to the space of the parent node.
@ TS_WORLD
Transform is relative to world space.
@ TS_LOCAL
Transform is relative to the local space.
void addBucketToList(GeometryBucket *bucket)
void translate(const Matrix3 &axes, const Vector3 &move)
InstancedObject(unsigned short index, SkeletonInstance *skeleton, AnimationStateSet *animations)
Matrix4 * mBoneMatrices
Cached bone matrices in skeleton local space.
void setPosition(Vector3 position)
SkeletonInstance * getSkeletonInstance(void)
const Vector3 & getPosition(void) const
unsigned short mNumBoneMatrices
GeometryBucketList mGeometryBucketList
Quaternion & getOrientation(void)
unsigned long mFrameAnimationLastUpdated
Records the last frame in which animation was updated.
InstancedObject(unsigned short index)
Matrix4 * mBoneWorldMatrices
Cached bone matrices, including any world transform.
void setOrientation(const Quaternion &q)
vector< GeometryBucket * >::type GeometryBucketList
list of Geometry Buckets that contains the instanced object
void roll(const Radian &angle)
SkeletonInstance * mSkeletonInstance
void rotate(const Quaternion &q)
void pitch(const Radian &angle)
void translate(const Vector3 &d)
void yaw(const Radian &angle)
A LODBucket is a collection of smaller buckets with the same LOD.
ushort getLod(void) const
Get the LOD index.
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables)
MaterialIterator getMaterialIterator(void)
Get an iterator over the materials in this LOD.
MapIterator< MaterialBucketMap > MaterialIterator
Iterator over the materials in this LOD.
Real getLodValue(void) const
Get the LOD value.
map< String, MaterialBucket * >::type MaterialBucketMap
Lookup of Material Buckets in this BatchInstance.
QueuedGeometryList mQueuedGeometryList
Geometry queued for a single LOD (deallocated here)
BatchInstance * getParent(void)
LODBucket(BatchInstance *parent, unsigned short lod, Real lodValue)
Real mLodValue
LOD value at which this LOD starts to apply (squared)
BatchInstance * mParent
Pointer to parent BatchInstance.
void dump(std::ofstream &of) const
Dump contents for diagnostics.
void addRenderables(RenderQueue *queue, uint8 group, Real lodValue)
Add children to the render queue.
void assign(QueuedSubMesh *qsm, ushort atLod)
Assign a queued submesh to this bucket, using specified mesh LOD.
void updateContainers(MaterialBucket *bucket, String &name)
fill the map
unsigned short mLod
LOD level (0 == full LOD)
MaterialBucketMap mMaterialBucketMap
Lookup of Material Buckets in this BatchInstance.
A MaterialBucket is a collection of smaller buckets with the same Material (and implicitly the same L...
LODBucket * mParent
Pointer to parent LODBucket.
GeometryBucketList mGeometryBucketList
list of Geometry Buckets in this BatchInstance
GeometryIterator getGeometryIterator(void)
Get an iterator over the contained geometry.
CurrentGeometryMap mCurrentGeometryMap
String mMaterialName
Material being used.
virtual ~MaterialBucket()
void updateContainers(GeometryBucket *bucket, const String &format)
fill in the map and the list
MaterialPtr mMaterial
Pointer to material being used.
map< String, GeometryBucket * >::type CurrentGeometryMap
LODBucket * getParent(void)
Technique * mTechnique
Active technique.
void setMaterial(const String &name)
MaterialBucket(LODBucket *parent, const String &materialName)
void setLastIndex(int index)
String getGeometryFormatString(SubMeshLodGeometryLink *geom)
Get a packed string identifying the geometry format.
void dump(std::ofstream &of) const
Dump contents for diagnostics.
const MaterialPtr & getMaterial(void) const
Get the material for this bucket.
void assign(QueuedGeometry *qsm)
Assign geometry to this bucket.
Technique * getCurrentTechnique(void) const
Get the current Technique.
MaterialBucket::GeometryBucketList * getGeometryBucketList(void) const
Return the geometry list.
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables)
VectorIterator< GeometryBucketList > GeometryIterator
Iterator over geometry.
void addRenderables(RenderQueue *queue, uint8 group, Real lodValue)
Add children to the render queue.
MaterialBucket::CurrentGeometryMap * getMaterialBucketMap(void) const
Return the geometry map.
const String & getMaterialName(void) const
Get the material name.
vector< GeometryBucket * >::type GeometryBucketList
list of Geometry Buckets in this BatchInstance
OptimisedSubMeshGeometry()
~OptimisedSubMeshGeometry()
Real mSquaredUpperDistance
virtual BatchInstance * getBatchInstance(const AxisAlignedBox &bounds, bool autoCreate)
Virtual method for getting a BatchInstance most suitable for the passed in bounds.
virtual bool getProvideWorldInverses(void) const
unsigned int mObjectCount
number of objects in the batch
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...
bool mProvideWorldInverses
Flags to indicate whether the World Transform Inverse matrices are passed to the shaders.
virtual uint32 packIndex(ushort x, ushort y, ushort z)
Pack 3 indexes into a single index value.
virtual uint8 getRenderQueueGroup(void) const
Gets the queue group for this entity, see setRenderQueueGroup for full details.
MapIterator< BatchInstanceMap > BatchInstanceIterator
Iterator for iterating over contained BatchInstances.
virtual Real getVolumeIntersection(const AxisAlignedBox &box, ushort x, ushort y, ushort z)
Get the volume intersection for an indexed BatchInstance with some bounds.
SkeletonPtr mBaseSkeleton
this is just a pointer to the base skeleton that will be used for each animated object in the batches...
SkeletonInstance * getBaseSkeletonInstance(void)
virtual void setBatchInstanceDimensions(const Vector3 &size)
Sets the size of a single BatchInstance of geometry.
virtual bool isVisible(void) const
Are the batches visible?
virtual void setProvideWorldInverses(bool flag)
void addBatchInstance(void)
Add a new batch instance.
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
vector< String >::type QueuedSubMeshOriginList
virtual bool getCastShadows(void)
Will the geometry from this object cast shadows?
AnimationStateSet * getBaseAnimationState(void)
virtual AxisAlignedBox calculateBounds(VertexData *vertexData, const Vector3 &position, const Quaternion &orientation, const Vector3 &scale)
Calculate world bounds from a set of vertex data.
uint8 mRenderQueueID
The render queue to use when rendering this object.
unsigned int getObjectCount(void)
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.
BatchInstance * mInstancedGeometryInstance
virtual Real getRenderingDistance(void) const
Gets the distance at which batches are no longer rendered.
virtual BatchInstance * getBatchInstance(uint32 index)
Get the BatchInstance using a packed index, returns null if it doesn't exist.
map< size_t, size_t >::type IndexRemap
OptimisedSubMeshGeometryList mOptimisedSubMeshGeometryList
List of geometry which has been optimised for SubMesh use This is the primary storage used for cleani...
virtual AxisAlignedBox getBatchInstanceBounds(ushort x, ushort y, ushort z)
Get the bounds of an indexed BatchInstance.
RenderOperationVector & getRenderOperationVector()
get the mRenderOps vector.
virtual void getBatchInstanceIndexes(const Vector3 &point, ushort &x, ushort &y, ushort &z)
Get the BatchInstance indexes for a point.
vector< SubMeshLodGeometryLink >::type SubMeshLodGeometryLinkList
virtual void setCastShadows(bool castShadows)
Sets whether this geometry should cast shadows.
SkeletonInstance * mSkeletonInstance
virtual const Vector3 & getBatchInstanceDimensions(void) const
Gets the size of a single batch of geometry.
Vector3 mHalfBatchInstanceDimensions
map< SubMesh *, SubMeshLodGeometryLinkList * >::type SubMeshGeometryLookup
SubMeshLodGeometryLinkList * determineGeometry(SubMesh *sm)
Look up or calculate the geometry data to use for this SubMesh.
virtual void setOrigin(const Vector3 &origin)
Sets the origin of the geometry.
void splitGeometry(VertexData *vd, IndexData *id, SubMeshLodGeometryLink *targetGeomLink)
Split some shared geometry into dedicated geometry.
virtual BatchInstance * getBatchInstance(const Vector3 &point, bool autoCreate)
Get the BatchInstance within which a point lies.
virtual void setVisible(bool visible)
Hides or shows all the batches.
bool mRenderQueueIDSet
Flags whether the RenderQueue's default should be used.
InstancedGeometry(SceneManager *owner, const String &name)
Constructor; do not use directly (.
const String & getName(void) const
Get the name of this object.
virtual BatchInstance * getBatchInstance(ushort x, ushort y, ushort z, bool autoCreate)
Get the BatchInstance using indexes.
virtual void build(void)
Build the geometry.
SkeletonPtr getBaseSkeleton(void)
virtual void reset(void)
Clears any of the entities / nodes added to this geometry and destroys anything which has already bee...
virtual const Vector3 & getOrigin(void) const
Gets the origin of this geometry.
vector< QueuedGeometry * >::type QueuedGeometryList
virtual Vector3 getBatchInstanceCentre(ushort x, ushort y, ushort z)
Get the centre of an indexed BatchInstance.
SubMeshGeometryLookup mSubMeshGeometryLookup
Cached links from SubMeshes to (potentially optimised) geometry This is not used for deletion since t...
map< uint32, BatchInstance * >::type BatchInstanceMap
Indexed BatchInstance map based on packed x/y/z BatchInstance index, 10 bits for each axis.
virtual BatchInstance * getInstancedGeometryInstance(void)
get the first BatchInstance or create on if it does not exists.
list< OptimisedSubMeshGeometry * >::type OptimisedSubMeshGeometryList
virtual void destroy(void)
Destroys all the built geometry state (reverse of build).
BatchInstanceIterator getBatchInstanceIterator(void)
Get an iterator over the BatchInstances in this geometry.
BatchInstanceMap mBatchInstanceMap
Map of BatchInstances.
void remapIndexes(T *src, T *dst, const IndexRemap &remap, size_t numIndexes)
Method for altering indexes based on a remap.
vector< QueuedSubMesh * >::type QueuedSubMeshList
AnimationStateSet * mAnimationState
This is the main animation state.
virtual void setRenderQueueGroup(uint8 queueID)
Sets the render queue group this object will be rendered through.
vector< RenderOperation * >::type RenderOperationVector
Simple vectors where are stored all the render operations of the Batch.
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 setRenderingDistance(Real dist)
Sets the distance at which batches are no longer rendered.
virtual Real getSquaredRenderingDistance(void) const
Gets the squared distance at which batches are no longer rendered.
virtual ~InstancedGeometry()
Destructor.
QueuedSubMeshList mQueuedSubMeshes
RenderOperationVector mRenderOps
This vector stores all the renderOperation used in the batch.
virtual void dump(const String &filename) const
Dump the contents of this InstancedGeometry to a file for diagnostic purposes.
Vector3 mBatchInstanceDimensions
Strategy for determining level of detail.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
A 3x3 matrix which can represent rotations around axes.
Class encapsulating a standard 4x4 homogeneous matrix.
vector< Real >::type LodValueList
MovableObject()
Constructor.
Implementation of a Quaternion, i.e.
static const Quaternion IDENTITY
Wrapper class which indicates a given angle value is in Radians.
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.
SimpleRenderable()
Constructor.
A SkeletonInstance is a single instance of a Skeleton used by a world object.
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
Concrete IteratorWrapper for nonconst access to the underlying container.
Summary class collecting together vertex source information.
SharedPtr< Skeleton > SkeletonPtr
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