add twirl and roll mods from OpenITG [original code by vyhd]

This commit is contained in:
AJ Kelly
2010-08-21 14:17:52 -05:00
parent b2714eec9e
commit dc394b8569
7 changed files with 89 additions and 35 deletions
+29 -4
View File
@@ -424,12 +424,34 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
return fPixelOffsetFromCenter; return fPixelOffsetFromCenter;
} }
float ArrowEffects::GetRotation( const PlayerState* pPlayerState, float fNoteBeat, bool bIsHoldHead ) float ArrowEffects::GetRotationX( const PlayerState *pPlayerState, float fYOffset )
{
const float* fEffects = pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects;
float fRotation = 0;
if( fEffects[PlayerOptions::EFFECT_ROLL] != 0 )
{
fRotation = fEffects[PlayerOptions::EFFECT_ROLL] * fYOffset/2;
}
return fRotation;
}
float ArrowEffects::GetRotationY( const PlayerState *pPlayerState, float fYOffset )
{
const float* fEffects = pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects;
float fRotation = 0;
if( fEffects[PlayerOptions::EFFECT_TWIRL] != 0 )
{
fRotation = fEffects[PlayerOptions::EFFECT_TWIRL] * fYOffset/2;
}
return fRotation;
}
float ArrowEffects::GetRotationZ( const PlayerState* pPlayerState, float fNoteBeat, bool bIsHoldHead )
{ {
const float* fEffects = pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects; const float* fEffects = pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects;
float fRotation = 0; float fRotation = 0;
if( fEffects[PlayerOptions::EFFECT_CONFUSION] != 0 ) if( fEffects[PlayerOptions::EFFECT_CONFUSION] != 0 )
fRotation += ReceptorGetRotation( pPlayerState ); fRotation += ReceptorGetRotationZ( pPlayerState );
// Doesn't affect hold heads, unlike confusion // Doesn't affect hold heads, unlike confusion
if( fEffects[PlayerOptions::EFFECT_DIZZY] != 0 && !bIsHoldHead ) if( fEffects[PlayerOptions::EFFECT_DIZZY] != 0 && !bIsHoldHead )
@@ -444,7 +466,7 @@ float ArrowEffects::GetRotation( const PlayerState* pPlayerState, float fNoteBea
return fRotation; return fRotation;
} }
float ArrowEffects::ReceptorGetRotation( const PlayerState* pPlayerState ) float ArrowEffects::ReceptorGetRotationZ( const PlayerState* pPlayerState )
{ {
const float* fEffects = pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects; const float* fEffects = pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects;
float fRotation = 0; float fRotation = 0;
@@ -626,7 +648,10 @@ float ArrowEffects::GetZPos( const PlayerState* pPlayerState, int iCol, float fY
bool ArrowEffects::NeedZBuffer( const PlayerState* pPlayerState ) bool ArrowEffects::NeedZBuffer( const PlayerState* pPlayerState )
{ {
const float* fEffects = pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects; const float* fEffects = pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects;
if( fEffects[PlayerOptions::EFFECT_BUMPY] != 0 ) // We also need to use the Z buffer if twirl is in play, because of
// hold modulation. -vyhd (OpenITG r623)
if( fEffects[PlayerOptions::EFFECT_BUMPY] != 0 ||
fEffects[PlayerOptions::EFFECT_TWIRL] != 0 )
return true; return true;
return false; return false;
+6 -2
View File
@@ -31,9 +31,13 @@ public:
// fRotation is Z rotation of an arrow. This will depend on the column of // fRotation is Z rotation of an arrow. This will depend on the column of
// the arrow and possibly the Arrow effect and the fYOffset (in the case of // the arrow and possibly the Arrow effect and the fYOffset (in the case of
// EFFECT_DIZZY). // EFFECT_DIZZY).
static float GetRotation( const PlayerState* pPlayerState, float fNoteBeat, bool bIsHoldHead ); static float GetRotationZ( const PlayerState* pPlayerState, float fNoteBeat, bool bIsHoldHead );
static float ReceptorGetRotation( const PlayerState* pPlayerState ); static float ReceptorGetRotationZ( const PlayerState* pPlayerState );
// Due to the handling logic for holds on Twirl, we need to use an offset instead.
// It's more intuitive for Roll to be based off offset, so use an offset there too.
static float GetRotationX( const PlayerState* pPlayerState, float fYOffset );
static float GetRotationY( const PlayerState *pPlayerState, float fYOffset );
// fXPos is a horizontal position in pixels relative to the center of the field. // fXPos is a horizontal position in pixels relative to the center of the field.
// This depends on the column of the arrow and possibly the Arrow effect and // This depends on the column of the arrow and possibly the Arrow effect and
+1 -1
View File
@@ -51,7 +51,7 @@ void GhostArrowRow::Update( float fDeltaTime )
m_Ghost[c]->SetY( fY ); m_Ghost[c]->SetY( fY );
m_Ghost[c]->SetZ( fZ ); m_Ghost[c]->SetZ( fZ );
const float fRotation = ArrowEffects::ReceptorGetRotation( m_pPlayerState ); const float fRotation = ArrowEffects::ReceptorGetRotationZ( m_pPlayerState );
m_Ghost[c]->SetRotationZ( fRotation ); m_Ghost[c]->SetRotationZ( fRotation );
const float fZoom = ArrowEffects::GetZoom( m_pPlayerState ); const float fZoom = ArrowEffects::GetZoom( m_pPlayerState );
+24 -5
View File
@@ -12,6 +12,7 @@
#include "NoteTypes.h" #include "NoteTypes.h"
#include "LuaBinding.h" #include "LuaBinding.h"
#include "Foreach.h" #include "Foreach.h"
#include "RageMath.h"
const RString& NoteNotePartToString( NotePart i ); const RString& NoteNotePartToString( NotePart i );
#define FOREACH_NotePart( i ) FOREACH_ENUM( NotePart, i ) #define FOREACH_NotePart( i ) FOREACH_ENUM( NotePart, i )
@@ -444,9 +445,21 @@ void NoteDisplay::DrawHoldPart( vector<Sprite*> &vpSpr, int iCol, int fYStep, fl
float fX = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset ); float fX = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset );
const float fXLeft = fX - fScaledFrameWidth/2; // XXX: Actor rotations use degrees, RageFastCos/Sin use radians. Convert here.
const float fRotationY = ArrowEffects::GetRotationY( m_pPlayerState, fYOffset ) * PI/180;
// if we're rotating, we need to modify the X and Z coords for the outer edges.
const float fRotOffsetX = fFrameWidth/2 * RageFastCos(fRotationY);
const float fRotOffsetZ = fFrameWidth/2 * RageFastSin(fRotationY);
//const float fXLeft = fX - (fScaledFrameWidth/2);
const float fXLeft = fX - fRotOffsetX;
const float fXCenter = fX; const float fXCenter = fX;
const float fXRight = fX + fScaledFrameWidth/2; //const float fXRight = fX + (fScaledFrameWidth/2);
const float fXRight = fX + fRotOffsetX;
const float fZLeft = fZ - fRotOffsetZ;
const float fZRight = fZ + fRotOffsetZ;
const float fDistFromTop = fY - fYTop; const float fDistFromTop = fY - fYTop;
float fTexCoordTop = SCALE( fDistFromTop, 0, fFrameHeight, rect.top, rect.bottom ); float fTexCoordTop = SCALE( fDistFromTop, 0, fFrameHeight, rect.top, rect.bottom );
fTexCoordTop += fAddToTexCoord; fTexCoordTop += fAddToTexCoord;
@@ -457,9 +470,9 @@ void NoteDisplay::DrawHoldPart( vector<Sprite*> &vpSpr, int iCol, int fYStep, fl
if( fAlpha > 0 ) if( fAlpha > 0 )
bAllAreTransparent = false; bAllAreTransparent = false;
queue.v[0].p = RageVector3(fXLeft, fY, fZ); queue.v[0].c = color; queue.v[0].t = RageVector2(fTexCoordLeft, fTexCoordTop); queue.v[0].p = RageVector3(fXLeft, fY, fZLeft); queue.v[0].c = color; queue.v[0].t = RageVector2(fTexCoordLeft, fTexCoordTop);
queue.v[1].p = RageVector3(fXCenter, fY, fZ); queue.v[1].c = color; queue.v[1].t = RageVector2(fTexCoordCenter, fTexCoordTop); queue.v[1].p = RageVector3(fXCenter, fY, fZ); queue.v[1].c = color; queue.v[1].t = RageVector2(fTexCoordCenter, fTexCoordTop);
queue.v[2].p = RageVector3(fXRight, fY, fZ); queue.v[2].c = color; queue.v[2].t = RageVector2(fTexCoordRight, fTexCoordTop); queue.v[2].p = RageVector3(fXRight, fY, fZRight); queue.v[2].c = color; queue.v[2].t = RageVector2(fTexCoordRight, fTexCoordTop);
queue.v+=3; queue.v+=3;
if( queue.Free() < 3 || bLast ) if( queue.Free() < 3 || bLast )
@@ -666,12 +679,18 @@ void NoteDisplay::DrawActor( const TapNote& tn, Actor* pActor, NotePart part, in
const float fGlow = ArrowEffects::GetGlow( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar ); const float fGlow = ArrowEffects::GetGlow( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar );
const RageColor diffuse = RageColor(fColorScale,fColorScale,fColorScale,fAlpha); const RageColor diffuse = RageColor(fColorScale,fColorScale,fColorScale,fAlpha);
const RageColor glow = RageColor(1,1,1,fGlow); const RageColor glow = RageColor(1,1,1,fGlow);
float fRotationX = 0;
float fRotationY = 0;
float fRotationZ = 0; float fRotationZ = 0;
fRotationZ = ArrowEffects::GetRotation( m_pPlayerState, fBeat, tn.type == tn.hold_head ); fRotationX = ArrowEffects::GetRotationX( m_pPlayerState, fYOffset );
fRotationY = ArrowEffects::GetRotationY( m_pPlayerState, fYOffset );
fRotationZ = ArrowEffects::GetRotationZ( m_pPlayerState, fBeat, tn.type == tn.hold_head );
if( tn.type != tn.hold_head ) if( tn.type != tn.hold_head )
fColorScale *= ArrowEffects::GetBrightness( m_pPlayerState, fBeat ); fColorScale *= ArrowEffects::GetBrightness( m_pPlayerState, fBeat );
pActor->SetRotationX( fRotationX );
pActor->SetRotationY( fRotationY );
pActor->SetRotationZ( fRotationZ ); pActor->SetRotationZ( fRotationZ );
pActor->SetXY( fX, fY ); pActor->SetXY( fX, fY );
pActor->SetZ( fZ ); pActor->SetZ( fZ );
+5 -1
View File
@@ -105,7 +105,7 @@ RString PlayerOptions::GetString( bool bForceNoteSkin ) const
void PlayerOptions::GetMods( vector<RString> &AddTo, bool bForceNoteSkin ) const void PlayerOptions::GetMods( vector<RString> &AddTo, bool bForceNoteSkin ) const
{ {
RString sReturn; //RString sReturn;
if( !m_fTimeSpacing ) if( !m_fTimeSpacing )
{ {
@@ -150,6 +150,8 @@ void PlayerOptions::GetMods( vector<RString> &AddTo, bool bForceNoteSkin ) const
AddPart( AddTo, m_fEffects[EFFECT_BUMPY], "Bumpy" ); AddPart( AddTo, m_fEffects[EFFECT_BUMPY], "Bumpy" );
AddPart( AddTo, m_fEffects[EFFECT_BEAT], "Beat" ); AddPart( AddTo, m_fEffects[EFFECT_BEAT], "Beat" );
AddPart( AddTo, m_fEffects[EFFECT_XMODE], "XMode" ); AddPart( AddTo, m_fEffects[EFFECT_XMODE], "XMode" );
AddPart( AddTo, m_fEffects[EFFECT_TWIRL], "Twirl" );
AddPart( AddTo, m_fEffects[EFFECT_ROLL], "Roll" );
AddPart( AddTo, m_fAppearances[APPEARANCE_HIDDEN], "Hidden" ); AddPart( AddTo, m_fAppearances[APPEARANCE_HIDDEN], "Hidden" );
AddPart( AddTo, m_fAppearances[APPEARANCE_HIDDEN_OFFSET], "HiddenOffset" ); AddPart( AddTo, m_fAppearances[APPEARANCE_HIDDEN_OFFSET], "HiddenOffset" );
@@ -355,6 +357,8 @@ bool PlayerOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut
else if( sBit == "bumpy" ) SET_FLOAT( fEffects[EFFECT_BUMPY] ) else if( sBit == "bumpy" ) SET_FLOAT( fEffects[EFFECT_BUMPY] )
else if( sBit == "beat" ) SET_FLOAT( fEffects[EFFECT_BEAT] ) else if( sBit == "beat" ) SET_FLOAT( fEffects[EFFECT_BEAT] )
else if( sBit == "xmode" ) SET_FLOAT( fEffects[EFFECT_XMODE] ) else if( sBit == "xmode" ) SET_FLOAT( fEffects[EFFECT_XMODE] )
else if( sBit == "twirl" ) SET_FLOAT( fEffects[EFFECT_TWIRL] )
else if( sBit == "roll" ) SET_FLOAT( fEffects[EFFECT_ROLL] )
else if( sBit == "hidden" ) SET_FLOAT( fAppearances[APPEARANCE_HIDDEN] ) else if( sBit == "hidden" ) SET_FLOAT( fAppearances[APPEARANCE_HIDDEN] )
else if( sBit == "hiddenoffset" ) SET_FLOAT( fAppearances[APPEARANCE_HIDDEN_OFFSET] ) else if( sBit == "hiddenoffset" ) SET_FLOAT( fAppearances[APPEARANCE_HIDDEN_OFFSET] )
else if( sBit == "sudden" ) SET_FLOAT( fAppearances[APPEARANCE_SUDDEN] ) else if( sBit == "sudden" ) SET_FLOAT( fAppearances[APPEARANCE_SUDDEN] )
+2
View File
@@ -59,6 +59,8 @@ public:
EFFECT_BUMPY, EFFECT_BUMPY,
EFFECT_BEAT, EFFECT_BEAT,
EFFECT_XMODE, EFFECT_XMODE,
EFFECT_TWIRL,
EFFECT_ROLL,
NUM_EFFECTS NUM_EFFECTS
}; };
enum Appearance { enum Appearance {
+1 -1
View File
@@ -56,7 +56,7 @@ void ReceptorArrowRow::Update( float fDeltaTime )
m_ReceptorArrow[c]->SetY( fY ); m_ReceptorArrow[c]->SetY( fY );
m_ReceptorArrow[c]->SetZ( fZ ); m_ReceptorArrow[c]->SetZ( fZ );
const float fRotation = ArrowEffects::ReceptorGetRotation( m_pPlayerState ); const float fRotation = ArrowEffects::ReceptorGetRotationZ( m_pPlayerState );
m_ReceptorArrow[c]->SetRotationZ( fRotation ); m_ReceptorArrow[c]->SetRotationZ( fRotation );
const float fZoom = ArrowEffects::GetZoom( m_pPlayerState ); const float fZoom = ArrowEffects::GetZoom( m_pPlayerState );