801 lines
21 KiB
C++
801 lines
21 KiB
C++
// KSeqAvatar.cpp: implementation of the KSeqAvatar class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
#include "KSeqAvatar.h"
|
|
#include ".\kseqavatarex.h"
|
|
#include "KRenderObjectBone.h"
|
|
#include "KRenderObjectMesh.h"
|
|
|
|
//#include "SDebug_Util.h"
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
KSeqAvatarEx::KSeqAvatarEx( bool bClone/*=false*/ )
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
m_pAvatarPart[i] = NULL;
|
|
if( !bClone )
|
|
m_pAvatarPart[i] = new KSeqAvatar(i);
|
|
}
|
|
|
|
m_bRenderRotCube = false;
|
|
}
|
|
|
|
KSeqAvatarEx::~KSeqAvatarEx()
|
|
{
|
|
Clear();
|
|
}
|
|
|
|
void KSeqAvatarEx::Initialize()
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->Initialize();
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::ReSet()
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->ReSet();
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::Clear()
|
|
{
|
|
KSeqForm::Clear();
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
SAFE_DELETE( m_pAvatarPart[i] );
|
|
}
|
|
}
|
|
|
|
bool KSeqAvatarEx::GetIsClip()
|
|
{
|
|
bool bClip = true;
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
{
|
|
bClip = m_pAvatarPart[i]->GetIsClip();
|
|
if( !bClip ) return bClip;
|
|
}
|
|
}
|
|
return bClip;
|
|
}
|
|
|
|
void KSeqAvatarEx::ClipTest( const K3DVector* pFrustrum)
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->ClipTest( pFrustrum );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::SetParentTransform( const K3DMatrix *pMatParent, const K3DMatrix *pMatAttach, BOOL bRotationLock )
|
|
{
|
|
if( m_pAvatarPart[ANIPART_BIPED] )
|
|
m_pAvatarPart[ANIPART_BIPED]->SetParentTransform( pMatParent, pMatAttach, bRotationLock );
|
|
}
|
|
|
|
bool KSeqAvatarEx::AddBoneEffect( int nAniIndex, int nIndex, const char *bonename, const char *filename )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] )
|
|
{
|
|
m_pAvatarPart[nAniIndex]->AddBoneEffect( nIndex, bonename, filename );
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//이펙트는 본체에만 추가 가능하다.
|
|
bool KSeqAvatarEx::AddEffectPos( int nAniIndex, int nAttachIndex, const char *filename )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] )
|
|
{
|
|
m_pAvatarPart[nAniIndex]->AddEffectPos( nAttachIndex, filename );
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void KSeqAvatarEx::AddMorphMesh( int nAniIndex, KMsgSET_MORPHMESH* pMsg )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] )
|
|
m_pAvatarPart[nAniIndex]->AddMorphMesh( pMsg );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::SetFixTexture( int nAniIndex, class KMsgSET_FIXTEXTURE* pMsg )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] )
|
|
m_pAvatarPart[nAniIndex]->SetFixTexture( pMsg );
|
|
}
|
|
}
|
|
|
|
bool KSeqAvatarEx::AddAnimation( int nAniIndex, const char *filename, bool bNowLoading )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] )
|
|
m_pAvatarPart[nAniIndex]->AddAnimation( filename, FALSE, bNowLoading ); //File Name은 특정한 키가 설정 되어 들어 간다.
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void KSeqAvatarEx::SetVisibility( float fVisibility )
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->SetVisibility( fVisibility );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::SetSkinDiffuse( KColor & diffuse )
|
|
{
|
|
for( int i(0); ANIPART_SHORTSKIRT >= i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->SetSkinDiffuse( diffuse );
|
|
}
|
|
}
|
|
|
|
//아바타 살들~
|
|
void KSeqAvatarEx::AddMesh( int nAniIndex, int nMeshIndex, KSeqObject *obj )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniIndex]->AddMesh( nMeshIndex, obj );
|
|
}
|
|
}
|
|
|
|
bool KSeqAvatarEx::AddMesh( int nAniIndex, int nMeshIndex, const char *filename, std::string& texName )
|
|
{
|
|
bool ret;
|
|
ret = AddMesh(nAniIndex, nMeshIndex, filename);
|
|
if (ret)
|
|
ChangeTexture(nAniIndex, nMeshIndex, texName);
|
|
else
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
|
|
KSeqObject *KSeqAvatarEx::GetMesh (int nAniIndex, int nMeshIndex)
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX ) {
|
|
if( m_pAvatarPart[nAniIndex] != NULL ) {
|
|
return m_pAvatarPart[nAniIndex]->GetMesh( nMeshIndex );
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
int KSeqAvatarEx::IsExistMesh( int nAniIndex, int nMeshIndex )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return -1;
|
|
|
|
return m_pAvatarPart[nAniIndex]->IsExistMesh( nMeshIndex );
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
int KSeqAvatarEx::IsExistDecoMesh( int nAniIndex, int nMeshIndex )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return -1;
|
|
|
|
return m_pAvatarPart[nAniIndex]->IsExistDecoMesh( nMeshIndex );
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
void KSeqAvatarEx::ChangeTexture(int nAniIndex, int nMeshIndex, std::string& texName)
|
|
{
|
|
if ((texName != "") && (texName != "0") && (texName != "NotFoundFile"))
|
|
{
|
|
std::string name = texName + ".dds";
|
|
_CID( CHANGE_MESH_TEXTURE );
|
|
KMsgCHANGE_MESH_TEXTURE msg;
|
|
msg.bForceChange = true;
|
|
msg.vTextureList.push_back(name.c_str());
|
|
Perform(nAniIndex, nMeshIndex, id_CHANGE_MESH_TEXTURE, msg );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::ChangeDecoTexture(int nAniIndex, int nMeshIndex, std::string& texName)
|
|
{
|
|
if ((texName != "") && (texName != "0") && (texName != "NotFoundFile"))
|
|
{
|
|
std::string name = texName + ".dds";
|
|
_CID( CHANGE_MESH_TEXTURE );
|
|
KMsgCHANGE_MESH_TEXTURE msg;
|
|
msg.bForceChange = true;
|
|
msg.vTextureList.push_back(name.c_str());
|
|
DecoPerform(nAniIndex, nMeshIndex, id_CHANGE_MESH_TEXTURE, msg );
|
|
}
|
|
}
|
|
|
|
bool KSeqAvatarEx::AddMesh( int nAniIndex, int nMeshIndex, const char *filename )
|
|
{
|
|
// _oprint( "AddMesh %d %d %s\n", nAniIndex, nMeshIndex, filename );
|
|
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return false;
|
|
|
|
return m_pAvatarPart[nAniIndex]->AddMesh( nMeshIndex, filename );
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool KSeqAvatarEx::AddDecoMesh( int nAniIndex, int nDecoMeshIndex, KSeqObject *obj )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return false;
|
|
|
|
m_pAvatarPart[nAniIndex]->AddDecoMesh( nDecoMeshIndex, obj );
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool KSeqAvatarEx::AddDecoMesh( int nAniIndex, int nDecoMeshIndex, const char *filename )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return false;
|
|
|
|
return m_pAvatarPart[nAniIndex]->AddDecoMesh( nDecoMeshIndex, filename );
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool KSeqAvatarEx::AddDecoMesh( int nAniIndex, int nMeshIndex, const char *filename, std::string& texName )
|
|
{
|
|
bool ret;
|
|
ret = AddDecoMesh(nAniIndex, nMeshIndex, filename);
|
|
if (ret)
|
|
ChangeDecoTexture(nAniIndex, nMeshIndex, texName);
|
|
else
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
|
|
//아바타 무기 링크들~
|
|
void KSeqAvatarEx::AddAttachItem( int nAniIndex, int nItemIndex, KSeqObject *obj )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniIndex]->AddAttachItem( nItemIndex, obj );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::AddAttachItem( int nAniIndex, int nItemIndex, const char *filename )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniIndex]->AddAttachItem( nItemIndex, filename );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::AddAttachItem( int nAniIndex, int nItemIndex, const char *filename, std::string& texName )
|
|
{
|
|
AddAttachItem(nAniIndex, nItemIndex, filename);
|
|
// ChangeTexture(nAniIndex, texName);
|
|
}
|
|
|
|
|
|
void KSeqAvatarEx::SetItemRenderFlag( int nAniIndex, BOOL bRenderFlag ) //특수 효과 끄기
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniIndex]->SetItemRenderFlag( bRenderFlag );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::SetItemRenderFlag( int nAniIndex, int nIndex, BOOL bRenderFlag ) //
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniIndex]->SetItemRenderFlag( nIndex, bRenderFlag );
|
|
}
|
|
}
|
|
|
|
bool KSeqAvatarEx::PlayAnimation( int nAniIndex, DWORD dwCurTime, const char *name, int nAniType, float fPlayRate )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return false;
|
|
|
|
return m_pAvatarPart[nAniIndex]->PlayAnimation( dwCurTime, name, nAniType, fPlayRate );
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool KSeqAvatarEx::PlayOverride( int nAniIndex, DWORD dwCurTime, const char *name, float fPlayRate )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return false;
|
|
|
|
return m_pAvatarPart[nAniIndex]->PlayOverride( dwCurTime, name, fPlayRate );
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void KSeqAvatarEx::SetAnimationPos(int nPosFlag)
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
m_pAvatarPart[i]->SetAnimationPos(nPosFlag);
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::SetTransform( const K3DMatrix &mat )
|
|
{
|
|
m_matTransform = mat;
|
|
|
|
//몸뚱이만, 제어
|
|
if( m_pAvatarPart[ANIPART_BIPED] )
|
|
m_pAvatarPart[ANIPART_BIPED]->SetParentTransform( &m_matTransform );
|
|
}
|
|
|
|
void KSeqAvatarEx::SetAttachEffectPos( int nAniIndex )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniIndex]->SetAttachEffectPos();
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::SetAttach( int nAniIndex ) //각각의 Animation에 Attach
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniIndex]->SetAttach();
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::SetDeform( int nAniIndex ) //각각의 채널과 Deform
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniIndex]->SetDeform();
|
|
}
|
|
}
|
|
|
|
//각각의 Animation을 합친다.
|
|
void KSeqAvatarEx::SetAttachBone()
|
|
{
|
|
_CID( GETVERSION );
|
|
KMsgGET_GETVERSION msg;
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETVERSION, msg );
|
|
if( msg.dwVersion == ( ( 1 << 16 ) | 0 ) ) SetAttachBone10();
|
|
else if( msg.dwVersion == ( ( 1 << 16 ) | 1 ) ) SetAttachBone11();
|
|
//else assert( 0 );
|
|
}
|
|
|
|
void KSeqAvatarEx::SetAttachBone10()
|
|
{
|
|
//나중에 최적화 할때 손보자..
|
|
// _oprint( "KSeqAvatarEx::SetAttachBone\n" );
|
|
|
|
//각 캐쉬의 포인터를 얻어 온다.
|
|
_CID( GETBONEMATRIX2 );
|
|
KMsgGET_BONEMATRIX2 msg;
|
|
|
|
msg.nDetailIndex = DETAIL_NECK;
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
m_pAvatarPart[ANIPART_EARRING]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //귀고리
|
|
m_pAvatarPart[ANIPART_HAIR]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //헤어
|
|
msg.pBoneMat = NULL;
|
|
|
|
msg.nDetailIndex = DETAIL_HEAD; //머리
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
msg.pBoneMat = NULL;
|
|
|
|
msg.nDetailIndex = DETAIL_BODY1; //가슴, 몸통
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
msg.pBoneMat = NULL;
|
|
|
|
msg.nDetailIndex = DETAIL_BODY2; //골반 위뼈
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
m_pAvatarPart[ANIPART_MANTLE]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //망토
|
|
m_pAvatarPart[ANIPART_NECKLACE]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //목걸이
|
|
m_pAvatarPart[ANIPART_LONGSKIRT]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //롱치마
|
|
|
|
msg.nDetailIndex = DETAIL_PELVIS; //골반
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
m_pAvatarPart[ANIPART_SHORTSKIRT]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //숏치마
|
|
m_pAvatarPart[ANIPART_MIDSKIRT]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //중치마
|
|
m_pAvatarPart[ANIPART_FABRIC]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //앞뒤가리게
|
|
msg.pBoneMat = NULL;
|
|
|
|
msg.nDetailIndex = DETAIL_LEFT_HAND; //왼손
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
m_pAvatarPart[ANIPART_WEAPON_LEFT]->SetParentTransform( &m_matTransform, msg.pBoneMat );//무기 왼손
|
|
msg.pBoneMat = NULL;
|
|
|
|
msg.nDetailIndex = DETAIL_RIGHT_HAND; //오른손
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
m_pAvatarPart[ANIPART_WEAPON_RIGHT]->SetParentTransform( &m_matTransform, msg.pBoneMat );//무기 오른손
|
|
|
|
|
|
msg.nDetailIndex = DETAIL_BODY1; // 데코레이션 메쉬 어깨날개 부분 강제로 부모메쉬설정
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
KSeqAvatar* a = m_pAvatarPart[ANIPART_BIPED];
|
|
if (a->GetDecoMesh(MDECOPART_SHOULDER) != NULL)
|
|
{
|
|
a->GetDecoMesh(MDECOPART_SHOULDER)->SetParentTransform( &m_matTransform, msg.pBoneMat );
|
|
}
|
|
|
|
if (a->GetDecoMesh(MDECOPART_SHOULDER2) != NULL)
|
|
{
|
|
a->GetDecoMesh(MDECOPART_SHOULDER2)->SetParentTransform(&m_matTransform, msg.pBoneMat);
|
|
}
|
|
|
|
msg.pBoneMat = NULL;
|
|
}
|
|
|
|
void KSeqAvatarEx::SetAttachBone11()
|
|
{
|
|
//나중에 최적화 할때 손보자..
|
|
// _oprint( "KSeqAvatarEx::SetAttachBone\n" );
|
|
|
|
//각 캐쉬의 포인터를 얻어 온다.
|
|
_CID( GETBONEMATRIX2 );
|
|
KMsgGET_BONEMATRIX2 msg;
|
|
|
|
msg.nDetailIndex = DETAIL_NECK;
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
msg.pBoneMat = NULL;
|
|
|
|
msg.nDetailIndex = DETAIL_HEAD; //머리
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
m_pAvatarPart[ANIPART_EARRING]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //귀고리
|
|
m_pAvatarPart[ANIPART_HAIR]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //헤어
|
|
msg.pBoneMat = NULL;
|
|
|
|
msg.nDetailIndex = DETAIL_BODY1; //가슴, 몸통
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
m_pAvatarPart[ANIPART_MANTLE]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //망토
|
|
m_pAvatarPart[ANIPART_NECKLACE]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //목걸이
|
|
msg.pBoneMat = NULL;
|
|
|
|
msg.nDetailIndex = DETAIL_BODY2; //골반 위뼈
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
|
|
msg.nDetailIndex = DETAIL_PELVIS; //골반
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
m_pAvatarPart[ANIPART_FABRIC]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //앞뒤가리게
|
|
m_pAvatarPart[ANIPART_LONGSKIRT]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //롱치마
|
|
m_pAvatarPart[ANIPART_MIDSKIRT]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //중치마
|
|
m_pAvatarPart[ANIPART_SHORTSKIRT]->SetParentTransform( &m_matTransform, msg.pBoneMat ); //숏치마
|
|
msg.pBoneMat = NULL;
|
|
|
|
msg.nDetailIndex = DETAIL_LEFT_HAND; //왼손
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
m_pAvatarPart[ANIPART_WEAPON_LEFT]->SetParentTransform( &m_matTransform, msg.pBoneMat );//무기 왼손
|
|
msg.pBoneMat = NULL;
|
|
|
|
msg.nDetailIndex = DETAIL_RIGHT_HAND; //오른손
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
m_pAvatarPart[ANIPART_WEAPON_RIGHT]->SetParentTransform( &m_matTransform, msg.pBoneMat );//무기 오른손
|
|
|
|
|
|
msg.nDetailIndex = DETAIL_BODY1; // 데코레이션 메쉬 어깨날개 부분 강제로 부모메쉬설정
|
|
m_pAvatarPart[ANIPART_BIPED]->Perform( id_GETBONEMATRIX2, msg );
|
|
KSeqAvatar* a = m_pAvatarPart[ANIPART_BIPED];
|
|
if (a->GetDecoMesh(MDECOPART_SHOULDER) != NULL)
|
|
{
|
|
a->GetDecoMesh(MDECOPART_SHOULDER)->SetParentTransform( &m_matTransform, msg.pBoneMat );
|
|
}
|
|
|
|
if (a->GetDecoMesh(MDECOPART_SHOULDER2) != NULL)
|
|
{
|
|
a->GetDecoMesh(MDECOPART_SHOULDER2)->SetParentTransform(&m_matTransform, msg.pBoneMat);
|
|
}
|
|
|
|
msg.pBoneMat = NULL;
|
|
}
|
|
|
|
void KSeqAvatarEx::ChangeAnimationType(int nAniIndex, int nAniType)
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniIndex]->SetItemRenderFlag( nAniType );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::ClearMesh( int nAniIndex )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniIndex]->Clear();
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::ClearMesh()
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->ClearMesh();
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::ClearAnimation()
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->ClearAnimation();
|
|
}
|
|
}
|
|
|
|
bool KSeqAvatarEx::IsLoadCompleted() const
|
|
{
|
|
if( m_pAvatarPart[ANIPART_BIPED] )
|
|
return m_pAvatarPart[ANIPART_BIPED]->GetCurrentAnimation() ? true : false;
|
|
|
|
return false;
|
|
}
|
|
|
|
void *KSeqAvatarEx::Perform( int nAniIndex, int nMeshIndex, KID id, KArg& msg )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] )
|
|
return m_pAvatarPart[nAniIndex]->MeshPerform( nMeshIndex, id, msg );
|
|
else
|
|
return NULL;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void *KSeqAvatarEx::DecoPerform( int nAniIndex, int nMeshIndex, KID id, KArg& msg )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] )
|
|
return m_pAvatarPart[nAniIndex]->DecoMeshPerform( nMeshIndex, id, msg );
|
|
else
|
|
return NULL;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void *KSeqAvatarEx::Perform( int nAniIndex, KID id, KArg& msg )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] )
|
|
return m_pAvatarPart[nAniIndex]->Perform( id, msg );
|
|
else
|
|
return NULL;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void *KSeqAvatarEx::Perform( KID id, KArg& msg )
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->Perform( id, msg );
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
KSeqObject* KSeqAvatarEx::Clone()
|
|
{
|
|
KSeqAvatarEx *newobj = new KSeqAvatarEx( true );
|
|
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
newobj->m_pAvatarPart[i] = (KSeqAvatar*)m_pAvatarPart[i]->Clone();
|
|
}
|
|
|
|
return newobj;
|
|
}
|
|
|
|
DWORD KSeqAvatarEx::GetAniTime()
|
|
{
|
|
if( m_pAvatarPart[0] )
|
|
return m_pAvatarPart[0]->GetAniTime();
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
int KSeqAvatarEx::Process( DWORD dwTime )
|
|
{
|
|
int process_state = 0;
|
|
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if(i==ANIPART_BIPED)
|
|
process_state = m_pAvatarPart[0]->Process( dwTime );
|
|
else
|
|
m_pAvatarPart[i]->Process( dwTime );
|
|
}
|
|
|
|
return process_state;
|
|
}
|
|
|
|
void KSeqAvatarEx::Render( KViewportObject *viewport, DWORD flag, const K3DMatrix * pAttachMat )
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->Render( viewport, flag, pAttachMat );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::SetAniTime( DWORD dwTime ) //툴에서 쓰려고...
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->SetAniTime( dwTime );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::SetMeshRenderFlag( int nAniPartIndex, int nIndex, BOOL bRenderFlag )
|
|
{
|
|
if( nAniPartIndex >= ANIPART_BIPED && nAniPartIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniPartIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniPartIndex]->SetMeshRenderFlag( nIndex, bRenderFlag );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::SetDecoMeshRenderFlag( int nAniPartIndex, int nIndex, BOOL bRenderFlag )
|
|
{
|
|
if( nAniPartIndex >= ANIPART_BIPED && nAniPartIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniPartIndex] == NULL ) return;
|
|
|
|
m_pAvatarPart[nAniPartIndex]->SetDecoMeshRenderFlag( nIndex, bRenderFlag );
|
|
}
|
|
}
|
|
|
|
DWORD KSeqAvatarEx::GetLength( int nAniPartIndex )
|
|
{
|
|
if( nAniPartIndex >= ANIPART_BIPED && nAniPartIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniPartIndex] == NULL ) return 0;
|
|
|
|
return m_pAvatarPart[nAniPartIndex]->GetLength();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
float KSeqAvatarEx::GetHeadZ()
|
|
{
|
|
if( m_pAvatarPart[ANIPART_BIPED] )
|
|
return m_pAvatarPart[ANIPART_BIPED]->GetHeadZ();
|
|
|
|
return 0.f;
|
|
}
|
|
|
|
KSeqObject *KSeqAvatarEx::GetCurrentAnimation()
|
|
{
|
|
if( m_pAvatarPart[ANIPART_BIPED] )
|
|
return m_pAvatarPart[ANIPART_BIPED]->GetCurrentAnimation();
|
|
return NULL;
|
|
}
|
|
const char *KSeqAvatarEx::GetCurrentAnimationName()
|
|
{
|
|
if( m_pAvatarPart[ANIPART_BIPED] )
|
|
return m_pAvatarPart[ANIPART_BIPED]->GetCurrentAnimationName();
|
|
return "NoAinmation";
|
|
}
|
|
bool KSeqAvatarEx::IsPlaying()
|
|
{
|
|
if( m_pAvatarPart[ANIPART_BIPED] )
|
|
return m_pAvatarPart[ANIPART_BIPED]->IsPlaying();
|
|
return false;
|
|
}
|
|
|
|
void KSeqAvatarEx::SetTimeRate( float fTimeRate )
|
|
{
|
|
for( int i(0); ANIPART_MAX>i; i++ )
|
|
{
|
|
if( m_pAvatarPart[i] )
|
|
m_pAvatarPart[i]->SetTimeRate( fTimeRate );
|
|
}
|
|
}
|
|
|
|
void KSeqAvatarEx::GetFrameInfo( int nAniIndex, const char * strKey, int &nBoneCount, DWORD &dwMinTime, DWORD &dwMaxTime )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] )
|
|
m_pAvatarPart[nAniIndex]->GetFrameInfo( strKey, nBoneCount, dwMinTime, dwMaxTime );
|
|
}
|
|
}
|
|
|
|
KSeqAvatar *KSeqAvatarEx::getAvatarPart(int partNo)
|
|
{
|
|
assert( partNo>=ANIPART_BIPED && partNo<ANIPART_MAX);
|
|
return m_pAvatarPart[partNo];
|
|
}
|
|
|
|
bool KSeqAvatarEx::CheckPendingSeq()
|
|
{
|
|
return m_pAvatarPart[ANIPART_BIPED]->CheckPendingSeq();
|
|
}
|
|
|
|
|
|
// sfreer 임시코드임. 인벤토리 창에 나오는 아바타에서 방패 장착시 표시 안되는 버그을 위해 추가한 함수. 2009.03.09
|
|
bool KSeqAvatarEx::PlayAnimation_temp( int nAniIndex, DWORD dwCurTime, const char *name, int nAniType, float fPlayRate )
|
|
{
|
|
if( nAniIndex >= ANIPART_BIPED && nAniIndex < ANIPART_MAX )
|
|
{
|
|
if( m_pAvatarPart[nAniIndex] == NULL ) return false;
|
|
|
|
return m_pAvatarPart[nAniIndex]->PlayAnimation_temp( dwCurTime, name, nAniType, fPlayRate );
|
|
}
|
|
|
|
return false;
|
|
}
|