From 3c15c15aa23e4e52f272bedd8f3dd499ddc17e23 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 29 Jul 2006 00:16:57 +0000 Subject: [PATCH] AddImageCoords --- stepmania/src/Sprite.cpp | 16 ++++++++++++++++ stepmania/src/Sprite.h | 1 + 2 files changed, 17 insertions(+) diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index 792f9f382a..c282d9be44 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -880,6 +880,20 @@ void Sprite::StretchTexCoords( float fX, float fY ) SetCustomTextureCoords( fTexCoords ); } +void Sprite::AddImageCoords( float fX, float fY ) +{ + float fTexCoords[8]; + GetActiveTextureCoords( fTexCoords ); + + for( int j=0; j<8; j+=2 ) + { + fTexCoords[j ] += fX / (float)m_pTexture->GetTextureWidth(); + fTexCoords[j+1] += fY / (float)m_pTexture->GetTextureHeight(); + } + + SetCustomTextureCoords( fTexCoords ); +} + // lua start #include "LuaBinding.h" @@ -914,6 +928,7 @@ public: static int texcoordvelocity( T* p, lua_State *L ) { p->SetTexCoordVelocity( FArg(1),FArg(2) ); return 0; } static int scaletoclipped( T* p, lua_State *L ) { p->ScaleToClipped( FArg(1),FArg(2) ); return 0; } static int stretchtexcoords( T* p, lua_State *L ) { p->StretchTexCoords( FArg(1),FArg(2) ); return 0; } + static int addimagecoords( T* p, lua_State *L ) { p->AddImageCoords( FArg(1),FArg(2) ); return 0; } static int setstate( T* p, lua_State *L ) { p->SetState( IArg(1) ); return 0; } static int GetAnimationLengthSeconds( T* p, lua_State *L ) { lua_pushnumber( L, p->GetAnimationLengthSeconds() ); return 1; } static int GetTexture( T* p, lua_State *L ) @@ -934,6 +949,7 @@ public: ADD_METHOD( texcoordvelocity ); ADD_METHOD( scaletoclipped ); ADD_METHOD( stretchtexcoords ); + ADD_METHOD( addimagecoords ); ADD_METHOD( setstate ); ADD_METHOD( GetAnimationLengthSeconds ); ADD_METHOD( GetTexture ); diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index 4d8fb847fd..a87a59d0a0 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -52,6 +52,7 @@ public: void StopUsingCustomCoords(); void GetActiveTextureCoords(float fTexCoordsOut[8]) const; void StretchTexCoords( float fX, float fY ); + void AddImageCoords( float fX, float fY ); // in image pixel space void SetTexCoordVelocity(float fVelX, float fVelY); // Scale the Sprite maintaining the aspect ratio so that it fits