Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Model.h

Go to the documentation of this file.
00001 /* Model - A 3D model. */ 00002 00003 #ifndef MODEL_H 00004 #define MODEL_H 00005 00006 #include "Actor.h" 00007 #include "RageTypes.h" 00008 #include "ModelTypes.h" 00009 #include <vector> 00010 #include <map> 00011 #include "RageModelGeometry.h" 00012 00013 #define LUA_Model_METHODS( T ) \ 00014 LUA_Actor_METHODS( T ) \ 00015 static int playanimation( T* p, lua_State *L ) { p->PlayAnimation(SArg(1),FArg(2)); return 0; } \ 00016 00017 #define LUA_Model_METHODS_MAP( T ) \ 00018 LUA_Actor_METHODS_MAP( T ) \ 00019 LUA_METHOD_MAP( T, playanimation ) \ 00020 00021 class Model : public Actor 00022 { 00023 public: 00024 Model (); 00025 virtual ~Model (); 00026 00027 void Clear (); 00028 void Load( CString sFile ); 00029 00030 void LoadPieces( CString sMeshesPath, CString sMaterialsPath, CString sBomesPath ); 00031 void LoadFromModelFile( CString sFile ); 00032 void LoadMilkshapeAscii( CString sFile ); 00033 void LoadMaterialsFromMilkshapeAscii( CString sPath ); 00034 bool LoadMilkshapeAsciiBones( CString sAniName, CString sPath ); 00035 void PlayAnimation( CString sAniName, float fPlayRate = 1 ); 00036 00037 virtual void Update( float fDelta ); 00038 virtual bool EarlyAbortDraw(); 00039 virtual void DrawPrimitives(); 00040 00041 void AdvanceFrame (float dt); 00042 void DrawCelShaded(); 00043 00044 virtual int GetNumStates() const; 00045 virtual void SetState( int iNewState ); 00046 virtual float GetAnimationLengthSeconds() const; 00047 virtual void SetSecondsIntoAnimation( float fSeconds ); 00048 00049 CString GetDefaultAnimation() { return m_sDefaultAnimation; }; 00050 void SetDefaultAnimation( CString sAnimation, float fPlayRate = 1 ); 00051 bool m_bRevertToDefaultAnimation; 00052 00053 bool MaterialsNeedNormals() const; 00054 00055 // 00056 // Commands 00057 // 00058 virtual void PushSelf( lua_State *L ); 00059 00060 private: 00061 RageModelGeometry *m_pGeometry; 00062 00063 vector<msMaterial> m_Materials; 00064 map<CString,msAnimation> m_mapNameToAnimation; 00065 const msAnimation* m_pCurAnimation; 00066 00067 static void SetBones( const msAnimation* pAnimation, float fFrame, vector<myBone_t> &vpBones ); 00068 vector<myBone_t> m_vpBones; 00069 00070 // If any vertex has a bone weight, then then render from m_pTempGeometry. 00071 // Otherwise, render directly from m_pGeometry. 00072 RageCompiledGeometry* m_pTempGeometry; 00073 void UpdateTempGeometry(); 00074 00075 /* Keep a copy of the mesh data only if m_pTempGeometry is in use. The normal and 00076 * position data will be changed; the rest is static and kept only to prevent making 00077 * a complete copy. */ 00078 vector<msMesh> m_vTempMeshes; 00079 00080 void DrawMesh( int i ) const; 00081 00082 float m_fCurFrame; 00083 CString m_sDefaultAnimation; 00084 float m_fDefaultAnimationRate; 00085 float m_fCurAnimationRate; 00086 00087 }; 00088 00089 #endif 00090 00091 /* 00092 * (c) 2003-2004 Chris Danford 00093 * All rights reserved. 00094 * 00095 * Permission is hereby granted, free of charge, to any person obtaining a 00096 * copy of this software and associated documentation files (the 00097 * "Software"), to deal in the Software without restriction, including 00098 * without limitation the rights to use, copy, modify, merge, publish, 00099 * distribute, and/or sell copies of the Software, and to permit persons to 00100 * whom the Software is furnished to do so, provided that the above 00101 * copyright notice(s) and this permission notice appear in all copies of 00102 * the Software and that both the above copyright notice(s) and this 00103 * permission notice appear in supporting documentation. 00104 * 00105 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00106 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00107 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00108 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00109 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00110 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00111 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00112 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00113 * PERFORMANCE OF THIS SOFTWARE. 00114 */

Generated on Thu Jan 27 20:57:24 2005 for StepMania by doxygen 1.3.7