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);
233 Real getBoundingRadius(
void)
const;
241 void getWorldTransforms(
Matrix4* xform)
const;
242 virtual unsigned short getNumWorldTransforms(
void)
const ;
243 Real getSquaredViewDepth(
const Camera* cam)
const;
245 bool getCastsShadows(
void)
const;
246 String getFormatString(
void)
const;
254 void dump(std::ofstream& of)
const;
297 void setPosition(
Vector3 position);
298 const Vector3& getPosition(
void)
const;
299 void yaw(
const Radian& angle);
300 void pitch(
const Radian& angle);
301 void roll(
const Radian& angle);
303 void setScale(
const Vector3& scale);
304 const Vector3& getScale()
const;
312 void translate(
const Vector3& d);
313 Matrix3 getLocalAxes(
void)
const;
314 void updateAnimation(
void);
362 GeometryIterator getGeometryIterator(
void);
366 void dump(std::ofstream& of)
const;
375 void setMaterial(
const String & name);
418 MaterialIterator getMaterialIterator(
void);
420 void dump(std::ofstream& of)
const;
493 const String& getMovableType(
void)
const;
494 void _notifyCurrentCamera(
Camera* cam);
497 Real getBoundingRadius(
void)
const;
499 bool isVisible(
void)
const;
502 bool debugRenderables =
false);
508 LODIterator getLODIterator(
void);
513 void updateBoundingBox();
516 void dump(std::ofstream& of)
const;
518 void updateContainers(
LODBucket* bucket );
520 void attachToScene();
521 void addInstancedObject(
unsigned short index,
InstancedObject*
object);
523 InstancedObjectIterator getObjectIterator();
598 virtual void getBatchInstanceIndexes(
const Vector3& point,
621 SubMeshLodGeometryLinkList* determineGeometry(
SubMesh* sm);
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);
707 virtual void addSceneNode(
const SceneNode* node);
719 virtual void build(
void);
728 void addBatchInstance(
void);
734 virtual void destroy(
void);
739 virtual void reset(
void);
751 mUpperDistance = dist;
752 mSquaredUpperDistance = mUpperDistance * mUpperDistance;
760 {
return mSquaredUpperDistance; }
763 virtual void setVisible(
bool visible);
785 virtual void setCastShadows(
bool castShadows);
800 mBatchInstanceDimensions = size;
801 mHalfBatchInstanceDimensions = size * 0.5;
831 virtual void setRenderQueueGroup(
uint8 queueID);
834 virtual uint8 getRenderQueueGroup(
void)
const;
838 BatchInstanceIterator getBatchInstanceIterator(
void);
843 bool debugRenderables =
false);
848 virtual void dump(
const String& filename)
const;
876 virtual void setProvideWorldInverses(
bool flag);
vector< GeometryBucket * >::type GeometryBucketList
list of Geometry Buckets in this BatchInstance
RenderOperationVector & getRenderOperationVector()
get the mRenderOps vector.
MapIterator< MaterialBucketMap > MaterialIterator
Iterator over the materials in this LOD.
vector< QueuedGeometry * >::type QueuedGeometryList
String mFormatString
String identifying the vertex / index format.
Concrete IteratorWrapper for nonconst access to the underlying container.
Transform is relative to the local space.
Technique * mTechnique
Active technique.
unsigned int getObjectCount(void)
Real mSquaredViewDepth
Cached squared view depth value to avoid recalculation by GeometryBucket.
SkeletonInstance * getBaseSkeletonInstance(void)
list< OptimisedSubMeshGeometry * >::type OptimisedSubMeshGeometryList
Real mBoundingRadius
Local bounding radius.
OptimisedSubMeshGeometry()
Abstract class defining a movable object in a scene.
Strategy for determining level of detail.
void copyIndexes(const T *src, T *dst, size_t count, size_t indexOffset)
AnimationStateSet * mAnimationState
This is the main animation state.
The details of a topological BatchInstance which is the highest level of partitioning for this class...
const String & getMaterialName(void) const
Get the material name.
Camera * mCamera
Current camera, passed on to do material LOD later.
BatchInstance * mInstancedGeometryInstance
Summary class collecting together vertex source information.
Implementation of a Quaternion, i.e.
map< unsigned short, InstancedObject * >::type ObjectsMap
SkeletonInstance * mSkeletonInstance
map< size_t, size_t >::type IndexRemap
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
A 3x3 matrix which can represent rotations around axes.
vector< QueuedSubMesh * >::type QueuedSubMeshList
GeometryBucketList & getGeometryBucketList(void)
AxisAlignedBox worldBounds
Pre-transformed world AABB.
float Real
Software floating point type.
virtual void setBatchInstanceDimensions(const Vector3 &size)
Sets the size of a single BatchInstance of geometry.
map< String, GeometryBucket * >::type CurrentGeometryMap
~OptimisedSubMeshGeometry()
Class to manage the scene object rendering queue.
Summary class collecting together index data source information.
MapIterator< BatchInstanceMap > BatchInstanceIterator
Iterator for iterating over contained BatchInstances.
virtual bool getCastShadows(void)
Will the geometry from this object cast shadows?
const LodStrategy * mLodStrategy
LOD strategy reference.
Matrix4 * mBoneMatrices
Cached bone matrices in skeleton local space.
Vector3 mHalfBatchInstanceDimensions
virtual Real getRenderingDistance(void) const
Gets the distance at which batches are no longer rendered.
VertexData * mVertexData
Vertex information, includes current number of vertices committed to be a part of this bucket...
Class representing a node in the scene graph.
QueuedSubMeshList mQueuedSubMeshes
Mesh::LodValueList mLodValues
LOD values as built up - use the max at each level.
Technique * getCurrentTechnique(void) const
Get the current Technique.
A LODBucket is a collection of smaller buckets with the same LOD.
GeometryBucketList mGeometryBucketList
list of Geometry Buckets in this BatchInstance
const String & getName(void) const
Get the name of this object.
void setLastIndex(int index)
AxisAlignedBox mAABB
Local AABB relative to BatchInstance centre.
ushort mCurrentLod
The current LOD level, as determined from the last camera.
Defines a part of a complete mesh.
uint8 mRenderQueueID
The render queue to use when rendering this object.
SkeletonInstance * mSkeletonInstance
GeometryBucketList mGeometryBucketList
virtual void setRenderingDistance(Real dist)
Sets the distance at which batches are no longer rendered.
Class encapsulating a set of AnimationState objects.
virtual bool isVisible(void) const
Are the batches visible?
bool mProvideWorldInverses
Flags to indicate whether the World Transform Inverse matrices are passed to the shaders.
vector< GeometryBucket * >::type GeometryBucketList
list of Geometry Buckets that contains the instanced object
virtual void setOrigin(const Vector3 &origin)
Sets the origin of the geometry.
unsigned short mNumBoneMatrices
Class encapsulating a standard 4x4 homogeneous matrix.
SubMeshLodGeometryLinkList * geometryLodList
Link to LOD list of geometry, potentially optimised.
Standard 3-dimensional vector.
AnimationStateSet * mAnimationState
State of animation for animable meshes.
map< String, MaterialBucket * >::type MaterialBucketMap
Lookup of Material Buckets in this BatchInstance.
Pre-transforms and batches up meshes for efficient use as instanced geometry in a scene...
HardwareIndexBuffer::IndexType mIndexType
Size of indexes.
OptimisedSubMeshGeometryList mOptimisedSubMeshGeometryList
List of geometry which has been optimised for SubMesh use This is the primary storage used for cleani...
A MaterialBucket is a collection of smaller buckets with the same Material (and implicitly the same L...
std::map< K, V, P, A > type
A SkeletonInstance is a single instance of a Skeleton used by a world object.
Real getLodValue(void) const
Get the LOD value.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
BatchInstance * getParent(void)
RenderOperationVector mRenderOps
This vector stores all the renderOperation used in the batch.
vector< Real >::type LodValueList
MaterialBucket * getParent(void)
SubMeshLodGeometryLink * geometry
MaterialPtr mMaterial
Pointer to material being used.
SkeletonPtr getBaseSkeleton(void)
IndexData * mIndexData
Index information, includes index type which limits the max number of vertices which are allowed in o...
ushort getLod(void) const
Get the LOD index.
SkeletonInstance * getSkeletonInstance(void)
String mMaterialName
Material being used.
Structure recording a queued submesh for the build.
virtual const Vector3 & getBatchInstanceDimensions(void) const
Gets the size of a single batch of geometry.
VectorIterator< GeometryBucketList > GeometryIterator
Iterator over geometry.
SceneManager * mSceneMgr
Scene manager link.
static const Vector3 UNIT_SCALE
Struct holding geometry optimised per SubMesh / LOD level, ready for copying to instances.
LODBucket * getParent(void)
Transform is relative to the space of the parent node.
map< uint32, BatchInstance * >::type BatchInstanceMap
Indexed BatchInstance map based on packed x/y/z BatchInstance index, 10 bits for each axis...
InstancedGeometry * getParent(void) const
unsigned long mFrameAnimationLastUpdated
Records the last frame in which animation was updated.
A GeometryBucket is a the lowest level bucket where geometry with the same vertex & index format is s...
void remapIndexes(T *src, T *dst, const IndexRemap &remap, size_t numIndexes)
Method for altering indexes based on a remap.
bool mRenderQueueIDSet
Flags whether the RenderQueue's default should be used.
LODBucket * mParent
Pointer to parent LODBucket.
A viewpoint from which the scene will be rendered.
Real mLodValue
Current LOD value, passed on to do material LOD later.
uint32 mBatchInstanceID
Unique identifier for the BatchInstance.
BatchInstance * mParent
Pointer to parent BatchInstance.
vector< SubMeshLodGeometryLink >::type SubMeshLodGeometryLinkList
virtual const Vector3 & getOrigin(void) const
Gets the origin of this geometry.
BatchInstanceMap mBatchInstanceMap
Map of BatchInstances.
uint32 getID(void) const
Get the BatchInstance ID of this BatchInstance.
unsigned int mObjectCount
number of objects in the batch
Saved link between SubMesh at a LOD and vertex/index data May point to original or optimised geometry...
AxisAlignedBox & getAABB(void)
Return the BoundingBox information. Useful when cloning the batch instance.
SkeletonPtr mBaseSkeleton
this is just a pointer to the base skeleton that will be used for each animated object in the batches...
LODBucketList mLodBucketList
List of LOD buckets.
vector< RenderOperation * >::type RenderOperationVector
Simple vectors where are stored all the render operations of the Batch.
Structure recording a queued geometry for low level builds.
SceneNode * mNode
Scene node.
AnimationStateSet * getBaseAnimationState(void)
const VertexData * getVertexData(void) const
Get the vertex data for this geometry.
const IndexData * getIndexData(void) const
Get the index data for this geometry.
size_t mMaxVertexIndex
Maximum vertex indexable.
unsigned short mLod
LOD level (0 == full LOD)
Real mLodValue
LOD value at which this LOD starts to apply (squared)
QueuedGeometryList mQueuedGeometry
Geometry which has been queued up pre-build (not for deallocation)
CurrentGeometryMap mCurrentGeometryMap
SceneNode * getSceneNode(void)
VectorIterator< LODBucketList > LODIterator
SubMeshGeometryLookup mSubMeshGeometryLookup
Cached links from SubMeshes to (potentially optimised) geometry This is not used for deletion since t...
MaterialBucket * mParent
Pointer to parent bucket.
Class representing an approach to rendering this particular Material.
Defines an instance of a discrete, movable object based on a Mesh.
QueuedGeometryList mQueuedGeometryList
Geometry queued for a single LOD (deallocated here)
Represents the state of an animation and the weight of its influence.
virtual Real getSquaredRenderingDistance(void) const
Gets the squared distance at which batches are no longer rendered.
virtual bool getProvideWorldInverses(void) const
static const Quaternion IDENTITY
Real mSquaredUpperDistance
const MaterialPtr & getMaterial(void) const
Get the material for this bucket.
map< SubMesh *, SubMeshLodGeometryLinkList * >::type SubMeshGeometryLookup
vector< LODBucket * >::type LODBucketList
list of LOD Buckets in this BatchInstance
ObjectsMap & getInstancesMap(void)
MaterialBucketMap mMaterialBucketMap
Lookup of Material Buckets in this BatchInstance.
A 3D box aligned with the x/y/z axes.
Manages the organisation and rendering of a 'scene' i.e.
unsigned short mTexCoordIndex
Index of the Texcoord where the index is stored.
vector< String >::type QueuedSubMeshOriginList
MapIterator< ObjectsMap > InstancedObjectIterator
InstancedGeometry * mParent
Parent static geometry.
Simple implementation of MovableObject and Renderable for single-part custom objects.
QueuedSubMeshList mQueuedSubMeshes
Local list of queued meshes (not used for deallocation)
InstancedGeometry * mBatch
Pointer to the Batch.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
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...
Vector3 mBatchInstanceDimensions
Matrix4 * mBoneWorldMatrices
Cached bone matrices, including any world transform.
Wrapper class which indicates a given angle value is in Radians.