// Z3DMultipartPortion.h: interface for the Z3DMultipartPortion class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_Z3DMULTIPARTPORTION_H__1B9AE6C4_16F6_11D5_A643_0000E8EB4C69__INCLUDED_) #define AFX_Z3DMULTIPARTPORTION_H__1B9AE6C4_16F6_11D5_A643_0000E8EB4C69__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "misc.h" #include "Z3DCharacterModel.h" #include "Z3DTexture.h" #include #include #define Z3D_MPID_FACE 10 #define Z3D_MPID_HAIR 11 #define Z3D_MPID_EAR 12 #define Z3D_MPID_SHOULDER 20 #define Z3D_MPID_CHEST 21 #define Z3D_MPID_ARM 23 #define Z3D_MPID_WAIST 24 #define Z3D_MPID_HAND 30 #define Z3D_MPID_LEG 40 #define Z3D_MPID_FOOT 50 #define Z3D_PORTION_BUFFER_BANK_SIZE 500 // ¹öÅØ½º ¹öÆÛ Å©±â´Â 500´ÜÀ§·Î ¼³Á¤µÊ enum Z3D_MULTIPART_PORTION_TYPE { Z3D_MPT_TEXPIECE = 0, Z3D_MPT_TEXTURE }; struct Z3DVBCacheNode { long lVertexCount; IDirect3DVertexBuffer8* pVB; Z3DVBCacheNode* pNext; }; struct Z3DIBCacheNode { long lIndexCount; IDirect3DIndexBuffer8* pIB; Z3DIBCacheNode* pNext; }; struct STVectorStorage { vector3 s; vector3 t; }; struct Z3DMultipartPortion { public: Z3DMultipartPortion( Z3D_MULTIPART_PORTION_TYPE mpt = Z3D_MPT_TEXPIECE ) { m_lVertexBufferVertexCount = 0; m_pVertexBuffer = NULL; m_lVertexCount = 0; for( int i = 0; i < Z3D_LOD_LEVEL; ++i ) { m_alIndexBufferIndexCount[i] = 0; m_apIndexBuffer[i] = NULL; m_alIndexCount[i] = NULL; } if( Z3D_MPT_TEXPIECE == mpt ) { m_pTexture = new Z3DTexture; m_pTexture2 = new Z3DTexture; } else { m_pTexture = NULL; m_pTexture2 = NULL; } m_MPT = mpt; m_vec_pMesh.clear(); m_pSTVertexBuffer = NULL; m_bSTVertexMode = false; m_pSTVectors = NULL; } ~Z3DMultipartPortion() { int i; SAFE_RELEASE( m_pSTVertexBuffer ); // for( i = 0; i < m_vecpSTVectors.size(); ++i ) // { // SAFE_DELETEA( m_vecpSTVectors[i] ); // } SAFE_DELETEA( m_pSTVectors ); for( i = 0; i < Z3D_LOD_LEVEL; ++i ) { SAFE_RELEASE( m_apIndexBuffer[i] ); } SAFE_RELEASE( m_pVertexBuffer ); m_vec_pMesh.clear(); std::map::iterator it_m; for( it_m = m_map_IdMeshTag.begin(); it_m != m_map_IdMeshTag.end(); it_m++ ) { it_m->second.Release(); } std::map::iterator it_t; for( it_t = m_map_IdTexPieceTag.begin(); it_t != m_map_IdTexPieceTag.end(); it_t++ ) { it_t->second.Release(); } for( it_t = m_map_IdTexPieceTag2.begin(); it_t != m_map_IdTexPieceTag2.end(); it_t++ ) { it_t->second.Release(); } SAFE_DELETE( m_pTexture ); SAFE_DELETE( m_pTexture2 ); std::map::iterator it; for( it = m_map_IdTextureTag.begin(); it != m_map_IdTextureTag.end(); it++ ) { it->second.Release(); } for( it = m_map_IdTextureTag2.begin(); it != m_map_IdTextureTag2.end(); it++ ) { it->second.Release(); } for( it = m_map_IdSpecTextureTag.begin(); it != m_map_IdSpecTextureTag.end(); it++ ) { it->second.Release(); } } void BuildSTVertex( IDirect3DDevice8* pDevice ); void BuildMesh( IDirect3DDevice8* pDevice ); bool SetMesh( const int nPartId, H3DMeshTag tagMesh ); bool DeleteMesh( const int nPartId ); bool SetTexPiece( const int nPartId, H3DTexPieceTag tagTexpiece ); bool SetTexPiece2( const int nPartId, H3DTexPieceTag tagTexpiece ); bool DeleteTexPiece( const int nPartId ); bool BatchOpen(); bool BatchClose( IDirect3DDevice8* pDevice ); bool SetTexture( const int nPartId, H3DTextureTag tagTexture ); bool SetTexture2( const int nPartId, H3DTextureTag tagTexture ); bool SetSpecTexture( const int nPartId, H3DTextureTag tagTexture ); bool DeleteTexture( const int nPartId ); bool DeleteTexture2( const int nPartId ); bool DeleteSpecTexture( const int nPartId ); static IDirect3DVertexBuffer8* _GetVertexBufferInterface( IDirect3DDevice8* pDevice, long& rlVertexCount ); static void _ReleaseVertexBufferInterface( IDirect3DVertexBuffer8* pVB ); static IDirect3DIndexBuffer8* _GetIndexBufferInterface( long lLODIndex, IDirect3DDevice8* pDevice, long rlIndexCount ); static void _ReleaseIndexBufferInterface( long lLODIndex, IDirect3DIndexBuffer8* pIB ); static void _Close(); public: //std::vector m_vecpSTVectors; STVectorStorage* m_pSTVectors; IDirect3DVertexBuffer8* m_pSTVertexBuffer; bool m_bSTVertexMode; long m_lVertexBufferVertexCount; long m_alIndexBufferIndexCount[Z3D_LOD_LEVEL]; std::vector m_vec_pMesh; std::map m_map_IdMeshTag; IDirect3DVertexBuffer8* m_pVertexBuffer; long m_lVertexCount; IDirect3DIndexBuffer8* m_apIndexBuffer[Z3D_LOD_LEVEL]; long m_alIndexCount[Z3D_LOD_LEVEL]; std::map m_map_IdTexPieceTag; std::map m_map_IdTexPieceTag2; Z3DTexture* m_pTexture; Z3DTexture* m_pTexture2; std::map m_map_IdTextureTag; std::map m_map_IdTextureTag2; std::map m_map_IdSpecTextureTag; std::vector m_vec_pTexture; std::vector m_vec_pTexture2; std::vector m_vec_pSpecTexture; Z3D_MULTIPART_PORTION_TYPE m_MPT; // vertex buffer ij½Ã ¸®½ºÆ®. SLL À̸ç Ãß°¡´Â header, »èÁ¦(¿À¹öÇ÷νÃ)´Â tail ¿¡¼­ ÀϾ // °Ë»öÀº headerºÎÅÍ ¼øÂ÷ÀûÀ¸·Î. strategy ´Â first match static const long ms_lMaxVBCacheCount; static long ms_lVBCacheCount; static Z3DVBCacheNode* ms_pVBCacheChainHeader; // index buffer ij½Ã ¸®½ºÆ®. SLL À̸ç Ãß°¡´Â header, »èÁ¦(¿À¹öÇ÷νÃ)´Â tail ¿¡¼­ ÀϾ // °Ë»öÀº headerºÎÅÍ ¼øÂ÷ÀûÀ¸·Î. strategy ´Â first match // LOD ·¹º§º°·Î µû·Î °ü¸®ÇÔ. (¹è¿­ À妽º°¡ ÇØ´ç LOD levelÀÇ µ¥ÀÌÅÍ) static const long ms_alMaxIBCacheCount[Z3D_LOD_LEVEL]; static long ms_alIBCacheCount[Z3D_LOD_LEVEL]; static Z3DIBCacheNode* ms_apIBCacheChainHeader[Z3D_LOD_LEVEL]; }; #endif // !defined(AFX_Z3DMULTIPARTPORTION_H__1B9AE6C4_16F6_11D5_A643_0000E8EB4C69__INCLUDED_)