update NFP
This commit is contained in:
@@ -14,108 +14,45 @@
|
|||||||
#include "GameDef.h"
|
#include "GameDef.h"
|
||||||
|
|
||||||
|
|
||||||
/* This is similar in style to Actor::Command. However, Actors don't store
|
|
||||||
* matrix stacks; they only store offsets and scales, and compound them into
|
|
||||||
* a single transformations at once. This makes some things easy, but it's not
|
|
||||||
* convenient for generic 3d transforms. For that, we have this, which has the
|
|
||||||
* small subset of the actor commands that applies to raw matrices, and we apply
|
|
||||||
* commands in the order given. "scale,2;x,1;" is very different from
|
|
||||||
* "x,1;scale,2;". */
|
|
||||||
static CString GetParam( const CStringArray& sParams, int iIndex, int& iMaxIndexAccessed )
|
|
||||||
{
|
|
||||||
iMaxIndexAccessed = max( iIndex, iMaxIndexAccessed );
|
|
||||||
if( iIndex < int(sParams.size()) )
|
|
||||||
return sParams[iIndex];
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void MatrixCommand(CString sCommandString, RageMatrix &mat)
|
|
||||||
{
|
|
||||||
CStringArray asCommands;
|
|
||||||
split( sCommandString, ";", asCommands, true );
|
|
||||||
|
|
||||||
for( unsigned c=0; c<asCommands.size(); c++ )
|
|
||||||
{
|
|
||||||
CStringArray asTokens;
|
|
||||||
split( asCommands[c], ",", asTokens, true );
|
|
||||||
|
|
||||||
int iMaxIndexAccessed = 0;
|
|
||||||
|
|
||||||
#define sParam(i) (GetParam(asTokens,i,iMaxIndexAccessed))
|
|
||||||
#define fParam(i) ((float)atof(sParam(i)))
|
|
||||||
#define iParam(i) (atoi(sParam(i)))
|
|
||||||
#define bParam(i) (iParam(i)!=0)
|
|
||||||
|
|
||||||
CString& sName = asTokens[0];
|
|
||||||
sName.MakeLower();
|
|
||||||
|
|
||||||
RageMatrix b;
|
|
||||||
// Act on command
|
|
||||||
if( sName=="x" ) RageMatrixTranslation( &b, fParam(1),0,0 );
|
|
||||||
else if( sName=="y" ) RageMatrixTranslation( &b, 0,fParam(1),0 );
|
|
||||||
else if( sName=="z" ) RageMatrixTranslation( &b, 0,0,fParam(1) );
|
|
||||||
else if( sName=="zoomx" ) RageMatrixScaling(&b, fParam(1),1,1 );
|
|
||||||
else if( sName=="zoomy" ) RageMatrixScaling(&b, 1,fParam(1),1 );
|
|
||||||
else if( sName=="zoomz" ) RageMatrixScaling(&b, 1,1,fParam(1) );
|
|
||||||
else if( sName=="rotationx" ) RageMatrixRotationX( &b, fParam(1) );
|
|
||||||
else if( sName=="rotationy" ) RageMatrixRotationY( &b, fParam(1) );
|
|
||||||
else if( sName=="rotationz" ) RageMatrixRotationZ( &b, fParam(1) );
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CString sError = ssprintf( "Unrecognized matrix command name '%s' in command string '%s'.", sName.GetString(), sCommandString.GetString() );
|
|
||||||
LOG->Warn( sError );
|
|
||||||
#if defined(WIN32) // XXX arch?
|
|
||||||
if( DISPLAY->IsWindowed() )
|
|
||||||
MessageBox(NULL, sError, "MatrixCommand", MB_OK);
|
|
||||||
#endif
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( iMaxIndexAccessed != (int)asTokens.size()-1 )
|
|
||||||
{
|
|
||||||
CString sError = ssprintf( "Wrong number of parameters in command '%s'. Expected %d but there are %d.", join(",",asTokens).GetString(), iMaxIndexAccessed+1, (int)asTokens.size() );
|
|
||||||
LOG->Warn( sError );
|
|
||||||
#if defined(WIN32) // XXX arch?
|
|
||||||
if( DISPLAY->IsWindowed() )
|
|
||||||
MessageBox(NULL, sError, "MatrixCommand", MB_OK);
|
|
||||||
#endif
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
RageMatrix a(mat);
|
|
||||||
RageMatrixMultiply(&mat, &a, &b);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
NoteFieldPositioning::Mode::Mode()
|
NoteFieldPositioning::Mode::Mode()
|
||||||
{
|
{
|
||||||
for( int tn=0; tn<MAX_NOTE_TRACKS; tn++ )
|
m_fFov = 0;
|
||||||
{
|
|
||||||
RageMatrixIdentity(&m_Position[tn]);
|
|
||||||
RageMatrixIdentity(&m_PerspPosition[tn]);
|
|
||||||
m_fFov[tn] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NoteFieldPositioning::Mode::BeginDrawTrack(int tn) const
|
void NoteFieldPositioning::Mode::BeginDrawTrack(int tn)
|
||||||
{
|
{
|
||||||
DISPLAY->MultMatrix((const float *) m_Position[tn]);
|
/* It's useful to be able to use Actors like this, functioning only
|
||||||
|
* for a transformation. However, this is a big waste of matrix
|
||||||
|
* stack space, as each of these will push. Profile this. XXX */
|
||||||
|
m_Center.BeginDraw();
|
||||||
|
if(tn != -1)
|
||||||
|
m_CenterTrack[tn].BeginDraw();
|
||||||
|
|
||||||
if(m_fFov[tn])
|
if(m_fFov)
|
||||||
DISPLAY->EnterPerspective(m_fFov[tn]);
|
DISPLAY->EnterPerspective(m_fFov);
|
||||||
|
|
||||||
DISPLAY->MultMatrix((const float *) m_PerspPosition[tn]);
|
m_Position.BeginDraw();
|
||||||
|
if(tn == -1)
|
||||||
|
m_PositionBackdrop.BeginDraw();
|
||||||
|
else
|
||||||
|
m_PositionTrack[tn].BeginDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NoteFieldPositioning::Mode::EndDrawTrack(int tn) const
|
void NoteFieldPositioning::Mode::EndDrawTrack(int tn)
|
||||||
{
|
{
|
||||||
if(m_fFov[tn])
|
if(tn == -1)
|
||||||
|
m_PositionBackdrop.EndDraw();
|
||||||
|
else
|
||||||
|
m_PositionTrack[tn].EndDraw();
|
||||||
|
m_Position.EndDraw();
|
||||||
|
|
||||||
|
if(m_fFov)
|
||||||
DISPLAY->ExitPerspective();
|
DISPLAY->ExitPerspective();
|
||||||
}
|
|
||||||
|
|
||||||
|
if(tn != -1)
|
||||||
|
m_CenterTrack[tn].EndDraw();
|
||||||
|
m_Center.EndDraw();
|
||||||
|
}
|
||||||
|
|
||||||
NoteFieldPositioning::NoteFieldPositioning(CString fn)
|
NoteFieldPositioning::NoteFieldPositioning(CString fn)
|
||||||
{
|
{
|
||||||
@@ -128,24 +65,40 @@ NoteFieldPositioning::NoteFieldPositioning(CString fn)
|
|||||||
Mode m;
|
Mode m;
|
||||||
|
|
||||||
const IniFile::key &k = i->second;
|
const IniFile::key &k = i->second;
|
||||||
for(int t = 0; t < MAX_NOTE_TRACKS; ++t)
|
|
||||||
{
|
|
||||||
IniFile::key::const_iterator val;
|
IniFile::key::const_iterator val;
|
||||||
|
|
||||||
val = k.find("Name");
|
val = k.find("Name");
|
||||||
ASSERT(val != k.end()); /* required */
|
ASSERT(val != k.end()); /* required */
|
||||||
m.name = val->second;
|
m.name = val->second;
|
||||||
|
|
||||||
val = k.find(ssprintf("Track%i", t+1));
|
val = k.find("Backdrop");
|
||||||
if(val != k.end())
|
if(val != k.end())
|
||||||
MatrixCommand(val->second, m.m_Position[t]);
|
m.Backdrop = val->second;
|
||||||
val = k.find(ssprintf("PTrack%i", t+1));
|
|
||||||
if(val != k.end())
|
|
||||||
MatrixCommand(val->second, m.m_PerspPosition[t]);
|
|
||||||
|
|
||||||
val = k.find(ssprintf("FOV%i", t+1));
|
val = k.find("Center");
|
||||||
if(val != k.end())
|
if(val != k.end())
|
||||||
m.m_fFov[t] = float(atof(val->second.c_str()));
|
m.m_Center.Command(val->second);
|
||||||
|
|
||||||
|
val = k.find("FOV");
|
||||||
|
if(val != k.end())
|
||||||
|
m.m_fFov = float(atof(val->second.c_str()));
|
||||||
|
|
||||||
|
val = k.find("Position");
|
||||||
|
if(val != k.end())
|
||||||
|
m.m_Position.Command(val->second);
|
||||||
|
|
||||||
|
val = k.find("BackdropPosition");
|
||||||
|
if(val != k.end())
|
||||||
|
m.m_PositionBackdrop.Command(val->second);
|
||||||
|
|
||||||
|
for(int t = 0; t < MAX_NOTE_TRACKS; ++t)
|
||||||
|
{
|
||||||
|
val = k.find(ssprintf("Center%i", t+1));
|
||||||
|
if(val != k.end())
|
||||||
|
m.m_CenterTrack[t].Command(val->second);
|
||||||
|
val = k.find(ssprintf("Position%i", t+1));
|
||||||
|
if(val != k.end())
|
||||||
|
m.m_PositionTrack[t].Command(val->second);
|
||||||
|
|
||||||
CString sGames;
|
CString sGames;
|
||||||
val = k.find("Games");
|
val = k.find("Games");
|
||||||
@@ -222,8 +175,37 @@ void NoteFieldPositioning::GetNamesForCurrentGame(vector<CString> &IDs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* XXX: Lots of GetID calls, which do a bunch of string compares; profile this. */
|
||||||
|
CString NoteFieldPositioning::GetBackdropBGA(PlayerNumber pn) const
|
||||||
|
{
|
||||||
|
const int mode = GetID(pn);
|
||||||
|
if(mode == -1)
|
||||||
|
return ""; /* none */
|
||||||
|
LOG->Trace("bd %s", Modes[mode].Backdrop.c_str() );
|
||||||
|
return Modes[mode].Backdrop;
|
||||||
|
}
|
||||||
|
|
||||||
void NoteFieldPositioning::BeginDrawTrack(PlayerNumber pn, int tn) const
|
void NoteFieldPositioning::BeginDrawBackdrop(PlayerNumber pn)
|
||||||
|
{
|
||||||
|
const int mode = GetID(pn);
|
||||||
|
if(mode == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DISPLAY->PushMatrix();
|
||||||
|
Modes[mode].BeginDrawTrack(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoteFieldPositioning::EndDrawBackdrop(PlayerNumber pn)
|
||||||
|
{
|
||||||
|
const int mode = GetID(pn);
|
||||||
|
if(mode == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Modes[mode].EndDrawTrack(-1);
|
||||||
|
DISPLAY->PopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoteFieldPositioning::BeginDrawTrack(PlayerNumber pn, int tn)
|
||||||
{
|
{
|
||||||
const int mode = GetID(pn);
|
const int mode = GetID(pn);
|
||||||
|
|
||||||
@@ -241,7 +223,7 @@ void NoteFieldPositioning::BeginDrawTrack(PlayerNumber pn, int tn) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NoteFieldPositioning::EndDrawTrack(PlayerNumber pn, int tn) const
|
void NoteFieldPositioning::EndDrawTrack(PlayerNumber pn, int tn)
|
||||||
{
|
{
|
||||||
const int mode = GetID(pn);
|
const int mode = GetID(pn);
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#ifndef NOTEFIELD_POSITIONING_H
|
#ifndef NOTEFIELD_POSITIONING_H
|
||||||
#define NOTEFIELD_POSITIONING_H
|
#define NOTEFIELD_POSITIONING_H
|
||||||
|
|
||||||
#include "RageMath.h"
|
|
||||||
#include "PlayerNumber.h"
|
#include "PlayerNumber.h"
|
||||||
#include "StyleDef.h"
|
#include "StyleDef.h"
|
||||||
#include "PlayerNumber.h"
|
#include "PlayerNumber.h"
|
||||||
#include "Style.h"
|
#include "Style.h"
|
||||||
|
#include "Actor.h"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
@@ -16,16 +16,22 @@ class NoteFieldPositioning
|
|||||||
Mode();
|
Mode();
|
||||||
bool MatchesCurrentGame() const;
|
bool MatchesCurrentGame() const;
|
||||||
|
|
||||||
void BeginDrawTrack(int tn) const;
|
void BeginDrawTrack(int tn);
|
||||||
void EndDrawTrack(int tn) const;
|
void EndDrawTrack(int tn);
|
||||||
|
|
||||||
CString name;
|
CString name;
|
||||||
set<Style> Styles;
|
set<Style> Styles;
|
||||||
|
|
||||||
RageMatrix m_Position[MAX_NOTE_TRACKS];
|
Actor m_Center;
|
||||||
|
Actor m_CenterTrack[MAX_NOTE_TRACKS];
|
||||||
|
|
||||||
/* 0 = no perspective */
|
/* 0 = no perspective */
|
||||||
float m_fFov[MAX_NOTE_TRACKS];
|
float m_fFov;
|
||||||
RageMatrix m_PerspPosition[MAX_NOTE_TRACKS];
|
Actor m_Position;
|
||||||
|
Actor m_PositionTrack[MAX_NOTE_TRACKS];
|
||||||
|
|
||||||
|
CString Backdrop;
|
||||||
|
Actor m_PositionBackdrop;
|
||||||
};
|
};
|
||||||
|
|
||||||
vector<Mode> Modes;
|
vector<Mode> Modes;
|
||||||
@@ -38,8 +44,12 @@ public:
|
|||||||
int GetID(const CString &name) const;
|
int GetID(const CString &name) const;
|
||||||
int GetID(PlayerNumber pn) const;
|
int GetID(PlayerNumber pn) const;
|
||||||
|
|
||||||
void BeginDrawTrack(PlayerNumber pn, int tn) const;
|
void BeginDrawTrack(PlayerNumber pn, int tn);
|
||||||
void EndDrawTrack(PlayerNumber pn, int tn) const;
|
void EndDrawTrack(PlayerNumber pn, int tn);
|
||||||
|
|
||||||
|
CString GetBackdropBGA(PlayerNumber pn) const;
|
||||||
|
void BeginDrawBackdrop(PlayerNumber pn);
|
||||||
|
void EndDrawBackdrop(PlayerNumber pn);
|
||||||
|
|
||||||
void GetNamesForCurrentGame(vector<CString> &IDs);
|
void GetNamesForCurrentGame(vector<CString> &IDs);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user