Files
itgmania212121/stepmania/src/Model.h
T

122 lines
3.7 KiB
C++
Raw Normal View History

2004-06-08 00:47:53 +00:00
/* Model - A 3D model. */
2003-04-25 21:05:40 +00:00
2004-06-08 00:47:53 +00:00
#ifndef MODEL_H
#define MODEL_H
2003-04-25 21:05:40 +00:00
#include "Actor.h"
#include "RageTypes.h"
#include "ModelTypes.h"
2003-05-04 05:21:16 +00:00
#include <vector>
#include <map>
#include "RageModelGeometry.h"
2003-04-25 21:05:40 +00:00
template<class T>
class LunaModel : public LunaActor<T>
{
public:
LunaModel() { LUA->Register( Register ); }
2005-02-12 20:29:38 +00:00
static int playanimation( T* p, lua_State *L ) { p->PlayAnimation(SArg(1),FArg(2)); return 0; }
2005-01-26 11:21:43 +00:00
static void Register(lua_State *L)
{
2005-02-12 20:29:38 +00:00
ADD_METHOD( playanimation )
LunaActor<T>::Register( L );
}
};
2003-04-25 21:05:40 +00:00
class Model : public Actor
{
public:
Model ();
virtual ~Model ();
void Clear ();
2004-02-08 11:17:03 +00:00
void Load( CString sFile );
2003-05-11 07:23:47 +00:00
2004-02-08 11:17:03 +00:00
void LoadPieces( CString sMeshesPath, CString sMaterialsPath, CString sBomesPath );
void LoadFromModelFile( CString sFile );
void LoadMilkshapeAscii( CString sFile );
void LoadMaterialsFromMilkshapeAscii( CString sPath );
bool LoadMilkshapeAsciiBones( CString sAniName, CString sPath );
void PlayAnimation( CString sAniName, float fPlayRate = 1 );
2003-04-25 21:05:40 +00:00
virtual void Update( float fDelta );
virtual bool EarlyAbortDraw();
2003-04-25 21:05:40 +00:00
virtual void DrawPrimitives();
void AdvanceFrame (float dt);
2004-06-18 11:02:40 +00:00
void DrawCelShaded();
2003-04-25 21:05:40 +00:00
virtual int GetNumStates() const;
2003-05-11 07:23:47 +00:00
virtual void SetState( int iNewState );
virtual float GetAnimationLengthSeconds() const;
virtual void SetSecondsIntoAnimation( float fSeconds );
CString GetDefaultAnimation() { return m_sDefaultAnimation; };
void SetDefaultAnimation( CString sAnimation, float fPlayRate = 1 );
bool m_bRevertToDefaultAnimation;
2003-05-11 07:23:47 +00:00
bool MaterialsNeedNormals() const;
2005-01-26 11:21:43 +00:00
//
// Commands
//
virtual void PushSelf( lua_State *L );
2003-05-11 07:23:47 +00:00
2003-04-25 21:05:40 +00:00
private:
RageModelGeometry *m_pGeometry;
vector<msMaterial> m_Materials;
map<CString,msAnimation> m_mapNameToAnimation;
2004-08-19 08:32:18 +00:00
const msAnimation* m_pCurAnimation;
2004-08-19 01:08:18 +00:00
static void SetBones( const msAnimation* pAnimation, float fFrame, vector<myBone_t> &vpBones );
vector<myBone_t> m_vpBones;
// If any vertex has a bone weight, then then render from m_pTempGeometry.
// Otherwise, render directly from m_pGeometry.
RageCompiledGeometry* m_pTempGeometry;
void UpdateTempGeometry();
/* Keep a copy of the mesh data only if m_pTempGeometry is in use. The normal and
* position data will be changed; the rest is static and kept only to prevent making
* a complete copy. */
vector<msMesh> m_vTempMeshes;
2004-08-19 01:47:58 +00:00
void DrawMesh( int i ) const;
2004-08-19 01:08:18 +00:00
float m_fCurFrame;
CString m_sDefaultAnimation;
float m_fDefaultAnimationRate;
float m_fCurAnimationRate;
2003-04-25 21:05:40 +00:00
};
#endif
2004-06-08 00:47:53 +00:00
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/