diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index b3088e92c8..e8774088d5 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -42,7 +42,7 @@ Actor::Actor() m_bShadow = false; m_fShadowLength = 4; - + m_bIsAnimating = true; m_bBlendAdd = false; } @@ -92,6 +92,15 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties m_temp.glow = m_effectColor1*fPercentBetweenColors + m_effectColor2*(1.0f-fPercentBetweenColors); m_temp.glow.a *= fOriginalAlpha; // don't glow if the Actor is transparent! break; + case rainbow: + m_temp.diffuse[0] = RageColor( + cosf( fPercentBetweenColors*2*PI ) * 0.5f + 0.5f, + cosf( fPercentBetweenColors*2*PI + PI * 2.0f / 3.0f ) * 0.5f + 0.5f, + cosf( fPercentBetweenColors*2*PI + PI * 4.0f / 3.0f) * 0.5f + 0.5f, + fOriginalAlpha ); + for( i=1; i<4; i++ ) + m_temp.diffuse[i] = m_temp.diffuse[0]; + break; case wag: m_temp.rotation = m_vEffectMagnitude * sinf( fPercentThroughEffect * 2.0f * PI ); break; @@ -119,7 +128,16 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties m_temp.pos.x = roundf( m_temp.pos.x ); m_temp.pos.y = roundf( m_temp.pos.y ); m_temp.pos.z = roundf( m_temp.pos.z ); - } + } + break; + case pulse: + { + float fMinZoom = m_vEffectMagnitude[0]; + float fMaxZoom = m_vEffectMagnitude[1]; + float fPercentOffset = sinf( fPercentThroughEffect*PI ); + float fZoom = SCALE( fPercentOffset, 0.f, 1.f, fMinZoom, fMaxZoom ); + m_temp.scale = RageVector3( fZoom, fZoom, fZoom ); + } break; default: ASSERT(0); // invalid Effect @@ -216,15 +234,17 @@ void Actor::Update( float fDeltaTime ) case diffuse_shift: case glow_blink: case glow_shift: + case rainbow: case wag: case bounce: case bob: + case pulse: m_fSecsIntoEffect += fDeltaTime; while( m_fSecsIntoEffect >= m_fEffectPeriodSeconds ) m_fSecsIntoEffect -= m_fEffectPeriodSeconds; break; case spin: - m_current.rotation += m_vEffectMagnitude; + m_current.rotation += fDeltaTime*m_vEffectMagnitude; if( m_current.rotation.x > PI*2 ) m_current.rotation.x -= PI*2; if( m_current.rotation.y > PI*2 ) m_current.rotation.y -= PI*2; if( m_current.rotation.z > PI*2 ) m_current.rotation.z -= PI*2; @@ -382,6 +402,13 @@ void Actor::SetEffectGlowShift( float fEffectPeriodSeconds, RageColor c1, RageCo m_fSecsIntoEffect = 0; } +void Actor::SetEffectRainbow( float fEffectPeriodSeconds ) +{ + m_Effect = rainbow; + m_fEffectPeriodSeconds = fEffectPeriodSeconds; + m_fSecsIntoEffect = 0; +} + void Actor::SetEffectWag( float fPeriod, RageVector3 vect ) { m_Effect = wag; @@ -418,6 +445,14 @@ void Actor::SetEffectVibrate( RageVector3 vect ) m_vEffectMagnitude = vect; } +void Actor::SetEffectPulse( float fPeriod, float fMinZoom, float fMaxZoom ) +{ + m_Effect = pulse; + m_fEffectPeriodSeconds = fPeriod; + m_vEffectMagnitude[0] = fMinZoom; + m_vEffectMagnitude[1] = fMaxZoom; +} + void Actor::Fade( float fSleepSeconds, CString sFadeString, float fFadeSeconds, bool bFadingOff ) { @@ -564,9 +599,11 @@ void Actor::Command( CString sCommandString ) else if( sName=="diffuseshift" ) SetEffectDiffuseShift(); else if( sName=="glowblink" ) SetEffectGlowBlink(); else if( sName=="glowshift" ) SetEffectGlowShift(); + else if( sName=="rainbow" ) SetEffectRainbow(); else if( sName=="wag" ) SetEffectWag(); else if( sName=="bounce" ) SetEffectBounce(); else if( sName=="bob" ) SetEffectBob(); + else if( sName=="pulse" ) SetEffectPulse(); else if( sName=="spin" ) SetEffectSpin(); else if( sName=="vibrate" ) SetEffectVibrate(); else if( sName=="stopeffect" ) SetEffectNone(); @@ -574,6 +611,8 @@ void Actor::Command( CString sCommandString ) else if( sName=="effectcolor2" ) SetEffectColor2( RageColor(fParam(0),fParam(1),fParam(2),fParam(3)) ); else if( sName=="effectperiod" ) SetEffectPeriod( fParam(0) ); else if( sName=="effectmagnitude" ) SetEffectMagnitude( RageVector3(fParam(0),fParam(1),fParam(2)) ); + else if( sName=="startanimating" ) this->StartAnimating(); + else if( sName=="stopanimating" ) this->StopAnimating(); else if( sName=="additiveblend" ) EnableAdditiveBlend( iParam(0)!=0 ); else { diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 6a6f7975b7..d41484da5d 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -31,8 +31,9 @@ public: enum Effect { no_effect, diffuse_blink, diffuse_shift, glow_blink, glow_shift, - wag, bounce, bob, - spin, vibrate, + rainbow, + wag, bounce, bob, pulse, + spin, vibrate }; struct TweenState @@ -224,6 +225,8 @@ public: float fEffectPeriodSeconds = 1.0f, RageColor c1 = RageColor(1,1,1,0.2f), RageColor c2 = RageColor(1,1,1,0.8f) ); + void SetEffectRainbow( + float fEffectPeriodSeconds = 2.0f ); void SetEffectWag( float fPeriod = 2.f, RageVector3 vect = RageVector3(0,0,0.2f) ); @@ -233,6 +236,10 @@ public: void SetEffectBob( float fPeriod = 2.f, RageVector3 vect = RageVector3(0,0,20) ); + void SetEffectPulse( + float fPeriod = 2.f, + float fMinZoom = 0.5f, + float fMaxZoom = 1.f ); void SetEffectSpin( RageVector3 vect = RageVector3(0,0,1) ); void SetEffectVibrate( @@ -252,11 +259,14 @@ public: m_bShadow = true; } } - void EnableShadow( bool b ) { m_bShadow = b; }; + void EnableShadow( bool b ) { m_bShadow = b; } - void EnableAdditiveBlend( bool b ) { m_bBlendAdd = b; }; - + virtual void EnableAdditiveBlend( bool b ) { m_bBlendAdd = b; } + + virtual void EnableAnimation( bool b ) { m_bIsAnimating = b; } + virtual void StartAnimating() { this->EnableAnimation(true); }; + virtual void StopAnimating() { this->EnableAnimation(false); }; // // fade command @@ -330,6 +340,7 @@ protected: // bool m_bShadow; float m_fShadowLength; + bool m_bIsAnimating; bool m_bBlendAdd; }; diff --git a/stepmania/src/BGAnimation.cpp b/stepmania/src/BGAnimation.cpp index 37e798493e..e1420809bb 100644 --- a/stepmania/src/BGAnimation.cpp +++ b/stepmania/src/BGAnimation.cpp @@ -16,11 +16,12 @@ #include "GameState.h" #include "IniFile.h" #include "BGAnimationLayer.h" +#include "RageUtil.h" BGAnimation::BGAnimation() { - m_fFadeSeconds = 0; + m_fLengthSeconds = 10; } BGAnimation::~BGAnimation() @@ -42,8 +43,6 @@ void BGAnimation::LoadFromStaticGraphic( CString sPath ) BGAnimationLayer* pLayer = new BGAnimationLayer; pLayer->LoadFromStaticGraphic( sPath ); m_Layers.push_back( pLayer ); - - m_fFadeSeconds = 0.5f; } void BGAnimation::LoadFromAniDir( CString sAniDir, CString sSongBGPath ) @@ -53,33 +52,59 @@ void BGAnimation::LoadFromAniDir( CString sAniDir, CString sSongBGPath ) if( sAniDir.Right(1) != "/" ) sAniDir += "/"; - // loading a directory of layers - CStringArray asImagePaths; - ASSERT( sAniDir != "" ); + ASSERT( IsADirectory(sAniDir) ); - GetDirListing( sAniDir+"*.png", asImagePaths, false, true ); - GetDirListing( sAniDir+"*.jpg", asImagePaths, false, true ); - GetDirListing( sAniDir+"*.gif", asImagePaths, false, true ); - GetDirListing( sAniDir+"*.avi", asImagePaths, false, true ); - GetDirListing( sAniDir+"*.mpg", asImagePaths, false, true ); - GetDirListing( sAniDir+"*.mpeg", asImagePaths, false, true ); - GetDirListing( sAniDir+"*.sprite", asImagePaths, false, true ); + CString sPathToIni = sAniDir + "BGAnimation.ini"; - SortCStringArray( asImagePaths ); - - for( unsigned i=0; iLoadFromAniLayerFile( asImagePaths[i], sSongBGPath ); - m_Layers.push_back( pLayer ); - } + // This is a new style BGAnimation (using .ini) + IniFile ini(sPathToIni); + ini.ReadFile(); - m_fFadeSeconds = 0; + ini.GetValueF( "BGAnimation", "LengthSeconds", m_fLengthSeconds ); + + for( int i=0; true; i++ ) + { + CString sLayer = ssprintf("Layer%d",i+1); + const IniFile::key* pKey = ini.GetKey( sLayer ); + if( pKey == NULL ) + break; + BGAnimationLayer* pLayer = new BGAnimationLayer; + pLayer->LoadFromIni( sAniDir, sLayer, sSongBGPath ); + m_Layers.push_back( pLayer ); + } + } + else + { + // This is an old style BGAnimation (not using .ini) + + // loading a directory of layers + CStringArray asImagePaths; + ASSERT( sAniDir != "" ); + + GetDirListing( sAniDir+"*.png", asImagePaths, false, true ); + GetDirListing( sAniDir+"*.jpg", asImagePaths, false, true ); + GetDirListing( sAniDir+"*.gif", asImagePaths, false, true ); + GetDirListing( sAniDir+"*.avi", asImagePaths, false, true ); + GetDirListing( sAniDir+"*.mpg", asImagePaths, false, true ); + GetDirListing( sAniDir+"*.mpeg", asImagePaths, false, true ); + GetDirListing( sAniDir+"*.sprite", asImagePaths, false, true ); + + SortCStringArray( asImagePaths ); + + for( unsigned i=0; iLoadFromAniLayerFile( asImagePaths[i], sSongBGPath ); + m_Layers.push_back( pLayer ); + } + } } void BGAnimation::LoadFromMovie( CString sMoviePath, bool bLoop, bool bRewind ) @@ -89,8 +114,6 @@ void BGAnimation::LoadFromMovie( CString sMoviePath, bool bLoop, bool bRewind ) BGAnimationLayer* pLayer = new BGAnimationLayer; pLayer->LoadFromMovie( sMoviePath, bLoop, bRewind ); m_Layers.push_back( pLayer ); - - m_fFadeSeconds = 0.5f; } void BGAnimation::LoadFromVisualization( CString sVisPath, CString sSongBGPath ) @@ -105,8 +128,6 @@ void BGAnimation::LoadFromVisualization( CString sVisPath, CString sSongBGPath ) pLayer = new BGAnimationLayer; pLayer->LoadFromVisualization( sVisPath ); m_Layers.push_back( pLayer ); - - m_fFadeSeconds = 0.5f; } diff --git a/stepmania/src/BGAnimation.h b/stepmania/src/BGAnimation.h index f5f5f23312..6fae54b8d3 100644 --- a/stepmania/src/BGAnimation.h +++ b/stepmania/src/BGAnimation.h @@ -43,7 +43,7 @@ public: protected: vector m_Layers; - float m_fFadeSeconds; + float m_fLengthSeconds; }; diff --git a/stepmania/src/BGAnimationLayer.cpp b/stepmania/src/BGAnimationLayer.cpp index 142709987e..f2b341d7e1 100644 --- a/stepmania/src/BGAnimationLayer.cpp +++ b/stepmania/src/BGAnimationLayer.cpp @@ -18,6 +18,8 @@ #include "RageMath.h" #include "SDL_utils.h" #include +#include "RageTimer.h" +#include "RageLog.h" inline float GetOffScreenLeft( Actor* pActor ) { return SCREEN_LEFT - pActor->GetZoomedWidth()/2; } @@ -42,7 +44,7 @@ inline bool HitGuardRailTop( Actor* pActor ) { return pActor->GetY() < GetGuar inline bool HitGuardRailBottom(Actor* pActor ) { return pActor->GetY() > GetGuardRailBottom(pActor); } -const float PARTICLE_VELOCITY = 300; +const float PARTICLE_SPEED = 300; const float SPIRAL_MAX_ZOOM = 2; const float SPIRAL_MIN_ZOOM = 0.3f; @@ -51,14 +53,48 @@ const float SPIRAL_MIN_ZOOM = 0.3f; BGAnimationLayer::BGAnimationLayer() { - m_iNumSprites = 0; - m_bCycleColor = false; - m_bCycleAlpha = false; - m_Effect = EFFECT_STRETCH_STILL; + Init(); +} + +void BGAnimationLayer::Init() +{ +// m_bCycleColor = false; +// m_bCycleAlpha = false; +// m_Effect = EFFECT_STRETCH_STILL; + + for( int i=0; im_fSongBeat; - if( m_bCycleColor ) - { - for( int i=0; i0 && IsOffScreenRight(&m_Sprites[i]) ) + m_Sprites[i].SetX( GetOffScreenLeft(&m_Sprites[i]) ); + if( m_vParticleVelocity[i].y<0 && IsOffScreenTop(&m_Sprites[i]) ) + m_Sprites[i].SetY( GetOffScreenBottom(&m_Sprites[i]) ); + if( m_vParticleVelocity[i].y>0 && IsOffScreenBottom(&m_Sprites[i]) ) + m_Sprites[i].SetY( GetOffScreenTop(&m_Sprites[i]) ); } } break; - case EFFECT_TILE_STILL: - break; - case EFFECT_TILE_SCROLL_LEFT: + case TYPE_TILES: + { + float fSecs = RageTimer::GetTimeSinceStart(); + float fTotalWidth = m_iNumTilesWide * m_fTilesSpacingX; + float fTotalHeight = m_iNumTilesHigh * m_fTilesSpacingY; + + ASSERT( m_iNumSprites == m_iNumTilesWide * m_iNumTilesHigh ); + + for( int x=0; xSetPosition( 0 ); // if movie texture, pause and play movie so we don't waste CPU cycles decoding frames that won't be shown m_Sprites[0].GetTexture()->Play(); + + for( int i=0; iy = pV->y * scale; } +void RageVec3Normalize( RageVector3* pOut, const RageVector3* pV ) +{ + float scale = 1.0f / sqrtf( pV->x*pV->x + pV->y*pV->y + pV->z*pV->z ); + pOut->x = pV->x * scale; + pOut->y = pV->y * scale; + pOut->z = pV->z * scale; +} + void RageVec3TransformCoord( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM ) { RageVector4 temp( pV->x, pV->y, pV->z, 1.0f ); diff --git a/stepmania/src/RageMath.h b/stepmania/src/RageMath.h index 1b84489fac..79b4d5168a 100644 --- a/stepmania/src/RageMath.h +++ b/stepmania/src/RageMath.h @@ -16,9 +16,9 @@ struct RageVector3; struct RageVector4; struct RageMatrix; -//#include "plib-1.6.0/sg.h" void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV ); +void RageVec3Normalize( RageVector3* pOut, const RageVector3* pV ); void RageVec3TransformCoord( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM ); void RageVec4TransformCoord( RageVector4* pOut, const RageVector4* pV, const RageMatrix* pM ); void RageMatrixIdentity( RageMatrix* pOut ); diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index 7044097ceb..8f8f4062f1 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -31,7 +31,6 @@ Sprite::Sprite() m_bDrawIfTextureNull = false; m_iNumStates = 0; m_iCurState = 0; - m_bIsAnimating = true; m_fSecsIntoState = 0.0; m_bUsingCustomTexCoords = false; } diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index 40903544ec..6a800c19b6 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -53,12 +53,10 @@ public: virtual void EnableAnimation( bool bEnable ) { - m_bIsAnimating = bEnable; + Actor::EnableAnimation( bEnable ); if(m_pTexture) bEnable ? m_pTexture->Play() : m_pTexture->Pause(); }; - virtual void StartAnimating() { EnableAnimation(true); }; - virtual void StopAnimating() { EnableAnimation(false); }; virtual void SetState( int iNewState ); int GetNumStates() { return m_iNumStates; }; @@ -86,7 +84,6 @@ protected: float m_fDelay[MAX_SPRITE_STATES]; int m_iNumStates; int m_iCurState; - bool m_bIsAnimating; float m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame bool m_bUsingCustomTexCoords; diff --git a/stepmania/stepmania.nsi b/stepmania/stepmania.nsi index 02ad0bb7ae..78f8b52e9f 100644 --- a/stepmania/stepmania.nsi +++ b/stepmania/stepmania.nsi @@ -19,7 +19,7 @@ !define PRODUCT_NAME_VER "${PRODUCT_NAME} ${VERSION}" Name "${PRODUCT_NAME}" -OutFile "StepMania-CVS-20030226.exe" +OutFile "StepMania-CVS-20030303.exe" ;OutFile "StepMania301.exe" ; Some default compiler settings (uncomment and change at will):