00001 #ifndef _MERCURY_LOADABLE_MODEL_H 00002 #define _MERCURY_LOADABLE_MODEL_H 00003 00004 #include "MercuryModel.h" 00005 #include "MercuryShapes.h" 00006 00008 class MercuryLoadableModel : public MercuryModel 00009 { 00010 public: 00011 virtual void Update(const float dTime); 00012 00014 struct LoadableModelAnimationInfo 00015 { 00016 LoadableModelAnimationInfo() : fPercent(1), fPlace(0), fRate(1), bLoop(1), bRunning(1) { } 00017 void Trigger() { fPlace = 0; bRunning = true; } 00018 MString sAnimationName; 00019 float fPercent; 00020 float fPlace; 00021 float fRate; 00022 bool bLoop; 00023 bool bRunning; 00024 }; 00025 00027 void SetAnimationState( const MVector < LoadableModelAnimationInfo > & AnimationInfos ) { m_vAnimationInfos = AnimationInfos; } 00028 00030 LoadableModelAnimationInfo & GetAnimationState( int iPlace ) { return m_vAnimationInfos[iPlace]; } 00031 00033 void GetAllAnimationStates( MVector < LoadableModelAnimationInfo > & AnimationInfos ) { AnimationInfos = m_vAnimationInfos; } 00034 CLASS_RTTI( MercuryLoadableModel, MercuryModel ); 00035 private: 00036 virtual void LoadModel(); 00037 00038 //Returns true if early exit is requested. 00039 bool LoadMesh( int iMesh ); 00040 void LoadBone( int iBone ); 00041 void LoadAnimation( int iAnimation ); 00042 void LoadMaterial( int iMaterial ); 00043 00044 00045 struct MLQVert 00046 { 00047 MercuryPoint pos; 00048 int iMappedVert; 00049 int iMappedMesh; 00050 float fPercent; 00051 }; 00052 00053 struct MLAnimationKey 00054 { 00055 float fSeconds; 00056 MercuryPoint Pos; 00057 MQuaternion Rot; 00058 }; 00059 00060 struct MLBoneAnimation 00061 { 00062 MVector<MLAnimationKey> vKeys; 00063 float fAnimationLength; 00064 int iCurrentPlace; 00065 }; 00066 00067 struct MLBone 00068 { 00069 MercuryPoint Pos; 00070 MQuaternion Rot; 00071 int iParent; 00072 int iExclusiveMesh; 00073 MercuryMatrix mXF; 00074 00075 MVector < MLQVert > m_vDissassembledVerts; 00076 MHash< MLBoneAnimation > m_mAnimations; 00077 }; 00078 00079 MVector< MLBone > m_vBones; 00080 MVector< LoadableModelAnimationInfo > m_vAnimationInfos; 00081 00082 MVector< int > m_vMeshMaterialAssignments; //Pureley temporary for loading process. 00083 00084 //Bone operations 00085 void ResetBoneMatrix( int iBone ); 00086 void MakeBoneMatrix( int iBone, const MercuryPoint & Pos, const MQuaternion & Rot ); 00087 00088 //For debugging bones 00089 MVector< MercuryShape * > m_vVisualJoints; 00090 }; 00091 00092 #endif 00093 00094 /* 00095 * Copyright (c) 2005-2006, Joshua Allen, Charles Lohr 00096 * All rights reserved. 00097 * 00098 * Redistribution and use in source and binary forms, with or 00099 * without modification, are permitted provided that the following 00100 * conditions are met: 00101 * - Redistributions of source code must retain the above 00102 * copyright notice, this list of conditions and the following disclaimer. 00103 * - Redistributions in binary form must reproduce the above copyright 00104 * notice, this list of conditions and the following disclaimer in 00105 * the documentation and/or other materials provided with the distribution. 00106 * - Neither the name of the Mercury Engine nor the names of its 00107 * contributors may be used to endorse or promote products derived from 00108 * this software without specific prior written permission. 00109 * 00110 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00111 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00112 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00113 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 00114 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00115 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00116 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00117 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00118 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00119 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00120 */