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 bool mVertexProgramInUse; 00164 00165 00167 ushort mMeshLodIndex; 00168 00170 Real mMeshLodFactorInv; 00172 ushort mMinMeshLodIndex; 00174 ushort mMaxMeshLodIndex; 00175 00177 Real mMaterialLodFactorInv; 00179 ushort mMinMaterialLodIndex; 00181 ushort mMaxMaterialLodIndex; 00182 00184 bool mUsingManualLOD; 00190 typedef std::vector<Entity*> LODEntityList; 00191 LODEntityList mLodEntityList; 00192 00195 SkeletonInstance* mSkeletonInstance; 00196 00198 void buildSubEntityList(MeshPtr& mesh, SubEntityList* sublist); 00199 00201 void attachObjectImpl(MovableObject *pMovable, TagPoint *pAttachingPoint); 00202 00204 void detachObjectImpl(MovableObject* pObject); 00205 00207 void detachAllObjectsImpl(void); 00208 00210 void reevaluateVertexProcessing(void); 00211 00212 public: 00214 typedef std::map<String, MovableObject*> ChildObjectList; 00215 protected: 00216 ChildObjectList mChildObjectList; 00217 00218 00220 AxisAlignedBox *mFullBoundingBox; 00221 00222 bool mNormaliseNormals; 00223 00224 ShadowRenderableList mShadowRenderables; 00225 00227 class _OgreExport EntityShadowRenderable : public ShadowRenderable 00228 { 00229 protected: 00230 Entity* mParent; 00231 // Shared link to position buffer 00232 HardwareVertexBufferSharedPtr mPositionBuffer; 00233 // Shared link to w-coord buffer (optional) 00234 HardwareVertexBufferSharedPtr mWBuffer; 00235 // Link to original vertex data 00236 const VertexData* mOriginalVertexData; 00237 // Original position buffer source binding 00238 unsigned short mOriginalPosBufferBinding; 00240 SubEntity* mSubEntity; 00241 00242 00243 public: 00244 EntityShadowRenderable(Entity* parent, 00245 HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData, 00246 bool createSeparateLightCap, SubEntity* subent, bool isLightCap = false); 00247 ~EntityShadowRenderable(); 00249 void getWorldTransforms(Matrix4* xform) const; 00251 const Quaternion& getWorldOrientation(void) const; 00253 const Vector3& getWorldPosition(void) const; 00254 HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; } 00255 HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; } 00257 void rebindPositionBuffer(void); 00259 bool isVisible(void) const; 00260 00261 }; 00262 public: 00265 ~Entity(); 00266 00269 MeshPtr& getMesh(void); 00270 00273 SubEntity* getSubEntity(unsigned int index); 00274 00278 SubEntity* getSubEntity( const String& name ); 00279 00282 unsigned int getNumSubEntities(void) const; 00283 00293 Entity* clone( const String& newName ); 00294 00303 void setMaterialName(const String& name); 00304 00307 void _notifyCurrentCamera(Camera* cam); 00308 00310 void setRenderQueueGroup(RenderQueueGroupID queueID); 00311 00314 const AxisAlignedBox& getBoundingBox(void) const; 00315 00317 AxisAlignedBox getChildObjectsBoundingBox(void) const; 00318 00321 void _updateRenderQueue(RenderQueue* queue); 00322 00324 const String& getName(void) const; 00325 00327 const String& getMovableType(void) const; 00328 00335 AnimationState* getAnimationState(const String& name); 00342 AnimationStateSet* getAllAnimationStates(void); 00343 00346 void setDisplaySkeleton(bool display); 00347 00348 00375 void setMeshLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99); 00376 00403 void setMaterialLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99); 00404 00406 void setRenderDetail(SceneDetailLevel renderDetail); 00407 00418 void attachObjectToBone(const String &boneName, MovableObject *pMovable, const Quaternion &offsetOrientation = Quaternion::IDENTITY, const Vector3 &offsetPosition = Vector3::ZERO); 00419 00421 MovableObject* detachObjectFromBone(const String &movableName); 00422 00429 void detachObjectFromBone(MovableObject* obj); 00430 00432 void detachAllObjectsFromBone(void); 00433 00434 typedef MapIterator<ChildObjectList> ChildObjectListIterator; 00436 ChildObjectListIterator getAttachedObjectIterator(void); 00438 Real getBoundingRadius(void) const; 00447 void setNormaliseNormals(bool normalise) { mNormaliseNormals = normalise; } 00448 00450 bool getNormaliseNormals(void) const {return mNormaliseNormals; } 00451 00452 00454 EdgeData* getEdgeList(void); 00456 ShadowRenderableListIterator getShadowVolumeRenderableIterator( 00457 ShadowTechnique shadowTechnique, const Light* light, 00458 HardwareIndexBufferSharedPtr* indexBuffer, 00459 bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ); 00460 00462 const Matrix4* _getBoneMatrices(void) { return mBoneMatrices;} 00464 unsigned short _getNumBoneMatrices(void) { return mNumBoneMatrices; } 00466 bool hasSkeleton(void) { return mSkeletonInstance != 0; } 00468 SkeletonInstance* getSkeleton(void) { return mSkeletonInstance; } 00478 bool isHardwareSkinningEnabled(void) { return mHardwareSkinning; } 00479 00481 void _notifyAttached(Node* parent, bool isTagPoint = false); 00482 00487 void shareSkeletonInstanceWith(Entity* entity); 00488 00489 00492 void Entity::stopSharingSkeletonInstance(); 00493 00494 00498 inline bool sharesSkeletonInstance() const { return mSharedSkeletonEntities != NULL; } 00499 00504 inline const EntitySet* getSkeletonInstanceSharingSet() const { return mSharedSkeletonEntities; } 00505 00513 void _updateAnimation(void); 00514 00518 const VertexData* _getSharedBlendedVertexData(void) const; 00519 00520 00521 00522 }; 00523 00524 } // namespace 00525 00526 #endif
Copyright © 2000-2005 by The OGRE Team
Last modified Wed Feb 23 00:19:05 2005