2003-05-11 14:47:29 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "ModelTypes.h"
|
|
|
|
|
#include "IniFile.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "RageTexture.h"
|
|
|
|
|
#include "RageTextureManager.h"
|
2003-07-10 16:51:15 +00:00
|
|
|
#include "RageLog.h"
|
2004-04-08 08:35:38 +00:00
|
|
|
#include "RageDisplay.h"
|
2003-05-11 14:47:29 +00:00
|
|
|
|
|
|
|
|
AnimatedTexture::AnimatedTexture()
|
|
|
|
|
{
|
|
|
|
|
iCurState = 0;
|
|
|
|
|
fSecsIntoFrame = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-21 22:24:48 +00:00
|
|
|
AnimatedTexture::~AnimatedTexture()
|
|
|
|
|
{
|
|
|
|
|
Unload();
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-11 14:47:29 +00:00
|
|
|
void AnimatedTexture::Load( CString sTexOrIniPath )
|
|
|
|
|
{
|
|
|
|
|
ASSERT( vFrames.empty() ); // don't load more than once
|
|
|
|
|
|
2003-10-29 20:32:29 +00:00
|
|
|
if( GetExtension(sTexOrIniPath).CompareNoCase("ini")==0 )
|
2003-05-11 14:47:29 +00:00
|
|
|
{
|
|
|
|
|
IniFile ini;
|
2004-05-23 02:27:51 +00:00
|
|
|
if( !ini.ReadFile( sTexOrIniPath ) )
|
|
|
|
|
RageException::Throw( "Error reading %s: %s", sTexOrIniPath.c_str(), ini.GetError().c_str() );
|
2003-07-10 16:51:15 +00:00
|
|
|
|
2003-05-11 14:47:29 +00:00
|
|
|
if( !ini.GetKey("AnimatedTexture") )
|
|
|
|
|
RageException::Throw( "The animated texture file '%s' doesn't contain a section called 'AnimatedTexture'.", sTexOrIniPath.c_str() );
|
|
|
|
|
for( int i=0; i<1000; i++ )
|
|
|
|
|
{
|
|
|
|
|
CString sFileKey = ssprintf( "Frame%04d", i );
|
|
|
|
|
CString sDelayKey = ssprintf( "Delay%04d", i );
|
|
|
|
|
|
|
|
|
|
CString sFileName;
|
|
|
|
|
float fDelay = 0;
|
|
|
|
|
if( ini.GetValue( "AnimatedTexture", sFileKey, sFileName ) &&
|
2003-10-02 02:03:29 +00:00
|
|
|
ini.GetValue( "AnimatedTexture", sDelayKey, fDelay ) )
|
2003-05-11 14:47:29 +00:00
|
|
|
{
|
|
|
|
|
RageTextureID ID;
|
2003-10-29 20:32:29 +00:00
|
|
|
ID.filename = Dirname(sTexOrIniPath) + sFileName;
|
2003-05-11 14:47:29 +00:00
|
|
|
ID.bStretch = true;
|
2003-06-09 19:22:04 +00:00
|
|
|
ID.bHotPinkColorKey = true;
|
2004-01-23 06:20:28 +00:00
|
|
|
ID.bMipMaps = true; // use mipmaps in Models
|
2003-05-11 14:47:29 +00:00
|
|
|
AnimatedTextureState state = {
|
|
|
|
|
TEXTUREMAN->LoadTexture( ID ),
|
|
|
|
|
fDelay
|
|
|
|
|
};
|
|
|
|
|
vFrames.push_back( state );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RageTextureID ID;
|
|
|
|
|
ID.filename = sTexOrIniPath;
|
2003-06-09 19:22:04 +00:00
|
|
|
ID.bHotPinkColorKey = true;
|
2003-05-11 14:47:29 +00:00
|
|
|
ID.bStretch = true;
|
2004-01-23 06:20:28 +00:00
|
|
|
ID.bMipMaps = true; // use mipmaps in Models
|
2003-05-11 14:47:29 +00:00
|
|
|
AnimatedTextureState state = {
|
|
|
|
|
TEXTUREMAN->LoadTexture( ID ),
|
|
|
|
|
10
|
|
|
|
|
};
|
|
|
|
|
vFrames.push_back( state );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AnimatedTexture::Update( float fDelta )
|
|
|
|
|
{
|
|
|
|
|
if( vFrames.empty() )
|
|
|
|
|
return;
|
|
|
|
|
ASSERT( iCurState < (int)vFrames.size() );
|
|
|
|
|
fSecsIntoFrame += fDelta;
|
|
|
|
|
if( fSecsIntoFrame > vFrames[iCurState].fDelaySecs )
|
2003-06-09 19:22:04 +00:00
|
|
|
{
|
|
|
|
|
fSecsIntoFrame -= vFrames[iCurState].fDelaySecs;
|
2003-05-11 14:47:29 +00:00
|
|
|
iCurState = (iCurState+1) % vFrames.size();
|
2003-06-09 19:22:04 +00:00
|
|
|
}
|
2003-05-11 14:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RageTexture* AnimatedTexture::GetCurrentTexture()
|
|
|
|
|
{
|
|
|
|
|
if( vFrames.empty() )
|
|
|
|
|
return NULL;
|
|
|
|
|
ASSERT( iCurState < (int)vFrames.size() );
|
|
|
|
|
return vFrames[iCurState].pTexture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AnimatedTexture::SetState( int iState )
|
|
|
|
|
{
|
|
|
|
|
CLAMP( iState, 0, GetNumStates()-1 );
|
|
|
|
|
iCurState = iState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AnimatedTexture::GetNumStates()
|
|
|
|
|
{
|
|
|
|
|
return vFrames.size();
|
|
|
|
|
}
|
2003-06-21 22:24:48 +00:00
|
|
|
|
|
|
|
|
void AnimatedTexture::Unload()
|
|
|
|
|
{
|
|
|
|
|
for(unsigned i = 0; i < vFrames.size(); ++i)
|
|
|
|
|
TEXTUREMAN->UnloadTexture(vFrames[i].pTexture);
|
|
|
|
|
vFrames.clear();
|
|
|
|
|
iCurState = 0;
|
|
|
|
|
fSecsIntoFrame = 0;
|
|
|
|
|
}
|
2004-01-28 08:53:40 +00:00
|
|
|
|
2004-04-08 08:35:38 +00:00
|
|
|
|
|
|
|
|
msMesh::msMesh()
|
|
|
|
|
{
|
|
|
|
|
ZERO( szName );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
msMesh::~msMesh()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-08 00:47:53 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2003-2004 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|