add support for models in NoteSkin
This commit is contained in:
+57
-13
@@ -1,7 +1,7 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
/*
|
/*
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
Class: Milkshape
|
Class: Model
|
||||||
|
|
||||||
Desc: Types defined in msLib.h.
|
Desc: Types defined in msLib.h.
|
||||||
|
|
||||||
@@ -10,11 +10,12 @@
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include "Milkshape.h"
|
#include "ModelTypes.h"
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
#include "RageDisplay.h"
|
#include "RageDisplay.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "RageTextureManager.h"
|
#include "RageTextureManager.h"
|
||||||
|
#include "IniFile.h"
|
||||||
|
|
||||||
|
|
||||||
const float FRAMES_PER_SECOND = 30;
|
const float FRAMES_PER_SECOND = 30;
|
||||||
@@ -39,6 +40,33 @@ void Model::Clear ()
|
|||||||
m_pModel = NULL;
|
m_pModel = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Model::LoadFromModelFile( CString sPath )
|
||||||
|
{
|
||||||
|
CString sDir, sThrowAway;
|
||||||
|
splitrelpath( sPath, sDir, sThrowAway, sThrowAway );
|
||||||
|
|
||||||
|
IniFile ini;
|
||||||
|
ini.SetPath( sPath );
|
||||||
|
ini.ReadFile();
|
||||||
|
|
||||||
|
if( !ini.GetKey("Model") )
|
||||||
|
RageException::Throw( "The model file '%s' is invalid.", sPath.c_str() );
|
||||||
|
|
||||||
|
CString sFileName;
|
||||||
|
ini.GetValue( "Model", "File", sFileName );
|
||||||
|
LoadMilkshapeAscii( sDir+sFileName );
|
||||||
|
|
||||||
|
float f;
|
||||||
|
if( ini.GetValueF( "Model", "BaseRotationXDegrees", f ) ) Actor::SetBaseRotationX( f );
|
||||||
|
if( ini.GetValueF( "Model", "BaseRotationYDegrees", f ) ) Actor::SetBaseRotationY( f );
|
||||||
|
if( ini.GetValueF( "Model", "BaseRotationZDegrees", f ) ) Actor::SetBaseRotationZ( f );
|
||||||
|
if( ini.GetValueF( "Model", "BaseZoomX", f ) ) Actor::SetBaseZoomX( f );
|
||||||
|
if( ini.GetValueF( "Model", "BaseZoomY", f ) ) Actor::SetBaseZoomY( f );
|
||||||
|
if( ini.GetValueF( "Model", "BaseZoomZ", f ) ) Actor::SetBaseZoomZ( f );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Model::LoadMilkshapeAscii( CString sPath )
|
bool Model::LoadMilkshapeAscii( CString sPath )
|
||||||
{
|
{
|
||||||
CString sDir, sThrowAway;
|
CString sDir, sThrowAway;
|
||||||
@@ -46,7 +74,7 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
|||||||
|
|
||||||
FILE *file = fopen (sPath, "rt");
|
FILE *file = fopen (sPath, "rt");
|
||||||
if (!file)
|
if (!file)
|
||||||
RageException::Throw( "Model:: Could not open '%s'.", sPath.c_str() );
|
RageException::Throw( "Model::LoadMilkshapeAscii Could not open '%s'.", sPath.c_str() );
|
||||||
|
|
||||||
Clear ();
|
Clear ();
|
||||||
|
|
||||||
@@ -378,14 +406,10 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
|||||||
sscanf (szLine, "\"%[^\"]\"", szName);
|
sscanf (szLine, "\"%[^\"]\"", szName);
|
||||||
strcpy( Material.szAlphaTexture, szName );
|
strcpy( Material.szAlphaTexture, szName );
|
||||||
|
|
||||||
Material.pTexture = NULL;
|
|
||||||
if( strcmp(Material.szDiffuseTexture, "")!=0 )
|
if( strcmp(Material.szDiffuseTexture, "")!=0 )
|
||||||
{
|
{
|
||||||
RageTextureID ID;
|
if( IsAFile(sDir+Material.szDiffuseTexture) )
|
||||||
ID.filename = sDir+Material.szDiffuseTexture;
|
Material.aniTexture.Load( sDir+Material.szDiffuseTexture );
|
||||||
ID.bStretch = true;
|
|
||||||
if( DoesFileExist(ID.filename) )
|
|
||||||
Material.pTexture = TEXTUREMAN->LoadTexture( ID );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -722,7 +746,7 @@ void Model::DrawPrimitives()
|
|||||||
mat.Diffuse,
|
mat.Diffuse,
|
||||||
mat.Specular,
|
mat.Specular,
|
||||||
mat.fShininess );
|
mat.fShininess );
|
||||||
DISPLAY->SetTexture( mat.pTexture );
|
DISPLAY->SetTexture( mat.aniTexture.GetCurrentTexture() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -758,10 +782,11 @@ void Model::DrawPrimitives()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VectorRotate (originalVert.Normal, m_pBones[originalVert.nBoneIndex].mFinal, tempVert.n);
|
|
||||||
|
|
||||||
int bone = originalVert.nBoneIndex;
|
int bone = originalVert.nBoneIndex;
|
||||||
VectorRotate (originalVert.Vertex, m_pBones[originalVert.nBoneIndex].mFinal, tempVert.p);
|
|
||||||
|
VectorRotate (originalVert.Normal, m_pBones[bone].mFinal, tempVert.n);
|
||||||
|
|
||||||
|
VectorRotate (originalVert.Vertex, m_pBones[bone].mFinal, tempVert.p);
|
||||||
tempVert.p[0] += m_pBones[bone].mFinal[0][3];
|
tempVert.p[0] += m_pBones[bone].mFinal[0][3];
|
||||||
tempVert.p[1] += m_pBones[bone].mFinal[1][3];
|
tempVert.p[1] += m_pBones[bone].mFinal[1][3];
|
||||||
tempVert.p[2] += m_pBones[bone].mFinal[2][3];
|
tempVert.p[2] += m_pBones[bone].mFinal[2][3];
|
||||||
@@ -971,4 +996,23 @@ void Model::Update( float fDelta )
|
|||||||
{
|
{
|
||||||
Actor::Update( fDelta );
|
Actor::Update( fDelta );
|
||||||
AdvanceFrame( fDelta );
|
AdvanceFrame( fDelta );
|
||||||
|
if( m_pModel )
|
||||||
|
for( int i=0; i<m_pModel->Materials.size(); i++ )
|
||||||
|
m_pModel->Materials[i].aniTexture.Update( fDelta );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Model::SetState( int iNewState )
|
||||||
|
{
|
||||||
|
if( m_pModel )
|
||||||
|
for( int i=0; i<m_pModel->Materials.size(); i++ )
|
||||||
|
m_pModel->Materials[i].aniTexture.SetState( iNewState );
|
||||||
|
}
|
||||||
|
|
||||||
|
int Model::GetNumStates()
|
||||||
|
{
|
||||||
|
int iMaxStates = 0;
|
||||||
|
if( m_pModel )
|
||||||
|
for( int i=0; i<m_pModel->Materials.size(); i++ )
|
||||||
|
iMaxStates = max( iMaxStates, m_pModel->Materials[i].aniTexture.GetNumStates() );
|
||||||
|
return iMaxStates;
|
||||||
}
|
}
|
||||||
@@ -35,6 +35,16 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void Clear ();
|
void Clear ();
|
||||||
|
void Load( CString sPath )
|
||||||
|
{
|
||||||
|
if( sPath == "" ) return;
|
||||||
|
if( sPath.Right(6) == ".model" )
|
||||||
|
LoadFromModelFile( sPath );
|
||||||
|
else
|
||||||
|
LoadMilkshapeAscii( sPath );
|
||||||
|
};
|
||||||
|
|
||||||
|
bool LoadFromModelFile( CString sPath );
|
||||||
bool LoadMilkshapeAscii( CString sPath );
|
bool LoadMilkshapeAscii( CString sPath );
|
||||||
bool LoadMilkshapeAsciiBones( CString sPath );
|
bool LoadMilkshapeAsciiBones( CString sPath );
|
||||||
|
|
||||||
@@ -45,6 +55,10 @@ public:
|
|||||||
void SetupBones ();
|
void SetupBones ();
|
||||||
void AdvanceFrame (float dt);
|
void AdvanceFrame (float dt);
|
||||||
|
|
||||||
|
virtual void SetState( int iNewState );
|
||||||
|
virtual int GetNumStates();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
msModel *m_pModel;
|
msModel *m_pModel;
|
||||||
RageVector3 m_vMins, m_vMaxs;
|
RageVector3 m_vMins, m_vMaxs;
|
||||||
|
|||||||
@@ -29,10 +29,10 @@
|
|||||||
|
|
||||||
Actor* MakeModelOrSprite( CString sFile )
|
Actor* MakeModelOrSprite( CString sFile )
|
||||||
{
|
{
|
||||||
if( sFile.Right(3)=="txt" )
|
if( sFile.Right(3)=="txt"||sFile.Right(5)=="model" )
|
||||||
{
|
{
|
||||||
Model* pModel = new Model;
|
Model* pModel = new Model;
|
||||||
pModel->LoadMilkshapeAscii( sFile );
|
pModel->Load( sFile );
|
||||||
return pModel;
|
return pModel;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -699,7 +699,20 @@ void NoteDisplay::DrawTap( const int iCol, const float fBeat, const bool bOnSame
|
|||||||
pActor->SetXY( fXPos, fYPos );
|
pActor->SetXY( fXPos, fYPos );
|
||||||
pActor->SetDiffuse( diffuse );
|
pActor->SetDiffuse( diffuse );
|
||||||
pActor->SetGlow( glow );
|
pActor->SetGlow( glow );
|
||||||
|
|
||||||
|
|
||||||
|
DISPLAY->EnableLighting( true );
|
||||||
|
DISPLAY->SetLightDirectional(
|
||||||
|
0,
|
||||||
|
RageColor(0.0f,0.0f,0.0f,1),
|
||||||
|
RageColor(1,1,1,1),
|
||||||
|
RageColor(1,1,1,1),
|
||||||
|
RageVector3(1, 0, +1) );
|
||||||
|
|
||||||
pActor->Draw();
|
pActor->Draw();
|
||||||
|
|
||||||
|
DISPLAY->SetLightOff( 0 );
|
||||||
|
DISPLAY->EnableLighting( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
#include "ScreenSandbox.h"
|
#include "ScreenSandbox.h"
|
||||||
#include "GameConstantsAndTypes.h"
|
#include "GameConstantsAndTypes.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
|
#include "RageDisplay.h"
|
||||||
|
#include "RageTimer.h"
|
||||||
|
|
||||||
|
|
||||||
ScreenSandbox::ScreenSandbox() : Screen("ScreenSandbox")
|
ScreenSandbox::ScreenSandbox() : Screen("ScreenSandbox")
|
||||||
@@ -32,12 +34,12 @@ ScreenSandbox::ScreenSandbox() : Screen("ScreenSandbox")
|
|||||||
// this->AddChild( &m_sprite );
|
// this->AddChild( &m_sprite );
|
||||||
|
|
||||||
m_model.SetXY(CENTER_X, CENTER_Y);
|
m_model.SetXY(CENTER_X, CENTER_Y);
|
||||||
m_model.SetZoomX(1);
|
m_model.SetZoom(3);
|
||||||
m_model.SetZoomY(-1);
|
//m_model.SetZoomY(-1);
|
||||||
m_model.LoadMilkshapeAscii( "arrow.txt" );
|
m_model.LoadMilkshapeAscii( "Down Tap Note 4th.txt" );
|
||||||
// m_model.LoadMilkshapeAsciiBones( "D:\\Dev\\ddrpc char hacking\\DDRPCRip\\models\\howtoplay.bones.txt" );
|
// m_model.LoadMilkshapeAsciiBones( "D:\\Dev\\ddrpc char hacking\\DDRPCRip\\models\\howtoplay.bones.txt" );
|
||||||
this->AddChild(&m_model);
|
this->AddChild(&m_model);
|
||||||
m_model.SetEffectSpin( RageVector3(0,90,0) );
|
m_model.SetEffectSpin( RageVector3(0,90,90) );
|
||||||
|
|
||||||
this->AddChild( &m_In );
|
this->AddChild( &m_In );
|
||||||
|
|
||||||
@@ -58,6 +60,22 @@ void ScreenSandbox::Update( float fDeltaTime )
|
|||||||
Screen::Update(fDeltaTime);
|
Screen::Update(fDeltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenSandbox::DrawPrimitives()
|
||||||
|
{
|
||||||
|
DISPLAY->EnableLighting( true );
|
||||||
|
DISPLAY->SetLightDirectional(
|
||||||
|
0,
|
||||||
|
RageColor(0,0,0,0),
|
||||||
|
RageColor(1,1,1,1),
|
||||||
|
RageColor(0,0,0,1),
|
||||||
|
RageVector3(0, -1, 0) );
|
||||||
|
|
||||||
|
Screen::DrawPrimitives();
|
||||||
|
|
||||||
|
DISPLAY->SetLightOff( 0 );
|
||||||
|
DISPLAY->EnableLighting( false );
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenSandbox::MenuLeft( PlayerNumber pn )
|
void ScreenSandbox::MenuLeft( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
m_In.Load( THEME->GetPathToB("_menu in") );
|
m_In.Load( THEME->GetPathToB("_menu in") );
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ public:
|
|||||||
|
|
||||||
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
|
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
|
||||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||||
|
virtual void Update(float f);
|
||||||
|
virtual void DrawPrimitives();
|
||||||
|
|
||||||
void MenuLeft( PlayerNumber pn );
|
void MenuLeft( PlayerNumber pn );
|
||||||
void MenuRight( PlayerNumber pn );
|
void MenuRight( PlayerNumber pn );
|
||||||
|
|
||||||
void Update(float f);
|
|
||||||
Model m_model;
|
Model m_model;
|
||||||
Quad m_quad;
|
Quad m_quad;
|
||||||
Transition m_In;
|
Transition m_In;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ IntDir=.\../Release6
|
|||||||
TargetDir=\stepmania\stepmania
|
TargetDir=\stepmania\stepmania
|
||||||
TargetName=StepMania
|
TargetName=StepMania
|
||||||
SOURCE="$(InputPath)"
|
SOURCE="$(InputPath)"
|
||||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
|
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
|
||||||
# End Special Build Tool
|
# End Special Build Tool
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ IntDir=.\../Debug6
|
|||||||
TargetDir=\stepmania\stepmania
|
TargetDir=\stepmania\stepmania
|
||||||
TargetName=StepMania-debug
|
TargetName=StepMania-debug
|
||||||
SOURCE="$(InputPath)"
|
SOURCE="$(InputPath)"
|
||||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
|
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
|
||||||
# End Special Build Tool
|
# End Special Build Tool
|
||||||
|
|
||||||
@@ -1008,10 +1008,6 @@ SOURCE=.\mathlib.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\Milkshape.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\Model.cpp
|
SOURCE=.\Model.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -1020,6 +1016,14 @@ SOURCE=.\Model.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ModelTypes.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ModelTypes.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\Quad.h
|
SOURCE=.\Quad.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -2029,6 +2033,10 @@ SOURCE=.\ScreenTitleMenu.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ScreenUnlock.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\ScreenUnlock.h
|
SOURCE=.\ScreenUnlock.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -2139,6 +2147,14 @@ SOURCE=.\ThemeManager.cpp
|
|||||||
|
|
||||||
SOURCE=.\ThemeManager.h
|
SOURCE=.\ThemeManager.h
|
||||||
# End Source File
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\UnlockSystem.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\UnlockSystem.h
|
||||||
|
# End Source File
|
||||||
# End Group
|
# End Group
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ try_element_again:
|
|||||||
static const char *masks[NUM_ELEMENT_CATEGORIES][12] = {
|
static const char *masks[NUM_ELEMENT_CATEGORIES][12] = {
|
||||||
{ "", NULL },
|
{ "", NULL },
|
||||||
{ "*.ini", NULL },
|
{ "*.ini", NULL },
|
||||||
{"*.sprite", "*.png", "*.jpg", "*.bmp", "*.gif","*.avi", "*.mpg", "*.mpeg", NULL},
|
{ "*.model", "*.sprite", "*.png", "*.jpg", "*.bmp", "*.gif","*.avi", "*.mpg", "*.mpeg", NULL},
|
||||||
{ "*.png", NULL },
|
{ "*.png", NULL },
|
||||||
{ ".set", ".mp3", ".ogg", ".wav", NULL },
|
{ ".set", ".mp3", ".ogg", ".wav", NULL },
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user