forked from stepmania/stepmania
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModel.h
119 lines (95 loc) · 4.08 KB
/
Model.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* Model - A 3D model. */
#ifndef MODEL_H
#define MODEL_H
#include "Actor.h"
#include "RageTypes.h"
#include "ModelTypes.h"
#include <vector>
#include <map>
class RageModelGeometry;
class RageCompiledGeometry;
class Model : public Actor
{
public:
Model();
virtual ~Model();
virtual Model *Copy() const;
void Clear();
void Load( const std::string &sFile );
bool LoadPieces(const std::string &sMeshesPath, const std::string &sMaterialsPath, const std::string &sBomesPath, std::string& load_fail_reason);
bool LoadMilkshapeAscii(const std::string &sFile, std::string& load_fail_reason);
bool LoadMaterialsFromMilkshapeAscii(const std::string &sPath, std::string& load_fail_reason);
bool LoadMilkshapeAsciiBones(const std::string &sAniName, const std::string &sPath);
void LoadFromNode( const XNode* pNode );
void PlayAnimation( const std::string &sAniName, float fPlayRate = 1 );
void SetRate( float fRate ) { m_fCurAnimationRate = fRate; }
void SetLoop( bool b ) { m_bLoop = b; }
void SetPosition( float fSeconds );
virtual void UpdateInternal(float delta);
virtual bool EarlyAbortDraw() const;
virtual void DrawPrimitives();
void DrawCelShaded();
void SetCelShading( bool bShading ) { m_bDrawCelShaded = bShading; }
virtual int GetNumStates() const;
virtual void SetState( size_t iNewState );
virtual float GetAnimationLengthSeconds() const
{ return m_animation_length_seconds; }
virtual void RecalcAnimationLengthSeconds();
virtual void SetSecondsIntoAnimation( float fSeconds );
std::string GetDefaultAnimation() const { return m_sDefaultAnimation; };
void SetDefaultAnimation( std::string sAnimation, float fPlayRate = 1 );
bool MaterialsNeedNormals() const;
// Lua
virtual void PushSelf( lua_State *L );
private:
RageModelGeometry *m_pGeometry;
float m_animation_length_seconds;
std::vector<msMaterial> m_Materials;
std::map<std::string,msAnimation> m_mapNameToAnimation;
const msAnimation* m_pCurAnimation;
static void SetBones( const msAnimation* pAnimation, float fFrame, std::vector<myBone_t> &vpBones );
std::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. */
std::vector<msMesh> m_vTempMeshes;
void DrawMesh( int i ) const;
void AdvanceFrame( float fDeltaTime );
float m_fCurFrame;
std::string m_sDefaultAnimation;
float m_fDefaultAnimationRate;
float m_fCurAnimationRate;
bool m_bLoop;
bool m_bDrawCelShaded; // for Lua models
bool m_loaded_safely;
Model& operator=(const Model& rhs);
};
#endif
/*
* (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.
*/