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 
135  const VertexData* findBlendedVertexData(const VertexData* orig);
139  SubEntity* findSubEntityForVertexData(const VertexData* orig);
140 
144  void extractTempBufferInfo(VertexData* sourceData, TempBlendedBufferInfo* info);
146  VertexData* cloneVertexDataRemoveBlendInfo(const VertexData* source);
148  void prepareTempBlendBuffers(void);
151  void markBuffersUnusedForAnimation(void);
155  void restoreBuffersForUnusedAnimation(bool hardwareAnimation);
156 
164  void bindMissingHardwarePoseBuffers(const VertexData* srcData,
165  VertexData* destData);
166 
170  void initialisePoseVertexData(const VertexData* srcData, VertexData* destData,
171  bool animateNormals);
172 
176  void finalisePoseNormals(const VertexData* srcData, VertexData* destData);
177 
182  unsigned short mNumBoneMatrices;
185 
187  void updateAnimation(void);
188 
192  unsigned long *mFrameBonesLastUpdated;
193 
199 
204  bool cacheBoneMatrices(void);
205 
212 
215 
228 
229 
232 
239 
248 
256 
260 
263 
266 
269 
271  void buildSubEntityList(MeshPtr& mesh, SubEntityList* sublist);
272 
274  void attachObjectImpl(MovableObject *pMovable, TagPoint *pAttachingPoint);
275 
277  void detachObjectImpl(MovableObject* pObject);
278 
280  void detachAllObjectsImpl(void);
281 
283  void reevaluateVertexProcessing(void);
284 
291  bool calcVertexProcessing(void);
292 
294  void applyVertexAnimation(bool hardwareAnimation, bool stencilShadows);
296  ushort initHardwareAnimationElements(VertexData* vdata, ushort numberOfElements, bool animateNormals);
298  bool tempVertexAnimBuffersBound(void) const;
300  bool tempSkelAnimBuffersBound(bool requestNormals) const;
301 
302  public:
305  protected:
307 
308 
311 
313 
316  {
317  protected:
329 
330 
331  public:
333  HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData,
334  bool createSeparateLightCap, SubEntity* subent, bool isLightCap = false);
336 
338  void _createSeparateLightCap();
340  void getWorldTransforms(Matrix4* xform) const;
341  HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; }
342  HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; }
344  void rebindPositionBuffer(const VertexData* vertexData, bool force);
346  bool isVisible(void) const;
348  virtual void rebindIndexBuffer(const HardwareIndexBufferSharedPtr& indexBuffer);
349  };
350  public:
353  ~Entity();
354 
357  const MeshPtr& getMesh(void) const;
358 
361  SubEntity* getSubEntity(unsigned int index) const;
362 
367  SubEntity* getSubEntity( const String& name ) const;
368 
371  unsigned int getNumSubEntities(void) const;
372 
382  Entity* clone( const String& newName ) const;
383 
392  void setMaterialName( const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
393 
394 
403  void setMaterial(const MaterialPtr& material);
404 
407  void _notifyCurrentCamera(Camera* cam);
408 
410  void setRenderQueueGroup(uint8 queueID);
411 
413  void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority);
414 
417  const AxisAlignedBox& getBoundingBox(void) const;
418 
420  AxisAlignedBox getChildObjectsBoundingBox(void) const;
421 
424  void _updateRenderQueue(RenderQueue* queue);
425 
427  const String& getMovableType(void) const;
428 
435  AnimationState* getAnimationState(const String& name) const;
437  bool hasAnimationState(const String& name) const;
447  AnimationStateSet* getAllAnimationStates(void) const;
448 
451  void setDisplaySkeleton(bool display);
452 
455  bool getDisplaySkeleton(void) const;
456 
457 
463  Entity* getManualLodLevel(size_t index) const;
464 
470  size_t getNumManualLodLevels(void) const;
471 
474  ushort getCurrentLodIndex() { return mMeshLodIndex; }
475 
505  void setMeshLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99);
506 
536  void setMaterialLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99);
537 
541  void setPolygonModeOverrideable(bool PolygonModeOverrideable);
561  TagPoint* attachObjectToBone(const String &boneName,
562  MovableObject *pMovable,
563  const Quaternion &offsetOrientation = Quaternion::IDENTITY,
564  const Vector3 &offsetPosition = Vector3::ZERO);
565 
571  MovableObject* detachObjectFromBone(const String &movableName);
572 
579  void detachObjectFromBone(MovableObject* obj);
580 
582  void detachAllObjectsFromBone(void);
583 
586  ChildObjectListIterator getAttachedObjectIterator(void);
588  Real getBoundingRadius(void) const;
589 
591  const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
593  const Sphere& getWorldBoundingSphere(bool derive = false) const;
594 
596  EdgeData* getEdgeList(void);
598  bool hasEdgeList(void);
600  ShadowRenderableListIterator getShadowVolumeRenderableIterator(
601  ShadowTechnique shadowTechnique, const Light* light,
602  HardwareIndexBufferSharedPtr* indexBuffer, size_t* indexBufferUsedSize,
603  bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 );
604 
606  const Matrix4* _getBoneMatrices(void) const { return mBoneMatrices;}
608  unsigned short _getNumBoneMatrices(void) const { return mNumBoneMatrices; }
610  bool hasSkeleton(void) const { return mSkeletonInstance != 0; }
612  SkeletonInstance* getSkeleton(void) const { return mSkeletonInstance; }
628  bool isHardwareAnimationEnabled(void);
629 
631  void _notifyAttached(Node* parent, bool isTagPoint = false);
639  int getSoftwareAnimationRequests(void) const { return mSoftwareAnimationRequests; }
651  int getSoftwareAnimationNormalsRequests(void) const { return mSoftwareAnimationNormalsRequests; }
667  void addSoftwareAnimationRequest(bool normalsAlso);
676  void removeSoftwareAnimationRequest(bool normalsAlso);
677 
682  void shareSkeletonInstanceWith(Entity* entity);
683 
686  bool hasVertexAnimation(void) const;
687 
688 
691  void stopSharingSkeletonInstance();
692 
693 
696  inline bool sharesSkeletonInstance() const { return mSharedSkeletonEntities != NULL; }
697 
701  inline const EntitySet* getSkeletonInstanceSharingSet() const { return mSharedSkeletonEntities; }
702 
713  void refreshAvailableAnimationState(void);
714 
722  void _updateAnimation(void);
723 
729  bool _isAnimated(void) const;
730 
733  bool _isSkeletonAnimated(void) const;
734 
744  VertexData* _getSkelAnimVertexData(void) const;
753  VertexData* _getSoftwareVertexAnimVertexData(void) const;
758  VertexData* _getHardwareVertexAnimVertexData(void) const;
762  TempBlendedBufferInfo* _getSkelAnimTempBufferInfo(void);
766  TempBlendedBufferInfo* _getVertexAnimTempBufferInfo(void);
768  uint32 getTypeFlags(void) const;
770  VertexData* getVertexDataForBinding(void);
771 
774  {
778  BIND_HARDWARE_MORPH
779  };
781  VertexDataBindChoice chooseVertexDataForBinding(bool hasVertexAnim);
782 
784  bool _getBuffersMarkedForAnimation(void) const { return mVertexAnimationAppliedThisFrame; }
787  void _markBuffersUsedForAnimation(void);
788 
797  bool isInitialised(void) const { return mInitialised; }
798 
810  void _initialise(bool forceReinitialise = false);
812  void _deinitialise(void);
813 
817  void backgroundLoadingComplete(Resource* res);
818 
820  void visitRenderables(Renderable::Visitor* visitor,
821  bool debugRenderables = false);
822 
824  Real _getMeshLodFactorTransformed() const;
825 
829  void setSkipAnimationStateUpdate(bool skip) {
830  mSkipAnimStateUpdates = skip;
831  }
832 
837  return mSkipAnimStateUpdates;
838  }
839 
844  void setAlwaysUpdateMainSkeleton(bool update) {
845  mAlwaysUpdateMainSkeleton = update;
846  }
847 
853  return mAlwaysUpdateMainSkeleton;
854  }
855 
856 
857  };
858 
861  {
862  protected:
863  MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
864  public:
867 
869 
870  const String& getType(void) const;
871  void destroyInstance( MovableObject* obj);
872 
873  };
877 } // namespace Ogre
878 
879 #include "OgreHeaderSuffix.h"
880 
881 #endif // __Entity_H__

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 16 2013 14:35:42