00001
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
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
00071
00072 RageCompiledGeometry* m_pTempGeometry;
00073
void UpdateTempGeometry();
00074
00075
00076
00077
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
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114