scripting support in BGAnimations
This commit is contained in:
+42
-3
@@ -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
|
||||
{
|
||||
|
||||
+16
-5
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
@@ -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; i<asImagePaths.size(); i++ )
|
||||
if( DoesFileExist(sPathToIni) )
|
||||
{
|
||||
const CString sPath = asImagePaths[i];
|
||||
CString sDir, sFName, sExt;
|
||||
splitrelpath( sPath, sDir, sFName, sExt );
|
||||
if( sFName.Left(1) == "_" )
|
||||
continue; // don't directly load files starting with an underscore
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer;
|
||||
pLayer->LoadFromAniLayerFile( 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; i<asImagePaths.size(); i++ )
|
||||
{
|
||||
const CString sPath = asImagePaths[i];
|
||||
CString sDir, sFName, sExt;
|
||||
splitrelpath( sPath, sDir, sFName, sExt );
|
||||
if( sFName.Left(1) == "_" )
|
||||
continue; // don't directly load files starting with an underscore
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer;
|
||||
pLayer->LoadFromAniLayerFile( 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
protected:
|
||||
vector<BGAnimationLayer*> m_Layers;
|
||||
float m_fFadeSeconds;
|
||||
float m_fLengthSeconds;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+396
-237
@@ -18,6 +18,8 @@
|
||||
#include "RageMath.h"
|
||||
#include "SDL_utils.h"
|
||||
#include <math.h>
|
||||
#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; i<MAX_SPRITES; i++ )
|
||||
m_vParticleVelocity[i] = RageVector3( 0, 0, 0 );
|
||||
|
||||
m_Type = TYPE_SPRITE;
|
||||
|
||||
m_fStretchTexCoordVelocityX = 0;
|
||||
m_fStretchTexCoordVelocityY = 0;
|
||||
m_bRewindMovie = false;
|
||||
m_fZoomMin = 1;
|
||||
m_fZoomMax = 1;
|
||||
m_fVelocityXMin = 10;
|
||||
m_fVelocityXMax = 10;
|
||||
m_fVelocityYMin = 0;
|
||||
m_fVelocityYMax = 0;
|
||||
m_fVelocityZMin = 0;
|
||||
m_fVelocityZMax = 0;
|
||||
m_fOverrideSpeed = 0;
|
||||
m_iNumParticles = 10;
|
||||
m_bParticlesBounce = false;
|
||||
m_iNumTilesWide = 10;
|
||||
m_iNumTilesHigh = 8;
|
||||
m_fTilesStartX = 0;
|
||||
m_fTilesStartY = 0;
|
||||
m_fTilesSpacingX = 64;
|
||||
m_fTilesSpacingY = 64;
|
||||
m_fTileVelocityX = 0;
|
||||
m_fTileVelocityY = 0;
|
||||
|
||||
|
||||
/* Why doesn't this use the existing tweening mechanism? I can't make
|
||||
* sense of what this code is doing; all I can tell is that it's duplicating
|
||||
* stuff we already have. -glenn */
|
||||
/*
|
||||
m_PosX = m_PosY = 0;
|
||||
m_Zoom = 0;
|
||||
m_Rot = 0;
|
||||
@@ -69,6 +105,7 @@ BGAnimationLayer::BGAnimationLayer()
|
||||
m_TweenSpeed = 0;
|
||||
m_TweenState = 0;
|
||||
m_TweenPassedX = m_TweenPassedY = 0;
|
||||
*/
|
||||
}
|
||||
|
||||
/* Static background layers are simple, uncomposited background images with nothing
|
||||
@@ -76,15 +113,17 @@ BGAnimationLayer::BGAnimationLayer()
|
||||
* so turn that off. */
|
||||
void BGAnimationLayer::LoadFromStaticGraphic( CString sPath )
|
||||
{
|
||||
Init();
|
||||
m_iNumSprites = 1;
|
||||
RageTextureID ID(sPath);
|
||||
ID.iAlphaBits = 0;
|
||||
m_iNumSprites = 1;
|
||||
m_Sprites[0].LoadBG( ID );
|
||||
m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
|
||||
}
|
||||
|
||||
void BGAnimationLayer::LoadFromMovie( CString sMoviePath, bool bLoop, bool bRewind )
|
||||
{
|
||||
Init();
|
||||
m_iNumSprites = 1;
|
||||
m_Sprites[0].LoadBG( sMoviePath );
|
||||
m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
|
||||
@@ -98,14 +137,17 @@ void BGAnimationLayer::LoadFromMovie( CString sMoviePath, bool bLoop, bool bRewi
|
||||
|
||||
void BGAnimationLayer::LoadFromVisualization( CString sMoviePath )
|
||||
{
|
||||
Init();
|
||||
m_iNumSprites = 1;
|
||||
m_Sprites[0].LoadBG( sMoviePath );
|
||||
m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
|
||||
m_Sprites[0].EnableAdditiveBlend( true );
|
||||
}
|
||||
|
||||
|
||||
void BGAnimationLayer::LoadFromAniLayerFile( CString sPath, CString sSongBGPath )
|
||||
{
|
||||
Init();
|
||||
CString lcPath = sPath;
|
||||
lcPath.MakeLower();
|
||||
|
||||
@@ -141,36 +183,23 @@ void BGAnimationLayer::LoadFromAniLayerFile( CString sPath, CString sSongBGPath
|
||||
"tileflipx",
|
||||
"tileflipy",
|
||||
"tilepulse",
|
||||
"stretchscrollhorizontal"
|
||||
};
|
||||
|
||||
for( int i=0; i<NUM_EFFECTS; i++ )
|
||||
{
|
||||
if( lcPath.Find(EFFECT_STRING[i]) != -1 )
|
||||
{
|
||||
m_Effect = (Effect)i;
|
||||
goto found_effect;
|
||||
}
|
||||
}
|
||||
// If we get here, we didn't find an effect string in the file name. Use the defualt effect (StretchStill)
|
||||
|
||||
found_effect:
|
||||
Effect effect = EFFECT_CENTER;
|
||||
|
||||
//////////////////////
|
||||
// init
|
||||
//////////////////////
|
||||
switch( m_Effect )
|
||||
for( int i=0; i<NUM_EFFECTS; i++ )
|
||||
if( lcPath.Find(EFFECT_STRING[i]) != -1 )
|
||||
effect = (Effect)i;
|
||||
|
||||
switch( effect )
|
||||
{
|
||||
case EFFECT_CENTER:
|
||||
m_Type = TYPE_SPRITE;
|
||||
m_iNumSprites = 1;
|
||||
m_Sprites[0].LoadBG( sPath );
|
||||
m_Sprites[0].Load( sPath );
|
||||
m_Sprites[0].SetXY( CENTER_X, CENTER_Y );
|
||||
break;
|
||||
case EFFECT_STRETCH_STILL:
|
||||
m_iNumSprites = 1;
|
||||
m_Sprites[0].LoadBG( sPath );
|
||||
m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
|
||||
break;
|
||||
case EFFECT_STRETCH_SCROLL_LEFT:
|
||||
case EFFECT_STRETCH_SCROLL_RIGHT:
|
||||
case EFFECT_STRETCH_SCROLL_UP:
|
||||
@@ -179,6 +208,7 @@ found_effect:
|
||||
case EFFECT_STRETCH_BUBBLE:
|
||||
case EFFECT_STRETCH_TWIST:
|
||||
{
|
||||
m_Type = TYPE_STRETCH;
|
||||
m_iNumSprites = 1;
|
||||
RageTextureID ID(sPath);
|
||||
ID.bStretch = true;
|
||||
@@ -186,77 +216,85 @@ found_effect:
|
||||
m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
|
||||
m_Sprites[0].SetCustomTextureRect( RectF(0,0,1,1) );
|
||||
|
||||
switch( m_Effect )
|
||||
switch( effect )
|
||||
{
|
||||
case EFFECT_STRETCH_SCROLL_LEFT: m_vTexCoordVelocity = RageVector2(+0.5f,0); break;
|
||||
case EFFECT_STRETCH_SCROLL_RIGHT: m_vTexCoordVelocity = RageVector2(-0.5f,0); break;
|
||||
case EFFECT_STRETCH_SCROLL_UP: m_vTexCoordVelocity = RageVector2(0,+0.5f); break;
|
||||
case EFFECT_STRETCH_SCROLL_DOWN: m_vTexCoordVelocity = RageVector2(0,-0.5f); break;
|
||||
case EFFECT_STRETCH_WATER:
|
||||
case EFFECT_STRETCH_BUBBLE:
|
||||
case EFFECT_STRETCH_TWIST:
|
||||
m_vTexCoordVelocity = RageVector2(-0.0f,0);
|
||||
case EFFECT_STRETCH_SCROLL_LEFT: m_fStretchTexCoordVelocityX = +0.5f; m_fStretchTexCoordVelocityY = 0; break;
|
||||
case EFFECT_STRETCH_SCROLL_RIGHT: m_fStretchTexCoordVelocityX = -0.5f; m_fStretchTexCoordVelocityY = 0; break;
|
||||
case EFFECT_STRETCH_SCROLL_UP: m_fStretchTexCoordVelocityX = 0; m_fStretchTexCoordVelocityY = +0.5f; break;
|
||||
case EFFECT_STRETCH_SCROLL_DOWN: m_fStretchTexCoordVelocityX = 0; m_fStretchTexCoordVelocityY = -0.5f; break;
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EFFECT_STRETCH_SCROLL_H:
|
||||
{
|
||||
m_iNumSprites = 1;
|
||||
RageTextureID ID(sPath);
|
||||
ID.bStretch = true;
|
||||
m_Sprites[0].LoadBG( ID );
|
||||
m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,0,SCREEN_RIGHT, int(m_Sprites[0].GetUnzoomedHeight())) );
|
||||
m_Sprites[0].SetCustomTextureRect( RectF(0,0,1,1) );
|
||||
m_vTexCoordVelocity = RageVector2(+0.5f,0);
|
||||
m_Sprites[0].SetY(m_fStretchScrollH_Y);
|
||||
}
|
||||
break;
|
||||
case EFFECT_STRETCH_SPIN:
|
||||
m_iNumSprites = 1;
|
||||
m_Sprites[0].LoadBG( sPath );
|
||||
m_Sprites[0].ScaleToCover( RectI(SCREEN_LEFT-200,SCREEN_TOP-200,SCREEN_RIGHT+200,SCREEN_BOTTOM+200) );
|
||||
m_fRotationalVelocity = 1;
|
||||
{
|
||||
m_Type = TYPE_STRETCH;
|
||||
m_iNumSprites = 1;
|
||||
m_Sprites[0].LoadBG( sPath );
|
||||
m_Sprites[0].ScaleToCover( RectI(SCREEN_LEFT-200,SCREEN_TOP-200,SCREEN_RIGHT+200,SCREEN_BOTTOM+200) );
|
||||
m_Sprites[0].SetEffectSpin( RageVector3(0,0,1) );
|
||||
}
|
||||
break;
|
||||
case EFFECT_PARTICLES_SPIRAL_OUT:
|
||||
case EFFECT_PARTICLES_SPIRAL_IN:
|
||||
{
|
||||
m_Sprites[0].LoadBG( sPath );
|
||||
/* {
|
||||
m_Type = TYPE_PARTICLES;
|
||||
m_Sprites[0].Load( sPath );
|
||||
int iSpriteArea = int( m_Sprites[0].GetUnzoomedWidth()*m_Sprites[0].GetUnzoomedHeight() );
|
||||
int iMaxArea = SCREEN_WIDTH*SCREEN_HEIGHT;
|
||||
m_iNumSprites = min( iMaxArea / iSpriteArea, MAX_SPRITES );
|
||||
for( int i=0; i<m_iNumSprites; i++ )
|
||||
m_iNumSprites = m_iNumParticles = iMaxArea / iSpriteArea;
|
||||
m_iNumSprites = m_iNumParticles = min( m_iNumSprites, MAX_SPRITES );
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].LoadBG( sPath );
|
||||
m_Sprites[i].Load( sPath );
|
||||
m_Sprites[i].SetZoom( randomf(0.2f,2) );
|
||||
m_Sprites[i].SetRotationZ( randomf(0,PI*2) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EFFECT_PARTICLES_FLOAT_UP:
|
||||
*/ case EFFECT_PARTICLES_FLOAT_UP:
|
||||
case EFFECT_PARTICLES_FLOAT_DOWN:
|
||||
case EFFECT_PARTICLES_FLOAT_LEFT:
|
||||
case EFFECT_PARTICLES_FLOAT_RIGHT:
|
||||
case EFFECT_PARTICLES_BOUNCE:
|
||||
{
|
||||
m_Sprites[0].LoadBG( sPath );
|
||||
m_Type = TYPE_PARTICLES;
|
||||
m_Sprites[0].Load( sPath );
|
||||
int iSpriteArea = int( m_Sprites[0].GetUnzoomedWidth()*m_Sprites[0].GetUnzoomedHeight() );
|
||||
int iMaxArea = SCREEN_WIDTH*SCREEN_HEIGHT;
|
||||
m_iNumSprites = min( iMaxArea / iSpriteArea, MAX_SPRITES );
|
||||
for( int i=0; i<m_iNumSprites; i++ )
|
||||
m_iNumSprites = m_iNumParticles = iMaxArea / iSpriteArea;
|
||||
m_iNumSprites = m_iNumParticles = min( m_iNumSprites, MAX_SPRITES );
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].LoadBG( sPath );
|
||||
m_Sprites[i].Load( sPath );
|
||||
m_Sprites[i].SetZoom( 0.7f + 0.6f*i/(float)m_iNumSprites );
|
||||
m_Sprites[i].SetX( randomf( GetGuardRailLeft(&m_Sprites[i]), GetGuardRailRight(&m_Sprites[i]) ) );
|
||||
m_Sprites[i].SetY( randomf( GetGuardRailTop(&m_Sprites[i]), GetGuardRailBottom(&m_Sprites[i]) ) );
|
||||
|
||||
if( m_Effect == EFFECT_PARTICLES_BOUNCE )
|
||||
switch( effect )
|
||||
{
|
||||
case EFFECT_PARTICLES_FLOAT_UP:
|
||||
case EFFECT_PARTICLES_SPIRAL_OUT:
|
||||
m_vParticleVelocity[i] = RageVector3( 0, -PARTICLE_SPEED*m_Sprites[i].GetZoom(), 0 );
|
||||
break;
|
||||
case EFFECT_PARTICLES_FLOAT_DOWN:
|
||||
case EFFECT_PARTICLES_SPIRAL_IN:
|
||||
m_vParticleVelocity[i] = RageVector3( 0, PARTICLE_SPEED*m_Sprites[i].GetZoom(), 0 );
|
||||
break;
|
||||
case EFFECT_PARTICLES_FLOAT_LEFT:
|
||||
m_vParticleVelocity[i] = RageVector3( -PARTICLE_SPEED*m_Sprites[i].GetZoom(), 0, 0 );
|
||||
break;
|
||||
case EFFECT_PARTICLES_FLOAT_RIGHT:
|
||||
m_vParticleVelocity[i] = RageVector3( +PARTICLE_SPEED*m_Sprites[i].GetZoom(), 0, 0 );
|
||||
break;
|
||||
case EFFECT_PARTICLES_BOUNCE:
|
||||
m_bParticlesBounce = true;
|
||||
m_Sprites[i].SetZoom( 1 );
|
||||
m_vHeadings[i] = RageVector2( randomf(), randomf() );
|
||||
RageVec2Normalize( &m_vHeadings[i], &m_vHeadings[i] );
|
||||
m_vParticleVelocity[i] = RageVector3( randomf(), randomf(), 0 );
|
||||
RageVec3Normalize( &m_vParticleVelocity[i], &m_vParticleVelocity[i] );
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,31 +308,57 @@ found_effect:
|
||||
case EFFECT_TILE_FLIP_Y:
|
||||
case EFFECT_TILE_PULSE:
|
||||
{
|
||||
m_Sprites[0].LoadBG( sPath );
|
||||
int iNumTilesWide = 1+int(SCREEN_WIDTH /m_Sprites[0].GetUnzoomedWidth());
|
||||
int iNumTilesHigh = 1+int(SCREEN_HEIGHT/m_Sprites[0].GetUnzoomedHeight());
|
||||
if( m_Effect == EFFECT_TILE_SCROLL_LEFT ||
|
||||
m_Effect == EFFECT_TILE_SCROLL_RIGHT ) {
|
||||
iNumTilesWide++;
|
||||
}
|
||||
if( m_Effect == EFFECT_TILE_SCROLL_UP ||
|
||||
m_Effect == EFFECT_TILE_SCROLL_DOWN ) {
|
||||
iNumTilesHigh++;
|
||||
}
|
||||
|
||||
iNumTilesWide = min( iNumTilesWide, MAX_TILES_WIDE );
|
||||
iNumTilesHigh = min( iNumTilesHigh, MAX_TILES_HIGH );
|
||||
|
||||
m_iNumSprites = min( iNumTilesWide * iNumTilesHigh, MAX_SPRITES );
|
||||
|
||||
for( int x=0; x<iNumTilesWide; x++ )
|
||||
m_Type = TYPE_TILES;
|
||||
RageTextureID ID(sPath);
|
||||
ID.bStretch = true;
|
||||
m_Sprites[0].Load( ID );
|
||||
m_iNumTilesWide = 2+int(SCREEN_WIDTH /m_Sprites[0].GetUnzoomedWidth());
|
||||
m_iNumTilesWide = min( m_iNumTilesWide, MAX_TILES_WIDE );
|
||||
m_iNumTilesHigh = 2+int(SCREEN_HEIGHT/m_Sprites[0].GetUnzoomedHeight());
|
||||
m_iNumTilesHigh = min( m_iNumTilesHigh, MAX_TILES_HIGH );
|
||||
m_iNumSprites = m_iNumTilesWide * m_iNumTilesHigh;
|
||||
m_fTilesStartX = m_Sprites[0].GetUnzoomedWidth() / 2;
|
||||
m_fTilesStartY = m_Sprites[0].GetUnzoomedHeight() / 2;
|
||||
m_fTilesSpacingX = m_Sprites[0].GetUnzoomedWidth();
|
||||
m_fTilesSpacingY = m_Sprites[0].GetUnzoomedHeight();
|
||||
// HACK: fix cracks in tiles
|
||||
m_fTilesSpacingX -= 1;
|
||||
m_fTilesSpacingY -= 1;
|
||||
for( int x=0; x<m_iNumTilesWide; x++ )
|
||||
{
|
||||
for( int y=0; y<iNumTilesHigh; y++ )
|
||||
for( int y=0; y<m_iNumTilesHigh; y++ )
|
||||
{
|
||||
int i = x+y*iNumTilesWide;
|
||||
m_Sprites[i].LoadBG( sPath );
|
||||
m_Sprites[i].SetX( (x+0.5f)*m_Sprites[i].GetUnzoomedWidth() );
|
||||
m_Sprites[i].SetY( (y+0.5f)*m_Sprites[i].GetUnzoomedHeight() );
|
||||
int i = y*m_iNumTilesWide + x;
|
||||
m_Sprites[i].Load( ID );
|
||||
|
||||
switch( effect )
|
||||
{
|
||||
case EFFECT_TILE_STILL:
|
||||
break;
|
||||
case EFFECT_TILE_SCROLL_LEFT:
|
||||
m_fTileVelocityX = -PARTICLE_SPEED;
|
||||
break;
|
||||
case EFFECT_TILE_SCROLL_RIGHT:
|
||||
m_fTileVelocityX = +PARTICLE_SPEED;
|
||||
break;
|
||||
case EFFECT_TILE_SCROLL_UP:
|
||||
m_fTileVelocityY = -PARTICLE_SPEED;
|
||||
break;
|
||||
case EFFECT_TILE_SCROLL_DOWN:
|
||||
m_fTileVelocityY = +PARTICLE_SPEED;
|
||||
break;
|
||||
case EFFECT_TILE_FLIP_X:
|
||||
m_Sprites[i].SetEffectSpin( RageVector3(2,0,0) );
|
||||
break;
|
||||
case EFFECT_TILE_FLIP_Y:
|
||||
m_Sprites[i].SetEffectSpin( RageVector3(0,2,0) );
|
||||
break;
|
||||
case EFFECT_TILE_PULSE:
|
||||
m_Sprites[i].SetEffectPulse( 1, 0.3f, 1.f );
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,21 +368,29 @@ found_effect:
|
||||
}
|
||||
|
||||
|
||||
m_bCycleColor = sPath.Find("cyclecolor") != -1;
|
||||
m_bCycleAlpha = sPath.Find("cyclealpha") != -1;
|
||||
sPath.MakeLower();
|
||||
|
||||
if( sPath.Find("cyclecolor") != -1 )
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
m_Sprites[i].SetEffectRainbow( 5 );
|
||||
|
||||
if( sPath.Find("cyclealpha") != -1 )
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
m_Sprites[i].SetEffectDiffuseShift( 2, RageColor(1,1,1,1), RageColor(1,1,1,0) );
|
||||
|
||||
if( sPath.Find("startonrandomframe") != -1 )
|
||||
for( int i=0; i<m_iNumSprites; i++ )
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
m_Sprites[i].SetState( rand()%m_Sprites[i].GetNumStates() );
|
||||
|
||||
if( sPath.Find("dontanimate") != -1 )
|
||||
for( int i=0; i<m_iNumSprites; i++ )
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
m_Sprites[i].StopAnimating();
|
||||
|
||||
if( sPath.Find("add") != -1 )
|
||||
for( int i=0; i<m_iNumSprites; i++ )
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
m_Sprites[i].EnableAdditiveBlend( true );
|
||||
|
||||
/*
|
||||
CString sDir, sFName, sExt;
|
||||
splitrelpath( sPath, sDir, sFName, sExt );
|
||||
CString sIniPath = sDir+"/"+sFName+".ini";
|
||||
@@ -362,75 +434,161 @@ found_effect:
|
||||
{
|
||||
m_Sprites[0].SetRotationZ(m_Rot);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void BGAnimationLayer::Update( float fDeltaTime )
|
||||
|
||||
void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer, CString sSongBGPath )
|
||||
{
|
||||
int i;
|
||||
Init();
|
||||
if( sAniDir.Right(1) != "/" )
|
||||
sAniDir += "/";
|
||||
|
||||
ASSERT( IsADirectory(sAniDir) );
|
||||
|
||||
CString sPathToIni = sAniDir + "BGAnimation.ini";
|
||||
|
||||
IniFile ini(sPathToIni);
|
||||
ini.ReadFile();
|
||||
|
||||
CString sFile;
|
||||
ini.GetValue( sLayer, "File", sFile );
|
||||
|
||||
bool bUseSongBG = false;
|
||||
ini.GetValueB( sLayer, "UseSongBG", bUseSongBG );
|
||||
if( bUseSongBG )
|
||||
sFile = sSongBGPath;
|
||||
|
||||
if( sFile == "" )
|
||||
RageException::Throw( "In the ini file for BGAnimation '%s', '%s' is missing a the line 'File='.", sAniDir.GetString(), sLayer.GetString() );
|
||||
|
||||
CString sPath = sAniDir+sFile;
|
||||
if( !DoesFileExist(sPath) )
|
||||
RageException::Throw( "In the ini file for BGAnimation '%s', the specified File '%s' does not exist.", sAniDir.GetString(), sFile.GetString() );
|
||||
|
||||
ini.GetValueI( sLayer, "Type", (int&)m_Type );
|
||||
ini.GetValue ( sLayer, "Command", m_sCommand );
|
||||
ini.GetValueF( sLayer, "StretchTexCoordVelocityX", m_fStretchTexCoordVelocityX );
|
||||
ini.GetValueF( sLayer, "StretchTexCoordVelocityY", m_fStretchTexCoordVelocityY );
|
||||
ini.GetValueB( sLayer, "RewindMovie", m_bRewindMovie );
|
||||
ini.GetValueF( sLayer, "ZoomMin", m_fZoomMin );
|
||||
ini.GetValueF( sLayer, "ZoomMax", m_fZoomMax );
|
||||
ini.GetValueF( sLayer, "VelocityXMin", m_fVelocityXMin );
|
||||
ini.GetValueF( sLayer, "VelocityXMax", m_fVelocityXMax );
|
||||
ini.GetValueF( sLayer, "VelocityYMin", m_fVelocityYMin );
|
||||
ini.GetValueF( sLayer, "VelocityYMax", m_fVelocityYMax );
|
||||
ini.GetValueF( sLayer, "VelocityZMin", m_fVelocityZMin );
|
||||
ini.GetValueF( sLayer, "VelocityZMax", m_fVelocityZMax );
|
||||
ini.GetValueF( sLayer, "OverrideSpeed", m_fOverrideSpeed );
|
||||
ini.GetValueI( sLayer, "NumParticles", m_iNumParticles );
|
||||
ini.GetValueB( sLayer, "ParticlesBounce", m_bParticlesBounce );
|
||||
ini.GetValueI( sLayer, "NumTilesWide", m_iNumTilesWide );
|
||||
ini.GetValueI( sLayer, "NumTilesHigh", m_iNumTilesHigh );
|
||||
ini.GetValueF( sLayer, "TilesStartX", m_fTilesStartX );
|
||||
ini.GetValueF( sLayer, "TilesStartY", m_fTilesStartY );
|
||||
ini.GetValueF( sLayer, "TilesSpacingX", m_fTilesSpacingX );
|
||||
ini.GetValueF( sLayer, "TilesSpacingY", m_fTilesSpacingY );
|
||||
ini.GetValueF( sLayer, "TileVelocityX", m_fTileVelocityX );
|
||||
ini.GetValueF( sLayer, "TileVelocityY", m_fTileVelocityY );
|
||||
|
||||
|
||||
switch( m_Type )
|
||||
{
|
||||
case TYPE_SPRITE:
|
||||
m_iNumSprites = 1;
|
||||
m_Sprites[0].Load( sPath );
|
||||
m_Sprites[0].SetXY( CENTER_X, CENTER_Y );
|
||||
break;
|
||||
case TYPE_STRETCH:
|
||||
{
|
||||
m_iNumSprites = 1;
|
||||
RageTextureID ID(sPath);
|
||||
ID.bStretch = true;
|
||||
m_Sprites[0].LoadBG( ID );
|
||||
m_Sprites[0].StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
|
||||
m_Sprites[0].SetCustomTextureRect( RectF(0,0,1,1) );
|
||||
}
|
||||
break;
|
||||
case TYPE_PARTICLES:
|
||||
{
|
||||
m_iNumSprites = m_iNumParticles;
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].Load( sPath );
|
||||
m_Sprites[i].SetXY( randomf(SCREEN_LEFT,SCREEN_RIGHT), randomf(SCREEN_TOP,SCREEN_BOTTOM) );
|
||||
m_Sprites[i].SetZoom( randomf(m_fZoomMin,m_fZoomMax) );
|
||||
m_vParticleVelocity[i] = RageVector3(
|
||||
randomf(m_fVelocityXMin,m_fVelocityXMax),
|
||||
randomf(m_fVelocityYMin,m_fVelocityYMax),
|
||||
randomf(m_fVelocityZMin,m_fVelocityZMax) );
|
||||
if( m_fOverrideSpeed != 0 )
|
||||
{
|
||||
RageVec3Normalize( &m_vParticleVelocity[i], &m_vParticleVelocity[i] );
|
||||
m_vParticleVelocity[i] *= m_fOverrideSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TYPE_TILES:
|
||||
{
|
||||
m_iNumTilesWide = 2+(int)(SCREEN_WIDTH /m_fTilesSpacingX);
|
||||
m_iNumTilesHigh = 2+(int)(SCREEN_HEIGHT/m_fTilesSpacingY);
|
||||
m_iNumSprites = m_iNumTilesWide * m_iNumTilesHigh;
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].Load( sPath );
|
||||
//m_Sprites[i].SetXY( ); // let Update set X and Y
|
||||
m_Sprites[i].SetZoom( randomf(m_fZoomMin,m_fZoomMax) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
bool bStartOnRandomFrame = false;
|
||||
ini.GetValueB( sLayer, "StartOnRandomFrame", bStartOnRandomFrame );
|
||||
if( bStartOnRandomFrame )
|
||||
{
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
m_Sprites[i].SetState( rand()%m_Sprites[i].GetNumStates() );
|
||||
}
|
||||
|
||||
if( m_sCommand != "" )
|
||||
{
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
m_Sprites[i].Command( m_sCommand );
|
||||
}
|
||||
}
|
||||
|
||||
void BGAnimationLayer::Update( float fDeltaTime )
|
||||
{
|
||||
const float fSongBeat = GAMESTATE->m_fSongBeat;
|
||||
if( m_bCycleColor )
|
||||
{
|
||||
for( int i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
RageColor color = RageColor(
|
||||
cosf( fSongBeat+i ) * 0.5f + 0.5f,
|
||||
cosf( fSongBeat+i + PI * 2.0f / 3.0f ) * 0.5f + 0.5f,
|
||||
cosf( fSongBeat+i + PI * 4.0f / 3.0f) * 0.5f + 0.5f,
|
||||
1.0f
|
||||
);
|
||||
m_Sprites[i].SetDiffuse( color );
|
||||
}
|
||||
}
|
||||
if( m_bCycleAlpha )
|
||||
{
|
||||
for( int i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
RageColor color = m_Sprites[i].GetDiffuse();
|
||||
color.a = cosf( fSongBeat/2 ) * 0.5f + 0.5f;
|
||||
m_Sprites[i].SetDiffuse( color );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
m_Sprites[i].Update( fDeltaTime );
|
||||
}
|
||||
|
||||
if(m_Effect == EFFECT_STRETCH_SCROLL_H)
|
||||
m_Sprites[0].SetY(m_fStretchScrollH_Y);
|
||||
|
||||
switch( m_Effect )
|
||||
switch( m_Type )
|
||||
{
|
||||
case EFFECT_CENTER:
|
||||
case EFFECT_STRETCH_STILL:
|
||||
case TYPE_SPRITE:
|
||||
break;
|
||||
case EFFECT_STRETCH_SCROLL_LEFT:
|
||||
case EFFECT_STRETCH_SCROLL_RIGHT:
|
||||
case EFFECT_STRETCH_SCROLL_UP:
|
||||
case EFFECT_STRETCH_SCROLL_DOWN:
|
||||
case EFFECT_STRETCH_SCROLL_H:
|
||||
float fTexCoords[8];
|
||||
m_Sprites[0].GetCustomTextureCoords( fTexCoords );
|
||||
|
||||
for( i=0; i<8; i+=2 )
|
||||
case TYPE_STRETCH:
|
||||
{
|
||||
fTexCoords[i ] += fDeltaTime*m_vTexCoordVelocity.x;
|
||||
fTexCoords[i+1] += fDeltaTime*m_vTexCoordVelocity.y;
|
||||
}
|
||||
float fTexCoords[8];
|
||||
m_Sprites[0].GetCustomTextureCoords( fTexCoords );
|
||||
|
||||
m_Sprites[0].SetCustomTextureCoords( fTexCoords );
|
||||
|
||||
for( i=0; i<8; i+=2 )
|
||||
{
|
||||
fTexCoords[i ] += fDeltaTime*m_fStretchTexCoordVelocityX;
|
||||
fTexCoords[i+1] += fDeltaTime*m_fStretchTexCoordVelocityY;
|
||||
}
|
||||
|
||||
m_Sprites[0].SetCustomTextureCoords( fTexCoords );
|
||||
}
|
||||
break;
|
||||
case EFFECT_STRETCH_SPIN:
|
||||
m_Sprites[0].SetRotationZ( m_Sprites[0].GetRotationZ() + fDeltaTime*m_fRotationalVelocity );
|
||||
case EFFECT_STRETCH_WATER:
|
||||
case EFFECT_STRETCH_BUBBLE:
|
||||
case EFFECT_STRETCH_TWIST:
|
||||
break;
|
||||
case EFFECT_PARTICLES_SPIRAL_OUT:
|
||||
/* case EFFECT_PARTICLES_SPIRAL_OUT:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetZoom( m_Sprites[i].GetZoom() + fDeltaTime );
|
||||
@@ -462,109 +620,101 @@ void BGAnimationLayer::Update( float fDeltaTime )
|
||||
m_Sprites[i].SetY( CENTER_Y + sinf(m_Sprites[i].GetRotationZ())*fRadius );
|
||||
}
|
||||
break;
|
||||
case EFFECT_PARTICLES_FLOAT_UP:
|
||||
*/
|
||||
case TYPE_PARTICLES:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetY( m_Sprites[i].GetY() - fDeltaTime * PARTICLE_VELOCITY * m_Sprites[i].GetZoom() );
|
||||
if( IsOffScreenTop(&m_Sprites[i]) )
|
||||
m_Sprites[i].SetY( GetOffScreenBottom(&m_Sprites[i]) );
|
||||
}
|
||||
break;
|
||||
case EFFECT_PARTICLES_FLOAT_DOWN:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetY( m_Sprites[i].GetY() + fDeltaTime * PARTICLE_VELOCITY * m_Sprites[i].GetZoom() );
|
||||
if( IsOffScreenBottom(&m_Sprites[i]) )
|
||||
m_Sprites[i].SetY( GetOffScreenTop(&m_Sprites[i]) );
|
||||
}
|
||||
break;
|
||||
case EFFECT_PARTICLES_FLOAT_LEFT:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetX( m_Sprites[i].GetX() - fDeltaTime * PARTICLE_VELOCITY * m_Sprites[i].GetZoom() );
|
||||
if( IsOffScreenLeft(&m_Sprites[i]) )
|
||||
m_Sprites[i].SetX( GetOffScreenRight(&m_Sprites[i]) );
|
||||
}
|
||||
break;
|
||||
case EFFECT_PARTICLES_FLOAT_RIGHT:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetX( m_Sprites[i].GetX() + fDeltaTime * PARTICLE_VELOCITY * m_Sprites[i].GetZoom() );
|
||||
if( IsOffScreenRight(&m_Sprites[i]) )
|
||||
m_Sprites[i].SetX( GetOffScreenLeft(&m_Sprites[i]) );
|
||||
}
|
||||
break;
|
||||
case EFFECT_PARTICLES_BOUNCE:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetX( m_Sprites[i].GetX() + fDeltaTime * PARTICLE_VELOCITY * m_vHeadings[i].x );
|
||||
m_Sprites[i].SetY( m_Sprites[i].GetY() + fDeltaTime * PARTICLE_VELOCITY * m_vHeadings[i].y );
|
||||
if( HitGuardRailLeft(&m_Sprites[i]) )
|
||||
m_Sprites[i].SetX( m_Sprites[i].GetX() + fDeltaTime*m_vParticleVelocity[i].x );
|
||||
m_Sprites[i].SetY( m_Sprites[i].GetY() + fDeltaTime*m_vParticleVelocity[i].y );
|
||||
m_Sprites[i].SetZ( m_Sprites[i].GetZ() + fDeltaTime*m_vParticleVelocity[i].z );
|
||||
if( m_bParticlesBounce )
|
||||
{
|
||||
m_vHeadings[i].x *= -1;
|
||||
m_Sprites[i].SetX( GetGuardRailLeft(&m_Sprites[i]) );
|
||||
if( HitGuardRailLeft(&m_Sprites[i]) )
|
||||
{
|
||||
m_vParticleVelocity[i].x *= -1;
|
||||
m_Sprites[i].SetX( GetGuardRailLeft(&m_Sprites[i]) );
|
||||
}
|
||||
if( HitGuardRailRight(&m_Sprites[i]) )
|
||||
{
|
||||
m_vParticleVelocity[i].x *= -1;
|
||||
m_Sprites[i].SetX( GetGuardRailRight(&m_Sprites[i]) );
|
||||
}
|
||||
if( HitGuardRailTop(&m_Sprites[i]) )
|
||||
{
|
||||
m_vParticleVelocity[i].y *= -1;
|
||||
m_Sprites[i].SetY( GetGuardRailTop(&m_Sprites[i]) );
|
||||
}
|
||||
if( HitGuardRailBottom(&m_Sprites[i]) )
|
||||
{
|
||||
m_vParticleVelocity[i].y *= -1;
|
||||
m_Sprites[i].SetY( GetGuardRailBottom(&m_Sprites[i]) );
|
||||
}
|
||||
}
|
||||
if( HitGuardRailRight(&m_Sprites[i]) )
|
||||
else // !m_bParticlesBounce
|
||||
{
|
||||
m_vHeadings[i].x *= -1;
|
||||
m_Sprites[i].SetX( GetGuardRailRight(&m_Sprites[i]) );
|
||||
}
|
||||
if( HitGuardRailTop(&m_Sprites[i]) )
|
||||
{
|
||||
m_vHeadings[i].y *= -1;
|
||||
m_Sprites[i].SetY( GetGuardRailTop(&m_Sprites[i]) );
|
||||
}
|
||||
if( HitGuardRailBottom(&m_Sprites[i]) )
|
||||
{
|
||||
m_vHeadings[i].y *= -1;
|
||||
m_Sprites[i].SetY( GetGuardRailBottom(&m_Sprites[i]) );
|
||||
if( m_vParticleVelocity[i].x<0 && IsOffScreenLeft(&m_Sprites[i]) )
|
||||
m_Sprites[i].SetX( GetOffScreenRight(&m_Sprites[i]) );
|
||||
if( m_vParticleVelocity[i].x>0 && 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; x<m_iNumTilesWide; x++ )
|
||||
{
|
||||
printf( "fY: " );
|
||||
for( int y=0; y<m_iNumTilesHigh; y++ )
|
||||
{
|
||||
int i = y*m_iNumTilesWide + x;
|
||||
|
||||
float fX = m_fTilesStartX + m_fTilesSpacingX * x + fSecs * m_fTileVelocityX;
|
||||
float fY = m_fTilesStartY + m_fTilesSpacingY * y + fSecs * m_fTileVelocityY;
|
||||
|
||||
fX += m_fTilesSpacingX/2;
|
||||
fY += m_fTilesSpacingY/2;
|
||||
|
||||
fX = fmodf( fX, fTotalWidth );
|
||||
fY = fmodf( fY, fTotalHeight );
|
||||
|
||||
if( fX < 0 ) fX += fTotalWidth;
|
||||
if( fY < 0 ) fY += fTotalHeight;
|
||||
|
||||
fX -= m_fTilesSpacingX/2;
|
||||
fY -= m_fTilesSpacingY/2;
|
||||
|
||||
printf( "%f, ", fY );
|
||||
|
||||
m_Sprites[i].SetX( fX );
|
||||
m_Sprites[i].SetY( fY );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
/*
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetX( m_Sprites[i].GetX() - fDeltaTime * PARTICLE_VELOCITY * (1 + m_vTexCoordVelocity.x) ); // metricable speed :)
|
||||
m_Sprites[i].SetX( m_Sprites[i].GetX() + fDeltaTime* );
|
||||
m_Sprites[i].SetY( m_Sprites[i].GetY() + fDeltaTime*m_vParticleVelocity[i].y );
|
||||
m_Sprites[i].SetZ( m_Sprites[i].GetZ() + fDeltaTime*m_vParticleVelocity[i].z );
|
||||
if( IsOffScreenLeft(&m_Sprites[i]) )
|
||||
m_Sprites[i].SetX( m_Sprites[i].GetX()-GetOffScreenLeft(&m_Sprites[i]) + GetOffScreenRight(&m_Sprites[i]) );
|
||||
}
|
||||
break;
|
||||
case EFFECT_TILE_SCROLL_RIGHT:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetX( m_Sprites[i].GetX() + fDeltaTime * PARTICLE_VELOCITY * (1 + m_vTexCoordVelocity.x) );
|
||||
if( IsOffScreenRight(&m_Sprites[i]) )
|
||||
m_Sprites[i].SetX( m_Sprites[i].GetX()-GetOffScreenRight(&m_Sprites[i]) + GetOffScreenLeft(&m_Sprites[i]) );
|
||||
}
|
||||
break;
|
||||
case EFFECT_TILE_SCROLL_UP:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetY( m_Sprites[i].GetY() - fDeltaTime * PARTICLE_VELOCITY );
|
||||
if( IsOffScreenTop(&m_Sprites[i]) )
|
||||
m_Sprites[i].SetY( m_Sprites[i].GetY()-GetOffScreenTop(&m_Sprites[i]) + GetOffScreenBottom(&m_Sprites[i]) );
|
||||
}
|
||||
break;
|
||||
case EFFECT_TILE_SCROLL_DOWN:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetY( m_Sprites[i].GetY() + fDeltaTime * PARTICLE_VELOCITY );
|
||||
if( IsOffScreenBottom(&m_Sprites[i]) )
|
||||
m_Sprites[i].SetY( m_Sprites[i].GetY()-GetOffScreenBottom(&m_Sprites[i]) + GetOffScreenTop(&m_Sprites[i]) );
|
||||
}
|
||||
break;
|
||||
case EFFECT_TILE_FLIP_X:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetRotationX( m_Sprites[i].GetRotationX() + fDeltaTime * PI );
|
||||
}
|
||||
break;
|
||||
case EFFECT_TILE_FLIP_Y:
|
||||
for( i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
m_Sprites[i].SetRotationY( m_Sprites[i].GetRotationY() + fDeltaTime * PI );
|
||||
*/
|
||||
}
|
||||
break;
|
||||
case EFFECT_TILE_PULSE:
|
||||
@@ -577,6 +727,7 @@ void BGAnimationLayer::Update( float fDeltaTime )
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
/*
|
||||
if(m_TweenStartTime != 0 && !(m_TweenStartTime < 0))
|
||||
{
|
||||
m_TweenStartTime -= fDeltaTime;
|
||||
@@ -675,14 +826,19 @@ void BGAnimationLayer::Update( float fDeltaTime )
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void BGAnimationLayer::Draw()
|
||||
{
|
||||
for( int i=0; i<m_iNumSprites; i++ )
|
||||
{
|
||||
for( unsigned i=0; i<m_iNumSprites; i++ )
|
||||
m_Sprites[i].Draw();
|
||||
}
|
||||
}
|
||||
|
||||
void BGAnimationLayer::SetDiffuse( RageColor c )
|
||||
{
|
||||
for(unsigned i=0; i<m_iNumSprites; i++)
|
||||
m_Sprites[i].SetDiffuse(c);
|
||||
}
|
||||
|
||||
void BGAnimationLayer::GainingFocus()
|
||||
@@ -691,6 +847,9 @@ void BGAnimationLayer::GainingFocus()
|
||||
m_Sprites[0].GetTexture()->SetPosition( 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; i<m_iNumSprites; i++ )
|
||||
m_Sprites[i].Command( m_sCommand );
|
||||
}
|
||||
|
||||
void BGAnimationLayer::LosingFocus()
|
||||
|
||||
@@ -12,39 +12,38 @@
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "RageTypes.h"
|
||||
#include "Sprite.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
|
||||
const int MAX_TILES_WIDE = 11;
|
||||
const int MAX_TILES_HIGH = 8;
|
||||
const int MAX_SPRITES = MAX_TILES_WIDE*MAX_TILES_HIGH;
|
||||
|
||||
#define MAX_TILES_WIDE (SCREEN_WIDTH/32+2)
|
||||
#define MAX_TILES_HIGH (SCREEN_HEIGHT/32+2)
|
||||
#define MAX_SPRITES (MAX_TILES_WIDE*MAX_TILES_HIGH)
|
||||
|
||||
class BGAnimationLayer
|
||||
{
|
||||
public:
|
||||
BGAnimationLayer();
|
||||
virtual ~BGAnimationLayer() { }
|
||||
void Init();
|
||||
|
||||
void LoadFromStaticGraphic( CString sPath );
|
||||
void LoadFromAniLayerFile( CString sPath, CString sSongBGPath );
|
||||
void LoadFromMovie( CString sMoviePath, bool bLoop, bool bRewind );
|
||||
void LoadFromVisualization( CString sMoviePath );
|
||||
void LoadFromIni( CString sDir, CString sLayer, CString sSongBGPath );
|
||||
|
||||
virtual void Update( float fDeltaTime );
|
||||
virtual void Draw();
|
||||
|
||||
virtual void SetDiffuse( RageColor c ) { for(int i=0; i<m_iNumSprites; i++) m_Sprites[i].SetDiffuse(c); }
|
||||
virtual void SetDiffuse( RageColor c );
|
||||
|
||||
void GainingFocus();
|
||||
void LosingFocus();
|
||||
|
||||
protected:
|
||||
Sprite m_Sprites[MAX_SPRITES];
|
||||
int m_iNumSprites;
|
||||
|
||||
bool m_bCycleColor;
|
||||
bool m_bCycleAlpha;
|
||||
bool m_bRewindMovie;
|
||||
Sprite m_Sprites[MAX_SPRITES];
|
||||
RageVector3 m_vParticleVelocity[MAX_SPRITES];
|
||||
int m_iNumSprites;
|
||||
|
||||
enum Effect {
|
||||
EFFECT_CENTER,
|
||||
@@ -72,31 +71,56 @@ protected:
|
||||
EFFECT_TILE_FLIP_X,
|
||||
EFFECT_TILE_FLIP_Y,
|
||||
EFFECT_TILE_PULSE,
|
||||
EFFECT_STRETCH_SCROLL_H,
|
||||
NUM_EFFECTS // leave this at the end
|
||||
NUM_EFFECTS, // leave this at the end
|
||||
EFFECT_INVALID
|
||||
};
|
||||
Effect m_Effect;
|
||||
|
||||
RageVector2 m_vHeadings[MAX_SPRITES]; // only used in EFFECT_PARTICLES_BOUNCE
|
||||
enum Type
|
||||
{
|
||||
TYPE_SPRITE,
|
||||
TYPE_STRETCH,
|
||||
TYPE_PARTICLES,
|
||||
TYPE_TILES,
|
||||
NUM_TYPES,
|
||||
TYPE_INVALID
|
||||
} m_Type;
|
||||
|
||||
RageVector2 m_vTexCoordVelocity;
|
||||
float m_PosX;
|
||||
float m_PosY;
|
||||
float m_Zoom;
|
||||
float m_Rot;
|
||||
float m_fRotationalVelocity;
|
||||
float m_fStretchScrollH_Y;
|
||||
float m_ShowTime;
|
||||
float m_HideTime;
|
||||
|
||||
float m_TweenStartTime;
|
||||
float m_TweenX;
|
||||
float m_TweenY;
|
||||
float m_TweenSpeed;
|
||||
|
||||
int m_TweenState;
|
||||
int m_TweenPassedX;
|
||||
int m_TweenPassedY;
|
||||
//
|
||||
// loaded prefs
|
||||
//
|
||||
|
||||
// common stuff
|
||||
CString m_sCommand;
|
||||
|
||||
// stretch stuff
|
||||
float m_fStretchTexCoordVelocityX;
|
||||
float m_fStretchTexCoordVelocityY;
|
||||
|
||||
// particle and tile stuff
|
||||
bool m_bRewindMovie;
|
||||
float m_fZoomMin, m_fZoomMax;
|
||||
float m_fVelocityXMin, m_fVelocityXMax;
|
||||
float m_fVelocityYMin, m_fVelocityYMax;
|
||||
float m_fVelocityZMin, m_fVelocityZMax;
|
||||
float m_fOverrideSpeed; // 0 means don't override speed
|
||||
|
||||
// particles stuff
|
||||
int m_iNumParticles;
|
||||
bool m_bParticlesBounce;
|
||||
|
||||
// tiles stuff
|
||||
int m_iNumTilesWide;
|
||||
int m_iNumTilesHigh;
|
||||
float m_fTilesStartX;
|
||||
float m_fTilesStartY;
|
||||
float m_fTilesSpacingX;
|
||||
float m_fTilesSpacingY;
|
||||
float m_fTileVelocityX;
|
||||
float m_fTileVelocityY;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,14 @@ void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV )
|
||||
pOut->y = 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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user