# 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
    00365         Entity* getManualLodLevel(size_t index) const;
    00366
    00372         size_t getNumManualLodLevels(void) const;
    00373
    00400         void setMeshLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99);
    00401
    00428         void setMaterialLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99);
    00429
    00431         void setRenderDetail(SceneDetailLevel renderDetail);
    00432
    00436         void setRenderDetailOverrideable(bool renderDetailOverrideable);
    00447         void attachObjectToBone(const String &boneName, MovableObject *pMovable, const Quaternion &offsetOrientation = Quaternion::IDENTITY, const Vector3 &offsetPosition = Vector3::ZERO);
    00448
    00450         MovableObject* detachObjectFromBone(const String &movableName);
    00451
    00458         void detachObjectFromBone(MovableObject* obj);
    00459
    00461         void detachAllObjectsFromBone(void);
    00462
    00463         typedef MapIterator<ChildObjectList> ChildObjectListIterator;
    00465         ChildObjectListIterator getAttachedObjectIterator(void);
    00467         Real getBoundingRadius(void) const;
    00469         const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
    00471         const Sphere& getWorldBoundingSphere(bool derive = false) const;
    00472
    00481         void setNormaliseNormals(bool normalise) { mNormaliseNormals = normalise; }
    00482
    00484         bool getNormaliseNormals(void) const {return mNormaliseNormals; }
    00485
    00486
    00488         EdgeData* getEdgeList(void);
    00490         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
    00491             ShadowTechnique shadowTechnique, const Light* light,
    00492             HardwareIndexBufferSharedPtr* indexBuffer,
    00493             bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 );
    00494
    00496         const Matrix4* _getBoneMatrices(void) { return mBoneMatrices;}
    00498         unsigned short _getNumBoneMatrices(void) { return mNumBoneMatrices; }
    00500         bool hasSkeleton(void) { return mSkeletonInstance != 0; }
    00502         SkeletonInstance* getSkeleton(void) { return mSkeletonInstance; }
    00512         bool isHardwareSkinningEnabled(void) const { return mHardwareSkinning; }
    00520         int getSoftwareSkinningRequests(void) const { return mSoftwareSkinningRequests; }
    00532         int getSoftwareSkinningNormalsRequests(void) const { return mSoftwareSkinningNormalsRequests; }
    00548         void addSoftwareSkinningRequest(bool normalsAlso);
    00557         void removeSoftwareSkinningRequest(bool normalsAlso);
    00558
    00560         void _notifyAttached(Node* parent, bool isTagPoint = false);
    00561
    00566         void shareSkeletonInstanceWith(Entity* entity);
    00567
    00568
    00571         void Entity::stopSharingSkeletonInstance();
    00572
    00573
    00577         inline bool sharesSkeletonInstance() const { return mSharedSkeletonEntities != NULL; }
    00578
    00583         inline const EntitySet* getSkeletonInstanceSharingSet() const { return mSharedSkeletonEntities; }
    00584
    00595         void refreshAvailableAnimationState(void);
    00596
    00604         void _updateAnimation(void);
    00605
    00609         const VertexData* _getSharedBlendedVertexData(void) const;
    00610
    00611
    00612
    00613     };
    00614
    00615 } // namespace
    00616
    00617 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Feb 12 12:59:44 2006