Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreEntity.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://ogre.sourceforge.net/
00006 
00007 Copyright (c) 2000-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __Entity_H__
00026 #define __Entity_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 #include "OgreCommon.h"
00030 
00031 #include "OgreString.h"
00032 #include "OgreMovableObject.h"
00033 #include "OgreAnimationState.h"
00034 #include "OgreQuaternion.h"
00035 #include "OgreVector3.h"
00036 #include "OgreHardwareBufferManager.h"
00037 #include "OgreMesh.h"
00038 
00039 namespace Ogre {
00071     class _OgreExport Entity: public MovableObject
00072     {
00073         // Allow SceneManager full access
00074         friend class SceneManager;
00075         friend class SubEntity;
00076     public:
00077     typedef std::set<Entity*> EntitySet;
00078     
00079     protected:
00080 
00083         Entity();
00086         Entity( const String& name, MeshPtr& mesh, SceneManager* creator);
00087 
00090         String mName;
00091 
00094         MeshPtr mMesh;
00095 
00098         typedef std::vector<SubEntity*> SubEntityList;
00099         SubEntityList mSubEntityList;
00100 
00104         SceneManager* mCreatorSceneManager;
00105 
00106 
00108         AnimationStateSet* mAnimationState;
00109 
00111         static String msMovableType;
00112 
00113 
00115         TempBlendedBufferInfo mTempBlendedBuffer;
00117         VertexData* mSharedBlendedVertexData;
00118 
00121         const VertexData* findBlendedVertexData(const VertexData* orig);
00124         SubEntity* findSubEntityForVertexData(const VertexData* orig);
00125 
00128         void extractTempBufferInfo(VertexData* sourceData, TempBlendedBufferInfo* info);
00130         VertexData* cloneVertexDataRemoveBlendInfo(const VertexData* source);
00132         void prepareTempBlendBuffers(void);
00133 
00135         Matrix4 *mBoneMatrices;
00136         unsigned short mNumBoneMatrices;
00138         unsigned long mFrameAnimationLastUpdated;
00139 
00141         void updateAnimation(void);
00142 
00146         unsigned long *mFrameBonesLastUpdated;
00147 
00153         EntitySet* mSharedSkeletonEntities;
00154         
00156         void cacheBoneMatrices(void);
00157 
00159         bool mDisplaySkeleton;
00161         bool mHardwareSkinning;
00163         int mSoftwareSkinningRequests;
00165         int mSoftwareSkinningNormalsRequests;
00167         bool mVertexProgramInUse;
00168 
00169 
00171         ushort mMeshLodIndex;
00172 
00174         Real mMeshLodFactorInv;
00176         ushort mMinMeshLodIndex;
00178         ushort mMaxMeshLodIndex;
00179 
00181         Real mMaterialLodFactorInv;
00183         ushort mMinMaterialLodIndex;
00185         ushort mMaxMaterialLodIndex;
00186 
00188         bool mUsingManualLOD;
00194         typedef std::vector<Entity*> LODEntityList;
00195         LODEntityList mLodEntityList;
00196 
00199         SkeletonInstance* mSkeletonInstance;
00200 
00202         void buildSubEntityList(MeshPtr& mesh, SubEntityList* sublist);
00203 
00205         void attachObjectImpl(MovableObject *pMovable, TagPoint *pAttachingPoint);
00206 
00208         void detachObjectImpl(MovableObject* pObject);
00209 
00211         void detachAllObjectsImpl(void);
00212 
00214         void reevaluateVertexProcessing(void);
00215 
00216     public:
00218         typedef std::map<String, MovableObject*> ChildObjectList;
00219     protected:
00220         ChildObjectList mChildObjectList;
00221 
00222 
00224         AxisAlignedBox *mFullBoundingBox;
00225 
00226         bool mNormaliseNormals;
00227 
00228         ShadowRenderableList mShadowRenderables;
00229 
00231         class _OgreExport EntityShadowRenderable : public ShadowRenderable
00232         {
00233         protected:
00234             Entity* mParent;
00235             // Shared link to position buffer
00236             HardwareVertexBufferSharedPtr mPositionBuffer;
00237             // Shared link to w-coord buffer (optional)
00238             HardwareVertexBufferSharedPtr mWBuffer;
00239             // Link to original vertex data
00240             const VertexData* mOriginalVertexData;
00241             // Original position buffer source binding
00242             unsigned short mOriginalPosBufferBinding;
00244             SubEntity* mSubEntity;
00245 
00246 
00247         public:
00248             EntityShadowRenderable(Entity* parent, 
00249                 HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData, 
00250                 bool createSeparateLightCap, SubEntity* subent, bool isLightCap = false);
00251             ~EntityShadowRenderable();
00253             void getWorldTransforms(Matrix4* xform) const;
00255             const Quaternion& getWorldOrientation(void) const;
00257             const Vector3& getWorldPosition(void) const;
00258             HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; }
00259             HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; }
00261             void rebindPositionBuffer(void);
00263             bool isVisible(void) const;
00264 
00265         };
00266     public:
00269         ~Entity();
00270 
00273         MeshPtr& getMesh(void);
00274 
00277         SubEntity* getSubEntity(unsigned int index);
00278     
00282         SubEntity* getSubEntity( const String& name );
00283 
00286         unsigned int getNumSubEntities(void) const;
00287 
00297         Entity* clone( const String& newName );
00298 
00307         void setMaterialName(const String& name);
00308 
00311         void _notifyCurrentCamera(Camera* cam);
00312 
00314         void setRenderQueueGroup(RenderQueueGroupID queueID);
00315         
00318         const AxisAlignedBox& getBoundingBox(void) const;
00319 
00321         AxisAlignedBox getChildObjectsBoundingBox(void) const;
00322 
00325         void _updateRenderQueue(RenderQueue* queue);
00326 
00328         const String& getName(void) const;
00329 
00331         const String& getMovableType(void) const;
00332 
00339         AnimationState* getAnimationState(const String& name);
00349         AnimationStateSet* getAllAnimationStates(void);
00350 
00353         void setDisplaySkeleton(bool display);
00354 
00357         bool getDisplaySkeleton(void) const;
00358 
00359 
00386         void setMeshLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99);
00387 
00414         void setMaterialLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99);
00415             
00417         void setRenderDetail(SceneDetailLevel renderDetail);
00418 
00422         void setRenderDetailOverrideable(bool renderDetailOverrideable);
00433         void attachObjectToBone(const String &boneName, MovableObject *pMovable, const Quaternion &offsetOrientation = Quaternion::IDENTITY, const Vector3 &offsetPosition = Vector3::ZERO);
00434 
00436         MovableObject* detachObjectFromBone(const String &movableName);
00437 
00444         void detachObjectFromBone(MovableObject* obj);
00445 
00447         void detachAllObjectsFromBone(void);
00448 
00449         typedef MapIterator<ChildObjectList> ChildObjectListIterator;
00451         ChildObjectListIterator getAttachedObjectIterator(void);
00453         Real getBoundingRadius(void) const;
00455         const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
00457         const Sphere& getWorldBoundingSphere(bool derive = false) const;
00458 
00467         void setNormaliseNormals(bool normalise) { mNormaliseNormals = normalise; }
00468 
00470         bool getNormaliseNormals(void) const {return mNormaliseNormals; }
00471 
00472 
00474         EdgeData* getEdgeList(void);
00476         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
00477             ShadowTechnique shadowTechnique, const Light* light, 
00478             HardwareIndexBufferSharedPtr* indexBuffer, 
00479             bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 );
00480 
00482         const Matrix4* _getBoneMatrices(void) { return mBoneMatrices;}
00484         unsigned short _getNumBoneMatrices(void) { return mNumBoneMatrices; }
00486         bool hasSkeleton(void) { return mSkeletonInstance != 0; }
00488         SkeletonInstance* getSkeleton(void) { return mSkeletonInstance; }
00498         bool isHardwareSkinningEnabled(void) const { return mHardwareSkinning; }
00506         int getSoftwareSkinningRequests(void) const { return mSoftwareSkinningRequests; }
00518         int getSoftwareSkinningNormalsRequests(void) const { return mSoftwareSkinningNormalsRequests; }
00534         void addSoftwareSkinningRequest(bool normalsAlso);
00543         void removeSoftwareSkinningRequest(bool normalsAlso);
00544 
00546         void _notifyAttached(Node* parent, bool isTagPoint = false);
00547 
00552         void shareSkeletonInstanceWith(Entity* entity);
00553 
00554     
00557         void Entity::stopSharingSkeletonInstance();
00558 
00559 
00563         inline bool sharesSkeletonInstance() const { return mSharedSkeletonEntities != NULL; }
00564 
00569         inline const EntitySet* getSkeletonInstanceSharingSet() const { return mSharedSkeletonEntities; }
00570 
00581         void refreshAvailableAnimationState(void);
00582 
00590         void _updateAnimation(void);
00591 
00595         const VertexData* _getSharedBlendedVertexData(void) const;
00596 
00597 
00598 
00599     };
00600 
00601 } // namespace
00602 
00603 #endif

Copyright © 2000-2005 by The OGRE Team
Last modified Sun Sep 25 17:35:53 2005