OGRE  2.0
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-2014 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 "OgreMovableObject.h"
35 #include "OgreQuaternion.h"
36 #include "OgreVector3.h"
38 #include "OgreRenderable.h"
40 #include "OgreSubEntity.h"
41 #include "OgreHeaderPrefix.h"
42 
43 namespace Ogre {
82  {
83  // Allow EntityFactory full access
84  friend class EntityFactory;
85  friend class SubEntity;
86  public:
87 
90 
91  protected:
92 
95  Entity( IdType id, ObjectMemoryManager *objectMemoryManager );
98  Entity( IdType id, ObjectMemoryManager *objectMemoryManager, const MeshPtr& mesh );
99 
103 
108 
109 
112 
113 
130 
134  const VertexData* findBlendedVertexData(const VertexData* orig);
138  SubEntity* findSubEntityForVertexData(const VertexData* orig);
139 
143  void extractTempBufferInfo(VertexData* sourceData, TempBlendedBufferInfo* info);
145  VertexData* cloneVertexDataRemoveBlendInfo(const VertexData* source);
147  void prepareTempBlendBuffers(void);
150  void markBuffersUnusedForAnimation(void);
154  void restoreBuffersForUnusedAnimation(bool hardwareAnimation);
155 
163  void bindMissingHardwarePoseBuffers(const VertexData* srcData,
164  VertexData* destData);
165 
169  void initialisePoseVertexData(const VertexData* srcData, VertexData* destData,
170  bool animateNormals);
171 
175  void finalisePoseNormals(const VertexData* srcData, VertexData* destData);
176 
181  unsigned short mNumBoneMatrices;
184 
186  void updateAnimation(void);
187 
191  unsigned long *mFrameBonesLastUpdated;
192 
198 
203  bool cacheBoneMatrices(void);
204 
211 
214 
229 
237 
241 
244 
247 
250 
252  void buildSubEntityList(MeshPtr& mesh, SubEntityList* sublist);
253 
255  void attachObjectImpl(MovableObject *pMovable, TagPoint *pAttachingPoint);
256 
258  void detachObjectImpl(MovableObject* pObject);
259 
261  void reevaluateVertexProcessing(void);
262 
269  bool calcVertexProcessing(void);
270 
272  void applyVertexAnimation(bool hardwareAnimation);
274  ushort initHardwareAnimationElements(VertexData* vdata, ushort numberOfElements, bool animateNormals);
276  bool tempVertexAnimBuffersBound(void) const;
278  bool tempSkelAnimBuffersBound(bool requestNormals) const;
279 
280  public:
283  ~Entity();
284 
287  const MeshPtr& getMesh(void) const;
288 
291  SubEntity* getSubEntity(size_t index);
292  const SubEntity* getSubEntity(size_t index) const;
293 
298  SubEntity* getSubEntity( const String& name );
299  const SubEntity* getSubEntity( const String& name ) const;
300 
303  size_t getNumSubEntities(void) const;
304 
314  Entity* clone(void) const;
315 
324  void setMaterialName( const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
325 
326 
335  void setMaterial(const MaterialPtr& material);
336 
339  void _notifyCurrentCamera(Camera* cam);
340 
342  void setRenderQueueGroup(uint8 queueID);
343 
345  void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority);
346 
349  void _updateRenderQueue(RenderQueue* queue, Camera *camera, const Camera *lodCamera);
350 
352  const String& getMovableType(void) const;
353 
360  AnimationState* getAnimationState(const String& name) const;
362  bool hasAnimationState(const String& name) const;
372  AnimationStateSet* getAllAnimationStates(void) const;
373 
376  void setDisplaySkeleton(bool display);
377 
380  bool getDisplaySkeleton(void) const;
381 
387  Entity* getManualLodLevel(size_t index) const;
388 
394  size_t getNumManualLodLevels(void) const;
395 
399  void setPolygonModeOverrideable(bool PolygonModeOverrideable);
419  TagPoint* attachObjectToBone(const String &boneName,
420  MovableObject *pMovable,
421  const Quaternion &offsetOrientation = Quaternion::IDENTITY,
422  const Vector3 &offsetPosition = Vector3::ZERO);
423 
429  MovableObject* detachObjectFromBone(const String &movableName);
430 
437  void detachObjectFromBone(MovableObject* obj);
438 
440  void detachAllObjectsFromBone(void);
441 
442 #ifdef ENABLE_INCOMPATIBLE_OGRE_2_0
443  typedef map<String, MovableObject*>::type ChildObjectList;
445  typedef MapIterator<ChildObjectList> ChildObjectListIterator;
447  ChildObjectListIterator getAttachedObjectIterator(void);
448 #endif
449 
450  EdgeData* getEdgeList(void);
452  bool hasEdgeList(void);
453 
455  const Matrix4* _getBoneMatrices(void) const { return mBoneMatrices;}
457  unsigned short _getNumBoneMatrices(void) const { return mNumBoneMatrices; }
459  bool hasSkeleton(void) const { return mSkeletonInstance != 0; }
461  OldSkeletonInstance* getSkeleton(void) const { return mSkeletonInstance; }
477  bool isHardwareAnimationEnabled(void);
478 
480  void _notifyAttached( Node* parent );
488  int getSoftwareAnimationRequests(void) const { return mSoftwareAnimationRequests; }
500  int getSoftwareAnimationNormalsRequests(void) const { return mSoftwareAnimationNormalsRequests; }
516  void addSoftwareAnimationRequest(bool normalsAlso);
525  void removeSoftwareAnimationRequest(bool normalsAlso);
526 
531  void shareSkeletonInstanceWith(Entity* entity);
532 
535  bool hasVertexAnimation(void) const;
536 
537 
540  void stopSharingSkeletonInstance();
541 
542 
545  inline bool sharesSkeletonInstance() const { return mSharedSkeletonEntities != NULL; }
546 
550  inline const EntitySet* getSkeletonInstanceSharingSet() const { return mSharedSkeletonEntities; }
551 
562  void refreshAvailableAnimationState(void);
563 
571  void _updateAnimation(void);
572 
578  bool _isAnimated(void) const;
579 
582  bool _isSkeletonAnimated(void) const;
583 
593  VertexData* _getSkelAnimVertexData(void) const;
602  VertexData* _getSoftwareVertexAnimVertexData(void) const;
607  VertexData* _getHardwareVertexAnimVertexData(void) const;
611  TempBlendedBufferInfo* _getSkelAnimTempBufferInfo(void);
615  TempBlendedBufferInfo* _getVertexAnimTempBufferInfo(void);
617  uint32 getTypeFlags(void) const;
619  VertexData* getVertexDataForBinding(void);
620 
623  {
627  BIND_HARDWARE_MORPH
628  };
630  VertexDataBindChoice chooseVertexDataForBinding(bool hasVertexAnim);
631 
633  bool _getBuffersMarkedForAnimation(void) const { return mVertexAnimationAppliedThisFrame; }
636  void _markBuffersUsedForAnimation(void);
637 
646  bool isInitialised(void) const { return mInitialised; }
647 
659  void _initialise(bool forceReinitialise = false);
661  void _deinitialise(void);
662 
664  void visitRenderables(Renderable::Visitor* visitor,
665  bool debugRenderables = false);
666 
670  void setSkipAnimationStateUpdate(bool skip) {
671  mSkipAnimStateUpdates = skip;
672  }
673 
678  return mSkipAnimStateUpdates;
679  }
680 
685  void setAlwaysUpdateMainSkeleton(bool update) {
686  mAlwaysUpdateMainSkeleton = update;
687  }
688 
694  return mAlwaysUpdateMainSkeleton;
695  }
696 
705  void setUpdateBoundingBoxFromSkeleton(bool update);
706 
712  return mUpdateBoundingBoxFromSkeleton;
713  }
714 
715 
716  };
717 
720  {
721  protected:
722  virtual MovableObject* createInstanceImpl( IdType id, ObjectMemoryManager *objectMemoryManager,
723  const NameValuePairList* params = 0 );
724  public:
727 
729 
730  const String& getType(void) const;
731  void destroyInstance( MovableObject* obj);
732 
733  };
737 } // namespace Ogre
738 
739 #include "OgreHeaderSuffix.h"
740 
741 #endif // __Entity_H__
Class encapsulating a set of AnimationState objects.
unsigned char uint8
Definition: OgrePlatform.h:422
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
LODEntityList mLodEntityList
Definition: OgreEntity.h:236
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
unsigned int uint32
Definition: OgrePlatform.h:420
#define _OgreExport
Definition: OgrePlatform.h:255
const EntitySet * getSkeletonInstanceSharingSet() const
Returns a pointer to the set of entities which share a OldSkeletonInstance.
Definition: OgreEntity.h:550
int mSoftwareAnimationNormalsRequests
Counter indicating number of requests for software blended normals.
Definition: OgreEntity.h:222
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:580
bool mVertexAnimationAppliedThisFrame
Have we applied any vertex animation to shared geometry?
Definition: OgreEntity.h:127
SubEntityList mSubEntityList
Definition: OgreEntity.h:107
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:213
bool isInitialised(void) const
Has this Entity been initialised yet?
Definition: OgreEntity.h:646
TempBlendedBufferInfo mTempVertexAnimInfo
Temp buffer details for software vertex anim of shared geometry.
Definition: OgreEntity.h:119
int getSoftwareAnimationNormalsRequests(void) const
Returns the number of requests that have been made for software animation of normals.
Definition: OgreEntity.h:500
VertexData * mHardwareVertexAnimVertexData
Vertex data details for hardware vertex anim of shared geometry.
Definition: OgreEntity.h:125
Matrix4 mLastParentXform
Last parent transform.
Definition: OgreEntity.h:246
bool mInitialised
Has this entity been initialised yet?
Definition: OgreEntity.h:243
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
static const Vector3 ZERO
Definition: OgreVector3.h:807
vector< Entity * >::type LODEntityList
List of LOD Entity instances (for manual LODs).
Definition: OgreEntity.h:235
int mSoftwareAnimationRequests
Counter indicating number of requests for software animation.
Definition: OgreEntity.h:220
bool mAlwaysUpdateMainSkeleton
Flag indicating whether to update the main entity skeleton even when an LOD is displayed.
Definition: OgreEntity.h:226
VertexDataBindChoice
Identify which vertex data we should be sending to the renderer.
Definition: OgreEntity.h:622
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:218
bool _getBuffersMarkedForAnimation(void) const
Are buffers already marked as vertex animated?
Definition: OgreEntity.h:633
EntitySet * mSharedSkeletonEntities
A set of all the entities which shares a single OldSkeletonInstance.
Definition: OgreEntity.h:197
int getSoftwareAnimationRequests(void) const
Returns the number of requests that have been made for software animation.
Definition: OgreEntity.h:488
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:210
Wrap-around class that contains multiple ArrayMemoryManager, one per render queue.
size_t mMeshStateCount
Mesh state count, used to detect differences.
Definition: OgreEntity.h:249
Abstract class defining a movable object in a scene.
bool mPreparedForShadowVolumes
Have the temp buffers already had their geometry prepared for use in rendering shadow volumes...
Definition: OgreEntity.h:129
std::set< T, P, A > type
Implementation of a Quaternion, i.e.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
bool sharesSkeletonInstance() const
Returns whether this entity shares it's SkeltonInstance with other entity instances.
Definition: OgreEntity.h:545
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:685
OldSkeletonInstance * getSkeleton(void) const
Get this Entity's personal skeleton instance.
Definition: OgreEntity.h:461
bool mUpdateBoundingBoxFromSkeleton
Flag indicating whether to update the bounding box from the bones of the skeleton.
Definition: OgreEntity.h:228
VertexData * mSkelAnimVertexData
Vertex data details for software skeletal anim of shared geometry.
Definition: OgreEntity.h:117
OldSkeletonInstance * mSkeletonInstance
This Entity's personal copy of the skeleton, if skeletally animated.
Definition: OgreEntity.h:240
static const Quaternion IDENTITY
map< unsigned short, bool >::type SchemeHardwareAnimMap
Definition: OgreEntity.h:89
bool mSkipAnimStateUpdates
Flag indicating whether to skip automatic updating of the Skeleton's AnimationState.
Definition: OgreEntity.h:224
static String FACTORY_TYPE_NAME
Definition: OgreEntity.h:728
Utility class which defines the sub-parts of an Entity.
Definition: OgreSubEntity.h:62
MeshPtr mMesh
The Mesh that this Entity is based on.
Definition: OgreEntity.h:102
Ogre::uint32 IdType
Big projects with lots, lots of units for very long periods of time (MMORPGs?) may want to define thi...
Definition: OgreId.h:36
vector< SubEntity >::type SubEntityList
List of SubEntities (point to SubMeshes).
Definition: OgreEntity.h:106
Defines an instance of a discrete, movable object based on a Mesh.
Definition: OgreEntity.h:81
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...
ushort mHardwarePoseCount
Number of hardware poses supported by materials.
Definition: OgreEntity.h:216
const Matrix4 * _getBoneMatrices(void) const
Internal method for retrieving bone matrix information.
Definition: OgreEntity.h:455
unsigned long * mFrameBonesLastUpdated
Records the last frame in which the bones was updated.
Definition: OgreEntity.h:191
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
std::map< K, V, P, A > type
unsigned short ushort
bool getSkipAnimationStateUpdate() const
Entity's skeleton's AnimationState will not be automatically updated when set to true.
Definition: OgreEntity.h:677
Summary class collecting together vertex source information.
TempBlendedBufferInfo mTempSkelAnimInfo
Temp buffer details for software skeletal anim of shared geometry.
Definition: OgreEntity.h:115
bool getAlwaysUpdateMainSkeleton() const
The skeleton of the main entity will be updated even if the an LOD entity is being displayed...
Definition: OgreEntity.h:693
Matrix4 * mBoneMatrices
Cached bone matrices in skeleton local space, might shares with other entity instances.
Definition: OgreEntity.h:180
Matrix4 * mBoneWorldMatrices
Cached bone matrices, including any world transform.
Definition: OgreEntity.h:178
Factory object for creating Entity instances.
Definition: OgreEntity.h:719
Class to manage the scene object rendering queue.
bool mDisplaySkeleton
Flag determines whether or not to display skeleton.
Definition: OgreEntity.h:206
This class contains the information required to describe the edge connectivity of a given set of vert...
VertexData * mSoftwareVertexAnimVertexData
Vertex data details for software vertex anim of shared geometry.
Definition: OgreEntity.h:121
void setSkipAnimationStateUpdate(bool skip)
Entity's skeleton's AnimationState will not be automatically updated when set to true.
Definition: OgreEntity.h:670
AnimationStateSet * mAnimationState
State of animation for animable meshes.
Definition: OgreEntity.h:111
_StringBase String
Definition: OgreCommon.h:53
A OldSkeletonInstance is a single instance of a Skeleton used by a world object.
unsigned long mFrameAnimationLastUpdated
Records the last frame in which animation was updated.
Definition: OgreEntity.h:183
bool hasSkeleton(void) const
Returns whether or not this entity is skeletally animated.
Definition: OgreEntity.h:459
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:58
unsigned short _getNumBoneMatrices(void) const
Internal method for retrieving bone matrix information.
Definition: OgreEntity.h:457
set< Entity * >::type EntitySet
Definition: OgreEntity.h:88
bool getUpdateBoundingBoxFromSkeleton() const
If true, the skeleton of the entity will be used to update the bounding box for culling.
Definition: OgreEntity.h:711
unsigned short mNumBoneMatrices
Definition: OgreEntity.h:181