Add crop property to Actor - currently only used in Sprite

This commit is contained in:
Chris Danford
2003-06-20 23:04:11 +00:00
parent c0b41e3c4f
commit aac9739fac
16 changed files with 198 additions and 160 deletions
+19 -6
View File
@@ -661,10 +661,12 @@ void Actor::AddRotationR( float rot )
RageQuatMultiply( &DestTweenState().quat, DestTweenState().quat, RageQuatFromR(rot) );
}
void Actor::Command( CString sCommandString )
float Actor::Command( CString sCommandString )
{
// OPTIMIZATION OPPORTUNITY: sCommandString could be parsed more efficiently.
sCommandString.MakeLower();
CStringArray asCommands;
split( sCommandString, ";", asCommands, true );
@@ -685,13 +687,12 @@ void Actor::Command( CString sCommandString )
#define bParam(i) (iParam(i)!=0)
CString& sName = asTokens[0];
sName.MakeLower();
if( sName.size() == 0 )
continue;
// Commands that go in the tweening queue:
if ( sName=="sleep" ) BeginTweening( fParam(1), TWEEN_LINEAR );
if ( sName=="sleep" ) { BeginTweening( fParam(1), TWEEN_LINEAR ); BeginTweening( 0, TWEEN_LINEAR ); }
else if( sName=="linear" ) BeginTweening( fParam(1), TWEEN_LINEAR );
else if( sName=="accelerate" ) BeginTweening( fParam(1), TWEEN_ACCELERATE );
else if( sName=="decelerate" ) BeginTweening( fParam(1), TWEEN_DECELERATE );
@@ -711,6 +712,10 @@ void Actor::Command( CString sCommandString )
// else if( sName=="zoomz" ) SetZoomZ( fParam(1) );
else if( sName=="zoomtowidth" ) ZoomToWidth( fParam(1) );
else if( sName=="zoomtoheight" ) ZoomToHeight( fParam(1) );
else if( sName=="cropleft" ) SetCropLeft( fParam(1) );
else if( sName=="croptop" ) SetCropTop( fParam(1) );
else if( sName=="cropright" ) SetCropRight( fParam(1) );
else if( sName=="cropbottom" ) SetCropBottom( fParam(1) );
else if( sName=="diffuse" ) SetDiffuse( RageColor(fParam(1),fParam(2),fParam(3),fParam(4)) );
else if( sName=="diffuseleftedge" ) SetDiffuseLeftEdge( RageColor(fParam(1),fParam(2),fParam(3),fParam(4)) );
else if( sName=="diffuserightedge" ) SetDiffuseRightEdge( RageColor(fParam(1),fParam(2),fParam(3),fParam(4)) );
@@ -777,6 +782,8 @@ void Actor::Command( CString sCommandString )
#endif
}
}
return GetTweenTimeLeft();
}
float Actor::GetCommandLength( CString command )
@@ -837,6 +844,7 @@ void Actor::TweenState::Init()
rotation = RageVector3( 0, 0, 0 );
quat = RageVector4( 0, 0, 0, 1 );
scale = RageVector3( 1, 1, 1 );
crop = RectF( 0,0,0,0 );
for(int i=0; i<4; i++)
diffuse[i] = RageColor( 1, 1, 1, 1 );
glow = RageColor( 1, 1, 1, 0 );
@@ -845,10 +853,15 @@ void Actor::TweenState::Init()
void Actor::TweenState::MakeWeightedAverage( TweenState& average_out, const TweenState& ts1, const TweenState& ts2, float fPercentBetween )
{
average_out.pos = ts1.pos + (ts2.pos - ts1.pos )*fPercentBetween;
average_out.scale = ts1.scale + (ts2.scale - ts1.scale )*fPercentBetween;
average_out.rotation = ts1.rotation+ (ts2.rotation - ts1.rotation)*fPercentBetween;
average_out.pos = ts1.pos + (ts2.pos - ts1.pos )*fPercentBetween;
average_out.scale = ts1.scale + (ts2.scale - ts1.scale )*fPercentBetween;
average_out.rotation = ts1.rotation + (ts2.rotation - ts1.rotation)*fPercentBetween;
RageQuatSlerp(&average_out.quat, ts1.quat, ts2.quat, fPercentBetween);
average_out.crop.left = ts1.crop.left + (ts2.crop.left - ts1.crop.left )*fPercentBetween;
average_out.crop.top = ts1.crop.top + (ts2.crop.top - ts1.crop.top )*fPercentBetween;
average_out.crop.right = ts1.crop.right + (ts2.crop.right - ts1.crop.right )*fPercentBetween;
average_out.crop.bottom = ts1.crop.bottom+ (ts2.crop.bottom - ts1.crop.bottom)*fPercentBetween;
for(int i=0; i<4; i++)
average_out.diffuse[i] = ts1.diffuse[i]+ (ts2.diffuse[i] - ts1.diffuse[i])*fPercentBetween;
+12 -1
View File
@@ -43,6 +43,7 @@ public:
RageVector3 rotation;
RageVector4 quat;
RageVector3 scale;
RectF crop; // 0 = no cropping, 1 = fully cropped
RageColor diffuse[4];
RageColor glow;
GlowMode glowmode;
@@ -119,6 +120,16 @@ public:
virtual void AddRotationP( float rot );
virtual void AddRotationR( float rot );
virtual float GetCropLeft() { return DestTweenState().crop.left; }
virtual float GetCropTop() { return DestTweenState().crop.top; }
virtual float GetCropRight() { return DestTweenState().crop.right;}
virtual float GetCropBottom() { return DestTweenState().crop.bottom;}
virtual void SetCropLeft( float percent ) { DestTweenState().crop.left = percent; }
virtual void SetCropTop( float percent ) { DestTweenState().crop.top = percent; }
virtual void SetCropRight( float percent ) { DestTweenState().crop.right = percent;}
virtual void SetCropBottom( float percent ){ DestTweenState().crop.bottom = percent;}
virtual void SetGlobalDiffuseColor( RageColor c );
virtual void SetGlobalX( float x );
@@ -245,7 +256,7 @@ public:
void FadeOn( float fSleepSeconds, CString sFadeString, float fFadeSeconds ) { Fade(fSleepSeconds,sFadeString,fFadeSeconds,false); };
void FadeOff( float fSleepSeconds, CString sFadeString, float fFadeSeconds ) { Fade(fSleepSeconds,sFadeString,fFadeSeconds,true); };
void Command( CString sCommandString );
float Command( CString sCommandString ); // return length in seconds to execute command
static float GetCommandLength( CString command );
virtual void SetState( int iNewState ) {};
+17 -14
View File
@@ -14,42 +14,45 @@
#include "Actor.h"
#define SET_XY( actor ) UtilSetXY( actor, m_sName );
#define ON_COMMAND( actor ) UtilOnCommand( actor, m_sName );
#define OFF_COMMAND( actor ) UtilOffCommand( actor, m_sName );
#define SET_XY_AND_ON_COMMAND( actor ) UtilSetXYAndOnCommand( actor, m_sName );
#define COMMAND( actor, command_name ) UtilCommand( actor, m_sName, command_name );
#define SET_XY( actor ) UtilSetXY( actor, m_sName )
#define ON_COMMAND( actor ) UtilOnCommand( actor, m_sName )
#define OFF_COMMAND( actor ) UtilOffCommand( actor, m_sName )
#define SET_XY_AND_ON_COMMAND( actor ) UtilSetXYAndOnCommand( actor, m_sName )
#define COMMAND( actor, command_name ) UtilCommand( actor, m_sName, command_name )
inline void UtilSetXY( Actor& actor, CString sClassName )
{
ASSERT( !actor.GetName().empty() );
actor.SetXY( THEME->GetMetricF(sClassName,actor.GetName()+"X"), THEME->GetMetricF(sClassName,actor.GetName()+"Y") );
}
inline void UtilOnCommand( Actor& actor, CString sClassName )
inline float UtilOnCommand( Actor& actor, CString sClassName )
{
actor.Command( THEME->GetMetric(sClassName,actor.GetName()+"OnCommand") );
ASSERT( !actor.GetName().empty() );
return actor.Command( THEME->GetMetric(sClassName,actor.GetName()+"OnCommand") );
}
inline void UtilCommand( Actor& actor, CString sClassName, CString sCommandName )
inline float UtilCommand( Actor& actor, CString sClassName, CString sCommandName )
{
actor.Command( THEME->GetMetric(sClassName,actor.GetName()+sCommandName+"Command") );
ASSERT( !actor.GetName().empty() );
return actor.Command( THEME->GetMetric(sClassName,actor.GetName()+sCommandName+"Command") );
}
inline void UtilOffCommand( Actor& actor, CString sClassName )
inline float UtilOffCommand( Actor& actor, CString sClassName )
{
// HACK: It's very often that we command things to TweenOffScreen
// that we aren't drawing. We know that an Actor is not being
// used if it's name is blank. So, do nothing on Actors with a blank name.
if( actor.GetName().empty() )
return;
actor.Command( THEME->GetMetric(sClassName,actor.GetName()+"OffCommand") );
return 0;
return actor.Command( THEME->GetMetric(sClassName,actor.GetName()+"OffCommand") );
}
inline void UtilSetXYAndOnCommand( Actor& actor, CString sClassName )
inline float UtilSetXYAndOnCommand( Actor& actor, CString sClassName )
{
UtilSetXY( actor, sClassName );
UtilOnCommand( actor, sClassName );
return UtilOnCommand( actor, sClassName );
}
#endif
+8 -11
View File
@@ -212,7 +212,7 @@ void BGAnimationLayer::LoadFromAniLayerFile( CString sPath )
ID.bStretch = true;
m_Sprites.back()->LoadBG( ID );
m_Sprites.back()->StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
m_Sprites.back()->SetCustomTextureRect( RectF(0,0,1,1) );
m_Sprites.back()->SetCustomTextureCoords( RectF(0,0,1,1) );
switch( effect )
{
@@ -546,7 +546,7 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer )
ID.bStretch = true;
m_Sprites.back()->LoadBG( ID );
m_Sprites.back()->StretchTo( RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM) );
m_Sprites.back()->SetCustomTextureRect( RectF(0,0,1,1) );
m_Sprites.back()->SetCustomTextureCoords( RectF(0,0,1,1) );
}
break;
case TYPE_PARTICLES:
@@ -638,16 +638,13 @@ void BGAnimationLayer::Update( float fDeltaTime )
case TYPE_STRETCH:
for( i=0; i<m_Sprites.size(); i++ )
{
float fTexCoords[8];
m_Sprites[i]->GetActiveTexCoords( fTexCoords );
RectF texCoords = *m_Sprites[i]->GetActiveTextureCoords();
texCoords.left += fDeltaTime*m_fStretchTexCoordVelocityX;
texCoords.right += fDeltaTime*m_fStretchTexCoordVelocityX;
texCoords.top += fDeltaTime*m_fStretchTexCoordVelocityY;
texCoords.bottom+= fDeltaTime*m_fStretchTexCoordVelocityY;
for( int j=0; j<8; j+=2 )
{
fTexCoords[j ] += fDeltaTime*m_fStretchTexCoordVelocityX;
fTexCoords[j+1] += fDeltaTime*m_fStretchTexCoordVelocityY;
}
m_Sprites[i]->SetCustomTextureCoords( fTexCoords );
m_Sprites[i]->SetCustomTextureCoords( texCoords );
}
break;
/* case EFFECT_PARTICLES_SPIRAL_OUT:
+4 -9
View File
@@ -57,16 +57,11 @@ void Banner::Update( float fDeltaTime )
m_fPercentScrolling += fDeltaTime/2;
m_fPercentScrolling -= (int)m_fPercentScrolling;
const RectF *pTextureRect = m_pTexture->GetTextureCoordRect(0);
RectF texCoords = *m_pTexture->GetTextureCoordRect(0);
texCoords.left += m_fPercentScrolling;
texCoords.right += m_fPercentScrolling;
float fTexCoords[8] =
{
0+m_fPercentScrolling, pTextureRect->top, // top left
0+m_fPercentScrolling, pTextureRect->bottom, // bottom left
1+m_fPercentScrolling, pTextureRect->bottom, // bottom right
1+m_fPercentScrolling, pTextureRect->top, // top right
};
Sprite::SetCustomTextureCoords( fTexCoords );
Sprite::SetCustomTextureCoords( texCoords );
}
}
+26 -24
View File
@@ -56,28 +56,30 @@ void CroppedSprite::CropToSize( float fWidth, float fHeight )
float fOriginalX = GetX();
float fOriginalY = GetY();
if( IsDiagonalBanner(iSourceWidth, iSourceHeight) ) // this is a SSR/DWI CroppedSprite
{
float fCustomImageCoords[8] = {
0.02f, 0.78f, // top left
0.22f, 0.98f, // bottom left
0.98f, 0.22f, // bottom right
0.78f, 0.02f, // top right
};
Sprite::SetCustomImageCoords( fCustomImageCoords );
if( m_fCropWidth != -1 && m_fCropHeight != -1)
m_size = RageVector2( m_fCropWidth, m_fCropHeight );
else
{
/* If no crop size is set, then we're only being used to crop diagonal
* banners so they look like regular ones. We don't actually care about
* the size of the image, only that it has an aspect ratio of 4:1. */
m_size = RageVector2(256, 64);
}
SetZoom( 1 );
}
else if( m_pTexture->GetID().filename.find( "(was rotated)" ) != m_pTexture->GetID().filename.npos &&
// TODO: Add this back in
// if( IsDiagonalBanner(iSourceWidth, iSourceHeight) ) // this is a SSR/DWI CroppedSprite
// {
// float fCustomImageCoords[8] = {
// 0.02f, 0.78f, // top left
// 0.22f, 0.98f, // bottom left
// 0.98f, 0.22f, // bottom right
// 0.78f, 0.02f, // top right
// };
// Sprite::SetCustomImageCoords( fCustomImageCoords );
//
// if( m_fCropWidth != -1 && m_fCropHeight != -1)
// m_size = RageVector2( m_fCropWidth, m_fCropHeight );
// else
// {
// /* If no crop size is set, then we're only being used to crop diagonal
// * banners so they look like regular ones. We don't actually care about
// * the size of the image, only that it has an aspect ratio of 4:1. */
// m_size = RageVector2(256, 64);
// }
// SetZoom( 1 );
// }
// else
if( m_pTexture->GetID().filename.find( "(was rotated)" ) != m_pTexture->GetID().filename.npos &&
m_fCropWidth != -1 && m_fCropHeight != -1 )
{
/* Dumb hack. Normally, we crop all sprites except for diagonal banners,
@@ -115,7 +117,7 @@ void CroppedSprite::CropToSize( float fWidth, float fHeight )
0,
1 - fPercentageToCutOffEachSide,
1 );
SetCustomImageRect( fCustomImageCoords );
SetCustomImageCoords( fCustomImageCoords );
}
else // crop Y
{
@@ -128,7 +130,7 @@ void CroppedSprite::CropToSize( float fWidth, float fHeight )
fPercentageToCutOffEachSide,
1,
1 - fPercentageToCutOffEachSide );
SetCustomImageRect( fCustomImageCoords );
SetCustomImageCoords( fCustomImageCoords );
}
m_size = RageVector2( m_fCropWidth, m_fCropHeight );
SetZoom( 1 );
+1 -1
View File
@@ -71,7 +71,7 @@ void GradeDisplay::Update( float fDeltaTime )
m_frectCurTexCoords.right = m_frectStartTexCoords.right*(1-fPercentIntoScrolling) + m_frectDestTexCoords.right*fPercentIntoScrolling;
m_frectCurTexCoords.bottom = m_frectStartTexCoords.bottom*(1-fPercentIntoScrolling) + m_frectDestTexCoords.bottom*fPercentIntoScrolling;
this->SetCustomTextureRect( m_frectCurTexCoords );
this->SetCustomTextureCoords( m_frectCurTexCoords );
}
}
+2 -2
View File
@@ -182,8 +182,8 @@ public:
1-fPercentCroppedFromRight,
1);
m_sprStreamNormal.SetCustomTextureRect( frectCustomTexCoords );
m_sprStreamHot.SetCustomTextureRect( frectCustomTexCoords );
m_sprStreamNormal.SetCustomTextureCoords( frectCustomTexCoords );
m_sprStreamHot.SetCustomTextureCoords( frectCustomTexCoords );
m_sprStreamHot.SetDiffuse( RageColor(1,1,1,m_fHotAlpha) );
+3 -3
View File
@@ -422,7 +422,7 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
// draw manually in small segments
RageVertex *v = &queue[0];
RageTexture* pTexture = pBottomCap->GetTexture();
const RectF *pRect = pBottomCap->GetCurrentTextureCoordRect();
const RectF *pRect = pBottomCap->GetCurrentTextureCoords();
DISPLAY->SetTexture( pTexture );
DISPLAY->SetBlendMode( BLEND_NORMAL );
DISPLAY->SetBackfaceCull( false );
@@ -489,7 +489,7 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
// draw manually in small segments
RageVertex *v = &queue[0];
RageTexture* pTexture = pSprBody->GetTexture();
const RectF *pRect = pSprBody->GetCurrentTextureCoordRect();
const RectF *pRect = pSprBody->GetCurrentTextureCoords();
DISPLAY->SetTexture( pTexture );
DISPLAY->SetBlendMode( BLEND_NORMAL );
DISPLAY->SetBackfaceCull( false );
@@ -569,7 +569,7 @@ void NoteDisplay::DrawHold( const HoldNote& hn, const bool bActive, const float
// draw manually in small segments
RageVertex *v = &queue[0];
RageTexture* pTexture = pSprTopCap->GetTexture();
const RectF *pRect = pSprTopCap->GetCurrentTextureCoordRect();
const RectF *pRect = pSprTopCap->GetCurrentTextureCoords();
DISPLAY->SetTexture( pTexture );
DISPLAY->SetBlendMode( BLEND_NORMAL );
DISPLAY->SetBackfaceCull( false );
+1 -1
View File
@@ -141,7 +141,7 @@ void NoteField::DrawBeatBar( const float fBeat )
m_sprBars.SetY( fYPos );
m_sprBars.SetDiffuse( RageColor(1,1,1,fAlpha) );
m_sprBars.SetState( iState );
m_sprBars.SetCustomTextureRect( RectF(0,SCALE(iState,0.f,4.f,0.f,1.f), fWidth/fFrameWidth, SCALE(iState+1,0.f,4.f,0.f,1.f)) );
m_sprBars.SetCustomTextureCoords( RectF(0,SCALE(iState,0.f,4.f,0.f,1.f), fWidth/fFrameWidth, SCALE(iState+1,0.f,4.f,0.f,1.f)) );
m_sprBars.SetZoomX( fWidth/m_sprBars.GetUnzoomedWidth() );
m_sprBars.Draw();
+2
View File
@@ -294,6 +294,7 @@ void Screen::ClearMessageQueue( const ScreenMessage SM )
#include "ScreenRaveOptions.h"
#include "ScreenSelectMode.h"
#include "ScreenBackgroundOptions.h"
#include "ScreenSelectMaster.h"
Screen* Screen::Create( CString sClassName )
{
@@ -359,6 +360,7 @@ Screen* Screen::Create( CString sClassName )
IF_RETURN( ScreenSelectCharacter );
IF_RETURN( ScreenRaveOptions );
IF_RETURN( ScreenBackgroundOptions );
IF_RETURN( ScreenSelectMaster );
RageException::Throw( "Invalid Screen class name '%s'", sClassName.c_str() );
}
+1 -1
View File
@@ -19,7 +19,7 @@
// Derived classes must send this when done
const ScreenMessage SM_AllDoneChoosing = (ScreenMessage)(SM_User+123); // unique
#define MAX_CHOICES 30
#define MAX_CHOICES 10
class ScreenSelect : public Screen
{
+4 -7
View File
@@ -53,13 +53,10 @@ static const ScreenMessage SM_AllowOptionsMenuRepeat = ScreenMessage(SM_User+1);
* on Y by flipping texture coordinates. */
static void FlipSpriteHorizontally(Sprite &s)
{
float Coords[8];
s.GetCurrentTextureCoords(Coords);
swap(Coords[0], Coords[6]); /* top left X <-> top right X */
swap(Coords[1], Coords[7]); /* top left Y <-> top right Y */
swap(Coords[2], Coords[4]); /* bottom left X <-> bottom left X */
swap(Coords[3], Coords[5]); /* bottom left Y <-> bottom left Y */
s.SetCustomTextureCoords(Coords);
RectF texCoords = *s.GetCurrentTextureCoords();
swap( texCoords.left, texCoords.right );
swap( texCoords.top, texCoords.bottom );
s.SetCustomTextureCoords( texCoords );
}
ScreenSelectMusic::ScreenSelectMusic() : Screen("ScreenSelectMusic")
+53 -50
View File
@@ -219,6 +219,9 @@ void Sprite::Update( float fDeltaTime )
}
}
/*
No longer needed. -Chris
static void TexCoordsFromArray(RageVertex *v, const float *f)
{
v[0].t = RageVector2( f[0], f[1] ); // top left
@@ -234,12 +237,18 @@ void TexCoordArrayFromRect(float fImageCoords[8], const RectF &rect)
fImageCoords[4] = rect.right; fImageCoords[5] = rect.bottom; // bottom right
fImageCoords[6] = rect.right; fImageCoords[7] = rect.top; // top right
}
*/
void Sprite::DrawPrimitives()
{
if( m_pTexture == NULL && !m_bDrawIfTextureNull )
return;
// bail if cropped all the way
if( m_temp.crop.left + m_temp.crop.right > 1 ||
m_temp.crop.top + m_temp.crop.bottom > 1 )
return;
if( m_pTexture && m_pTexture->IsAMovie() && m_pTexture->IsPlaying() )
SDL_Delay( PREFSMAN->m_iMovieDecodeMS ); // let the movie decode a frame
@@ -263,11 +272,19 @@ void Sprite::DrawPrimitives()
}
RectF croppedQuadVerticies = quadVerticies;
#define IF_CROP_POS(side,opp_side) if(m_temp.crop.side>0) croppedQuadVerticies.side = SCALE( m_temp.crop.side, 0.f, 1.f, quadVerticies.side, quadVerticies.opp_side );
IF_CROP_POS( left, right );
IF_CROP_POS( top, bottom );
IF_CROP_POS( right, left );
IF_CROP_POS( bottom, top );
static RageVertex v[4];
v[0].p = RageVector3( quadVerticies.left, quadVerticies.top, 0 ); // top left
v[1].p = RageVector3( quadVerticies.left, quadVerticies.bottom, 0 ); // bottom left
v[2].p = RageVector3( quadVerticies.right, quadVerticies.bottom, 0 ); // bottom right
v[3].p = RageVector3( quadVerticies.right, quadVerticies.top, 0 ); // top right
v[0].p = RageVector3( croppedQuadVerticies.left, croppedQuadVerticies.top, 0 ); // top left
v[1].p = RageVector3( croppedQuadVerticies.left, croppedQuadVerticies.bottom, 0 ); // bottom left
v[2].p = RageVector3( croppedQuadVerticies.right, croppedQuadVerticies.bottom, 0 ); // bottom right
v[3].p = RageVector3( croppedQuadVerticies.right, croppedQuadVerticies.top, 0 ); // top right
DISPLAY->SetTexture( m_pTexture );
@@ -277,9 +294,21 @@ void Sprite::DrawPrimitives()
if( m_pTexture )
{
float TexCoords[8];
GetActiveTexCoords(TexCoords);
TexCoordsFromArray(v, TexCoords);
const RectF texCoords = *(m_bUsingCustomTexCoords ?
GetCustomTextureCoords() :
GetCurrentTextureCoords());
RectF croppedTexCoords = texCoords;
#define IF_CROP_TEX(side,opp_side) if(m_temp.crop.side>0) croppedTexCoords.side = SCALE( m_temp.crop.side, 0.f, 1.f, texCoords.side, texCoords.opp_side );
IF_CROP_TEX( left, right );
IF_CROP_TEX( top, bottom );
IF_CROP_TEX( right, left );
IF_CROP_TEX( bottom, top );
v[0].t = RageVector2( croppedTexCoords.left, croppedTexCoords.top ); // top left
v[1].t = RageVector2( croppedTexCoords.left, croppedTexCoords.bottom ); // bottom left
v[2].t = RageVector2( croppedTexCoords.right, croppedTexCoords.bottom ); // bottom right
v[3].t = RageVector2( croppedTexCoords.right, croppedTexCoords.top ); // top right
}
DISPLAY->SetTextureModeModulate();
@@ -337,70 +366,44 @@ void Sprite::SetState( int iNewState )
m_fSecsIntoState = 0.0;
}
void Sprite::SetCustomTextureRect( const RectF &new_texcoord_frect )
void Sprite::SetCustomTextureCoords( const RectF &new_texcoord_frect )
{
m_bUsingCustomTexCoords = true;
m_bTextureWrapping = true;
TexCoordArrayFromRect(m_CustomTexCoords, new_texcoord_frect);
m_CustomTexCoords = new_texcoord_frect;
}
void Sprite::SetCustomTextureCoords( float fTexCoords[8] ) // order: top left, bottom left, bottom right, top right
const RectF* Sprite::GetCustomTextureCoords() const
{
m_bUsingCustomTexCoords = true;
m_bTextureWrapping = true;
for( int i=0; i<8; i++ )
m_CustomTexCoords[i] = fTexCoords[i];
return &m_CustomTexCoords;
}
void Sprite::GetCustomTextureCoords( float fTexCoordsOut[8] ) const // order: top left, bottom left, bottom right, top right
{
for( int i=0; i<8; i++ )
fTexCoordsOut[i] = m_CustomTexCoords[i];
}
void Sprite::SetCustomImageRect( RectF rectImageCoords )
void Sprite::SetCustomImageCoords( const RectF &newImageCoords )
{
// Convert to a rectangle in texture coordinate space.
rectImageCoords.left *= m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth();
rectImageCoords.right *= m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth();
rectImageCoords.top *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight();
rectImageCoords.bottom *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight();
RectF texCoords;
texCoords.left = newImageCoords.left * m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth();
texCoords.right = newImageCoords.right * m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth();
texCoords.top = newImageCoords.top * m_pTexture->GetImageHeight()/ (float)m_pTexture->GetTextureHeight();
texCoords.bottom = newImageCoords.bottom * m_pTexture->GetImageHeight()/ (float)m_pTexture->GetTextureHeight();
SetCustomTextureRect( rectImageCoords );
SetCustomTextureCoords( texCoords );
}
void Sprite::SetCustomImageCoords( float fImageCoords[8] ) // order: top left, bottom left, bottom right, top right
{
// convert image coords to texture coords in place
for( int i=0; i<8; i+=2 )
{
fImageCoords[i+0] *= m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth();
fImageCoords[i+1] *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight();
}
SetCustomTextureCoords( fImageCoords );
}
const RectF *Sprite::GetCurrentTextureCoordRect() const
const RectF *Sprite::GetCurrentTextureCoords() const
{
unsigned int uFrameNo = m_States[m_iCurState].iFrameIndex;
return m_pTexture->GetTextureCoordRect( uFrameNo );
}
void Sprite::GetCurrentTextureCoords(float fImageCoords[8]) const
{
const RectF *pTexCoordRect = GetCurrentTextureCoordRect();
TexCoordArrayFromRect(fImageCoords, *pTexCoordRect);
}
/* If we're using custom coordinates, return them; otherwise return the coordinates
* for the current state. */
void Sprite::GetActiveTexCoords(float fImageCoords[8]) const
const RectF* Sprite::GetActiveTextureCoords() const
{
if(m_bUsingCustomTexCoords) GetCustomTextureCoords(fImageCoords);
else GetCurrentTextureCoords(fImageCoords);
if(m_bUsingCustomTexCoords)
return GetCustomTextureCoords();
else
return GetCurrentTextureCoords();
}
+6 -12
View File
@@ -40,17 +40,12 @@ public:
virtual int GetNumStates() { return m_States.size(); };
CString GetTexturePath() { return m_pTexture==NULL ? "" : m_pTexture->GetID().filename; };
void SetCustomTextureRect( const RectF &new_texcoord_frect );
void SetCustomTextureCoords( float fTexCoords[8] );
void GetCustomTextureCoords( float fTexCoordsOut[8] ) const;
void SetCustomSourceRect( const RectF &rectSourceCoords ); // in source pixel space
void SetCustomImageRect( RectF rectImageCoords ); // in image pixel space
void SetCustomImageCoords( float fImageCoords[8] );
const RectF *GetCurrentTextureCoordRect() const;
void SetCustomTextureCoords( const RectF &newTexCoords );
const RectF* GetCustomTextureCoords() const;
void SetCustomImageCoords( const RectF &newImageCoords ); // in image space (not texture space)
void StopUsingCustomCoords();
void GetActiveTexCoords(float fImageCoords[8]) const;
void GetCurrentTextureCoords(float fImageCoords[8]) const;
const RectF* GetActiveTextureCoords() const; // depends on m_bUsingCustomTexCoords
const RectF* GetCurrentTextureCoords() const;
protected:
virtual bool LoadFromTexture( RageTextureID ID );
@@ -71,8 +66,7 @@ protected:
float m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame
bool m_bUsingCustomTexCoords;
//FRECT m_CustomTexCoordRect;
float m_CustomTexCoords[8]; // (x,y) * 4
RectF m_CustomTexCoords;
};
#endif
+39 -18
View File
@@ -1,5 +1,5 @@
# Microsoft Developer Studio Project File - Name="StepMania" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# Microsoft Developer Studio Generated Build File, Format Version 60000
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
@@ -61,10 +61,10 @@ LINK32=link.exe
# SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
# Begin Special Build Tool
IntDir=.\../Debug6
TargetDir=\temp\stepmania
TargetDir=\stepmania\stepmania
TargetName=StepMania-debug
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -82,25 +82,29 @@ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania
# PROP Intermediate_Dir "StepMania___Xbox_Debug___VC6"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
XBCP=xbecopy.exe
# ADD BASE XBCP /NOLOGO
# ADD XBCP /NOLOGO
XBE=imagebld.exe
# ADD BASE XBE /nologo /stack:0x10000 /debug
# ADD XBE /nologo /stack:0x10000 /debug
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /Fr /YX"global.h" /FD /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /Fr /YX"global.h" /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 $(intdir)\verstub.obj kernel32.lib shell32.lib user32.lib gdi32.lib advapi32.lib winmm.lib /nologo /pdb:"../debug6/StepMania-debug.pdb" /map /debug /machine:IX86 /nodefaultlib:"libcmtd.lib" /out:"../StepMania-debug.exe"
# SUBTRACT BASE LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
# ADD LINK32 $(intdir)\verstub.obj kernel32.lib shell32.lib user32.lib gdi32.lib advapi32.lib winmm.lib /nologo /pdb:"../debug6/StepMania-debug.pdb" /map /debug /machine:IX86 /nodefaultlib:"libcmtd.lib" /out:"../StepMania-debug.exe"
# SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /Fr /YX"global.h" /FD /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /Fr /YX"global.h" /FD /c
XBE=imagebld.exe
# ADD BASE XBE /nologo /stack:0x10000 /debug
# ADD XBE /nologo /stack:0x10000 /debug
XBCP=xbecopy.exe
# ADD BASE XBCP /NOLOGO
# ADD XBCP /NOLOGO
# Begin Special Build Tool
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
IntDir=.\StepMania___Xbox_Debug___VC6
TargetDir=.\StepMania___Xbox_Debug___VC6
TargetName=StepMania
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -137,10 +141,10 @@ LINK32=link.exe
# SUBTRACT LINK32 /verbose /pdb:none
# Begin Special Build Tool
IntDir=.\../Release6
TargetDir=\temp\stepmania
TargetDir=\stepmania\stepmania
TargetName=StepMania
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -3948,6 +3952,23 @@ SOURCE=.\ScreenSelectGroup.h
# End Source File
# Begin Source File
SOURCE=.\ScreenSelectMaster.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
!ELSEIF "$(CFG)" == "StepMania - Xbox Debug"
!ELSEIF "$(CFG)" == "StepMania - Win32 Release"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\ScreenSelectMaster.h
# End Source File
# Begin Source File
SOURCE=.\ScreenSelectMode.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"