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 © 2000-2002 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 00038 namespace Ogre { 00070 class _OgreExport Entity: public MovableObject 00071 { 00072 // Allow SceneManager full access 00073 friend class SceneManager; 00074 friend class SubEntity; 00075 public: 00076 typedef std::set<Entity*> EntitySet; 00077 00078 protected: 00079 00082 Entity(); 00085 Entity( const String& name, Mesh* mesh, SceneManager* creator); 00086 00089 String mName; 00090 00093 Mesh* mMesh; 00094 00097 typedef std::vector<SubEntity*> SubEntityList; 00098 SubEntityList mSubEntityList; 00099 00103 SceneManager* mCreatorSceneManager; 00104 00105 00107 AnimationStateSet* mAnimationState; 00108 00110 static String msMovableType; 00111 00112 00114 TempBlendedBufferInfo mTempBlendedBuffer; 00116 VertexData* mSharedBlendedVertexData; 00117 00120 const VertexData* findBlendedVertexData(const VertexData* orig); 00123 SubEntity* findSubEntityForVertexData(const VertexData* orig); 00124 00127 void extractTempBufferInfo(VertexData* sourceData, TempBlendedBufferInfo* info); 00129 VertexData* cloneVertexDataRemoveBlendInfo(const VertexData* source); 00131 void prepareTempBlendBuffers(void); 00132 00134 Matrix4 *mBoneMatrices; 00135 unsigned short mNumBoneMatrices; 00137 unsigned long mFrameAnimationLastUpdated; 00138 00140 void updateAnimation(void); 00141 00145 unsigned long *mFrameBonesLastUpdated; 00146 00152 EntitySet* mSharedSkeletonEntities; 00153 00155 void cacheBoneMatrices(void); 00156 00158 bool mDisplaySkeleton; 00160 bool mHardwareSkinning; 00162 bool mVertexProgramInUse; 00163 00164 00166 ushort mMeshLodIndex; 00167 00169 Real mMeshLodFactorInv; 00171 ushort mMinMeshLodIndex; 00173 ushort mMaxMeshLodIndex; 00174 00176 Real mMaterialLodFactorInv; 00178 ushort mMinMaterialLodIndex; 00180 ushort mMaxMaterialLodIndex; 00181 00183 bool mUsingManualLOD; 00189 typedef std::vector<Entity*> LODEntityList; 00190 LODEntityList mLodEntityList; 00191 00194 SkeletonInstance* mSkeletonInstance; 00195 00197 void buildSubEntityList(Mesh* mesh, SubEntityList* sublist); 00198 00200 void attachObjectImpl(MovableObject *pMovable, TagPoint *pAttachingPoint); 00201 00203 void detachObjectImpl(MovableObject* pObject); 00204 00206 void detachAllObjectsImpl(void); 00207 00209 void reevaluateVertexProcessing(void); 00210 00211 public: 00213 typedef std::map<String, MovableObject*> ChildObjectList; 00214 protected: 00215 ChildObjectList mChildObjectList; 00216 00217 00219 AxisAlignedBox *mFullBoundingBox; 00220 00221 bool mNormaliseNormals; 00222 00223 ShadowRenderableList mShadowRenderables; 00224 00226 class _OgreExport EntityShadowRenderable : public ShadowRenderable 00227 { 00228 protected: 00229 Entity* mParent; 00230 // Shared link to position buffer 00231 HardwareVertexBufferSharedPtr mPositionBuffer; 00232 // Shared link to w-coord buffer (optional) 00233 HardwareVertexBufferSharedPtr mWBuffer; 00234 // Link to original vertex data 00235 const VertexData* mOriginalVertexData; 00236 // Original position buffer source binding 00237 unsigned short mOriginalPosBufferBinding; 00239 SubEntity* mSubEntity; 00240 00241 00242 public: 00243 EntityShadowRenderable(Entity* parent, 00244 HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData, 00245 bool createSeparateLightCap, SubEntity* subent, bool isLightCap = false); 00246 ~EntityShadowRenderable(); 00248 void getWorldTransforms(Matrix4* xform) const; 00250 const Quaternion& getWorldOrientation(void) const; 00252 const Vector3& getWorldPosition(void) const; 00253 HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; } 00254 HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; } 00256 void rebindPositionBuffer(void); 00258 bool isVisible(void) const; 00259 00260 }; 00261 public: 00264 ~Entity(); 00265 00268 Mesh* getMesh(void); 00269 00272 SubEntity* getSubEntity(unsigned int index); 00273 00277 SubEntity* getSubEntity( const String& name ); 00278 00281 unsigned int getNumSubEntities(void) const; 00282 00292 Entity* clone( const String& newName ); 00293 00302 void setMaterialName(const String& name); 00303 00306 void _notifyCurrentCamera(Camera* cam); 00307 00309 void setRenderQueueGroup(RenderQueueGroupID queueID); 00310 00313 const AxisAlignedBox& getBoundingBox(void) const; 00314 00316 AxisAlignedBox getChildObjectsBoundingBox(void) const; 00317 00320 void _updateRenderQueue(RenderQueue* queue); 00321 00323 const String& getName(void) const; 00324 00326 const String& getMovableType(void) const; 00327 00334 AnimationState* getAnimationState(const String& name); 00341 AnimationStateSet* getAllAnimationStates(void); 00342 00345 void setDisplaySkeleton(bool display); 00346 00347 00374 void setMeshLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99); 00375 00402 void setMaterialLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99); 00403 00405 void setRenderDetail(SceneDetailLevel renderDetail); 00406 00417 void attachObjectToBone(const String &boneName, MovableObject *pMovable, const Quaternion &offsetOrientation = Quaternion::IDENTITY, const Vector3 &offsetPosition = Vector3::ZERO); 00418 00420 MovableObject* detachObjectFromBone(const String &movableName); 00421 00428 void detachObjectFromBone(MovableObject* obj); 00429 00431 void detachAllObjectsFromBone(void); 00432 00433 typedef MapIterator<ChildObjectList> ChildObjectListIterator; 00435 ChildObjectListIterator getAttachedObjectIterator(void); 00437 Real getBoundingRadius(void) const; 00446 void setNormaliseNormals(bool normalise) { mNormaliseNormals = normalise; } 00447 00449 bool getNormaliseNormals(void) const {return mNormaliseNormals; } 00450 00451 00453 EdgeData* getEdgeList(void); 00455 ShadowRenderableListIterator getShadowVolumeRenderableIterator( 00456 ShadowTechnique shadowTechnique, const Light* light, 00457 HardwareIndexBufferSharedPtr* indexBuffer, 00458 bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ); 00459 00461 ShadowRenderableListIterator getLastShadowVolumeRenderableIterator (void); 00462 00464 const Matrix4* _getBoneMatrices(void) { return mBoneMatrices;} 00466 unsigned short _getNumBoneMatrices(void) { return mNumBoneMatrices; } 00468 bool hasSkeleton(void) { return mSkeletonInstance != 0; } 00470 SkeletonInstance* getSkeleton(void) { return mSkeletonInstance; } 00480 bool isHardwareSkinningEnabled(void) { return mHardwareSkinning; } 00481 00483 void _notifyAttached(Node* parent, bool isTagPoint = false); 00484 00489 void shareSkeletonInstanceWith(Entity* entity); 00490 00491 00494 void Entity::stopSharingSkeletonInstance(); 00495 00496 00500 inline bool sharesSkeletonInstance() const { return mSharedSkeletonEntities != NULL; } 00501 00506 inline const EntitySet* getSkeletonInstanceSharingSet() const { return mSharedSkeletonEntities; } 00507 00508 00509 }; 00510 00511 } // namespace 00512 00513 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:23 2004