Fixed all texture atlas references names.

Changed texture atlas binary file extension to "eta" and magic code to EETA ( Entropia Engine Texture Atlas ).
Removed EE::Utils, moved classes to EE::Math and EE::System. Still deciding this, but i need to commit, because of the number of changes, i don't want to lose anything.
And many many changes more.
This commit is contained in:
spartanj@gmail.com
2012-11-30 22:54:42 -03:00
parent 8e1988a392
commit 604b926a7f
65 changed files with 821 additions and 878 deletions

View File

@@ -768,7 +768,7 @@ bool cMap::LoadFromStream( cIOStream& IOS ) {
eeSAFE_DELETE_ARRAY( tProp );
}
//! Load SubTexture Groups
//! Load Texture Atlases
if ( MapHdr.TextureAtlasCount ) {
sMapTextureAtlas * tSG = eeNewArray( sMapTextureAtlas, MapHdr.TextureAtlasCount );
@@ -780,7 +780,7 @@ bool cMap::LoadFromStream( cIOStream& IOS ) {
TextureAtlases.push_back( std::string( tSG[i].Path ) );
}
//! Load the Texture groups if needed
//! Load the Texture Atlases if needed
for ( i = 0; i < TextureAtlases.size(); i++ ) {
std::string sgname = FileSystem::FileRemoveExtension( FileSystem::FileNameFromPath( TextureAtlases[i] ) );

View File

@@ -109,8 +109,8 @@ void cMapEditor::CreateWinMenu() {
WinMenu->AddMenuButton( "View", PU3 );
cUIPopUpMenu * PU4 = mTheme->CreatePopUpMenu( mUIContainer );
PU4->Add( "New Texture Group..." );
PU4->Add( "Add External Texture Group..." );
PU4->Add( "New Texture Atlas..." );
PU4->Add( "Add External Texture Atlas..." );
PU4->AddSeparator();
PU4->Add( "Map Properties..." );
@@ -277,7 +277,7 @@ void cMapEditor::CreateSubTextureContainer( Int32 Width ) {
mSGCont->Enabled( true );
mSGCont->Visible( true );
Txt = mTheme->CreateTextBox( "SubTexture Groups:", mSGCont, eeSize( Width, 16 ), eeVector2i( 0, 0 ), TxtFlags );
Txt = mTheme->CreateTextBox( "Texture Atlases:", mSGCont, eeSize( Width, 16 ), eeVector2i( 0, 0 ), TxtFlags );
mTextureAtlasesList = mTheme->CreateDropDownList( mSGCont, eeSize( Width, 21 ), eeVector2i( 0, Txt->Pos().y +Txt->Size().Height() + 4 ), UI_CONTROL_DEFAULT_ALIGN | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
mTextureAtlasesList->AddEventListener( cUIEvent::EventOnItemSelected, cb::Make1( this, &cMapEditor::OnTextureAtlasChange ) );
@@ -883,16 +883,16 @@ void cMapEditor::MapMenuClick( const cUIEvent * Event ) {
const String& txt = reinterpret_cast<cUIMenuItem*> ( Event->Ctrl() )->Text();
if ( "New Texture Group..." == txt ) {
if ( "New Texture Atlas..." == txt ) {
cUIWindow * tWin = mTheme->CreateWindow( NULL, eeSize( 1024, 768 ), eeVector2i(), UI_CONTROL_DEFAULT_FLAGS_CENTERED, UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON, eeSize( 1024, 768 ) );
eeNew ( Tools::cTextureAtlasEditor, ( tWin ) );
tWin->Center();
tWin->Show();
} else if ( "Add External Texture Group..." == txt ) {
cUICommonDialog * TGDialog = mTheme->CreateCommonDialog( NULL, eeSize(), eeVector2i(), UI_CONTROL_DEFAULT_FLAGS_CENTERED, UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL, eeSize(), 255, UI_CDL_DEFAULT_FLAGS, "*.etg" );
} else if ( "Add External Texture Atlas..." == txt ) {
cUICommonDialog * TGDialog = mTheme->CreateCommonDialog( NULL, eeSize(), eeVector2i(), UI_CONTROL_DEFAULT_FLAGS_CENTERED, UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL, eeSize(), 255, UI_CDL_DEFAULT_FLAGS, std::string( "*" ) + EE_TEXTURE_ATLAS_EXTENSION );
TGDialog->Title( "Load texture group..." );
TGDialog->AddEventListener( cUIEvent::EventOpenFile, cb::Make1( this, &cMapEditor::TextureGroupOpen ) );
TGDialog->Title( "Load Texture Atlas..." );
TGDialog->AddEventListener( cUIEvent::EventOpenFile, cb::Make1( this, &cMapEditor::TextureAtlasOpen ) );
TGDialog->Center();
TGDialog->Show();
} else if ( "Map Properties..." == txt ) {
@@ -990,7 +990,7 @@ void cMapEditor::RefreshLayersList() {
}
}
void cMapEditor::TextureGroupOpen( const cUIEvent * Event ) {
void cMapEditor::TextureAtlasOpen( const cUIEvent * Event ) {
cUICommonDialog * CDL = reinterpret_cast<cUICommonDialog*> ( Event->Ctrl() );
std::string sgname = FileSystem::FileRemoveExtension( FileSystem::FileNameFromPath( CDL->GetFullPath() ) );

View File

@@ -1,5 +1,5 @@
#include <eepp/graphics/cprimitives.hpp>
#include <eepp/utils/polygon2.hpp>
#include <eepp/math/polygon2.hpp>
namespace EE { namespace Graphics {

View File

@@ -22,8 +22,8 @@ cTextureAtlasLoader::cTextureAtlasLoader() :
{
}
cTextureAtlasLoader::cTextureAtlasLoader( const std::string& TextureGroupPath, const bool& Threaded, GLLoadCallback LoadCallback ) :
mTextureGroupPath( TextureGroupPath ),
cTextureAtlasLoader::cTextureAtlasLoader( const std::string& TextureAtlasPath, const bool& Threaded, GLLoadCallback LoadCallback ) :
mTextureAtlasPath( TextureAtlasPath ),
mThreaded( Threaded ),
mLoaded(false),
mPack(NULL),
@@ -35,8 +35,8 @@ cTextureAtlasLoader::cTextureAtlasLoader( const std::string& TextureGroupPath, c
Load();
}
cTextureAtlasLoader::cTextureAtlasLoader( const Uint8* Data, const Uint32& DataSize, const std::string& TextureGroupName, const bool& Threaded, GLLoadCallback LoadCallback ) :
mTextureGroupPath( TextureGroupName ),
cTextureAtlasLoader::cTextureAtlasLoader( const Uint8* Data, const Uint32& DataSize, const std::string& TextureAtlasName, const bool& Threaded, GLLoadCallback LoadCallback ) :
mTextureAtlasPath( TextureAtlasName ),
mThreaded( Threaded ),
mLoaded(false),
mPack(NULL),
@@ -45,11 +45,11 @@ cTextureAtlasLoader::cTextureAtlasLoader( const Uint8* Data, const Uint32& DataS
mTextureAtlas(NULL),
mLoadCallback( LoadCallback )
{
LoadFromMemory( Data, DataSize, TextureGroupName );
LoadFromMemory( Data, DataSize, TextureAtlasName );
}
cTextureAtlasLoader::cTextureAtlasLoader( cPack * Pack, const std::string& FilePackPath, const bool& Threaded, GLLoadCallback LoadCallback ) :
mTextureGroupPath( FilePackPath ),
mTextureAtlasPath( FilePackPath ),
mThreaded( Threaded ),
mLoaded(false),
mPack(NULL),
@@ -80,20 +80,20 @@ void cTextureAtlasLoader::LoadFromStream( cIOStream& IOS ) {
mRL.Threaded( mThreaded );
if ( IOS.IsOpen() ) {
IOS.Read( (char*)&mTexGrHdr, sizeof(sTextureGroupHdr) );
IOS.Read( (char*)&mTexGrHdr, sizeof(sTextureAtlasHdr) );
if ( mTexGrHdr.Magic == ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'T' << 16 ) | ( 'G' << 24 ) ) ) {
if ( mTexGrHdr.Magic == EE_TEXTURE_ATLAS_MAGIC || mTexGrHdr.Magic == EE_TEXTURE_ATLAS_MAGIC_OLD ) {
for ( Uint32 i = 0; i < mTexGrHdr.TextureCount; i++ ) {
sTextureHdr tTextureHdr;
sTempTexGroup tTexGroup;
sTempTexAtlas tTexAtlas;
IOS.Read( (char*)&tTextureHdr, sizeof(sTextureHdr) );
tTexGroup.Texture = tTextureHdr;
tTexGroup.SubTextures.resize( tTextureHdr.SubTextureCount );
tTexAtlas.Texture = tTextureHdr;
tTexAtlas.SubTextures.resize( tTextureHdr.SubTextureCount );
std::string name( &tTextureHdr.Name[0] );
std::string path( FileSystem::FileRemoveFileName( mTextureGroupPath ) + name );
std::string path( FileSystem::FileRemoveFileName( mTextureAtlasPath ) + name );
//! Checks if the texture is already loaded
cTexture * tTex = cTextureFactory::instance()->GetByName( path );
@@ -106,9 +106,9 @@ void cTextureAtlasLoader::LoadFromStream( cIOStream& IOS ) {
}
}
IOS.Read( (char*)&tTexGroup.SubTextures[0], sizeof(sSubTextureHdr) * tTextureHdr.SubTextureCount );
IOS.Read( (char*)&tTexAtlas.SubTextures[0], sizeof(sSubTextureHdr) * tTextureHdr.SubTextureCount );
mTempGroups.push_back( tTexGroup );
mTempAtlass.push_back( tTexAtlas );
}
}
@@ -122,16 +122,16 @@ void cTextureAtlasLoader::LoadFromStream( cIOStream& IOS ) {
}
}
void cTextureAtlasLoader::Load( const std::string& TextureGroupPath ) {
if ( TextureGroupPath.size() )
mTextureGroupPath = TextureGroupPath;
void cTextureAtlasLoader::Load( const std::string& TextureAtlasPath ) {
if ( TextureAtlasPath.size() )
mTextureAtlasPath = TextureAtlasPath;
if ( FileSystem::FileExists( mTextureGroupPath ) ) {
cIOStreamFile IOS( mTextureGroupPath, std::ios::in | std::ios::binary );
if ( FileSystem::FileExists( mTextureAtlasPath ) ) {
cIOStreamFile IOS( mTextureAtlasPath, std::ios::in | std::ios::binary );
LoadFromStream( IOS );
} else if ( cPackManager::instance()->FallbackToPacks() ) {
std::string tgPath( mTextureGroupPath );
std::string tgPath( mTextureAtlasPath );
cPack * tPack = cPackManager::instance()->Exists( tgPath );
@@ -153,9 +153,9 @@ void cTextureAtlasLoader::LoadFromPack( cPack * Pack, const std::string& FilePac
}
}
void cTextureAtlasLoader::LoadFromMemory( const Uint8* Data, const Uint32& DataSize, const std::string& TextureGroupName ) {
if ( TextureGroupName.size() )
mTextureGroupPath = TextureGroupName;
void cTextureAtlasLoader::LoadFromMemory( const Uint8* Data, const Uint32& DataSize, const std::string& TextureAtlasName ) {
if ( TextureAtlasName.size() )
mTextureAtlasPath = TextureAtlasName;
cIOStreamMemory IOS( (const char*)Data, DataSize );
@@ -170,12 +170,12 @@ void cTextureAtlasLoader::CreateSubTextures() {
mIsLoading = false;
bool IsAlreadyLoaded = false;
for ( Uint32 z = 0; z < mTempGroups.size(); z++ ) {
sTempTexGroup * tTexGroup = &mTempGroups[z];
sTextureHdr * tTexHdr = &tTexGroup->Texture;
for ( Uint32 z = 0; z < mTempAtlass.size(); z++ ) {
sTempTexAtlas * tTexAtlas = &mTempAtlass[z];
sTextureHdr * tTexHdr = &tTexAtlas->Texture;
std::string name( &tTexHdr->Name[0] );
std::string path( FileSystem::FileRemoveFileName( mTextureGroupPath ) + name );
std::string path( FileSystem::FileRemoveFileName( mTextureAtlasPath ) + name );
FileSystem::FilePathRemoveProcessPath( path );
@@ -186,21 +186,21 @@ void cTextureAtlasLoader::CreateSubTextures() {
// Create the Texture Atlas with the name of the real texture, not the Childs ( example load 1.png and not 1_ch1.png )
if ( 0 == z ) {
if ( mTexGrHdr.Flags & HDR_TEXTURE_GROUP_REMOVE_EXTENSION )
if ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_REMOVE_EXTENSION )
name = FileSystem::FileRemoveExtension( name );
std::string etgpath = FileSystem::FileRemoveExtension( path ) + ".etg";
std::string etapath = FileSystem::FileRemoveExtension( path ) + EE_TEXTURE_ATLAS_EXTENSION;
cTextureAtlas * tTextureAtlas = cTextureAtlasManager::instance()->GetByName( name );
if ( NULL != tTextureAtlas && tTextureAtlas->Path() == etgpath ) {
if ( NULL != tTextureAtlas && tTextureAtlas->Path() == etapath ) {
mTextureAtlas = tTextureAtlas;
IsAlreadyLoaded = true;
} else {
mTextureAtlas = eeNew( cTextureAtlas, ( name ) );
mTextureAtlas->Path( etgpath );
mTextureAtlas->Path( etapath );
cTextureAtlasManager::instance()->Add( mTextureAtlas );
}
@@ -209,11 +209,11 @@ void cTextureAtlasLoader::CreateSubTextures() {
if ( NULL != tTex ) {
if ( !IsAlreadyLoaded ) {
for ( Int32 i = 0; i < tTexHdr->SubTextureCount; i++ ) {
sSubTextureHdr * tSh = &tTexGroup->SubTextures[i];
sSubTextureHdr * tSh = &tTexAtlas->SubTextures[i];
std::string SubTextureName( &tSh->Name[0] );
if ( mTexGrHdr.Flags & HDR_TEXTURE_GROUP_REMOVE_EXTENSION )
if ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_REMOVE_EXTENSION )
SubTextureName = FileSystem::FileRemoveExtension( SubTextureName );
eeRecti tRect( tSh->X, tSh->Y, tSh->X + tSh->Width, tSh->Y + tSh->Height );
@@ -227,7 +227,7 @@ void cTextureAtlasLoader::CreateSubTextures() {
}
}
} else {
cLog::instance()->Write( "cTextureAtlasLoader::CreateSubTextures: Failed to find texture group texture, it seems that is not loaded for some reason. Couldn't find: " + path );
cLog::instance()->Write( "cTextureAtlasLoader::CreateSubTextures: Failed to find texture atlas texture, it seems that is not loaded for some reason. Couldn't find: " + path );
eeASSERT( NULL != tTex );
@@ -268,16 +268,16 @@ Uint32 cTextureAtlasLoader::GetTexturesLoadedCount() {
}
bool cTextureAtlasLoader::UpdateTextureAtlas() {
if ( NULL == mTextureAtlas || !mTextureGroupPath.size() )
if ( NULL == mTextureAtlas || !mTextureAtlasPath.size() )
return false;
//! Update the data of the texture atlas
for ( Uint32 z = 0; z < mTempGroups.size(); z++ ) {
sTempTexGroup * tTexGroup = &mTempGroups[z];
sTextureHdr * tTexHdr = &tTexGroup->Texture;
for ( Uint32 z = 0; z < mTempAtlass.size(); z++ ) {
sTempTexAtlas * tTexAtlas = &mTempAtlass[z];
sTextureHdr * tTexHdr = &tTexAtlas->Texture;
for ( Int32 i = 0; i < tTexHdr->SubTextureCount; i++ ) {
sSubTextureHdr * tSh = &tTexGroup->SubTextures[i];
sSubTextureHdr * tSh = &tTexAtlas->SubTextures[i];
cSubTexture * tSubTexture = mTextureAtlas->GetById( tSh->ResourceID );
if ( NULL != tSubTexture ) {
@@ -289,18 +289,18 @@ bool cTextureAtlasLoader::UpdateTextureAtlas() {
}
}
cIOStreamFile fs( mTextureGroupPath, std::ios::out | std::ios::binary );
cIOStreamFile fs( mTextureAtlasPath, std::ios::out | std::ios::binary );
if ( fs.IsOpen() ) {
fs.Write( reinterpret_cast<char*> (&mTexGrHdr), sizeof(sTextureGroupHdr) );
fs.Write( reinterpret_cast<char*> (&mTexGrHdr), sizeof(sTextureAtlasHdr) );
for ( Uint32 z = 0; z < mTempGroups.size(); z++ ) {
sTempTexGroup * tTexGroup = &mTempGroups[z];
sTextureHdr * tTexHdr = &tTexGroup->Texture;
for ( Uint32 z = 0; z < mTempAtlass.size(); z++ ) {
sTempTexAtlas * tTexAtlas = &mTempAtlass[z];
sTextureHdr * tTexHdr = &tTexAtlas->Texture;
fs.Write( reinterpret_cast<char*> ( tTexHdr ), sizeof(sTextureHdr) );
fs.Write( reinterpret_cast<char*> ( &tTexGroup->SubTextures[0] ), sizeof(sSubTextureHdr) * (std::streamsize)tTexGroup->SubTextures.size() );
fs.Write( reinterpret_cast<char*> ( &tTexAtlas->SubTextures[0] ), sizeof(sSubTextureHdr) * (std::streamsize)tTexAtlas->SubTextures.size() );
}
return true;
@@ -348,7 +348,7 @@ bool cTextureAtlasLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std:
Load( TextureAtlasPath );
mSkipResourceLoad = false;
if ( !mTempGroups.size() )
if ( !mTempAtlass.size() )
return false;
Int32 x, y, c;
@@ -360,8 +360,8 @@ bool cTextureAtlasLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std:
Uint32 z;
Uint32 totalSubTextures = 0;
for ( z = 0; z < mTempGroups.size(); z++ )
totalSubTextures += mTempGroups[z].Texture.SubTextureCount;
for ( z = 0; z < mTempAtlass.size(); z++ )
totalSubTextures += mTempAtlass[z].Texture.SubTextureCount;
Uint32 totalImages = 0;
std::vector<std::string> PathFiles = FileSystem::FilesGetInPath( ImagesPath );
@@ -377,13 +377,13 @@ bool cTextureAtlasLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std:
if ( totalSubTextures != totalImages ) {
NeedUpdate = 2;
} else {
for ( z = 0; z < mTempGroups.size(); z++ ) {
sTempTexGroup * tTexGroup = &mTempGroups[z];
sTextureHdr * tTexHdr = &tTexGroup->Texture;
for ( z = 0; z < mTempAtlass.size(); z++ ) {
sTempTexAtlas * tTexAtlas = &mTempAtlass[z];
sTextureHdr * tTexHdr = &tTexAtlas->Texture;
if ( 2 != NeedUpdate ) {
for ( Int32 i = 0; i < tTexHdr->SubTextureCount; i++ ) {
sSubTextureHdr * tSh = &tTexGroup->SubTextures[i];
sSubTextureHdr * tSh = &tTexAtlas->SubTextures[i];
std::string path( ImagesPath + tSh->Name );
@@ -420,7 +420,7 @@ bool cTextureAtlasLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std:
std::string tapath( FileSystem::FileRemoveExtension( TextureAtlasPath ) + "." + cImage::SaveTypeToExtension( mTexGrHdr.Format ) );
if ( 2 == NeedUpdate ) {
cTexturePacker tp( mTexGrHdr.Width, mTexGrHdr.Height, 0 != ( mTexGrHdr.Flags & HDR_TEXTURE_GROUP_POW_OF_TWO ), mTexGrHdr.PixelBorder, mTexGrHdr.Flags & HDR_TEXTURE_GROUP_ALLOW_FLIPPING );
cTexturePacker tp( mTexGrHdr.Width, mTexGrHdr.Height, 0 != ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_POW_OF_TWO ), mTexGrHdr.PixelBorder, mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_ALLOW_FLIPPING );
tp.AddTexturesPath( ImagesPath );
@@ -428,16 +428,16 @@ bool cTextureAtlasLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std:
tp.Save( tapath, (EE_SAVE_TYPE)mTexGrHdr.Format );
} else if ( 1 == NeedUpdate ) {
std::string etgpath = FileSystem::FileRemoveExtension( tapath ) + ".etg";
std::string etapath = FileSystem::FileRemoveExtension( tapath ) + EE_TEXTURE_ATLAS_EXTENSION;
cIOStreamFile fs( etgpath , std::ios::out | std::ios::binary );
cIOStreamFile fs( etapath , std::ios::out | std::ios::binary );
if ( !fs.IsOpen() )
return false;
fs.Write( reinterpret_cast<const char*> (&mTexGrHdr), sizeof(sTextureGroupHdr) );
fs.Write( reinterpret_cast<const char*> (&mTexGrHdr), sizeof(sTextureAtlasHdr) );
for ( Uint32 z = 0; z < mTempGroups.size(); z++ ) {
for ( Uint32 z = 0; z < mTempAtlass.size(); z++ ) {
if ( z != 0 ) {
tapath = FileSystem::FileRemoveExtension( TextureAtlasPath ) + "_ch" + String::toStr( z ) + "." + cImage::SaveTypeToExtension( mTexGrHdr.Format );
}
@@ -448,13 +448,13 @@ bool cTextureAtlasLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std:
cImage Img( imgPtr, x, y, c );
Img.AvoidFreeImage( true );
sTempTexGroup * tTexGroup = &mTempGroups[z];
sTextureHdr * tTexHdr = &tTexGroup->Texture;
sTempTexAtlas * tTexAtlas = &mTempAtlass[z];
sTextureHdr * tTexHdr = &tTexAtlas->Texture;
fs.Write( reinterpret_cast<const char*> (tTexHdr), sizeof(sTextureHdr) );
for ( Int32 i = 0; i < tTexHdr->SubTextureCount; i++ ) {
sSubTextureHdr * tSh = &tTexGroup->SubTextures[i];
sSubTextureHdr * tSh = &tTexAtlas->SubTextures[i];
std::string imgcopypath( ImagesPath + tSh->Name );
@@ -478,7 +478,7 @@ bool cTextureAtlasLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std:
}
}
fs.Write( reinterpret_cast<const char*> (&tTexGroup->SubTextures[0]), sizeof(sSubTextureHdr) * tTexHdr->SubTextureCount );
fs.Write( reinterpret_cast<const char*> (&tTexAtlas->SubTextures[0]), sizeof(sSubTextureHdr) * tTexHdr->SubTextureCount );
Img.SaveToFile( tapath, (EE_SAVE_TYPE)mTexGrHdr.Format );

View File

@@ -558,9 +558,9 @@ void cTexturePacker::SaveSubTextures() {
if ( NULL != mParent )
return;
sTextureGroupHdr TexGrHdr;
sTextureAtlasHdr TexGrHdr;
TexGrHdr.Magic = ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'T' << 16 ) | ( 'G' << 24 ) );
TexGrHdr.Magic = EE_TEXTURE_ATLAS_MAGIC;
TexGrHdr.TextureCount = 1 + GetChildCount();
TexGrHdr.Format = mFormat;
TexGrHdr.Width = mWidth;
@@ -569,13 +569,13 @@ void cTexturePacker::SaveSubTextures() {
TexGrHdr.Flags = 0;
if ( mAllowFlipping )
TexGrHdr.Flags |= HDR_TEXTURE_GROUP_ALLOW_FLIPPING;
TexGrHdr.Flags |= HDR_TEXTURE_ATLAS_ALLOW_FLIPPING;
if ( !mSaveExtensions )
TexGrHdr.Flags |= HDR_TEXTURE_GROUP_REMOVE_EXTENSION;
TexGrHdr.Flags |= HDR_TEXTURE_ATLAS_REMOVE_EXTENSION;
if ( mForcePowOfTwo )
TexGrHdr.Flags |= HDR_TEXTURE_GROUP_POW_OF_TWO;
TexGrHdr.Flags |= HDR_TEXTURE_ATLAS_POW_OF_TWO;
std::vector<sTextureHdr> TexHdr( TexGrHdr.TextureCount );
@@ -592,11 +592,11 @@ void cTexturePacker::SaveSubTextures() {
std::vector<sSubTextureHdr> tSubTexturesHdr;
std::string path = FileSystem::FileRemoveExtension( mFilepath ) + ".etg";
std::string path = FileSystem::FileRemoveExtension( mFilepath ) + EE_TEXTURE_ATLAS_EXTENSION;
cIOStreamFile fs ( path , std::ios::out | std::ios::binary );
if ( fs.IsOpen() ) {
fs.Write( reinterpret_cast<const char*> (&TexGrHdr), sizeof(sTextureGroupHdr) );
fs.Write( reinterpret_cast<const char*> (&TexGrHdr), sizeof(sTextureAtlasHdr) );
fs.Write( reinterpret_cast<const char*> (&TexHdr[ 0 ]), sizeof(sTextureHdr) );

View File

@@ -1,8 +1,8 @@
#include <eepp/utils/cinterpolation.hpp>
#include <eepp/utils/easing.hpp>
using namespace EE::Utils::easing;
#include <eepp/math/cinterpolation.hpp>
#include <eepp/math/easing.hpp>
using namespace EE::Math::easing;
namespace EE { namespace Utils {
namespace EE { namespace Math {
cInterpolation::cInterpolation() :
mType(LINEAR),

View File

@@ -1,6 +1,6 @@
#include <eepp/utils/cperlinnoise.hpp>
#include <eepp/math/cperlinnoise.hpp>
namespace EE { namespace Utils {
namespace EE { namespace Math {
cPerlinNoise::cPerlinNoise() {
Init();

View File

@@ -1,8 +1,8 @@
#include <eepp/utils/cwaypoints.hpp>
#include <eepp/utils/easing.hpp>
using namespace EE::Utils::easing;
#include <eepp/math/cwaypoints.hpp>
#include <eepp/math/easing.hpp>
using namespace EE::Math::easing;
namespace EE { namespace Utils {
namespace EE { namespace Math {
cWaypoints::cWaypoints() :
mType(LINEAR),

39
src/eepp/math/easing.cpp Normal file
View File

@@ -0,0 +1,39 @@
#include <eepp/math/easing.hpp>
namespace EE { namespace Math { namespace easing {
easingCbFunc easingCb[] = {
LinearInterpolation,
QuadraticIn,
QuadraticOut,
QuadraticInOut,
SineIn,
SineOut,
SineInOut,
ExponentialIn,
ExponentialOut,
ExponentialInOut,
QuarticIn,
QuarticOut,
QuarticInOut,
QuinticIn,
QuinticOut,
QuinticInOut,
CircularIn,
CircularOut,
CircularInOut,
CubicIn,
CubicOut,
CubicInOut,
BackIn,
BackOut,
BackInOut,
BounceIn,
BounceOut,
BounceInOut,
ElasticIn,
ElasticOut,
ElasticInOut
};
}}}

View File

@@ -1,6 +1,8 @@
#include <eepp/utils/safedatapointer.hpp>
#include <eepp/system/safedatapointer.hpp>
#include <eepp/base/memorymanager.hpp>
#include <cstddef>
namespace EE { namespace Utils {
namespace EE { namespace System {
SafeDataPointer::SafeDataPointer() :
Data( NULL ),

View File

@@ -1,6 +1,6 @@
#include <eepp/utils/utils.hpp>
#include <eepp/system/utils.hpp>
namespace EE { namespace Utils {
namespace EE { namespace System {
Uint32 MakeHash( const std::string& str ) {
return MakeHash( reinterpret_cast<const Uint8*>( &str[0] ) );

View File

@@ -144,7 +144,7 @@ cUITheme * cUITheme::LoadFromTextureAtlas( cUITheme * tTheme, cTextureAtlas * Te
Element = std::string( tTheme->Abbr() + "_" + *it );
Found = SearchFilesInGroup( TextureAtlas, Element, IsComplex );
Found = SearchFilesInAtlas( TextureAtlas, Element, IsComplex );
if ( Found ) {
ElemFound.push_back( Element );
@@ -235,7 +235,7 @@ cUITheme * cUITheme::LoadFromTextureAtlas( cTextureAtlas * TextureAtlas, const s
return LoadFromTextureAtlas( eeNew( cUITheme, ( Name, NameAbbr ) ), TextureAtlas );
}
bool cUITheme::SearchFilesInGroup( cTextureAtlas * SG, std::string Element, Uint32& IsComplex ) {
bool cUITheme::SearchFilesInAtlas( cTextureAtlas * SG, std::string Element, Uint32& IsComplex ) {
bool Found = false;
Uint32 i = 0, s = 0;
std::string ElemName;

View File

@@ -13,7 +13,7 @@ cTextureAtlasEditor::cTextureAtlasEditor( cUIWindow * AttatchTo, const TGEditorC
mUIWindow( AttatchTo ),
mCloseCb( callback ),
mTexturePacker( NULL ),
mTextureGroupLoader( NULL ),
mTextureAtlasLoader( NULL ),
mCurSubTexture( NULL )
{
if ( NULL == cUIThemeManager::instance()->DefaultTheme() ) {
@@ -102,7 +102,7 @@ cTextureAtlasEditor::cTextureAtlasEditor( cUIWindow * AttatchTo, const TGEditorC
HBOffsetButton->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cTextureAtlasEditor::OnHBOffset ) );
HBOffsetButton->Text( "Half-Bottom Offset" );
mUIWindow->Title( "Texture Group Editor" );
mUIWindow->Title( "Texture Atlas Editor" );
mUIWindow->AddEventListener( cUIEvent::EventOnWindowClose, cb::Make1( this, &cTextureAtlasEditor::WindowClose ) );
CreateTGEditor();
@@ -122,7 +122,7 @@ cTextureAtlasEditor::cTextureAtlasEditor( cUIWindow * AttatchTo, const TGEditorC
cTextureAtlasEditor::~cTextureAtlasEditor() {
eeSAFE_DELETE( mTexturePacker );
eeSAFE_DELETE( mTextureGroupLoader );
eeSAFE_DELETE( mTextureAtlasLoader );
if ( !cUIManager::instance()->IsShootingDown() ) {
mTGEU->Close();
@@ -236,27 +236,27 @@ void cTextureAtlasEditor::FileMenuClick( const cUIEvent * Event ) {
const String& txt = reinterpret_cast<cUIMenuItem*> ( Event->Ctrl() )->Text();
if ( "New..." == txt ) {
eeNew( cTextureAtlasNew, ( cb::Make1( this, &cTextureAtlasEditor::OnTextureGroupCreate ) ) );
eeNew( cTextureAtlasNew, ( cb::Make1( this, &cTextureAtlasEditor::OnTextureAtlasCreate ) ) );
} else if ( "Open..." == txt ) {
cUICommonDialog * TGDialog = mTheme->CreateCommonDialog( NULL, eeSize(), eeVector2i(), UI_CONTROL_DEFAULT_FLAGS_CENTERED, UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL, eeSize(), 255, UI_CDL_DEFAULT_FLAGS, "*.etg" );
cUICommonDialog * TGDialog = mTheme->CreateCommonDialog( NULL, eeSize(), eeVector2i(), UI_CONTROL_DEFAULT_FLAGS_CENTERED, UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL, eeSize(), 255, UI_CDL_DEFAULT_FLAGS, std::string( "*" ) + EE_TEXTURE_ATLAS_EXTENSION );
TGDialog->Title( "Open Texture Group" );
TGDialog->AddEventListener( cUIEvent::EventOpenFile, cb::Make1( this, &cTextureAtlasEditor::OpenTextureGroup ) );
TGDialog->Title( "Open Texture Atlas" );
TGDialog->AddEventListener( cUIEvent::EventOpenFile, cb::Make1( this, &cTextureAtlasEditor::OpenTextureAtlas ) );
TGDialog->Center();
TGDialog->Show();
} else if ( "Save" == txt ) {
if ( NULL != mTextureGroupLoader && mTextureGroupLoader->IsLoaded() ) {
mTextureGroupLoader->UpdateTextureAtlas();
if ( NULL != mTextureAtlasLoader && mTextureAtlasLoader->IsLoaded() ) {
mTextureAtlasLoader->UpdateTextureAtlas();
}
} else if ( "Close" == txt ) {
if ( NULL != mTextureGroupLoader && mTextureGroupLoader->IsLoaded() ) {
cUIMessageBox * MsgBox = mTheme->CreateMessageBox( MSGBOX_OKCANCEL, "Do you really want to close the current texture group?\nAll changes will be lost." );
MsgBox->AddEventListener( cUIEvent::EventMsgBoxConfirmClick, cb::Make1( this, &cTextureAtlasEditor::OnTextureGroupClose ) );
MsgBox->Title( "Close Texture Group?" );
if ( NULL != mTextureAtlasLoader && mTextureAtlasLoader->IsLoaded() ) {
cUIMessageBox * MsgBox = mTheme->CreateMessageBox( MSGBOX_OKCANCEL, "Do you really want to close the current texture atlas?\nAll changes will be lost." );
MsgBox->AddEventListener( cUIEvent::EventMsgBoxConfirmClick, cb::Make1( this, &cTextureAtlasEditor::OnTextureAtlasClose ) );
MsgBox->Title( "Close Texture Atlas?" );
MsgBox->Center();
MsgBox->Show();
} else {
OnTextureGroupClose( NULL );
OnTextureAtlasClose( NULL );
}
} else if ( "Quit" == txt ) {
if ( mUIWindow == cUIManager::instance()->MainControl() ) {
@@ -267,28 +267,28 @@ void cTextureAtlasEditor::FileMenuClick( const cUIEvent * Event ) {
}
}
void cTextureAtlasEditor::OnTextureGroupCreate( cTexturePacker * TexPacker ) {
void cTextureAtlasEditor::OnTextureAtlasCreate( cTexturePacker * TexPacker ) {
eeSAFE_DELETE( mTexturePacker );
mTexturePacker = TexPacker;
eeSAFE_DELETE( mTextureGroupLoader );
eeSAFE_DELETE( mTextureAtlasLoader );
std::string FPath( FileSystem::FileRemoveExtension( mTexturePacker->GetFilepath() ) + ".etg" );
std::string FPath( FileSystem::FileRemoveExtension( mTexturePacker->GetFilepath() + EE_TEXTURE_ATLAS_EXTENSION ) );
mTextureGroupLoader = eeNew( cTextureAtlasLoader, ( FPath, true, cb::Make1( this, &cTextureAtlasEditor::OnTextureGroupLoaded ) ) );
mTextureAtlasLoader = eeNew( cTextureAtlasLoader, ( FPath, true, cb::Make1( this, &cTextureAtlasEditor::OnTextureAtlasLoaded ) ) );
}
void cTextureAtlasEditor::UpdateControls() {
if ( NULL != mTextureGroupLoader && mTextureGroupLoader->IsLoaded() ) {
if ( NULL != mTextureAtlasLoader && mTextureAtlasLoader->IsLoaded() ) {
FillSubTextureList();
}
}
void cTextureAtlasEditor::FillSubTextureList() {
if ( NULL == mTextureGroupLoader || NULL == mTextureGroupLoader->GetTextureAtlas() || !mTextureGroupLoader->IsLoaded() )
if ( NULL == mTextureAtlasLoader || NULL == mTextureAtlasLoader->GetTextureAtlas() || !mTextureAtlasLoader->IsLoaded() )
return;
std::list<cSubTexture*>& Res = mTextureGroupLoader->GetTextureAtlas()->GetResources();
std::list<cSubTexture*>& Res = mTextureAtlasLoader->GetTextureAtlas()->GetResources();
mSubTextureList->Clear();
@@ -309,8 +309,8 @@ void cTextureAtlasEditor::FillSubTextureList() {
}
void cTextureAtlasEditor::OnSubTextureChange( const cUIEvent * Event ) {
if ( NULL != mTextureGroupLoader && NULL != mTextureGroupLoader->GetTextureAtlas() ) {
mCurSubTexture = mTextureGroupLoader->GetTextureAtlas()->GetByName( mSubTextureList->GetItemSelectedText() );
if ( NULL != mTextureAtlasLoader && NULL != mTextureAtlasLoader->GetTextureAtlas() ) {
mCurSubTexture = mTextureAtlasLoader->GetTextureAtlas()->GetByName( mSubTextureList->GetItemSelectedText() );
if ( NULL != mCurSubTexture ) {
mSubTextureEditor->SubTexture( mCurSubTexture );
@@ -323,32 +323,32 @@ void cTextureAtlasEditor::OnSubTextureChange( const cUIEvent * Event ) {
}
void cTextureAtlasEditor::Update() {
if ( NULL != mTextureGroupLoader && !mTextureGroupLoader->IsLoaded() ) {
mTextureGroupLoader->Update();
if ( NULL != mTextureAtlasLoader && !mTextureAtlasLoader->IsLoaded() ) {
mTextureAtlasLoader->Update();
}
}
void cTextureAtlasEditor::OpenTextureGroup( const cUIEvent * Event ) {
void cTextureAtlasEditor::OpenTextureAtlas( const cUIEvent * Event ) {
cUICommonDialog * CDL = reinterpret_cast<cUICommonDialog*> ( Event->Ctrl() );
eeSAFE_DELETE( mTextureGroupLoader );
mTextureGroupLoader = eeNew( cTextureAtlasLoader, ( CDL->GetFullPath(), true, cb::Make1( this, &cTextureAtlasEditor::OnTextureGroupLoaded ) ) );
eeSAFE_DELETE( mTextureAtlasLoader );
mTextureAtlasLoader = eeNew( cTextureAtlasLoader, ( CDL->GetFullPath(), true, cb::Make1( this, &cTextureAtlasEditor::OnTextureAtlasLoaded ) ) );
}
void cTextureAtlasEditor::OnTextureGroupLoaded( cTextureAtlasLoader * TGLoader ) {
if ( NULL != mTextureGroupLoader && mTextureGroupLoader->IsLoaded() ) {
void cTextureAtlasEditor::OnTextureAtlasLoaded( cTextureAtlasLoader * TGLoader ) {
if ( NULL != mTextureAtlasLoader && mTextureAtlasLoader->IsLoaded() ) {
UpdateControls();
}
}
void cTextureAtlasEditor::SaveTextureGroup( const cUIEvent * Event ) {
if ( NULL != mTextureGroupLoader && mTextureGroupLoader->IsLoaded() ) {
mTextureGroupLoader->UpdateTextureAtlas();
void cTextureAtlasEditor::SaveTextureAtlas( const cUIEvent * Event ) {
if ( NULL != mTextureAtlasLoader && mTextureAtlasLoader->IsLoaded() ) {
mTextureAtlasLoader->UpdateTextureAtlas();
}
}
void cTextureAtlasEditor::OnTextureGroupClose( const cUIEvent * Event ) {
eeSAFE_DELETE( mTextureGroupLoader );
void cTextureAtlasEditor::OnTextureAtlasClose( const cUIEvent * Event ) {
eeSAFE_DELETE( mTextureAtlasLoader );
mSubTextureList->Clear();
mSpinOffX->Value( 0 );
mSpinOffY->Value( 0 );

View File

@@ -18,7 +18,7 @@ cTextureAtlasNew::cTextureAtlasNew( TGCreateCb NewTGCb ) :
mUIWindow = mTheme->CreateWindow( NULL, eeSize( 378, 244 ), eeVector2i(), UI_CONTROL_DEFAULT_FLAGS_CENTERED, UI_WIN_DEFAULT_FLAGS | UI_WIN_MODAL );
mUIWindow->AddEventListener( cUIEvent::EventOnWindowClose, cb::Make1( this, &cTextureAtlasNew::WindowClose ) );
mUIWindow->Title( "New Texture Group" );
mUIWindow->Title( "New Texture Atlas" );
Int32 PosX = mUIWindow->Container()->Size().Width() - 110;
@@ -53,10 +53,10 @@ cTextureAtlasNew::cTextureAtlasNew( TGCreateCb NewTGCb ) :
mComboWidth->ListBox()->SetSelected( "512" );
mComboHeight->ListBox()->SetSelected( "512" );
CreateTxtBox( eeVector2i( 10, 110 ), "Space between sub texturesF (pixels):" );
CreateTxtBox( eeVector2i( 10, 110 ), "Space between sub textures (pixels):" );
mPixelSpace = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 100, 22 ), eeVector2i( PosX, 110 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_SIZE, 0, false );
CreateTxtBox( eeVector2i( 10, 140 ), "Texture Group Folder Path:" );
CreateTxtBox( eeVector2i( 10, 140 ), "Texture Atlas Folder Path:" );
mTGPath = mTheme->CreateTextInput( mUIWindow->Container(), eeSize( mUIWindow->Container()->Size().Width() - 60, 22 ), eeVector2i( 10, 160 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_AUTO_SIZE , false, 512 );
mTGPath->AllowEditing( false );
@@ -90,8 +90,8 @@ void cTextureAtlasNew::OKClick( const cUIEvent * Event ) {
cUICommonDialog * TGDialog = mTheme->CreateCommonDialog( NULL, eeSize(), eeVector2i(), UI_CONTROL_DEFAULT_FLAGS_CENTERED, UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL, eeSize(), 255, UI_CDL_DEFAULT_FLAGS | CDL_FLAG_SAVE_DIALOG, "*." + ext );
TGDialog->Title( "Save Texture Group" );
TGDialog->AddEventListener( cUIEvent::EventSaveFile, cb::Make1( this, &cTextureAtlasNew::TextureGroupSave ) );
TGDialog->Title( "Save Texture Atlas" );
TGDialog->AddEventListener( cUIEvent::EventSaveFile, cb::Make1( this, &cTextureAtlasNew::TextureAtlasSave ) );
TGDialog->Center();
TGDialog->Show();
}
@@ -108,7 +108,7 @@ static bool IsValidExtension( const std::string& ext ) {
return ext == "png" || ext == "bmp" || ext == "dds" || ext == "tga";
}
void cTextureAtlasNew::TextureGroupSave( const cUIEvent * Event ) {
void cTextureAtlasNew::TextureAtlasSave( const cUIEvent * Event ) {
cUICommonDialog * CDL = reinterpret_cast<cUICommonDialog*> ( Event->Ctrl() );
std::string FPath( CDL->GetFullPath() );
@@ -153,7 +153,7 @@ void cTextureAtlasNew::OnDialogFolderSelect( const cUIEvent * Event ) {
if ( MouseEvent->Flags() & EE_BUTTON_LMASK ) {
cUICommonDialog * TGDialog = mTheme->CreateCommonDialog( NULL, eeSize(), eeVector2i(), UI_CONTROL_DEFAULT_FLAGS_CENTERED, UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL, eeSize(), 255, UI_CDL_DEFAULT_FLAGS | CDL_FLAG_ALLOW_FOLDER_SELECT, "*" );
TGDialog->Title( "Create Texture Group ( Select Folder Containing Textures )" );
TGDialog->Title( "Create Texture Atlas ( Select Folder Containing Textures )" );
TGDialog->AddEventListener( cUIEvent::EventOpenFile, cb::Make1( this, &cTextureAtlasNew::OnSelectFolder ) );
TGDialog->Center();
TGDialog->Show();

View File

@@ -1,310 +0,0 @@
#include <eepp/utils/easing.hpp>
namespace EE { namespace Utils { namespace easing {
easingCbFunc easingCb[] = {
LinearInterpolation,
QuadraticIn,
QuadraticOut,
QuadraticInOut,
SineIn,
SineOut,
SineInOut,
ExponentialIn,
ExponentialOut,
ExponentialInOut,
QuarticIn,
QuarticOut,
QuarticInOut,
QuinticIn,
QuinticOut,
QuinticInOut,
CircularIn,
CircularOut,
CircularInOut,
CubicIn,
CubicOut,
CubicInOut,
BackIn,
BackOut,
BackInOut,
BounceIn,
BounceOut,
BounceInOut,
ElasticIn,
ElasticOut,
ElasticInOut
};
eeFloat LinearInterpolation( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
return b + t * c / d;
}
eeFloat QuadraticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d;
return c * t * t + b;
}
eeFloat QuadraticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d;
return -c * t * ( t - 2 ) + b;
}
eeFloat QuadraticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d / 2;
if ( t < 1 )
return c / 2 * t * t + b;
--t;
return -c / 2 * ( t * ( t - 2 ) - 1 ) + b;
}
eeFloat SineIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
return -c * eecos( t / d * ( EE_PI / 2 ) ) + c + b;
}
eeFloat SineOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
return c * eesin( t / d * ( EE_PI / 2 ) ) + b;
}
eeFloat SineInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
return -c / 2 * ( eecos( EE_PI * t / d ) - 1 ) + b;
}
eeFloat ExponentialIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
return t == 0 ? b : c * eepow( 2, 10 * ( t / d - 1 ) ) + b;
}
eeFloat ExponentialOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
return t == d ? b + c : c * ( -eepow( 2, -10 * t / d ) + 1 ) + b;
}
eeFloat ExponentialInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
if (t == 0)
return b;
if (t == d)
return b + c;
if ( ( t /= d / 2 ) < 1 )
return c / 2 * eepow( 2, 10 * (t - 1) ) + b;
return c / 2 * ( -eepow( 2, -10 * --t ) + 2 ) + b;
}
eeFloat QuarticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d;
return c * t * t * t * t + b;
}
eeFloat QuarticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t = t / d - 1;
return -c * ( t * t * t * t - 1 ) + b;
}
eeFloat QuarticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d / 2;
if ( t < 1)
return c / 2 * t * t * t * t + b;
t -= 2;
return -c / 2 * ( t * t * t * t - 2 ) + b;
}
eeFloat QuinticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d;
return c * t * t * t * t * t + b;
}
eeFloat QuinticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t = t / d - 1;
return c * ( t * t * t * t * t + 1) + b;
}
eeFloat QuinticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d / 2;
if ( t < 1 )
return c / 2 * t * t * t * t * t + b;
t -= 2;
return c / 2 * ( t * t * t * t * t + 2) + b;
}
eeFloat CircularIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d;
return -c * ( eesqrt( 1 - t * t ) - 1) + b;
}
eeFloat CircularOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t = t / d - 1;
return c * eesqrt( 1 - t * t ) + b;
}
eeFloat CircularInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d / 2;
if ( t < 1 )
return -c / 2 * ( eesqrt( 1 - t * t ) - 1 ) + b;
t -= 2;
return c / 2 * ( eesqrt( 1 - t * t ) + 1) + b;
}
eeFloat CubicIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d;
return c * t * t * t + b;
}
eeFloat CubicOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t = t / d - 1;
return c * ( t * t * t + 1) + b;
}
eeFloat CubicInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d / 2;
if ( t < 1 )
return c / 2 * t * t * t + b;
t -= 2;
return c / 2 * ( t * t * t + 2 ) + b;
}
eeFloat BackIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
eeFloat s = 1.70158f;
t /= d;
return c * t * t * ( ( s + 1 ) * t - s) + b;
}
eeFloat BackOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
eeFloat s = 1.70158f;
t = t / d - 1;
return c * ( t * t * ( ( s + 1 ) * t + s ) + 1 ) + b;
}
eeFloat BackInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
float s = 1.70158f;
t /= d / 2;
s *= ( 1.525f );
if ( t < 1 )
return c / 2 * ( t * t * ( ( s + 1 ) * t - s ) ) + b;
t -= 2;
return c / 2 * ( t * t * ( ( s + 1 ) * t + s ) + 2) + b;
}
eeFloat BounceOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
t /= d;
if ( t < ( 1.f / 2.75f ) ) {
return c * ( 7.5625f * t * t ) + b;
} else if ( t < ( 2.f / 2.75f) ) {
t -= ( 1.5f / 2.75f );
return c * ( 7.5625f * t * t + 0.75f ) + b;
} else if (t < ( 2.5f / 2.75f ) ) {
t -= ( 2.25f / 2.75f );
return c * ( 7.5625f * t * t + 0.9375f ) + b;
} else {
t -= ( 2.625f / 2.75f );
return c * ( 7.5625f * t * t + 0.984375f ) + b;
}
}
eeFloat BounceIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
return c - BounceOut( d - t, 0, c, d ) + b;
}
eeFloat BounceInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
if ( t < d * 0.5f )
return BounceIn( t * 2.f, 0.f, c, d ) * 0.5f + b;
return BounceOut( t * 2.f - d, 0.f, c, d ) * 0.5f + c * 0.5f + b;
}
eeFloat ElasticIn( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
if ( t == 0.f )
return b;
t /= d;
if ( t == 1.f )
return b + c;
eeFloat p = d * 0.3f;
eeFloat s = p / 4.f;
eeFloat a = c;
t -= 1.f;
return -( a * eepow( 2.f , 10.f * t ) * eesin( ( t * d - s ) * ( 2.f * EE_PI ) / p ) ) + b;
}
eeFloat ElasticOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
if ( t == 0.f )
return b;
t /= d;
if ( t ==1 )
return b + c;
eeFloat p = d * 0.3f;
eeFloat s = p / 4.f;
eeFloat a = c;
return ( a * eepow( 2.f, -10.f * t ) * eesin( ( t * d - s ) * ( 2.f * EE_PI ) / p ) + c + b );
}
eeFloat ElasticInOut( eeFloat t, eeFloat b, eeFloat c, eeFloat d ) {
if ( t == 0 )
return b;
t /= d / 2;
if ( t == 2 )
return b + c;
eeFloat p = d * ( 0.3f * 1.5f );
eeFloat a = c;
eeFloat s = p / 4.f;
if ( t < 1 ) {
t -= 1.f;
return -0.5f * ( a * eepow( 2.f, 10.f * t ) * eesin( ( t * d - s ) * ( 2.f * EE_PI ) / p ) ) + b;
}
t -= 1.f;
return a * eepow( 2.f, -10.f * t ) * eesin( ( t * d - s ) * ( 2.f * EE_PI ) / p ) * 0.5f + c + b;
}
}}}

View File

@@ -145,14 +145,14 @@ void cEETest::CreateAquaTextureAtlas() {
std::string tgpath( MyPath + "data/aquatg/aqua" );
std::string Path( MyPath + "data/aqua" );
if ( !FileSystem::FileExists( tgpath + ".etg" ) ) {
if ( !FileSystem::FileExists( tgpath + EE_TEXTURE_ATLAS_EXTENSION ) ) {
cTexturePacker tp( 256, 256, true, 2 );
tp.AddTexturesPath( Path );
tp.PackTextures();
tp.Save( tgpath + ".png", EE_SAVE_TYPE_PNG );
} else {
cTextureAtlasLoader tgl;
tgl.UpdateTextureAtlas( tgpath + ".etg", Path );
tgl.UpdateTextureAtlas( tgpath + EE_TEXTURE_ATLAS_EXTENSION, Path );
}
}
@@ -258,7 +258,7 @@ void cEETest::CreateUI() {
//mTheme = cUITheme::LoadFromPath( eeNew( cUIAquaTheme, ( "aqua", "aqua" ) ), MyPath + "data/aqua/" );
cTextureAtlasLoader tgl( MyPath + "data/aquatg/aqua.etg" );
cTextureAtlasLoader tgl( MyPath + "data/aquatg/aqua" + EE_TEXTURE_ATLAS_EXTENSION );
tgl.GetTexture()->TextureFilter( TEX_FILTER_NEAREST );
mTheme = cUITheme::LoadFromTextureAtlas( eeNew( cUIAquaTheme, ( "aqua", "aqua" ) ), cTextureAtlasManager::instance()->GetByName( "aqua" ) );
@@ -470,7 +470,7 @@ void cEETest::CreateUI() {
Menu->Add( "Open...", mTheme->GetIconByName( "document-open" ) );
Menu->AddSeparator();
Menu->Add( "Map Editor" );
Menu->Add( "Texture Group Editor" );
Menu->Add( "Texture Atlas Editor" );
Menu->AddSeparator();
Menu->Add( "Show Screen 1" );
Menu->Add( "Show Screen 2" );
@@ -707,7 +707,7 @@ void cEETest::ItemClick( const cUIEvent * Event ) {
mUIWindow->Show();
} else if ( "Map Editor" == txt ) {
CreateMapEditor();
} else if ( "Texture Group Editor" == txt ) {
} else if ( "Texture Atlas Editor" == txt ) {
CreateETGEditor();
} else if ( "Multi Viewport" == txt ) {
MultiViewportMode = !MultiViewportMode;
@@ -902,7 +902,7 @@ void cEETest::LoadTextures() {
if ( cImage::GetInfo( MyPath + "data/extra/bnb.png", &x, &y, &c ) )
{
mTGL = eeNew( cTextureAtlasLoader, ( MyPath + "data/extra/bnb.etg" ) );
mTGL = eeNew( cTextureAtlasLoader, ( MyPath + "data/extra/bnb" + EE_TEXTURE_ATLAS_EXTENSION ) );
}
mBlindy.AddFramesByPattern( "rn" );