OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreEntity.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __Entity_H__
29 #define __Entity_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreCommon.h"
33 
34 #include "OgreString.h"
35 #include "OgreMovableObject.h"
36 #include "OgreQuaternion.h"
37 #include "OgreVector3.h"
39 #include "OgreMesh.h"
40 #include "OgreRenderable.h"
42 #include "OgreHeaderPrefix.h"
43 
44 namespace Ogre {
83  {
84  // Allow EntityFactory full access
85  friend class EntityFactory;
86  friend class SubEntity;
87  public:
88 
91 
92  protected:
93 
96  Entity();
99  Entity( const String& name, const MeshPtr& mesh);
100 
104 
109 
110 
113 
114 
131 
134  const VertexData* findBlendedVertexData(const VertexData* orig);
137  SubEntity* findSubEntityForVertexData(const VertexData* orig);
138 
141  void extractTempBufferInfo(VertexData* sourceData, TempBlendedBufferInfo* info);
143  VertexData* cloneVertexDataRemoveBlendInfo(const VertexData* source);
145  void prepareTempBlendBuffers(void);
148  void markBuffersUnusedForAnimation(void);
152  void restoreBuffersForUnusedAnimation(bool hardwareAnimation);
153 
159  void bindMissingHardwarePoseBuffers(const VertexData* srcData,
160  VertexData* destData);
161 
165  void initialisePoseVertexData(const VertexData* srcData, VertexData* destData,
166  bool animateNormals);
167 
171  void finalisePoseNormals(const VertexData* srcData, VertexData* destData);
172 
177  unsigned short mNumBoneMatrices;
180 
182  void updateAnimation(void);
183 
187  unsigned long *mFrameBonesLastUpdated;
188 
195 
201  bool cacheBoneMatrices(void);
202 
210 
213 
226 
227 
230 
237 
246 
254 
258 
261 
264 
267 
269  void buildSubEntityList(MeshPtr& mesh, SubEntityList* sublist);
270 
272  void attachObjectImpl(MovableObject *pMovable, TagPoint *pAttachingPoint);
273 
275  void detachObjectImpl(MovableObject* pObject);
276 
278  void detachAllObjectsImpl(void);
279 
281  void reevaluateVertexProcessing(void);
282 
289  bool calcVertexProcessing(void);
290 
292  void applyVertexAnimation(bool hardwareAnimation, bool stencilShadows);
294  ushort initHardwareAnimationElements(VertexData* vdata,
295  ushort numberOfElements, bool animateNormals);
297  bool tempVertexAnimBuffersBound(void) const;
299  bool tempSkelAnimBuffersBound(bool requestNormals) const;
300 
301  public:
304  protected:
306 
307 
310 
312 
315  {
316  protected:
328 
329 
330  public:
332  HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData,
333  bool createSeparateLightCap, SubEntity* subent, bool isLightCap = false);
335 
337  void _createSeparateLightCap();
339  void getWorldTransforms(Matrix4* xform) const;
340  HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; }
341  HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; }
343  void rebindPositionBuffer(const VertexData* vertexData, bool force);
345  bool isVisible(void) const;
347  virtual void rebindIndexBuffer(const HardwareIndexBufferSharedPtr& indexBuffer);
348  };
349  public:
352  ~Entity();
353 
356  const MeshPtr& getMesh(void) const;
357 
360  SubEntity* getSubEntity(unsigned int index) const;
361 
365  SubEntity* getSubEntity( const String& name ) const;
366 
369  unsigned int getNumSubEntities(void) const;
370 
380  Entity* clone( const String& newName ) const;
381 
390  void setMaterialName( const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
391 
392 
401  void setMaterial(const MaterialPtr& material);
402 
405  void _notifyCurrentCamera(Camera* cam);
406 
408  void setRenderQueueGroup(uint8 queueID);
409 
411  void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority);
412 
415  const AxisAlignedBox& getBoundingBox(void) const;
416 
418  AxisAlignedBox getChildObjectsBoundingBox(void) const;
419 
422  void _updateRenderQueue(RenderQueue* queue);
423 
425  const String& getMovableType(void) const;
426 
433  AnimationState* getAnimationState(const String& name) const;
435  bool hasAnimationState(const String& name) const;
445  AnimationStateSet* getAllAnimationStates(void) const;
446 
449  void setDisplaySkeleton(bool display);
450 
453  bool getDisplaySkeleton(void) const;
454 
455 
461  Entity* getManualLodLevel(size_t index) const;
462 
468  size_t getNumManualLodLevels(void) const;
469 
472  ushort getCurrentLodIndex() { return mMeshLodIndex; }
473 
500  void setMeshLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99);
501 
528  void setMaterialLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99);
529 
533  void setPolygonModeOverrideable(bool PolygonModeOverrideable);
548  TagPoint* attachObjectToBone(const String &boneName,
549  MovableObject *pMovable,
550  const Quaternion &offsetOrientation = Quaternion::IDENTITY,
551  const Vector3 &offsetPosition = Vector3::ZERO);
552 
557  MovableObject* detachObjectFromBone(const String &movableName);
558 
565  void detachObjectFromBone(MovableObject* obj);
566 
568  void detachAllObjectsFromBone(void);
569 
572  ChildObjectListIterator getAttachedObjectIterator(void);
574  Real getBoundingRadius(void) const;
575 
577  const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
579  const Sphere& getWorldBoundingSphere(bool derive = false) const;
580 
582  EdgeData* getEdgeList(void);
584  bool hasEdgeList(void);
586  ShadowRenderableListIterator getShadowVolumeRenderableIterator(
587  ShadowTechnique shadowTechnique, const Light* light,
588  HardwareIndexBufferSharedPtr* indexBuffer,
589  bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 );
590 
592  const Matrix4* _getBoneMatrices(void) const { return mBoneMatrices;}
594  unsigned short _getNumBoneMatrices(void) const { return mNumBoneMatrices; }
596  bool hasSkeleton(void) const { return mSkeletonInstance != 0; }
598  SkeletonInstance* getSkeleton(void) const { return mSkeletonInstance; }
614  bool isHardwareAnimationEnabled(void);
615 
617  void _notifyAttached(Node* parent, bool isTagPoint = false);
625  int getSoftwareAnimationRequests(void) const { return mSoftwareAnimationRequests; }
637  int getSoftwareAnimationNormalsRequests(void) const { return mSoftwareAnimationNormalsRequests; }
653  void addSoftwareAnimationRequest(bool normalsAlso);
662  void removeSoftwareAnimationRequest(bool normalsAlso);
663 
668  void shareSkeletonInstanceWith(Entity* entity);
669 
672  bool hasVertexAnimation(void) const;
673 
674 
677  void stopSharingSkeletonInstance();
678 
679 
683  inline bool sharesSkeletonInstance() const { return mSharedSkeletonEntities != NULL; }
684 
689  inline const EntitySet* getSkeletonInstanceSharingSet() const { return mSharedSkeletonEntities; }
690 
701  void refreshAvailableAnimationState(void);
702 
710  void _updateAnimation(void);
711 
717  bool _isAnimated(void) const;
718 
721  bool _isSkeletonAnimated(void) const;
722 
732  VertexData* _getSkelAnimVertexData(void) const;
741  VertexData* _getSoftwareVertexAnimVertexData(void) const;
746  VertexData* _getHardwareVertexAnimVertexData(void) const;
750  TempBlendedBufferInfo* _getSkelAnimTempBufferInfo(void);
754  TempBlendedBufferInfo* _getVertexAnimTempBufferInfo(void);
756  uint32 getTypeFlags(void) const;
758  VertexData* getVertexDataForBinding(void);
759 
762  {
766  BIND_HARDWARE_MORPH
767  };
769  VertexDataBindChoice chooseVertexDataForBinding(bool hasVertexAnim);
770 
772  bool _getBuffersMarkedForAnimation(void) const { return mVertexAnimationAppliedThisFrame; }
775  void _markBuffersUsedForAnimation(void);
776 
785  bool isInitialised(void) const { return mInitialised; }
786 
797  void _initialise(bool forceReinitialise = false);
799  void _deinitialise(void);
800 
804  void backgroundLoadingComplete(Resource* res);
805 
807  void visitRenderables(Renderable::Visitor* visitor,
808  bool debugRenderables = false);
809 
811  Real _getMeshLodFactorTransformed() const;
812 
816  void setSkipAnimationStateUpdate(bool skip) {
817  mSkipAnimStateUpdates = skip;
818  }
819 
824  return mSkipAnimStateUpdates;
825  }
826 
827 
832  void setAlwaysUpdateMainSkeleton(bool update) {
833  mAlwaysUpdateMainSkeleton = update;
834  }
835 
841  return mAlwaysUpdateMainSkeleton;
842  }
843 
844 
845  };
846 
849  {
850  protected:
851  MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
852  public:
855 
857 
858  const String& getType(void) const;
859  void destroyInstance( MovableObject* obj);
860 
861  };
865 } // namespace
866 
867 #include "OgreHeaderSuffix.h"
868 
869 #endif
Class encapsulating a set of AnimationState objects.
unsigned char uint8
Definition: OgrePlatform.h:272
HardwareVertexBufferSharedPtr getPositionBuffer(void)
Definition: OgreEntity.h:340
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
vector< SubEntity * >::type SubEntityList
List of SubEntities (point to SubMeshes).
Definition: OgreEntity.h:107
LODEntityList mLodEntityList
Definition: OgreEntity.h:253
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:270
#define _OgreExport
Definition: OgrePlatform.h:233
const EntitySet * getSkeletonInstanceSharingSet() const
Returns a pointer to the set of entities which share a SkeletonInstance.
Definition: OgreEntity.h:689
ushort getCurrentLodIndex()
Returns the current LOD used to render.
Definition: OgreEntity.h:472
int mSoftwareAnimationNormalsRequests
Counter indicating number of requests for software blended normals.
Definition: OgreEntity.h:221
ushort mMinMeshLodIndex
Index of minimum detail LOD (NB higher index is lower detail)
Definition: OgreEntity.h:234
SkeletonInstance * getSkeleton(void) const
Get this Entity's personal skeleton instance.
Definition: OgreEntity.h:598
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:553
bool mVertexAnimationAppliedThisFrame
Have we applied any vertex animation to shared geometry?
Definition: OgreEntity.h:128
SubEntityList mSubEntityList
Definition: OgreEntity.h:108
Structure for recording the use of temporary blend buffers.
bool mCurrentHWAnimationState
Current state of the hardware animation as represented by the entities parameters.
Definition: OgreEntity.h:212
bool isInitialised(void) const
Has this Entity been initialised yet?
Definition: OgreEntity.h:785
TempBlendedBufferInfo mTempVertexAnimInfo
Temp buffer details for software vertex anim of shared geometry.
Definition: OgreEntity.h:120
int getSoftwareAnimationNormalsRequests(void) const
Returns the number of requests that have been made for software animation of normals.
Definition: OgreEntity.h:637
VertexData * mHardwareVertexAnimVertexData
Vertex data details for hardware vertex anim of shared geometry.
Definition: OgreEntity.h:126
Matrix4 mLastParentXform
Last parent transform.
Definition: OgreEntity.h:263
HardwareVertexBufferSharedPtr getWBuffer(void)
Definition: OgreEntity.h:341
bool mInitialised
Has this entity been initialised yet?
Definition: OgreEntity.h:260
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
map< String, MovableObject * >::type ChildObjectList
Contains the child objects (attached to bones) indexed by name.
Definition: OgreEntity.h:303
static const Vector3 ZERO
Definition: OgreVector3.h:796
vector< Entity * >::type LODEntityList
List of LOD Entity instances (for manual LODs).
Definition: OgreEntity.h:252
Shared pointer implementation used to share index buffers.
int mSoftwareAnimationRequests
Counter indicating number of requests for software animation.
Definition: OgreEntity.h:219
A 3D box aligned with the x/y/z axes.
bool mAlwaysUpdateMainSkeleton
Flag indicating whether to update the main entity skeleton even when an LOD is displayed.
Definition: OgreEntity.h:225
VertexDataBindChoice
Identify which vertex data we should be sending to the renderer.
Definition: OgreEntity.h:761
Represents the state of an animation and the weight of its influence.
bool mVertexProgramInUse
Flag indicating whether we have a vertex program in use on any of our subentities.
Definition: OgreEntity.h:217
bool _getBuffersMarkedForAnimation(void) const
Are buffers already marked as vertex animated?
Definition: OgreEntity.h:772
ChildObjectList mChildObjectList
Definition: OgreEntity.h:305
EntitySet * mSharedSkeletonEntities
A set of all the entities which shares a single SkeletonInstance.
Definition: OgreEntity.h:194
int getSoftwareAnimationRequests(void) const
Returns the number of requests that have been made for software animation.
Definition: OgreEntity.h:625
Interface definition for a factory class which produces a certain kind of MovableObject, and can be registered with Root in order to allow all clients to produce new instances of this object, integrated with the standard Ogre processing.
SchemeHardwareAnimMap mSchemeHardwareAnim
Flag indicating whether hardware animation is supported by this entities materials data is saved per ...
Definition: OgreEntity.h:209
size_t mMeshStateCount
Mesh state count, used to detect differences.
Definition: OgreEntity.h:266
Abstract class defining a movable object in a scene.
MapIterator< ChildObjectList > ChildObjectListIterator
Definition: OgreEntity.h:570
bool mPreparedForShadowVolumes
Have the temp buffers already had their geometry prepared for use in rendering shadow volumes...
Definition: OgreEntity.h:130
std::set< T, P, A > type
Implementation of a Quaternion, i.e.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
unsigned short mOriginalPosBufferBinding
Original position buffer source binding.
Definition: OgreEntity.h:325
bool sharesSkeletonInstance() const
Returns whether this entity shares it's SkeltonInstance with other entity instances.
Definition: OgreEntity.h:683
void setAlwaysUpdateMainSkeleton(bool update)
The skeleton of the main entity will be updated even if the an LOD entity is being displayed...
Definition: OgreEntity.h:832
Shared pointer implementation used to share index buffers.
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:73
VertexData * mSkelAnimVertexData
Vertex data details for software skeletal anim of shared geometry.
Definition: OgreEntity.h:118
static const Quaternion IDENTITY
ShadowTechnique
An enumeration of broad shadow techniques.
Definition: OgreCommon.h:193
map< unsigned short, bool >::type SchemeHardwareAnimMap
Definition: OgreEntity.h:90
bool mSkipAnimStateUpdates
Flag indicating whether to skip automatic updating of the Skeleton's AnimationState.
Definition: OgreEntity.h:223
Real mMeshLodFactorTransformed
LOD bias factor, transformed for optimisation when calculating adjusted lod value.
Definition: OgreEntity.h:232
static String FACTORY_TYPE_NAME
Definition: OgreEntity.h:856
Utility class which defines the sub-parts of an Entity.
Definition: OgreSubEntity.h:63
MeshPtr mMesh
The Mesh that this Entity is based on.
Definition: OgreEntity.h:103
const VertexData * mCurrentVertexData
Link to current vertex data used to bind (maybe changes)
Definition: OgreEntity.h:323
AxisAlignedBox mFullBoundingBox
Bounding box that 'contains' all the mesh of each child entity.
Definition: OgreEntity.h:309
ushort mMaxMaterialLodIndex
Index of maximum detail LOD (NB lower index is higher detail)
Definition: OgreEntity.h:245
Class which represents the renderable aspects of a set of shadow volume faces.
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
Defines an instance of a discrete, movable object based on a Mesh.
Definition: OgreEntity.h:82
Nested class to allow entity shadows.
Definition: OgreEntity.h:314
A tagged point on a skeleton, which can be used to attach entities to on specific other entities...
Definition: OgreTagPoint.h:60
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Real mMaterialLodFactorTransformed
LOD bias factor, transformed for optimisation when calculating adjusted lod value.
Definition: OgreEntity.h:241
ushort mHardwarePoseCount
Number of hardware poses supported by materials.
Definition: OgreEntity.h:215
const Matrix4 * _getBoneMatrices(void) const
Internal method for retrieving bone matrix information.
Definition: OgreEntity.h:592
unsigned long * mFrameBonesLastUpdated
Records the last frame in which the bones was updated It's a pointer because it can be shared between...
Definition: OgreEntity.h:187
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
unsigned short ushort
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:78
bool getSkipAnimationStateUpdate() const
Entity's skeleton's AnimationState will not be automatically updated when set to true.
Definition: OgreEntity.h:823
ushort mMaxMeshLodIndex
Index of maximum detail LOD (NB lower index is higher detail)
Definition: OgreEntity.h:236
Summary class collecting together vertex source information.
TempBlendedBufferInfo mTempSkelAnimInfo
Temp buffer details for software skeletal anim of shared geometry.
Definition: OgreEntity.h:116
bool getAlwaysUpdateMainSkeleton() const
The skeleton of the main entity will be updated even if the an LOD entity is being displayed...
Definition: OgreEntity.h:840
Matrix4 * mBoneMatrices
Cached bone matrices in skeleton local space, might shares with other entity instances.
Definition: OgreEntity.h:176
Matrix4 * mBoneWorldMatrices
Cached bone matrices, including any world transform.
Definition: OgreEntity.h:174
Real mMaterialLodFactor
LOD bias factor, not transformed.
Definition: OgreEntity.h:239
ShadowRenderableList mShadowRenderables
Definition: OgreEntity.h:311
Factory object for creating Entity instances.
Definition: OgreEntity.h:848
Class to manage the scene object rendering queue.
bool mDisplaySkeleton
Flag determines whether or not to display skeleton.
Definition: OgreEntity.h:204
This class contains the information required to describe the edge connectivity of a given set of vert...
HardwareVertexBufferSharedPtr mPositionBuffer
Shared link to position buffer.
Definition: OgreEntity.h:319
VertexData * mSoftwareVertexAnimVertexData
Vertex data details for software vertex anim of shared geometry.
Definition: OgreEntity.h:122
ushort mMeshLodIndex
The LOD number of the mesh to use, calculated by _notifyCurrentCamera.
Definition: OgreEntity.h:229
void setSkipAnimationStateUpdate(bool skip)
Entity's skeleton's AnimationState will not be automatically updated when set to true.
Definition: OgreEntity.h:816
AnimationStateSet * mAnimationState
State of animation for animable meshes.
Definition: OgreEntity.h:112
_StringBase String
SkeletonInstance * mSkeletonInstance
This Entity's personal copy of the skeleton, if skeletally animated.
Definition: OgreEntity.h:257
Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr.
Definition: OgreMaterial.h:688
unsigned long mFrameAnimationLastUpdated
Records the last frame in which animation was updated.
Definition: OgreEntity.h:179
Concrete IteratorWrapper for nonconst access to the underlying container.
Specialisation of SharedPtr to allow SharedPtr to be assigned to MeshPtr.
Definition: OgreMesh.h:875
SubEntity * mSubEntity
Link to SubEntity, only present if SubEntity has it's own geometry.
Definition: OgreEntity.h:327
bool hasSkeleton(void) const
Returns whether or not this entity is skeletally animated.
Definition: OgreEntity.h:596
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:63
unsigned short _getNumBoneMatrices(void) const
Internal method for retrieving bone matrix information.
Definition: OgreEntity.h:594
A SkeletonInstance is a single instance of a Skeleton used by a world object.
ushort mMinMaterialLodIndex
Index of minimum detail LOD (NB higher index is lower detail)
Definition: OgreEntity.h:243
HardwareVertexBufferSharedPtr mWBuffer
Shared link to w-coord buffer (optional)
Definition: OgreEntity.h:321
set< Entity * >::type EntitySet
Definition: OgreEntity.h:89
vector< ShadowRenderable * >::type ShadowRenderableList
unsigned short mNumBoneMatrices
Definition: OgreEntity.h:177