1583 lines
40 KiB
C++
1583 lines
40 KiB
C++
#ifndef __KRESOURCE_H__
|
|
#define __KRESOURCE_H__
|
|
|
|
#include <kfile/KStream.h>
|
|
#include "K3DTypes.h"
|
|
#include "K3DBound.h"
|
|
#include "KRenderDevice.h"
|
|
#include "KRenderDefine.h"
|
|
#include "KSmartPtr.h"
|
|
#include <dump/XException.h>
|
|
#include "_TextureMode.h"
|
|
|
|
#include <algorithm>
|
|
#include <assert.h>
|
|
//#include <string>
|
|
//#include <vector>
|
|
|
|
class KResource
|
|
{
|
|
public:
|
|
KResource();
|
|
protected: // Resource must be created in heap and must be deleted by Release() or Discard()
|
|
virtual ~KResource();
|
|
public:
|
|
enum RESTYPE
|
|
{
|
|
RESTYPE_UNKNOWN,
|
|
RESTYPE_RENDERTARGET,
|
|
RESTYPE_TEXTURE,
|
|
RESTYPE_TEXTURE_FONT,
|
|
RESTYPE_CUBETEXTURE,
|
|
RESTYPE_VERTEXBUFFER,
|
|
RESTYPE_VERTEXBUFFERBLEND,
|
|
RESTYPE_VERTEXBUFFERSPEEDTREE,
|
|
RESTYPE_VERTEXBUFFERSPEEDGRASS,
|
|
RESTYPE_VERTEXBUFFERPOOLDEFAULT,
|
|
RESTYPE_VERTEXANIMATION,
|
|
RESTYPE_INDEXBUFFER,
|
|
RESTYPE_INDEXARRAY, ///< 인덱스 배열
|
|
RESTYPE_VERTEXARRAY, ///< 버텍스 배열
|
|
RESTYPE_MESH,
|
|
RESTYPE_MESHMATRIX,
|
|
RESTYPE_MESHUV,
|
|
RESTYPE_MESHVISIBILITY,
|
|
RESTYPE_EVENTPOINT,
|
|
RESTYPE_EVENTBOX,
|
|
RESTYPE_CAMERA,
|
|
RESTYPE_LIGHT,
|
|
RESTYPE_SOUND,
|
|
RESTYPE_SPRITE,
|
|
RESTYPE_SPRITEANIMATION,
|
|
RESTYPE_FXBILLBOARD,
|
|
RESTYPE_FXPARTICLE,
|
|
RESTYPE_FXAFTERIMAGE,
|
|
RESTYPE_USERBUFFER,
|
|
RESTYPE_BONE,
|
|
};
|
|
int GetResourceType() const;
|
|
|
|
enum RESSTATE
|
|
{
|
|
RESSTATE_NOTAVAILABLE = 0,
|
|
RESSTATE_AVAILABLE = 1,
|
|
RESSTATE_LOADING = 2,
|
|
RESSTATE_BUSY = 3,
|
|
RESSTATE_ERROR = 4,
|
|
};
|
|
int GetState() const;
|
|
virtual bool Discard();
|
|
|
|
virtual bool Backup() { return true; };
|
|
virtual bool PreReload() { return true; };
|
|
virtual bool Reload() = 0;
|
|
|
|
/** 이 두개의 Function은 어쩔수 없이 public으로 노출시켜 놓았지만 절대로 사용하면 안된다! (KSmartPtr이 알아서 사용)
|
|
KSmartPtr 사용 시 문제 되는 부분(DeviceLost)이 있어서 사용 되어 지고 있음. 그외 리소스를 재사용 하기 위해서 사용 */
|
|
int AddRef();
|
|
virtual void Release();
|
|
/// 재사용
|
|
virtual void Recycle();
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
int GetRefCount() const;
|
|
|
|
void SetName(const char *name);
|
|
LPCSTR GetName() const;
|
|
|
|
void SetLoadedTime( DWORD dwTime ) { m_dwLoadedTime = dwTime; }
|
|
DWORD GetLoadedTime() const { return m_dwLoadedTime; }
|
|
|
|
void SetVersion( DWORD dwVersion );
|
|
DWORD GetVersion();
|
|
|
|
int m_nTextureMode;
|
|
int GetTextureMode(char * name)
|
|
{ if (m_nTextureMode<=0) m_nTextureMode = _TextureModeGet(name);
|
|
return m_nTextureMode;
|
|
}
|
|
|
|
protected:
|
|
volatile int m_nRef;
|
|
int m_type;
|
|
std::string m_strName;
|
|
bool m_state;
|
|
DWORD m_dwLoadedTime; ///< Load된 시간
|
|
DWORD m_dwVersion;
|
|
};
|
|
|
|
|
|
class K3DTexture : public KResource
|
|
{
|
|
public:
|
|
K3DTexture();
|
|
|
|
virtual void LockRect( KRect *rect, void** ppBuf, int& stride ) = 0;
|
|
virtual void Unlock() = 0;
|
|
|
|
virtual bool Reload() = 0;
|
|
|
|
virtual bool IsValid() const;
|
|
|
|
virtual void Refresh( KStream &stream, int nQuality ) = 0;
|
|
|
|
void SetManagedByTexManager() { m_bManagedByTexManager = true; }
|
|
bool GetManagedByTexManager() { return m_bManagedByTexManager; }
|
|
|
|
int GetWidth() const { return m_size.width; }
|
|
int GetHeight() const { return m_size.height; }
|
|
int GetMipsLevels() const { return m_nMipsLevels; }
|
|
int GetQuality() const { return m_nQuality; }
|
|
const KSize &GetSize() const { return m_size; }
|
|
K3DFORMAT GetFormat() const { return m_format; }
|
|
void *GetSurface() const { return m_pSurface; }
|
|
|
|
int GetLevel() const { return m_nLevels; }
|
|
|
|
/// 2011.03.22 - prodongi
|
|
void SetTextOriImgSize(int width, int height) { m_textOriImgSize = KSize(width, height); }
|
|
void SetTextOriImgRect(KRect const& r) { m_textOriImgRect = r; }
|
|
KRect const* GetTextOriImgRect() const { return &m_textOriImgRect; }
|
|
int GetTextOriImgWidth() const { return m_textOriImgSize.width; }
|
|
int GetTextOriImgHeight() const { return m_textOriImgSize.height; }
|
|
|
|
/// custom flags - by Tyburn
|
|
unsigned char& Flags() { return m_flags; }
|
|
unsigned char GetFlags() const { return m_flags; }
|
|
|
|
void SetColorizedMode( short mode ) { m_ColorizedMode = mode; }
|
|
short GetColorizedMode() { return m_ColorizedMode; }
|
|
|
|
virtual void Release();
|
|
|
|
virtual bool SaveToFile( const std::string& strFile ) { return false; }
|
|
|
|
enum
|
|
{
|
|
COLORIZED_DEF = 0,
|
|
COLORIZED_KEEP_ALPHA,
|
|
COLORIZED_USEALPHA,
|
|
COLORIZED_GRAY,
|
|
};
|
|
|
|
virtual HRESULT LoadSurfaceFromSurface( K3DTexture* pDestTexture, DWORD c1, DWORD c2, DWORD c3, DWORD c4, short nMode ) { return S_FALSE; }
|
|
|
|
enum
|
|
{
|
|
DEPTH_DISABLE = 0,
|
|
DEPTH_ENABLE,
|
|
//DEPTH_USEASTEXTURE // 렌더링 할 때는 컬러 버퍼 끄고 해야 된다 by blackfish (현재 nvidia만 지원해서 일단 제거)
|
|
};
|
|
protected:
|
|
virtual ~K3DTexture();
|
|
|
|
bool m_bManagedByTexManager;
|
|
unsigned char m_flags; ///< custom flags
|
|
short m_nQuality;
|
|
short m_nMipsLevels;
|
|
void* m_pSurface;
|
|
KSize m_size;
|
|
K3DFORMAT m_format;
|
|
UINT m_nLevels; ///< 밉맵 단계
|
|
short m_ColorizedMode;
|
|
KSize m_textOriImgSize; /// 2011.03.22 freetype으로 생성한 텍스트 이미지를 현재 텍스춰에 복사 할때, 원본 텍스트 이미지 사이즈 - prodongi
|
|
KRect m_textOriImgRect; /// 2011.03.22 freetype으로 생성한 텍스트 이미지를 현재 텍스춰에 복사 할때, 원본 텍스트 이미지 영역 - prodongi
|
|
};
|
|
DECL_SPTR(K3DTexture)
|
|
|
|
class K3DRenderTarget : public K3DTexture
|
|
{
|
|
public:
|
|
K3DRenderTarget() { m_size.cx = m_size.cy = 0; m_type = RESTYPE_RENDERTARGET; m_format = K3DFMT_UNKNOWN; }
|
|
protected:
|
|
virtual ~K3DRenderTarget() {}
|
|
public:
|
|
virtual K3DTexture *CreateCloneTexture() = 0;
|
|
virtual void CopyTo( K3DTexture *pTex ) = 0;
|
|
protected:
|
|
};
|
|
DECL_SPTR(K3DRenderTarget)
|
|
|
|
class K3DRenderTargetCube : public K3DTexture
|
|
{
|
|
public:
|
|
K3DRenderTargetCube() { m_size.cx = m_size.cy = 0; m_type = RESTYPE_CUBETEXTURE; m_format = K3DFMT_UNKNOWN; }
|
|
virtual ~K3DRenderTargetCube() {}
|
|
public:
|
|
virtual K3DTexture *CreateCloneTexture() = 0;
|
|
virtual void CopyTo( K3DTexture *pTex ) = 0;
|
|
};
|
|
DECL_SPTR(K3DRenderTargetCube)
|
|
|
|
/// 바닥 충돌용
|
|
class K3DVertexRes : public KResource
|
|
{
|
|
public:
|
|
K3DVertexRes() { m_vtxCount = 0; m_pVtxArray = NULL; m_type = RESTYPE_VERTEXARRAY; }
|
|
|
|
protected:
|
|
virtual ~K3DVertexRes() { SAFE_DELETE_ARRAY(m_pVtxArray); }
|
|
|
|
public:
|
|
|
|
void LinkArray( K3DVertex * pArray, DWORD nCnt )
|
|
{
|
|
assert( m_pVtxArray == NULL && "재사용 불가" );
|
|
|
|
if( nCnt )
|
|
{
|
|
m_vtxCount = nCnt;
|
|
m_pVtxArray = pArray;
|
|
}
|
|
}
|
|
|
|
void SetArray( K3DVertex * pArray, DWORD nCnt )
|
|
{
|
|
assert( m_pVtxArray == NULL && "재사용 불가" );
|
|
|
|
if( nCnt )
|
|
{
|
|
m_vtxCount = nCnt;
|
|
m_pVtxArray = new K3DVertex[nCnt];
|
|
memcpy( m_pVtxArray, pArray, sizeof(K3DVertex)*nCnt );
|
|
}
|
|
}
|
|
|
|
virtual bool Reload() { return false; };
|
|
K3DVertex * GetArray() { return m_pVtxArray; }
|
|
DWORD GetCnt() { return m_vtxCount; }
|
|
|
|
protected:
|
|
K3DVertex * m_pVtxArray;
|
|
DWORD m_vtxCount;
|
|
};
|
|
DECL_SPTR(K3DVertexRes)
|
|
|
|
/// 바닥 충돌용
|
|
class K3DUnsignedShortRes : public KResource
|
|
{
|
|
public:
|
|
K3DUnsignedShortRes() { m_idxCount = 0; m_pIdxArray = NULL; m_type = RESTYPE_INDEXARRAY; }
|
|
|
|
protected:
|
|
virtual ~K3DUnsignedShortRes() { SAFE_DELETE_ARRAY(m_pIdxArray); }
|
|
|
|
public:
|
|
void SetArray( unsigned short * pArray, DWORD nCnt )
|
|
{
|
|
assert( m_pIdxArray == NULL && "재사용 불가" );
|
|
|
|
if( nCnt )
|
|
{
|
|
m_idxCount = nCnt;
|
|
m_pIdxArray = new unsigned short[nCnt];
|
|
memcpy( m_pIdxArray, pArray, sizeof(unsigned short)*nCnt );
|
|
}
|
|
}
|
|
unsigned short * GetArray() { return m_pIdxArray; }
|
|
DWORD GetCnt() { return m_idxCount; }
|
|
virtual bool Reload() { return false; };
|
|
|
|
protected:
|
|
DWORD m_idxCount;
|
|
unsigned short * m_pIdxArray;
|
|
};
|
|
DECL_SPTR(K3DUnsignedShortRes)
|
|
|
|
class K3DIndexBuffer : public KResource
|
|
{
|
|
public:
|
|
K3DIndexBuffer() { m_idxCount = 0; m_format = K3DFMT_UNKNOWN; m_type = RESTYPE_INDEXBUFFER; m_bIsValid = false; }
|
|
protected:
|
|
virtual ~K3DIndexBuffer() {}
|
|
public:
|
|
K3DFORMAT GetFormat() const { return m_format; }
|
|
DWORD GetIndexCount() const { return m_idxCount; }
|
|
|
|
virtual void Lock( void** ppBuf, int& size, DWORD flags = 0 ) = 0;
|
|
virtual void Unlock() = 0;
|
|
|
|
virtual bool Reload() = 0;
|
|
|
|
const bool IsValidVtx() { return m_bIsValid; }
|
|
void SetValidVtx( bool bValid ) { m_bIsValid = bValid; }
|
|
|
|
protected:
|
|
K3DFORMAT m_format;
|
|
DWORD m_vtxStride;
|
|
DWORD m_idxCount;
|
|
DWORD m_usage;
|
|
D3DPOOL m_Pool;
|
|
bool m_bIsValid;
|
|
};
|
|
DECL_SPTR(K3DIndexBuffer)
|
|
|
|
class K3DVertexBuffer : public KResource
|
|
{
|
|
public:
|
|
K3DVertexBuffer() { m_vtxCount = m_vtxStride = m_format = 0; m_type = RESTYPE_VERTEXBUFFER; m_Pool=D3DPOOL_DEFAULT; m_bIsValid = false; m_bUseRecycle = true; }
|
|
protected:
|
|
virtual ~K3DVertexBuffer() {}
|
|
public:
|
|
|
|
DWORD GetVertexFormat() const
|
|
{
|
|
if( m_type == RESTYPE_VERTEXBUFFERBLEND )
|
|
return 0;
|
|
else
|
|
return m_format;
|
|
}
|
|
DWORD GetVertexStride() const { return m_vtxStride; }
|
|
DWORD GetVertexCount() const { return m_vtxCount; }
|
|
|
|
virtual void Lock( void** ppBuf, int& size, DWORD flags = 0 ) = 0;
|
|
virtual void Unlock() = 0;
|
|
|
|
virtual bool Reload() = 0;
|
|
|
|
virtual bool IsLock() { return false; }
|
|
|
|
void SetUseRecycle( bool bFlag ) { m_bUseRecycle = bFlag; }
|
|
|
|
const bool IsValidVtx() { return m_bIsValid; }
|
|
void SetValidVtx( bool bValid ) { m_bIsValid = bValid; }
|
|
|
|
public:
|
|
static int CalcVertexStride( DWORD vtxFormat )
|
|
{
|
|
return D3DXGetFVFVertexSize(vtxFormat);
|
|
|
|
/* int res = 0;
|
|
if ( vtxFormat & K3DFVF_XYZ ) res += 4*3;
|
|
if ( vtxFormat & K3DFVF_XYZRHW ) res += 4*4;
|
|
|
|
if ( vtxFormat & K3DFVF_NORMAL ) res += 4*3;
|
|
if ( vtxFormat & K3DFVF_PSIZE ) res += 4;
|
|
if ( vtxFormat & K3DFVF_DIFFUSE ) res += 4;
|
|
if ( vtxFormat & K3DFVF_SPECULAR) res += 4;
|
|
|
|
int texFormat = (vtxFormat & K3DFVF_TEXCOUNT_MASK) >> K3DFVF_TEXCOUNT_SHIFT;
|
|
res += 4 * texFormat * 2;
|
|
return res;*/
|
|
}
|
|
protected:
|
|
DWORD m_format;
|
|
DWORD m_vtxStride;
|
|
DWORD m_vtxCount;
|
|
DWORD m_usage;
|
|
D3DPOOL m_Pool;
|
|
bool m_bIsValid;
|
|
bool m_bUseRecycle;
|
|
};
|
|
DECL_SPTR(K3DVertexBuffer)
|
|
|
|
|
|
template<typename T, bool UseUpperBound = false>
|
|
class KKeyRes
|
|
{
|
|
public:
|
|
KKeyRes()
|
|
{
|
|
m_keyCount = 0;
|
|
m_keys = NULL;
|
|
}
|
|
virtual ~KKeyRes()
|
|
{
|
|
if ( m_keys )
|
|
delete[] m_keys;
|
|
m_keys = NULL;
|
|
}
|
|
|
|
const KInterval &GetInterval()
|
|
{
|
|
return m_interval;
|
|
}
|
|
|
|
void SetKeyCount( int count )
|
|
{
|
|
m_keyCount = count; // [MEMORY_LEAK] 2012. 3. 2 - marine 소멸자에서 지워주고 있음,,
|
|
//_LEAK_SUN
|
|
SAFE_DELETE_ARRAY( m_keys );
|
|
m_keys = new T[count];
|
|
}
|
|
|
|
int GetKeyCount()
|
|
{
|
|
return m_keyCount;
|
|
}
|
|
void SetKey( int index, T *key, int count = 1 )
|
|
{
|
|
for ( int i=0 ; i<count ; ++i )
|
|
m_keys[index + i] = key[i];
|
|
sortKeys( index + count );
|
|
|
|
if(!UseUpperBound)
|
|
{
|
|
m_interval.Set( m_keys[0].time, m_keys[index+count-1].time );
|
|
}
|
|
else
|
|
{
|
|
m_interval.Set( 0, m_keys[index+count-1].time );
|
|
}
|
|
}
|
|
|
|
T& GetKey(int iIndex)
|
|
{
|
|
return m_keys[iIndex];
|
|
}
|
|
|
|
void Rearrange()
|
|
{
|
|
sortKeys( m_keyCount );
|
|
m_interval.Set( m_keys[0].time, m_keys[m_keyCount-1].time );
|
|
}
|
|
|
|
void SetWholeKey( T *key, int count )
|
|
{
|
|
SetKeyCount( count );
|
|
SetKey( 0, key, count );
|
|
}
|
|
|
|
int GetIndexNumber(int time)
|
|
{
|
|
T pred;
|
|
pred.time = time;
|
|
T *found = std::lower_bound( m_keys, (m_keys + m_keyCount), pred );
|
|
return static_cast<int>(found - m_keys);
|
|
}
|
|
|
|
void GetData( int time, T*& key1, T*& key2 )
|
|
{
|
|
T pred;
|
|
pred.time = time;
|
|
|
|
T * found;
|
|
|
|
if(!UseUpperBound)
|
|
{
|
|
found = std::lower_bound( m_keys, (m_keys + m_keyCount), pred );
|
|
if ( found == m_keys ) // found first key means time less than first time
|
|
{
|
|
key1 = found;
|
|
key2 = NULL;
|
|
return;
|
|
}
|
|
else if ( found == (m_keys+m_keyCount) ) // found end mark return last key
|
|
{
|
|
key1 = &m_keys[m_keyCount-1];
|
|
key2 = NULL;
|
|
return;
|
|
}
|
|
else if ( found->time == time )
|
|
{
|
|
key1 = found;
|
|
key2 = NULL;
|
|
return;
|
|
}
|
|
key1 = found-1;
|
|
key2 = found;
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
found = std::upper_bound( m_keys, (m_keys + m_keyCount), pred );
|
|
|
|
if ( found == (m_keys+m_keyCount - 1) ) // found first key is last key.
|
|
{
|
|
key1 = found;
|
|
key2 = m_keys;
|
|
return;
|
|
}
|
|
else if ( found == (m_keys+m_keyCount) ) // found end mark return last key
|
|
{
|
|
key1 = &m_keys[m_keyCount-1];
|
|
key2 = NULL;
|
|
return;
|
|
}
|
|
else if ( found->time == time )
|
|
{
|
|
key1 = found;
|
|
key2 = NULL;
|
|
return;
|
|
}
|
|
key1 = found;
|
|
key2 = found + 1;
|
|
return;
|
|
}
|
|
|
|
|
|
}
|
|
protected:
|
|
void sortKeys( int count )
|
|
{
|
|
std::sort( m_keys, m_keys+count );
|
|
}
|
|
KInterval m_interval;
|
|
int m_keyCount;
|
|
T* m_keys;
|
|
};
|
|
|
|
|
|
class K3DResVertexAnimation : public KResource
|
|
{
|
|
public:
|
|
K3DResVertexAnimation();
|
|
protected:
|
|
virtual ~K3DResVertexAnimation();
|
|
public:
|
|
struct Key
|
|
{
|
|
int time;
|
|
K3DVertexBufferSPtr m_spVB;
|
|
K3DVertexResSPtr m_spVB_array; ///< 높이, 충돌
|
|
Key();
|
|
bool operator<( const Key &target ) const;
|
|
};
|
|
const KInterval &GetInterval();
|
|
void SetKeyCount( int count );
|
|
|
|
/** 경고 : 만약 SetKey를 한 K3DResVertexAnimation에 두고 같은 Frame에 관해서 반복할 경우
|
|
Resource Leak 발생 가능. ( 즉 이 펑션은 한 K3DResVertexAnimation의 동일 Frame에 관해서
|
|
한번만 불려야 함) */
|
|
void SetKey( int index, Key *key, int count = 1 );
|
|
|
|
/** 경고 : 만약 SetWholeKey를 한 K3DResVertexAnimation에 두고 여러번 호출 할 경우
|
|
Resource Leak 발생 가능. (즉 이 펑션은 한 K3DResVertexAnimation에 관해서 한번만 불려야 함) */
|
|
void SetWholeKey( Key *key, int count );
|
|
|
|
void GetData( int time, Key*& key1, Key*& key2 );
|
|
|
|
void SetIndexBuffer( K3DIndexBuffer *pIB );
|
|
/// 충돌, 바닥 높이용
|
|
void SetIndexArray( K3DUnsignedShortRes *pUS );
|
|
void SetPrimitivesInfo(int nPrimitiveCount, int nSimultaneousFrameCount)
|
|
{
|
|
m_nPrimitiveCount = nPrimitiveCount;
|
|
m_nSimultaneousFrameCount = nSimultaneousFrameCount;
|
|
}
|
|
int GetPrimitiveCount() { return m_nPrimitiveCount; }
|
|
int GetSimultaneousFrameCount() { return m_nSimultaneousFrameCount; }
|
|
bool IsTransparent();
|
|
void SetMaterial( K3DMaterial *mat );
|
|
void SetBlendMode( int blendmode );
|
|
void SetTexturePack( struct TEXPACK * pTexPack );
|
|
|
|
K3DMaterial *GetMaterial();
|
|
int GetBlendMode();
|
|
TEXPACK* GetTexturePack();
|
|
|
|
|
|
K3DIndexBuffer* GetIndexBuffer();
|
|
K3DUnsignedShortRes* GetIndexArray();
|
|
|
|
DWORD GetLightMapIndex() { return m_lightMapIndex; }
|
|
void SetLightMapIndex(DWORD index) { m_lightMapIndex = index; }
|
|
|
|
virtual bool Reload();
|
|
|
|
int GetKeyCount();
|
|
K3DResVertexAnimation::Key& GetKey( int nIndex );
|
|
|
|
private:
|
|
bool m_bUseAnimation;
|
|
bool m_bTransparent;
|
|
Key m_akey;
|
|
KKeyRes<Key> m_keys;
|
|
|
|
TEXPACK m_TexPack;
|
|
|
|
int m_nBlendMode;
|
|
K3DMaterial m_Mtl;
|
|
K3DIndexBufferSPtr m_spIB;
|
|
K3DUnsignedShortResSPtr m_spUS;
|
|
|
|
DWORD m_lightMapIndex;
|
|
int m_nPrimitiveCount;
|
|
int m_nSimultaneousFrameCount;
|
|
};
|
|
DECL_SPTR(K3DResVertexAnimation)
|
|
|
|
|
|
////애니메이션은 어떻게 할까?
|
|
//struct SET_RESOURCE
|
|
//{
|
|
// K3DVertexBuffer* pVB;
|
|
// K3DIndexBuffer* pIB;
|
|
//};
|
|
//
|
|
//struct SET_TEXTURE
|
|
//{
|
|
// K3DTexture* pTex_Base; //기본 텍스쳐
|
|
// K3DTexture* pTex_Spec; //스페큘러
|
|
// K3DTexture* pTex_SpecColor; //스페큘러 컬러
|
|
// K3DTexture* pTex_Illumin; //셀프 일루미네이션
|
|
//};
|
|
|
|
struct Kgeneric_key_t
|
|
{
|
|
int time;
|
|
|
|
union {
|
|
struct { /* linear position */
|
|
float pos[3];
|
|
} lin_pos;
|
|
|
|
struct { /* linear rotation */
|
|
float quat[4];
|
|
} lin_rot;
|
|
};
|
|
|
|
bool operator<( const Kgeneric_key_t &target ) const
|
|
{
|
|
return time < target.time;
|
|
};
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
K3DVector pos;
|
|
K3DQuaternion quat;
|
|
} BONE_ANI_DATA;
|
|
|
|
class K3DBone;
|
|
class K3DBone
|
|
{
|
|
public:
|
|
K3DBone();
|
|
~K3DBone();
|
|
|
|
//작업중...
|
|
Kgeneric_key_t* GetPosKey( DWORD mSec, K3DVector &pos );
|
|
Kgeneric_key_t* GetRotKey( DWORD mSec, K3DQuaternion &quat );
|
|
|
|
void CalcTM(DWORD mSec, DWORD mSecLimit, BONE_ANI_DATA *pAniData=NULL, float fWeight=0.f );
|
|
void Interpolate(DWORD mSec, K3DVector &pos, K3DQuaternion &quat);
|
|
|
|
//float * fGetCacheTM() { return m_cacheTM; }
|
|
float * fGetBaseTM() { return m_BaseTM; }
|
|
|
|
K3DMatrix * GetCacheTM() { return &m_CacheMat; }
|
|
K3DMatrix * GetBaseTM() { return &m_BaseMat; }
|
|
|
|
BONE_ANI_DATA * GetCacheAniData() { return &m_CacheAniData; }
|
|
|
|
bool SetViewVectorX( float x )
|
|
{
|
|
float angRadian = (rand()%270)*K3D_PI/180;
|
|
K3DMatrixRotationZ( *GetCacheTM(), angRadian );
|
|
return false;
|
|
}
|
|
bool SetViewVectorZ( float z )
|
|
{
|
|
float angRadian = (rand()%270)*K3D_PI/180;
|
|
K3DMatrixRotationZ( *GetCacheTM(), angRadian );
|
|
return false;
|
|
}
|
|
|
|
int GetParentIndex() { return m_nParentIndex; }
|
|
void SetParentIndex( int nParentIndex )
|
|
{
|
|
m_nParentIndex = nParentIndex;
|
|
}
|
|
|
|
void SetBaseTM( float * pBaseTM )
|
|
{
|
|
memcpy( m_BaseTM, pBaseTM, sizeof(m_BaseTM) );
|
|
|
|
m_BaseMat = K3DMatrix( m_BaseTM );
|
|
}
|
|
|
|
void SetFlag( DWORD dwFlag )
|
|
{
|
|
m_dwFlag = dwFlag;
|
|
}
|
|
|
|
void SetPosKey( DWORD dwPosCount, Kgeneric_key_t* pPosKey )
|
|
{
|
|
m_dwPosCount = dwPosCount;
|
|
if(m_dwPosCount>0)
|
|
{
|
|
m_PosKey.SetWholeKey( pPosKey, m_dwPosCount );
|
|
}
|
|
}
|
|
|
|
void SetRotKey( DWORD dwRotCount, Kgeneric_key_t* pRotKey )
|
|
{
|
|
m_dwRotCount = dwRotCount;
|
|
if(m_dwRotCount>0)
|
|
{
|
|
m_RotKey.SetWholeKey( pRotKey, m_dwRotCount );
|
|
}
|
|
}
|
|
|
|
void SetChildList( DWORD dwChildCount, int * pChildList )
|
|
{
|
|
m_dwChildCount = dwChildCount;
|
|
if( m_dwChildCount>0 )
|
|
{
|
|
m_pChildList = new int[m_dwChildCount];
|
|
memset( m_pChildList, 0, sizeof(int)*m_dwChildCount );
|
|
memcpy( m_pChildList, pChildList, sizeof(int)*m_dwChildCount );
|
|
|
|
m_pChild = new K3DBone*[m_dwChildCount];
|
|
memset( m_pChild, 0, sizeof(K3DBone*)*m_dwChildCount );
|
|
}
|
|
}
|
|
|
|
void SetChildBone( unsigned int nIndex, K3DBone * pChildBone )
|
|
{
|
|
assert( m_dwChildCount > nIndex );
|
|
m_pChild[nIndex] = pChildBone;
|
|
}
|
|
|
|
int GetChildIndex( unsigned int nIndex )
|
|
{
|
|
assert( m_dwChildCount > nIndex );
|
|
return m_pChildList[nIndex];
|
|
}
|
|
|
|
int GetChildCount() { return m_dwChildCount; }
|
|
void SetParentBone( K3DBone * pParentBone )
|
|
{
|
|
m_pParent = pParentBone;
|
|
}
|
|
K3DBone * GetParentBone() { return m_pParent; }
|
|
|
|
int GetIndex() { return m_nIndex; }
|
|
void SetIndex( int nIndex ) { m_nIndex = nIndex; }
|
|
|
|
const char * GetName() { return m_szBoneName; }
|
|
|
|
void SetName( const char * pName ) { strcpy(m_szBoneName, pName); }
|
|
|
|
protected:
|
|
char m_szBoneName[64];
|
|
int m_nParentIndex;
|
|
float m_BaseTM[16];
|
|
//float m_cacheTM[16];
|
|
DWORD m_dwFlag; ///< Key flag
|
|
|
|
DWORD m_dwPosCount;
|
|
Kgeneric_key_t* m_pPosKey;
|
|
|
|
DWORD m_dwRotCount;
|
|
Kgeneric_key_t* m_pRotKey;
|
|
|
|
DWORD m_dwChildCount;
|
|
int * m_pChildList;
|
|
K3DBone** m_pChild;
|
|
|
|
K3DBone * m_pParent;
|
|
int m_nIndex; ///< 자신의 인덱스
|
|
|
|
K3DMatrix m_BaseMat; ///< 현재 사용 안함.
|
|
K3DMatrix m_CacheMat;
|
|
|
|
BONE_ANI_DATA m_CacheAniData; ///< 보간 전달용
|
|
|
|
KKeyRes<Kgeneric_key_t> m_PosKey;
|
|
KKeyRes<Kgeneric_key_t> m_RotKey;
|
|
};
|
|
|
|
/// Bone 추가 작업 중..
|
|
class K3DBoneResource : public KResource
|
|
{
|
|
public:
|
|
K3DBoneResource();
|
|
protected:
|
|
virtual ~K3DBoneResource();
|
|
public:
|
|
const KInterval &GetInterval();
|
|
virtual bool Reload();
|
|
void AddBone(int nIndex, K3DBone * pBone);
|
|
int GetBoneCount() { return m_nBoneCount; }
|
|
|
|
void SetBone( int nBoneCount );
|
|
inline K3DBone * GetBone( int nIndex )
|
|
{
|
|
if( m_nBoneCount == 0 || m_nBoneCount <= nIndex ) return NULL;
|
|
return m_pBoneList[nIndex];
|
|
}
|
|
|
|
void SetChildCount( int nChildCount );
|
|
int GetChildCount() { return m_nChildCount; }
|
|
|
|
void CalcBoneTransforms( DWORD dwTime, K3DMatrix *pMatList, BONE_ANI_DATA *pAniData, BONE_ANI_DATA *pPrevAniData=NULL, float fWeight=0.f );
|
|
void SetTimeSpan( DWORD dwTimeSpan ) { m_dwTimeSpan = dwTimeSpan; m_Interval.Set(0,m_dwTimeSpan); }
|
|
DWORD GetTimeSpan() { return m_dwTimeSpan; }
|
|
K3DMatrix * GetBoneBaseTM() { return m_pBoneBaseTM; }
|
|
|
|
/// 머리 Z(높이)
|
|
float GetHeadZ();
|
|
void GetHandLeft( K3DVector & pos );
|
|
void GetHandRight( K3DVector & pos );
|
|
|
|
inline K3DBone * GetBone( const char * pBoneName, int &index )
|
|
{
|
|
if( pBoneName == NULL )
|
|
{
|
|
index = -1;
|
|
return NULL;
|
|
}
|
|
|
|
std::string strBoneName1, strBoneName2;
|
|
strBoneName1.reserve( strlen( pBoneName ) );
|
|
GetPureBoneName( strBoneName1, pBoneName );
|
|
// strBoneName2.reserve( 1024 );
|
|
|
|
|
|
for(int i(0); GetBoneCount()>i; i++ )
|
|
{
|
|
////같은 이름 Bone 찾기.
|
|
//if( _stricmp( pBoneName, GetBone(i)->GetName() ) == 0 )
|
|
//{
|
|
// index = i;
|
|
// return GetBone(i);
|
|
//}
|
|
|
|
/* 원본 */
|
|
/*
|
|
GetPureBoneName( strBoneName1, pBoneName );
|
|
GetPureBoneName( strBoneName2, GetBone( i )->GetName() );
|
|
if( strBoneName1 == strBoneName2 )
|
|
{
|
|
index = i;
|
|
return GetBone( i );
|
|
}
|
|
*/
|
|
if ( strBoneName1 == GetBone( i )->GetName() )
|
|
{
|
|
// _oprint( "GetBone Found bone, total bones = %d, time elapsed = %d\n", GetBoneCount(), GetSafeTickCount() - dwTickCount );
|
|
index = i;
|
|
return GetBone( i );
|
|
}
|
|
}
|
|
|
|
index = -1;
|
|
return NULL;
|
|
}
|
|
|
|
private:
|
|
void GetPureBoneName( std::string& strPureName, const char* szName )
|
|
{
|
|
strPureName.erase( strPureName.begin(), strPureName.end() );
|
|
|
|
int len = ( int ) strlen( szName );
|
|
for( int i = 0; i < len; i++ )
|
|
{
|
|
char c = szName[ i ];
|
|
if( c >= 'A' && c <= 'Z' )
|
|
{
|
|
c -= 'A' - 'a';
|
|
strPureName.push_back( c );
|
|
}
|
|
else if( c >= 'a' && c <= 'z' )
|
|
{
|
|
strPureName.push_back( c );
|
|
}
|
|
else if( c >= '0' && c <= '9' )
|
|
{
|
|
strPureName.push_back( c );
|
|
}
|
|
}
|
|
}
|
|
|
|
KInterval m_Interval;
|
|
int m_nBoneCount;
|
|
K3DBone ** m_pBoneList;
|
|
|
|
K3DBone * m_pParent;
|
|
int m_nChildCount;
|
|
K3DBone** m_ppChild;
|
|
|
|
DWORD m_dwTimeSpan;
|
|
K3DMatrix * m_pBoneBaseTM;
|
|
};
|
|
DECL_SPTR(K3DBoneResource)
|
|
|
|
struct K3DWeight
|
|
{
|
|
K3DWeight()
|
|
{
|
|
memset( m_szBoneName, 0, sizeof(m_szBoneName) );
|
|
m_nTotal = 0;
|
|
m_nWeight = 0;
|
|
m_pVertexIndex = NULL;
|
|
m_pVertexWeight = NULL;
|
|
m_pOffsetVector = NULL;
|
|
|
|
m_nUseBoneCount = 0;
|
|
m_pUseBoneList = NULL;
|
|
}
|
|
|
|
~K3DWeight()
|
|
{
|
|
SAFE_DELETE_ARRAY(m_pVertexIndex );
|
|
SAFE_DELETE_ARRAY(m_pVertexWeight);
|
|
SAFE_DELETE_ARRAY(m_pOffsetVector);
|
|
|
|
SAFE_DELETE_ARRAY(m_pUseBoneList);
|
|
}
|
|
|
|
char m_szBoneName[64];
|
|
int m_nTotal;
|
|
int m_nWeight; ///< weight 수
|
|
float * m_pVertexIndex; ///< bone index
|
|
float * m_pVertexWeight; ///< bone weight
|
|
K3DVector * m_pOffsetVector;
|
|
|
|
int m_nUseBoneCount;
|
|
int * m_pUseBoneList;
|
|
};
|
|
|
|
struct K3DMeshTM
|
|
{
|
|
char szName[64];
|
|
float fTM[16];
|
|
K3DMatrix mTM;
|
|
};
|
|
|
|
class K3DMeshResource : public KResource
|
|
{
|
|
public:
|
|
K3DMeshResource();
|
|
protected:
|
|
virtual ~K3DMeshResource();
|
|
public:
|
|
const KInterval &GetInterval();
|
|
void SetVBResource( K3DResVertexAnimation **vbres, int count );
|
|
int GetResCount();
|
|
K3DResVertexAnimation* GetRes( int index );
|
|
K3DResVertexAnimationSPtr* GetResList();
|
|
void SetBound( const K3DBoundRotCube &cube, const K3DBoundSphere &sphere );
|
|
const K3DBoundRotCube &GetBoundCube();
|
|
const K3DBoundSphere &GetBoundSphere();
|
|
virtual bool Reload();
|
|
|
|
int GetWeightResCount();
|
|
K3DWeight* GetWeightRes(int nIndex);
|
|
K3DWeight** GetWeightResList();
|
|
void SetWeightResource( K3DWeight **ppWeight, int count );
|
|
|
|
void SetNodeTM( K3DMatrix * pMatrix, int count );
|
|
K3DMatrix * GetNodeTM( int nIndex );
|
|
|
|
int GetMeshTMCount() { return m_nMeshTMCount; }
|
|
K3DMatrix * GetMeshTMArray() { return m_pMeshTM_Array; }
|
|
|
|
void SetMeshTM( K3DMeshTM * pMeshTM, int count );
|
|
inline K3DMeshTM * GetMeshTM( const char * name )
|
|
{
|
|
if( m_nMeshTMCount <= 0 ) return NULL;
|
|
|
|
for( int i(0); m_nMeshTMCount>i; i++ )
|
|
{
|
|
if( strcmp( m_pMeshTM[i].szName, name ) == 0 )
|
|
return &m_pMeshTM[i];
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
private:
|
|
KInterval m_Interval;
|
|
int m_nVBCount;
|
|
K3DBoundRotCube m_boundCube;
|
|
K3DBoundSphere m_boundSphere;
|
|
|
|
K3DResVertexAnimationSPtr* m_spVBArray;
|
|
int m_nWeightCount;
|
|
K3DWeight** m_ppWeight;
|
|
|
|
int m_nNodeCount;
|
|
K3DMatrix * m_pNodeTM;
|
|
|
|
int m_nMeshTMCount;
|
|
K3DMeshTM * m_pMeshTM;
|
|
K3DMatrix * m_pMeshTM_Array;
|
|
};
|
|
DECL_SPTR(K3DMeshResource)
|
|
|
|
|
|
class K3DResMeshMatrixAnimation : public KResource
|
|
{
|
|
public:
|
|
K3DResMeshMatrixAnimation();
|
|
protected:
|
|
virtual ~K3DResMeshMatrixAnimation();
|
|
public:
|
|
struct Key
|
|
{
|
|
int time;
|
|
K3DMatrix mat;
|
|
bool operator<( const Key &target ) const;
|
|
};
|
|
|
|
const KInterval &GetInterval();
|
|
void SetKeyCount( int count );
|
|
void SetKey( int index, Key *key, int count = 1 );
|
|
void SetWholeKey( Key *key, int count );
|
|
void GetLerpMatrix(int time, K3DMatrix* pMat);
|
|
|
|
virtual bool Reload();
|
|
int GetKeyCount() { return m_keys.GetKeyCount(); }
|
|
private:
|
|
KKeyRes<Key> m_keys;
|
|
};
|
|
DECL_SPTR(K3DResMeshMatrixAnimation)
|
|
|
|
class K3DResMeshUVAnimation : public KResource
|
|
{
|
|
public:
|
|
K3DResMeshUVAnimation();
|
|
protected:
|
|
virtual ~K3DResMeshUVAnimation();
|
|
public:
|
|
struct Key
|
|
{
|
|
int time;
|
|
K3DMatrix mat;
|
|
bool operator<( const Key &target ) const;
|
|
};
|
|
|
|
const KInterval &GetInterval();
|
|
void SetKeyCount( int count );
|
|
void SetKey( int index, Key *key, int count = 1 );
|
|
void SetWholeKey( Key *key, int count );
|
|
void GetLerpMatrix(int time, K3DMatrix* pMat);
|
|
void SetMode( int nMode );
|
|
int GetMode();
|
|
void SetUvAnimation( bool bUseUvAni, int nMaxFrame, int nLoopFrame );
|
|
virtual bool Reload();
|
|
|
|
private:
|
|
int m_nMode;
|
|
bool m_bUseUvAni;
|
|
int m_nUvMaxFrame;
|
|
int m_nUvLoopFrame;
|
|
KKeyRes<Key> m_keys;
|
|
};
|
|
DECL_SPTR(K3DResMeshUVAnimation)
|
|
|
|
class K3DResMeshVisibilityAnimation : public KResource
|
|
{
|
|
public:
|
|
K3DResMeshVisibilityAnimation();
|
|
protected:
|
|
virtual ~K3DResMeshVisibilityAnimation();
|
|
public:
|
|
struct Key
|
|
{
|
|
int time;
|
|
float val;
|
|
bool operator<( const Key &target ) const;
|
|
};
|
|
const KInterval &GetInterval();
|
|
void SetKeyCount( int count );
|
|
void SetKey( int index, Key *key, int count = 1 );
|
|
void SetWholeKey( Key *key, int count );
|
|
void GetVisibility(int time, float* pVisi);
|
|
|
|
virtual bool Reload();
|
|
private:
|
|
KKeyRes<Key> m_keys;
|
|
};
|
|
DECL_SPTR(K3DResMeshVisibilityAnimation)
|
|
|
|
class K3DResEventPoint : public KResource
|
|
{
|
|
public:
|
|
K3DResEventPoint();
|
|
protected:
|
|
virtual ~K3DResEventPoint();
|
|
public:
|
|
const KInterval &GetInterval();
|
|
void SetRes( K3DResMeshMatrixAnimation *matres );
|
|
void GetData( int time, K3DMatrix *point );
|
|
virtual bool Reload();
|
|
|
|
private:
|
|
KInterval m_Interval;
|
|
K3DResMeshMatrixAnimationSPtr m_spResMat;
|
|
};
|
|
DECL_SPTR(K3DResEventPoint)
|
|
|
|
class K3DResEventBox : public KResource
|
|
{
|
|
public:
|
|
K3DResEventBox();
|
|
protected:
|
|
virtual ~K3DResEventBox();
|
|
public:
|
|
const KInterval &GetInterval();
|
|
void SetRes( const K3DBoundRotCube &cube, K3DResMeshMatrixAnimation *matres );
|
|
void GetData( int time, K3DBoundRotCube *cube );
|
|
virtual bool Reload();
|
|
private:
|
|
KInterval m_Interval;
|
|
K3DBoundRotCube m_Cube;
|
|
K3DResMeshMatrixAnimationSPtr m_spResMat;
|
|
};
|
|
DECL_SPTR(K3DResEventBox)
|
|
|
|
|
|
class K3DResCamera : public KResource
|
|
{
|
|
public:
|
|
K3DResCamera();
|
|
protected:
|
|
virtual ~K3DResCamera();
|
|
public:
|
|
struct Key
|
|
{
|
|
int time;
|
|
float fov;
|
|
K3DVector pos;
|
|
K3DVector view;
|
|
K3DVector up;
|
|
|
|
bool operator<( const Key &target ) const;
|
|
};
|
|
const KInterval &GetInterval();
|
|
void SetKeyCount( int count );
|
|
void SetKey( int index, Key *key, int count = 1 );
|
|
void SetWholeKey( Key *key, int count );
|
|
void GetData( int time, Key*& key1, Key*& key2 );
|
|
virtual bool Reload();
|
|
private:
|
|
KKeyRes<Key> m_keys;
|
|
};
|
|
DECL_SPTR(K3DResCamera)
|
|
|
|
class K3DResLight : public KResource
|
|
{
|
|
public:
|
|
K3DResLight();
|
|
protected:
|
|
virtual ~K3DResLight();
|
|
public:
|
|
struct Key
|
|
{
|
|
int time;
|
|
K3DLight light;
|
|
bool operator<( const Key &target ) const;
|
|
};
|
|
const KInterval &GetInterval();
|
|
void SetKeyCount( int count );
|
|
void SetKey( int index, Key *key, int count = 1 );
|
|
void SetWholeKey( Key *key, int count );
|
|
void GetData( int time, Key*& key1, Key*& key2 );
|
|
virtual bool Reload();
|
|
|
|
private:
|
|
KKeyRes<Key> m_keys;
|
|
};
|
|
DECL_SPTR(K3DResLight)
|
|
|
|
//class KResSound : public KResource
|
|
//{
|
|
//public:
|
|
// KResSound();
|
|
//protected:
|
|
// virtual ~KResSound();
|
|
//public:
|
|
// struct Key
|
|
// {
|
|
// bool bPlay;
|
|
// int time;
|
|
// KSoundData * data;
|
|
// bool operator<( const Key &target ) const;
|
|
// };
|
|
// const KInterval &GetInterval();
|
|
// void SetKeyCount( int count );
|
|
// void SetKey( int index, Key *key, int count = 1 );
|
|
// void SetWholeKey( Key *key, int count );
|
|
// void GetData( int time, Key*& key1, Key*& key2 );
|
|
// void ResetPlayFlag();
|
|
// virtual bool Reload();
|
|
//
|
|
//protected:
|
|
// KKeyRes<Key> m_keys;
|
|
//};
|
|
|
|
class KResSprite : public KResource
|
|
{
|
|
public:
|
|
KResSprite();
|
|
protected:
|
|
virtual ~KResSprite();
|
|
public:
|
|
void SetTexture( K3DTexture *pTex, const KRect *srcrect );
|
|
void AddNote( const char *note );
|
|
int GetNoteCount();
|
|
LPCSTR GetNote( int index );
|
|
void SetMirror( bool h, bool v );
|
|
void SetCWRotation(bool r);
|
|
void SetCCWRotation(bool r);
|
|
bool IsCWRotate();
|
|
bool IsCCWRotate();
|
|
void SetAdditiveRenderMode( bool useAdditive );
|
|
bool IsAdditiveRenderMode();
|
|
bool IsMirrorHori();
|
|
bool IsMirrorVert();
|
|
void SetOffset( const K3DPoint &offset );
|
|
void GetSourceUVRect( float &left, float &top, float &right, float &bottom );
|
|
float GetSizeX();
|
|
float GetSizeY();
|
|
void SetSize( float cx, float cy );
|
|
K3DTexture *GetTexture();
|
|
const KRect &GetSourceRect();
|
|
const K3DPoint &GetOffset();
|
|
virtual bool Reload();
|
|
void SetTransform( const K3DMatrix &mat );
|
|
const K3DMatrix &GetTransform();
|
|
void SetVisibility( float vis );
|
|
float GetVisibility();
|
|
class KSpriteBoundBox
|
|
{
|
|
public:
|
|
KSpriteBoundBox();
|
|
KSpriteBoundBox(LPCSTR lpszName, KRect & rcArea);
|
|
KSpriteBoundBox(const KSpriteBoundBox & rhs);
|
|
KSpriteBoundBox & operator=(const KSpriteBoundBox & rhs);
|
|
bool operator<(KSpriteBoundBox & rhs) const;
|
|
KRect GetRect();
|
|
private:
|
|
void _Copy(const KSpriteBoundBox & rhs);
|
|
std::string m_sBoxName;
|
|
KRect m_rcArea;
|
|
};
|
|
|
|
int GetBoundBoxSize();
|
|
KSpriteBoundBox & GetBoundBox(int nIndex);
|
|
void PushBoundBox(KSpriteBoundBox & cBoundBox);
|
|
|
|
// MJ 2005/02/23
|
|
KRect GetRectSrc() { return m_rectSrc; };
|
|
|
|
private:
|
|
K3DTextureSPtr m_spTexture;
|
|
KRect m_rectSrc;
|
|
K3DPoint m_ptOffset;
|
|
float m_fSizeX;
|
|
float m_fSizeY;
|
|
float m_fLeft, m_fTop, m_fRight, m_fBottom;
|
|
K3DMatrix m_matTransform;
|
|
float m_fVisibility;
|
|
bool m_bMirrorH;
|
|
bool m_bMirrorV;
|
|
std::vector<std::string> m_sNote;
|
|
std::vector<KSpriteBoundBox> m_vtBoundBox;
|
|
bool m_bUseAdditive;
|
|
bool m_bCWRotation;
|
|
bool m_bCCWRotation;
|
|
};
|
|
DECL_SPTR(KResSprite)
|
|
|
|
class KResSpriteAnimation : public KResource
|
|
{
|
|
public:
|
|
KResSpriteAnimation();
|
|
protected:
|
|
virtual ~KResSpriteAnimation();
|
|
public:
|
|
struct Track
|
|
{
|
|
struct Note
|
|
{
|
|
DWORD m_dwFrameNumber;
|
|
std::string m_sNote;
|
|
};
|
|
std::string name;
|
|
std::vector<Note> m_vtNote;
|
|
|
|
~Track() { m_vtNote.clear(); }
|
|
};
|
|
struct Key
|
|
{
|
|
int time;
|
|
KResSpriteSPtr spSprite;
|
|
Key();
|
|
bool operator<( const Key &target ) const;
|
|
};
|
|
const KInterval &GetInterval();
|
|
void SetKeyCount( int count );
|
|
/** 경고 : 만약 SetKey를 한 KResSpriteAnimation에 두고 같은 Frame에 관해서 반복할 경우
|
|
Resource Leak 발생 가능. ( 즉 이 펑션은 한 KResSpriteAnimation의 동일 Frame에 관해서
|
|
한번만 불려야 함) */
|
|
void SetKey( int index, Key *key, int count = 1 );
|
|
KResSpriteAnimation::Key& GetKey( int nIndex ) { return m_keys.GetKey(nIndex); };
|
|
|
|
/** 경고 : 만약 SetWholeKey를 한 KResSpriteAnimation에 두고 여러번 호출 할 경우
|
|
Resource Leak 발생 가능. (즉 이 펑션은 한 KResSpriteAnimaion에 관해서 한번만 불려야 함) */
|
|
void SetWholeKey( Key *key, int count );
|
|
int GetKeyCount();
|
|
void GetData( int time, Key*& key1, Key*& key2 );
|
|
virtual bool Reload();
|
|
int GetIndexNumber(DWORD dwTime);
|
|
void AddTrack(const Track & trackData);
|
|
DWORD GetTrackSize();
|
|
Track & GetTrack(int nIndeX);
|
|
KResSprite * GetSpriteByFrame(int nFrame);
|
|
|
|
void SetLoad( bool bFlag ) { m_bIsLoad = bFlag; }
|
|
const bool IsLoaded() { return m_bIsLoad; }
|
|
void AddFrame( const char * pStr )
|
|
{
|
|
m_FrameList.push_back( std::string(pStr) );
|
|
}
|
|
const std::vector<std::string> & GetFrame()
|
|
{
|
|
return m_FrameList;
|
|
}
|
|
|
|
void ClearFrame()
|
|
{
|
|
m_FrameList.clear();
|
|
}
|
|
|
|
void SetEncrypt( bool bEncrypt ) { m_bEncrypt = bEncrypt; }
|
|
const bool IsEncrypt() { return m_bEncrypt; }
|
|
|
|
|
|
void SetUseColorKey( bool bFlag ) { m_bUseColorKey = bFlag; }
|
|
void SetColorKey( KColor color ) { m_ColorKey = color; }
|
|
const KColor& GetColorKey() { return m_ColorKey; }
|
|
const bool IsUseColorKey() { return m_bUseColorKey; }
|
|
|
|
private:
|
|
std::vector<Track> m_vtTrack;
|
|
KKeyRes<Key, true> m_keys;
|
|
|
|
bool m_bIsLoad; //
|
|
std::vector<std::string> m_FrameList; ///< 순서대로 찍는다.
|
|
|
|
bool m_bEncrypt;
|
|
bool m_bUseColorKey;
|
|
KColor m_ColorKey;
|
|
};
|
|
DECL_SPTR(KResSpriteAnimation)
|
|
|
|
|
|
class KResFXBillboard : public KResource
|
|
{
|
|
public:
|
|
KResFXBillboard();
|
|
protected:
|
|
virtual ~KResFXBillboard();
|
|
public:
|
|
void SetTexture( K3DTexture *pTex);
|
|
void SetVertices( K3DVertex *vtxs );
|
|
const K3DVertex *GetVertices();
|
|
|
|
// Property Set
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void SetAdditiveRenderMode( bool useAdditive ) { m_bUseAdditive = useAdditive;}
|
|
bool GetAdditiveRenderMode() { return m_bUseAdditive; }
|
|
void SetUVAnimation( bool useUVAni, int nMaxFrame, int nLoopFrame ) { m_bUseUVAnimation = useUVAni; m_nUVMaxFrame = nMaxFrame; m_nUvLoopFrame = nLoopFrame; }
|
|
int GetUVAniMaxFrame() { return m_nUVMaxFrame;}
|
|
bool GetUVAnimation() { return m_bUseUVAnimation;}
|
|
int GetUvLoopFrame() { return m_nUvLoopFrame; }
|
|
void SetAlignedCameraMode( bool bAlignedCamera ){ m_bAlignedCamera = bAlignedCamera;}
|
|
bool GetAlignedCameraMode() { return m_bAlignedCamera; }
|
|
void SetLoopMode( bool IsLoop ) { m_bIsLoop = IsLoop; }
|
|
bool IsLoop() { return m_bIsLoop; }
|
|
void SetRange( int nStart, int nEnd )
|
|
{
|
|
m_nRangeStart = nStart;
|
|
if ( nEnd == 0 )
|
|
nEnd = m_interval.GetEnd();
|
|
m_nRangeEnd = nEnd;
|
|
}
|
|
int GetRangeStart() { return m_nRangeStart; }
|
|
int GetRangeEnd() { return m_nRangeEnd; }
|
|
void SetScale( const K3DVector &scale ) { m_vecScale = scale; }
|
|
const K3DVector &GetScale() { return m_vecScale; }
|
|
void SetFixedAxis( int nAxis ) { m_nFixedAxis = nAxis; }
|
|
int GetFixedAxis() { return m_nFixedAxis; }
|
|
void SetRotateSpeed( float fSpeed ) { m_fRotateSpeed = fSpeed; }
|
|
float GetRotateSpeed() { return m_fRotateSpeed; }
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void SetRes( K3DResMeshMatrixAnimation *pResMat, K3DResMeshVisibilityAnimation *pResVis);
|
|
const KInterval &GetInterval();
|
|
K3DTexture *GetTexture();
|
|
void GetData( int time, float *vis, K3DMatrix *mat );
|
|
virtual bool Reload();
|
|
|
|
private:
|
|
bool m_bIsLoop;
|
|
bool m_bAlignedCamera;
|
|
bool m_bUseUVAnimation;
|
|
bool m_bUseAdditive;
|
|
KInterval m_interval;
|
|
int m_nUVMaxFrame;
|
|
int m_nUvLoopFrame;
|
|
int m_nRangeStart, m_nRangeEnd;
|
|
K3DVector m_vecScale;
|
|
int m_nFixedAxis;
|
|
float m_fRotateSpeed;
|
|
K3DTextureSPtr m_spTex;
|
|
K3DVertex m_vtxBillBoard[4];
|
|
K3DResMeshMatrixAnimationSPtr m_spResMat;
|
|
K3DResMeshVisibilityAnimationSPtr m_spResVis;
|
|
};
|
|
DECL_SPTR(KResFXBillboard)
|
|
|
|
class KResFXParticle : public KResource
|
|
{
|
|
public:
|
|
KResFXParticle();
|
|
protected:
|
|
virtual ~KResFXParticle();
|
|
public:
|
|
void SetTexture( K3DTexture *pTex );
|
|
void SetRes( K3DResMeshMatrixAnimation *pResMat, K3DResMeshVisibilityAnimation *pResVis);
|
|
const KInterval &GetInterval();
|
|
K3DTexture *GetTexture();
|
|
void SetVertices( K3DVertex *vtxs );
|
|
void CalcNormal( K3DVertex* vtxs );
|
|
const K3DVector& GetNormal();
|
|
const K3DVertex *GetVertices();
|
|
|
|
// Property Set
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void SetAdditiveRenderMode( bool useAdditive ) { m_bUseAdditive = useAdditive; }
|
|
bool GetAdditiveRenderMode() { return m_bUseAdditive; }
|
|
void SetUVAnimation( bool useUVAni, int nMaxFrame, int nLoopFrame ) { m_bUseUVAnimation = useUVAni; m_nUVMaxFrame = nMaxFrame; m_nUvLoopFrame = nLoopFrame; }
|
|
int GetUVAniMaxFrame() { return m_nUVMaxFrame; }
|
|
int GetUvLoopFrame() { return m_nUvLoopFrame; }
|
|
bool GetUVAnimation() { return m_bUseUVAnimation; }
|
|
void SetCreateTime( int nTime ) { m_nTimeCreate = nTime;}
|
|
int GetCreateTime() { return m_nTimeCreate; }
|
|
void SetLifeTime( int nLifeTime, int nVari ) { m_nLifeTime = nLifeTime; m_nLifeTimeVariation = nVari; }
|
|
int GetLifeTime() { return m_nLifeTime; }
|
|
int GetLifeTimeVariation() { return m_nLifeTimeVariation; }
|
|
void SetBeginSpeed( const K3DVector &speed ) { m_vecBeginSpeed = speed; }
|
|
const K3DVector &GetBeginSpeed() { return m_vecBeginSpeed; }
|
|
void SetSpreadAngle( float fAngle ) { m_fSpreadAngle = fAngle; }
|
|
float GetSpreadAngle() { return m_fSpreadAngle; }
|
|
void SetVelocity( const K3DVector &velocity ) { m_vecVelocity = velocity; }
|
|
const K3DVector &GetVelocity() { return m_vecVelocity; }
|
|
void SetLoopMode( bool IsLoop ) { m_bIsLoop = IsLoop; }
|
|
bool IsLoop() { return m_bIsLoop; }
|
|
void SetRange( int nStart, int nEnd )
|
|
{
|
|
m_nRangeStart = nStart;
|
|
if ( nEnd == 0 )
|
|
nEnd = m_interval.GetEnd() - m_nRangeStart;
|
|
m_nRangeEnd = m_nRangeStart + nEnd;
|
|
}
|
|
int GetRangeStart() { return m_nRangeStart; }
|
|
int GetRangeEnd() { return m_nRangeEnd; }
|
|
void SetScale( const K3DVector &scale ) { m_vecScale = scale; }
|
|
const K3DVector &GetScale() { return m_vecScale; }
|
|
void SetGravityAccel( float fGravityAccel ) { m_fGravityAccel = fGravityAccel; }
|
|
float GetGravityAccel() { return m_fGravityAccel; }
|
|
void SetGravity( const K3DVector &gravity ) { m_vecGravity = gravity; }
|
|
const K3DVector &GetGravity() { return m_vecGravity; }
|
|
void SetAttachParent( bool bAttachParent ) { m_bAttachParent = bAttachParent; }
|
|
bool IsAttachParent() { return m_bAttachParent; }
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void GetData( int time, float *vis, K3DMatrix *mat );
|
|
void GetParticleData( int time, float *vis, K3DMatrix *mat );
|
|
virtual bool Reload();
|
|
|
|
private:
|
|
bool m_bIsLoop;
|
|
bool m_bUseUVAnimation;
|
|
bool m_bUseAdditive;
|
|
KInterval m_interval;
|
|
int m_nUVMaxFrame;
|
|
int m_nUvLoopFrame;
|
|
int m_nRangeStart, m_nRangeEnd;
|
|
int m_nTimeCreate;
|
|
int m_nLifeTime;
|
|
int m_nLifeTimeVariation;
|
|
K3DVector m_vecBeginSpeed;
|
|
K3DVector m_vecScale;
|
|
float m_fSpreadAngle;
|
|
K3DVector m_vecVelocity;
|
|
float m_fGravityAccel;
|
|
K3DVector m_vecGravity;
|
|
K3DVertex m_vtxBillBoard[4];
|
|
K3DVector m_vecNormal;
|
|
|
|
K3DTextureSPtr m_spTex;
|
|
K3DResMeshMatrixAnimationSPtr m_spResMat;
|
|
K3DResMeshVisibilityAnimationSPtr m_spResVis;
|
|
|
|
bool m_bAttachParent;
|
|
};
|
|
DECL_SPTR(KResFXParticle)
|
|
|
|
class KFXAfterImagePrimitive;
|
|
class KResFXAfterImage : public KResource
|
|
{
|
|
public:
|
|
KResFXAfterImage();
|
|
protected:
|
|
virtual ~KResFXAfterImage();
|
|
public:
|
|
void SetTexture( K3DTexture *pTex );
|
|
void SetVertices( K3DVertex *vtxs );
|
|
const K3DVertex *GetVertices();
|
|
|
|
// Property Set
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void SetAdditiveRenderMode( bool useAdditive ) { m_bUseAdditive = useAdditive;}
|
|
bool GetAdditiveRenderMode() { return m_bUseAdditive; }
|
|
void SetUVAnimation( bool useUVAni, int nMaxFrame) {m_bUseUVAnimation = useUVAni;m_nUVMaxFrame = nMaxFrame;}
|
|
int GetUVAniMaxFrame() { return m_nUVMaxFrame;}
|
|
bool GetUVAnimation() { return m_bUseUVAnimation;}
|
|
void SetAlignedCameraMode( bool bAlignedCamera ){m_bAlignedCamera = bAlignedCamera;}
|
|
bool GetAlignedCameraMode() {return m_bAlignedCamera;}
|
|
void SetLoopMode( bool IsLoop ) { m_bIsLoop = IsLoop; }
|
|
bool IsLoop() { return m_bIsLoop; }
|
|
void SetRange( int nStart, int nEnd )
|
|
{
|
|
m_nRangeStart = nStart;
|
|
if ( nEnd == 0 )
|
|
nEnd = m_interval.GetEnd();
|
|
m_nRangeEnd = nEnd;
|
|
}
|
|
int GetRangeStart() { return m_nRangeStart; }
|
|
int GetRangeEnd() { return m_nRangeEnd; }
|
|
void SetScale( const K3DVector &scale ) { m_vecScale = scale; }
|
|
const K3DVector &GetScale() { return m_vecScale; }
|
|
void SetFrameTime (int nFrameTime) { m_nFrameTime = nFrameTime;}
|
|
void SetFrameNumber(int nFrameNumber) { m_nFrameNumber = nFrameNumber;}
|
|
int GetFrameTime() { return m_nFrameTime;}
|
|
int GetFrameNumber() { return m_nFrameNumber;}
|
|
void SetBlendMode( int blendmode ) { m_nBlendMode = blendmode; }
|
|
int GetBlendMode() { return m_nBlendMode; }
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void SetRes( K3DResMeshMatrixAnimation *matres, K3DResMeshVisibilityAnimation *visres);
|
|
const KInterval &GetInterval();
|
|
K3DTexture *GetTexture();
|
|
void GetData( int time, K3DSPRITEVERTEX& vtx0, K3DSPRITEVERTEX& vtx1, const K3DMatrix& matParent, float& vis );
|
|
virtual bool Reload();
|
|
|
|
private:
|
|
bool m_bIsLoop;
|
|
bool m_bAlignedCamera;
|
|
bool m_bUseUVAnimation;
|
|
bool m_bUseAdditive;
|
|
KInterval m_interval;
|
|
int m_nUVMaxFrame;
|
|
int m_nRangeStart, m_nRangeEnd;
|
|
K3DVector m_vecScale;
|
|
|
|
K3DTextureSPtr m_spTex;
|
|
K3DResMeshMatrixAnimationSPtr m_spResMat;
|
|
K3DResMeshVisibilityAnimationSPtr m_spResVis;
|
|
|
|
K3DVertex m_vtxAfterImage[4];
|
|
int m_nFrameTime;
|
|
int m_nFrameNumber;
|
|
int m_nBlendMode;
|
|
};
|
|
DECL_SPTR(KResFXAfterImage)
|
|
#endif |