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

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.