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 protected: 00076 00079 Entity(); 00082 Entity( const String& name, Mesh* mesh, SceneManager* creator); 00083 00086 String mName; 00087 00090 Mesh* mMesh; 00091 00094 typedef std::vector<SubEntity*> SubEntityList; 00095 SubEntityList mSubEntityList; 00096 00100 SceneManager* mCreatorSceneManager; 00101 00102 00104 AnimationStateSet mAnimationState; 00105 00107 static String msMovableType; 00108 00109 00111 TempBlendedBufferInfo mTempBlendedBuffer; 00113 VertexData* mSharedBlendedVertexData; 00114 00117 const VertexData* findBlendedVertexData(const VertexData* orig); 00120 SubEntity* findSubEntityForVertexData(const VertexData* orig); 00121 00124 void extractTempBufferInfo(VertexData* sourceData, TempBlendedBufferInfo* info); 00126 VertexData* cloneVertexDataRemoveBlendInfo(const VertexData* source); 00128 void prepareTempBlendBuffers(void); 00129 00131 Matrix4 *mBoneMatrices; 00132 unsigned short mNumBoneMatrices; 00134 unsigned long mFrameAnimationLastUpdated; 00135 00137 void updateAnimation(void); 00138 00140 void cacheBoneMatrices(void); 00141 00143 bool mDisplaySkeleton; 00145 bool mHardwareSkinning; 00147 bool mVertexProgramInUse; 00148 00149 00151 ushort mMeshLodIndex; 00152 00154 Real mMeshLodFactorInv; 00156 ushort mMinMeshLodIndex; 00158 ushort mMaxMeshLodIndex; 00159 00161 Real mMaterialLodFactorInv; 00163 ushort mMinMaterialLodIndex; 00165 ushort mMaxMaterialLodIndex; 00166 00168 bool mUsingManualLOD; 00174 typedef std::vector<Entity*> LODEntityList; 00175 LODEntityList mLodEntityList; 00176 00179 SkeletonInstance* mSkeletonInstance; 00180 00182 void buildSubEntityList(Mesh* mesh, SubEntityList* sublist); 00183 00185 void attachObjectImpl(MovableObject *pMovable, TagPoint *pAttachingPoint); 00186 00188 void reevaluateVertexProcessing(void); 00189 00190 public: 00192 typedef std::map<String, MovableObject*> ChildObjectList; 00193 protected: 00194 ChildObjectList mChildObjectList; 00195 00196 00198 AxisAlignedBox *mFullBoundingBox; 00199 00200 bool mNormaliseNormals; 00201 00202 ShadowRenderableList mShadowRenderables; 00203 00205 class _OgreExport EntityShadowRenderable : public ShadowRenderable 00206 { 00207 protected: 00208 Entity* mParent; 00209 // Shared link to position buffer 00210 HardwareVertexBufferSharedPtr mPositionBuffer; 00211 // Shared link to w-coord buffer (optional) 00212 HardwareVertexBufferSharedPtr mWBuffer; 00213 // Link to original vertex data 00214 const VertexData* mOriginalVertexData; 00215 // Original position buffer source binding 00216 unsigned short mOriginalPosBufferBinding; 00218 SubEntity* mSubEntity; 00219 00220 00221 public: 00222 EntityShadowRenderable(Entity* parent, 00223 HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData, 00224 bool createSeparateLightCap, SubEntity* subent, bool isLightCap = false); 00225 ~EntityShadowRenderable(); 00227 void getWorldTransforms(Matrix4* xform) const; 00229 const Quaternion& getWorldOrientation(void) const; 00231 const Vector3& getWorldPosition(void) const; 00232 HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; } 00233 HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; } 00235 void rebindPositionBuffer(void); 00237 bool isVisible(void) const; 00238 00239 }; 00240 public: 00243 ~Entity(); 00244 00247 Mesh* getMesh(void); 00248 00251 SubEntity* getSubEntity(unsigned int index); 00252 00256 SubEntity* getSubEntity( const String& name ); 00257 00260 unsigned int getNumSubEntities(void) const; 00261 00271 Entity* clone( const String& newName ); 00272 00281 void setMaterialName(const String& name); 00282 00285 void _notifyCurrentCamera(Camera* cam); 00286 00289 const AxisAlignedBox& getBoundingBox(void) const; 00290 00292 AxisAlignedBox getChildObjectsBoundingBox(void) const; 00293 00296 void _updateRenderQueue(RenderQueue* queue); 00297 00299 const String& getName(void) const; 00300 00302 const String& getMovableType(void) const; 00303 00310 AnimationState* getAnimationState(const String& name); 00317 AnimationStateSet* getAllAnimationStates(void); 00318 00321 void setDisplaySkeleton(bool display); 00322 00323 00350 void setMeshLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99); 00351 00378 void setMaterialLodBias(Real factor, ushort maxDetailIndex = 0, ushort minDetailIndex = 99); 00379 00381 void setRenderDetail(SceneDetailLevel renderDetail); 00382 00393 void attachObjectToBone(const String &boneName, MovableObject *pMovable, const Quaternion &offsetOrientation = Quaternion::IDENTITY, const Vector3 &offsetPosition = Vector3::ZERO); 00394 00396 MovableObject* detachObjectFromBone(const String &movableName); 00397 00398 typedef MapIterator<ChildObjectList> ChildObjectListIterator; 00400 ChildObjectListIterator getAttachedObjectIterator(void); 00402 Real getBoundingRadius(void) const; 00411 void setNormaliseNormals(bool normalise) { mNormaliseNormals = normalise; } 00412 00414 bool getNormaliseNormals(void) const {return mNormaliseNormals; } 00415 00416 00418 EdgeData* getEdgeList(void); 00420 ShadowRenderableListIterator getShadowVolumeRenderableIterator( 00421 ShadowTechnique shadowTechnique, const Light* light, 00422 HardwareIndexBufferSharedPtr* indexBuffer, 00423 bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ); 00424 00425 00427 const Matrix4* _getBoneMatrices(void) { return mBoneMatrices;} 00429 unsigned short _getNumBoneMatrices(void) { return mNumBoneMatrices; } 00431 bool hasSkeleton(void) { return mSkeletonInstance != 0; } 00433 SkeletonInstance* getSkeleton(void) { return mSkeletonInstance; } 00443 bool isHardwareSkinningEnabled(void) { return mHardwareSkinning; } 00444 00446 void _notifyAttached(Node* parent, bool isTagPoint = false); 00447 00448 00449 }; 00450 00451 } // namespace 00452 00453 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:08 2004