101 lines
2.4 KiB
C++
101 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <toolkit/ILock.h>
|
|
#include "KSmartPtr.h"
|
|
//#include <vector>
|
|
#include <map>
|
|
|
|
const int c_nMaxTextureCount = 65535; ///< 타일값을 WORD형으로 저장하므로
|
|
|
|
class K3DRenderDevice;
|
|
DECL_SPTR(K3DTexture)
|
|
|
|
class CTerrainTextureInfo
|
|
{
|
|
public:
|
|
CTerrainTextureInfo();
|
|
virtual ~CTerrainTextureInfo();
|
|
|
|
bool Initialize( const char* szTextureInfoFileName, K3DRenderDevice* pDevice );
|
|
void Release();
|
|
|
|
const std::vector<std::string>& GetTextureCategoryNames() const { return m_CategoryNames; }
|
|
|
|
void EnumTextureNumberList( std::vector< WORD > & vList ) const
|
|
{
|
|
for( std::map< WORD, TEXINFO_STRUCT >::const_iterator it = m_mapTexInfo.begin(); it != m_mapTexInfo.end(); ++it )
|
|
vList.push_back( (*it).first );
|
|
}
|
|
|
|
bool IsValidTexture( WORD wTextureNum ) const
|
|
{
|
|
std::map< WORD, TEXINFO_STRUCT >::const_iterator it = m_mapTexInfo.find( wTextureNum );
|
|
if( it == m_mapTexInfo.end() )
|
|
return false;
|
|
return (*it).second.spTexture != NULL ;
|
|
}
|
|
|
|
int GetTextureCategory( WORD wTextureNum ) const
|
|
{
|
|
std::map< WORD, TEXINFO_STRUCT >::const_iterator it = m_mapTexInfo.find( wTextureNum );
|
|
if( it == m_mapTexInfo.end() )
|
|
return -1;
|
|
return (*it).second.nCategory;
|
|
}
|
|
|
|
float GetTextureDetailRatio( WORD wTextureNum ) const
|
|
{
|
|
std::map< WORD, TEXINFO_STRUCT >::const_iterator it = m_mapTexInfo.find( wTextureNum );
|
|
if( it == m_mapTexInfo.end() )
|
|
return 1.0f;
|
|
return (*it).second.fDetailRatio;
|
|
}
|
|
|
|
const char* GetTextureName( WORD wTextureNum, bool bNoReturnNull = true ) const
|
|
{
|
|
std::map< WORD, TEXINFO_STRUCT >::const_iterator it = m_mapTexInfo.find( wTextureNum );
|
|
if( it == m_mapTexInfo.end() )
|
|
return "";
|
|
return (*it).second.strName.c_str();
|
|
}
|
|
|
|
K3DTexture* GetTexture( WORD wTextureNum );
|
|
|
|
K3DTexture* GetNotFoundTexture();
|
|
|
|
void RemoveUnnecessaryTexture();
|
|
|
|
private:
|
|
K3DRenderDevice* m_pDevice;
|
|
|
|
struct TEXINFO_STRUCT
|
|
{
|
|
TEXINFO_STRUCT()
|
|
{
|
|
bIsLoadFailed= false;
|
|
nCategory = 0;
|
|
fDetailRatio = 1.f;
|
|
dwLastAccessTime = 0;
|
|
}
|
|
|
|
bool bIsLoadFailed;
|
|
int nCategory;
|
|
DWORD dwLastAccessTime;
|
|
float fDetailRatio;
|
|
std::string strName;
|
|
K3DTextureSPtr spTexture;
|
|
};
|
|
std::map< WORD, TEXINFO_STRUCT > m_mapTexInfo;
|
|
|
|
DWORD m_dwLastTextureRemoveTime;
|
|
|
|
std::vector<std::string> m_CategoryNames;
|
|
|
|
K3DTextureSPtr m_spDummyTexture;
|
|
XCriticalSection m_lckTexture;
|
|
|
|
bool InitializeDummyTexture();
|
|
void ReleaseDummyTexture();
|
|
|
|
};
|