From f9ff8d49fb4f352e661ba809051dfbb2d6d3f95b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 9 Jul 2003 01:34:48 +0000 Subject: [PATCH] Z-buffer for effects on the Z axis. --- stepmania/src/ArrowEffects.cpp | 17 ++++++++++++++++- stepmania/src/ArrowEffects.h | 3 +++ stepmania/src/NoteDisplay.cpp | 10 ++++++---- stepmania/src/PlayerOptions.cpp | 2 ++ stepmania/src/PlayerOptions.h | 1 + 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/stepmania/src/ArrowEffects.cpp b/stepmania/src/ArrowEffects.cpp index b0fc1967f4..01549f8c8c 100644 --- a/stepmania/src/ArrowEffects.cpp +++ b/stepmania/src/ArrowEffects.cpp @@ -238,5 +238,20 @@ float ArrowGetBrightness( PlayerNumber pn, float fNoteBeat ) float ArrowGetZPos( PlayerNumber pn, int iCol, float fYPos ) { - return 0; + float fZPos=0; + const float* fEffects = GAMESTATE->m_CurrentPlayerOptions[pn].m_fEffects; + + if( fEffects[PlayerOptions::EFFECT_BUMPY] > 0 ) + fZPos += fEffects[PlayerOptions::EFFECT_BUMPY] * 40*sinf( fYPos/16.0f ); + + return fZPos; +} + +bool ArrowsNeedZBuffer( PlayerNumber pn ) +{ + const float* fEffects = GAMESTATE->m_CurrentPlayerOptions[pn].m_fEffects; + if( fEffects[PlayerOptions::EFFECT_BUMPY] > 0 ) + return true; + + return false; } diff --git a/stepmania/src/ArrowEffects.h b/stepmania/src/ArrowEffects.h index 67d2915936..79f58795ba 100644 --- a/stepmania/src/ArrowEffects.h +++ b/stepmania/src/ArrowEffects.h @@ -44,8 +44,11 @@ float ArrowGetYPos( PlayerNumber pn, float fYOffset ); // fYPos (in the case of EFFECT_DRUNK). float ArrowGetXPos( PlayerNumber pn, int iCol, float fYPos ); +// Z position; normally 0. Only visible in perspective modes. float ArrowGetZPos( PlayerNumber pn, int iCol, float fYPos ); +// Enable this if any ZPos effects are enabled. +bool ArrowsNeedZBuffer( PlayerNumber pn ); // fAlpha is the transparency of the arrow. It depends on fYPos and the // AppearanceType. diff --git a/stepmania/src/NoteDisplay.cpp b/stepmania/src/NoteDisplay.cpp index b859278c43..588481304d 100644 --- a/stepmania/src/NoteDisplay.cpp +++ b/stepmania/src/NoteDisplay.cpp @@ -400,7 +400,9 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float const float fYTail = bReverse ? fStartYPos : fEndYPos; // the center the tail // const bool bWavy = GAMESTATE->m_PlayerOptions[m_PlayerNumber].m_fEffects[PlayerOptions::EFFECT_DRUNK] > 0; - const int fYStep = 16; //bWavy ? 16 : 128; // use small steps only if wavy + const bool WavyPartsNeedZBuffer = ArrowsNeedZBuffer( m_PlayerNumber ); + /* Hack: Z effects need a finer grain step. */ + const int fYStep = WavyPartsNeedZBuffer? 4: 16; //bWavy ? 16 : 128; // use small steps only if wavy const float fColorScale = 1*fLife + (1-fLife)*cache->m_fHoldNGGrayPercent; @@ -427,7 +429,7 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float DISPLAY->SetTexture( pTexture ); DISPLAY->SetBlendMode( BLEND_NORMAL ); DISPLAY->SetBackfaceCull( false ); - DISPLAY->SetZBuffer( false ); + DISPLAY->SetZBuffer( WavyPartsNeedZBuffer ); if( bDrawGlowOnly ) DISPLAY->SetTextureModeGlow(); else @@ -498,7 +500,7 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float DISPLAY->SetTexture( pTexture ); DISPLAY->SetBlendMode( BLEND_NORMAL ); DISPLAY->SetBackfaceCull( false ); - DISPLAY->SetZBuffer( false ); + DISPLAY->SetZBuffer( WavyPartsNeedZBuffer ); if( bDrawGlowOnly ) DISPLAY->SetTextureModeGlow(); else @@ -582,7 +584,7 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float DISPLAY->SetTexture( pTexture ); DISPLAY->SetBlendMode( BLEND_NORMAL ); DISPLAY->SetBackfaceCull( false ); - DISPLAY->SetZBuffer( false ); + DISPLAY->SetZBuffer( WavyPartsNeedZBuffer ); if( bDrawGlowOnly ) DISPLAY->SetTextureModeGlow(); else diff --git a/stepmania/src/PlayerOptions.cpp b/stepmania/src/PlayerOptions.cpp index b000f4335f..2be9c368a8 100644 --- a/stepmania/src/PlayerOptions.cpp +++ b/stepmania/src/PlayerOptions.cpp @@ -92,6 +92,7 @@ CString PlayerOptions::GetString() if( m_fEffects[EFFECT_MINI]==1 ) sReturn += "Mini, "; if( m_fEffects[EFFECT_FLIP]==1 ) sReturn += "Flip, "; if( m_fEffects[EFFECT_TORNADO]==1 ) sReturn += "Tornado, "; + if( m_fEffects[EFFECT_BUMPY]==1 ) sReturn += "Bumpy, "; if( m_fAppearances[APPEARANCE_HIDDEN]==1 ) sReturn += "Hidden, "; if( m_fAppearances[APPEARANCE_SUDDEN]==1 ) sReturn += "Sudden, "; @@ -184,6 +185,7 @@ void PlayerOptions::FromString( CString sOptions ) else if( sBit == "mini" ) m_fEffects[EFFECT_MINI] = 1; else if( sBit == "flip" ) m_fEffects[EFFECT_FLIP] = 1; else if( sBit == "tornado" ) m_fEffects[EFFECT_TORNADO] = 1; + else if( sBit == "bumpy" ) m_fEffects[EFFECT_BUMPY] = 1; else if( sBit == "hidden" ) m_fAppearances[APPEARANCE_HIDDEN] = 1; else if( sBit == "sudden" ) m_fAppearances[APPEARANCE_SUDDEN] = 1; else if( sBit == "stealth" ) m_fAppearances[APPEARANCE_STEALTH] = 1; diff --git a/stepmania/src/PlayerOptions.h b/stepmania/src/PlayerOptions.h index 16700f5cc1..bdb12115ad 100644 --- a/stepmania/src/PlayerOptions.h +++ b/stepmania/src/PlayerOptions.h @@ -35,6 +35,7 @@ struct PlayerOptions EFFECT_MINI, EFFECT_FLIP, EFFECT_TORNADO, + EFFECT_BUMPY, NUM_EFFECTS }; enum Appearance {