#include "stdafx.h" #include "krenderobjectBone.h" #include "krenderobjectMesh.h" #include "K3DCamera.h" #include "KRenderDeviceDX.h" #include "KDeviceManager.h" //#include "K3DFrustum.h" #include "GameDefine.h" #include "KResource.h" #include "KViewport.h" //아이템, 이펙트 링크시크는 위치 char * pAttachName[ATTACH_MAX] = { "Head", //0 "Bip01 L Hand", //"HandL", //1 "Bip01 R Hand", //"HandR", //2 "Bip01 L Forearm", //"Arm2L", //3 "Bip01 R Forearm", //"Arm2R", //4 "Bip01 L Forearm", //"Arm2L", //5 deco "Bip01 R Forearm", //"Arm2R", //6 deco "Body2", //7 "Saddle", //EFFECT_POS_SADDLE, //8 "Back", //"Back" 9 "Bip01 L Hand_weapon", //Left Hand //10 "Bip01 R Hand_weapon", //Right Hand //11 "Bip01 L Hand_weaponL01", //Left Hand //12 Weapon Effect "Bip01 R Hand_weaponR01", //Right Hand //13 Weapon Effect "Bip01 L Hand_weaponL01", //Left Hand //13 Weapon Effect "Bip01 R Hand_weaponR01", //Right Hand //14 Weapon Effect }; char * pEffectPosBody = "Bip01 Body1"; //이펙트 링크시키는 위치 char * pEffectPosName[] = { "Bip01 Head", //EFFECT_POS_TOP, "Bip01 Spine1", //EFFECT_POS_MIDDLE, "Bip01 Body1", //EFFECT_POS_DAMAGE, "Bip01 Body1", //EFFECT_POS_ETC, "saddle", //EFFECT_POS_SADDLE, "Bip01 L Hand_weaponL01", //EFFECT_POS_W_LEFT "Bip01 R Hand_weaponR01", //EFFECT_POS_W_RIGHT "Bip01 R Hand_weaponR01", //EFFECT_POS_W_TWOHAND }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // KBoneSeqObject Implement //////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool KBoneSeqObject::m_bIsBoneDraw = false; bool KBoneSeqObject::m_bIsAxisDraw = false; KBoneSeqObject::KBoneSeqObject() { K3DMatrixIdentity( m_matLocal ); K3DMatrixIdentity( m_matResult ); m_pBoneCacheTM = NULL; m_bValidPrevBoneCache = false; m_pBoneCacheAniData = NULL; m_pPrevBoneCacheAniData = NULL; m_pMatHead = NULL; m_pMatNeck = NULL; m_pMatBody1 = NULL; m_pMatBody2 = NULL; m_pMatPelvis = NULL; m_pMatLeftHand = NULL; m_pMatRightHand = NULL; m_pMatLeftFoot = NULL; m_pMatRightFoot = NULL; m_pMatLeftFist = NULL; m_pMatRightFist = NULL; } KBoneSeqObject::~KBoneSeqObject() { SAFE_DELETE_ARRAY(m_pBoneCacheTM); SAFE_DELETE_ARRAY(m_pBoneCacheAniData ); SAFE_DELETE_ARRAY(m_pPrevBoneCacheAniData); } void KBoneSeqObject::SetDeform( KSeqObject * pMeshSeq ) { realizeTime(); _CID( SETDEFORM_BONE ); KMsgSET_DEFORM defmsg( m_nBoneCnt, m_pBoneCacheTM ); defmsg.pBoneSeq = this; pMeshSeq->Perform( id_SETDEFORM_BONE, defmsg ); //아래와 같은 경우는, 헤어 같은 다른 본에붙는 Mesh 들이다.. if( m_pMatParent && m_pMatAttach ) { pMeshSeq->SetParentTransform( m_pMatParent, m_pMatAttach ); } } void KBoneSeqObject::SetAttach( int nAttachIndex, KSeqObject * pMeshSeq ) { if( nAttachIndex < 0 || nAttachIndex > ATTACH_MAX ) { assert(0); return; } int index = -1; GetBone(pAttachName[nAttachIndex], index); if( index >= 0 ) pMeshSeq->SetParentTransform( pMeshSeq->GetParentTransform(), &m_pBoneCacheTM[index] ); else {//MAX, XSI 본이 틀려 예외 추가 //2009-02-17: hunee //이펙트 버그 수정, weapon1일때만 적용 됨 ㅠㅠ //weapon2일때도 적용되게 수정 if( nAttachIndex == ATTACH_HAND_LEFT_WEAPON01 || nAttachIndex == ATTACH_HAND_LEFT_WEAPON02) { GetBone(pAttachName[ATTACH_HAND_LEFT_WEAPON], index); if( index >= 0 ) pMeshSeq->SetParentTransform( pMeshSeq->GetParentTransform(), &m_pBoneCacheTM[index] ); } else if( nAttachIndex == ATTACH_HAND_RIGHT_WEAPON01 || nAttachIndex == ATTACH_HAND_RIGHT_WEAPON02) { GetBone(pAttachName[ATTACH_HAND_RIGHT_WEAPON], index); if( index >= 0 ) pMeshSeq->SetParentTransform( pMeshSeq->GetParentTransform(), &m_pBoneCacheTM[index] ); } } } void KBoneSeqObject::SetAttachEffectPos( int nEffectPosIndex, KSeqObject * pMeshSeq ) { int index = -1; if( strcmp(pEffectPosName[nEffectPosIndex], "Bip01 L Hand" ) == 0 ) int x = 0; GetBone(pEffectPosName[nEffectPosIndex], index); if( index == 5 || index == 6) int x = 0; if( index == -1 && ( nEffectPosIndex == EFFECT_POS_MIDDLE ) ) { //Spine1 이 없으면 Body1 도 한번 더 검색 : 몬스터에 없을 경우가 있다. GetBone(pEffectPosBody, index); } if( index == -1 && ( nEffectPosIndex == EFFECT_POS_TOP ) ) { GetBone(pAttachName[ATTACH_HEAD], index); } if( index == -1 && ( nEffectPosIndex == EFFECT_POS_DAMAGE || nEffectPosIndex == EFFECT_POS_MIDDLE ) ) { GetBone(pAttachName[ATTACH_BODY], index); } if( index == -1 && ( nEffectPosIndex == EFFECT_POS_SADDLE ) ) { GetBone(pAttachName[ATTACH_SADDLE], index); } if( index == -1 && ( nEffectPosIndex == EFFECT_POS_W_LEFT ) ) { GetBone(pAttachName[ATTACH_HAND_LEFT], index ); if( index == -1 ) GetBone(pAttachName[ATTACH_HAND_LEFT_WEAPON], index ); } if( index == -1 && ( nEffectPosIndex == EFFECT_POS_W_RIGHT ) ) { GetBone(pAttachName[ATTACH_HAND_RIGHT], index ); if( index == -1 ) GetBone(pAttachName[ATTACH_HAND_RIGHT_WEAPON], index ); } if( index == -1 && ( nEffectPosIndex == EFFECT_POS_W_TWOHAND ) ) { GetBone(pAttachName[ATTACH_HAND_RIGHT], index ); if( index == -1 ) GetBone(pAttachName[ATTACH_HAND_RIGHT_WEAPON], index ); } if( index >= 0 ) { pMeshSeq->SetParentTransform( pMeshSeq->GetParentTransform(), &m_pBoneCacheTM[index], TRUE ); } else{ // assert(0); // _oprint( "SetAttachEffectPos : 이름 못 찾음 %s, %d\n", pEffectPosName[nEffectPosIndex], nEffectPosIndex ); } } void KBoneSeqObject::SetAttachEffectBone( int nBoneIndex, KSeqObject * pMeshSeq ) { if( nBoneIndex >= 0 && nBoneIndex < GetBoneCount() ) pMeshSeq->SetParentTransform( pMeshSeq->GetParentTransform(), &m_pBoneCacheTM[nBoneIndex] ); } void KBoneSeqObject::Reset() { KSeqObject::Reset(); m_bValidPrevBoneCache = false; m_dwTime = 0; } void KBoneSeqObject::SetRes( K3DBoneResource *bone ) { assert( m_spResBone == NULL ); m_spResBone = bone; if( m_spResBone == NULL ) return; if( m_spResBone->GetVersion() == ( DWORD ) ( ( 1 << 16 ) | 0 ) ) SetRes10( bone ); else if( m_spResBone->GetVersion() == ( DWORD ) ( ( 1 << 16 ) | 1 ) ) SetRes11( bone ); else assert( 0 ); } K3DMatrix * const KBoneSeqObject::GetBoneMatrixByName(char *boneName) { int nIndex=-1; m_spResBone->GetBone( boneName, nIndex ); if( nIndex != -1 ) return &m_pBoneCacheTM[nIndex]; return NULL; } const char * KBoneSeqObject::GetResourceName() { if( m_spResBone ) return m_spResBone->GetName(); return "EmptyBoneResource"; } void KBoneSeqObject::SetRes10( K3DBoneResource* bone ) { m_interval.Expand( m_spResBone->GetInterval() ); m_nBoneCnt = m_spResBone->GetBoneCount(); m_pBoneCacheTM = new K3DMatrix[m_nBoneCnt]; memset( m_pBoneCacheTM, 0, sizeof(K3DMatrix)*m_nBoneCnt ); m_pBoneCacheAniData = new BONE_ANI_DATA[m_nBoneCnt]; m_pPrevBoneCacheAniData = new BONE_ANI_DATA[m_nBoneCnt]; m_dwPrevBoneCacheTime=0; for( int i(0); m_nBoneCnt>i; i++ ) { K3DMatrixIdentity( m_pBoneCacheTM[i] ); m_pBoneCacheAniData[i].pos = K3DVector(0,0,0); m_pBoneCacheAniData[i].quat = K3DQuaternion(0,0,0,1); m_pPrevBoneCacheAniData[i].pos = K3DVector(0,0,0); m_pPrevBoneCacheAniData[i].quat = K3DQuaternion(0,0,0,1); } //캐쉬 Matrix 등록 int nIndex = -1; m_spResBone->GetBone( "Head", nIndex ); if( nIndex != -1 ) m_pMatHead = &m_pBoneCacheTM[nIndex]; if( !m_pMatHead ) { m_spResBone->GetBone( "Bip01 Head", nIndex ); if( nIndex != -1 ) m_pMatHead = &m_pBoneCacheTM[nIndex]; } m_spResBone->GetBone( "Neck", nIndex ); if( nIndex != -1 ) m_pMatNeck = &m_pBoneCacheTM[nIndex]; if( !m_pMatNeck ) { m_spResBone->GetBone( "Bip01 Neck", nIndex ); if( nIndex != -1 ) m_pMatNeck = &m_pBoneCacheTM[nIndex]; } m_spResBone->GetBone( "Body1", nIndex ); if( nIndex != -1 ) m_pMatBody1 = &m_pBoneCacheTM[nIndex]; if( !m_pMatBody1 ) { m_spResBone->GetBone( "Bip01 Body1", nIndex ); if( nIndex != -1 ) m_pMatBody1 = &m_pBoneCacheTM[nIndex]; } if( !m_pMatBody1 ) m_pMatBody1 = m_pMatNeck; m_spResBone->GetBone( "Body2", nIndex ); if( nIndex != -1 ) m_pMatBody2 = &m_pBoneCacheTM[nIndex]; if( !m_pMatBody2 ) { m_spResBone->GetBone( "Bip01 Body2", nIndex ); if( nIndex != -1 ) m_pMatBody2 = &m_pBoneCacheTM[nIndex]; if( !m_pMatBody2 ) { m_spResBone->GetBone( "Bip02", nIndex ); if( nIndex != -1 ) m_pMatBody2 = &m_pBoneCacheTM[nIndex]; } } if( !m_pMatBody2 ) m_pMatBody2 = m_pMatNeck; //Pelvis m_spResBone->GetBone( "@HideBip01", nIndex ); if( nIndex != -1 ) m_pMatPelvis = &m_pBoneCacheTM[nIndex]; if( !m_pMatPelvis ) { m_spResBone->GetBone( "Pelvis", nIndex ); if( nIndex != -1 ) m_pMatPelvis = &m_pBoneCacheTM[nIndex]; } if( !m_pMatPelvis ) { m_spResBone->GetBone( "Bip01 Pelvis", nIndex ); if( nIndex != -1 ) m_pMatPelvis = &m_pBoneCacheTM[nIndex]; } if( !m_pMatLeftHand ) { m_spResBone->GetBone( "Bip01 L Forearm", nIndex ); if( nIndex != -1 ) m_pMatLeftHand = &m_pBoneCacheTM[nIndex]; } if( !m_pMatRightHand ) { m_spResBone->GetBone( "Bip01 R Forearm", nIndex ); if( nIndex != -1 ) m_pMatRightHand = &m_pBoneCacheTM[nIndex]; } m_spResBone->GetBone( "FootL", nIndex ); if( nIndex != -1 ) m_pMatLeftFoot = &m_pBoneCacheTM[nIndex]; m_spResBone->GetBone( "FootR", nIndex ); if( nIndex != -1 ) m_pMatRightFoot = &m_pBoneCacheTM[nIndex]; m_spResBone->GetBone( "Bip01 L Hand", nIndex ); if( nIndex != -1 ) m_pMatLeftFist = &m_pBoneCacheTM[nIndex]; m_spResBone->GetBone( "Bip01 R Hand", nIndex ); if( nIndex != -1 ) m_pMatRightFist = &m_pBoneCacheTM[nIndex]; } void KBoneSeqObject::SetRes11( K3DBoneResource* bone ) { m_interval.Expand( m_spResBone->GetInterval() ); m_nBoneCnt = m_spResBone->GetBoneCount(); m_pBoneCacheTM = new K3DMatrix[m_nBoneCnt]; memset( m_pBoneCacheTM, 0, sizeof(K3DMatrix)*m_nBoneCnt ); m_pBoneCacheAniData = new BONE_ANI_DATA[m_nBoneCnt]; m_pPrevBoneCacheAniData = new BONE_ANI_DATA[m_nBoneCnt]; for( int i(0); m_nBoneCnt>i; i++ ) { K3DMatrixIdentity( m_pBoneCacheTM[i] ); m_pBoneCacheAniData[i].pos = K3DVector(0,0,0); m_pBoneCacheAniData[i].quat = K3DQuaternion(0,0,0,1); m_pPrevBoneCacheAniData[i].pos = K3DVector(0,0,0); m_pPrevBoneCacheAniData[i].quat = K3DQuaternion(0,0,0,1); } //캐쉬 Matrix 등록 int nIndex = -1; m_spResBone->GetBone( "Head", nIndex ); if( nIndex != -1 ) m_pMatHead = &m_pBoneCacheTM[nIndex]; if( !m_pMatHead ) { m_spResBone->GetBone( "Bip01 Head", nIndex ); if( nIndex != -1 ) m_pMatHead = &m_pBoneCacheTM[nIndex]; } m_spResBone->GetBone( "Neck", nIndex ); if( nIndex != -1 ) m_pMatNeck = &m_pBoneCacheTM[nIndex]; if( !m_pMatNeck ) { m_spResBone->GetBone( "Bip01 Neck", nIndex ); if( nIndex != -1 ) m_pMatNeck = &m_pBoneCacheTM[nIndex]; } m_spResBone->GetBone( "Body1", nIndex ); if( nIndex != -1 ) m_pMatBody1 = &m_pBoneCacheTM[nIndex]; if( !m_pMatBody1 ) { m_spResBone->GetBone( "Bip01 Body1", nIndex ); if( nIndex != -1 ) m_pMatBody1 = &m_pBoneCacheTM[nIndex]; } if( !m_pMatBody1) m_pMatBody1 = m_pMatNeck; m_spResBone->GetBone( "Body2", nIndex ); if( nIndex != -1 ) m_pMatBody2 = &m_pBoneCacheTM[nIndex]; if( !m_pMatBody2 ) { m_spResBone->GetBone( "Bip01 Body2", nIndex ); if( nIndex != -1 ) m_pMatBody2 = &m_pBoneCacheTM[nIndex]; if( !m_pMatBody2 ) { m_spResBone->GetBone( "Bip02", nIndex ); if( nIndex != -1 ) m_pMatBody2 = &m_pBoneCacheTM[nIndex]; } } if( !m_pMatBody2 ) m_pMatBody2 = m_pMatNeck; //Pelvis m_spResBone->GetBone( "@HideBip01", nIndex ); if( nIndex != -1 ) m_pMatPelvis = &m_pBoneCacheTM[nIndex]; if( !m_pMatPelvis ) { m_spResBone->GetBone( "Pelvis", nIndex ); if( nIndex != -1 ) m_pMatPelvis = &m_pBoneCacheTM[nIndex]; } if( !m_pMatPelvis ) { m_spResBone->GetBone( "Bip01 Pelvis", nIndex ); if( nIndex != -1 ) m_pMatPelvis = &m_pBoneCacheTM[nIndex]; } m_spResBone->GetBone( "Bip01_L_Hand", nIndex ); if( nIndex != -1 ) m_pMatLeftHand = &m_pBoneCacheTM[nIndex]; m_spResBone->GetBone( "Bip01_R_Hand", nIndex ); if( nIndex != -1 ) m_pMatRightHand = &m_pBoneCacheTM[nIndex]; m_spResBone->GetBone( "FootL", nIndex ); if( nIndex != -1 ) m_pMatLeftFoot = &m_pBoneCacheTM[nIndex]; m_spResBone->GetBone( "FootR", nIndex ); if( nIndex != -1 ) m_pMatRightFoot = &m_pBoneCacheTM[nIndex]; m_spResBone->GetBone( "Bip01 L Hand", nIndex ); if( nIndex != -1 ) m_pMatLeftFist = &m_pBoneCacheTM[nIndex]; m_spResBone->GetBone( "Bip01 R Hand", nIndex ); if( nIndex != -1 ) m_pMatRightFist = &m_pBoneCacheTM[nIndex]; } void KBoneSeqObject::Render( KViewportObject *viewport, DWORD flag, const K3DMatrix * pAttachMat ) { //- 작업중. realizeTime(); if( m_bIsBoneDraw ) viewport->RegisterWire( &m_prWire ); if( m_bIsAxisDraw ) viewport->RegisterWire( &m_prAxisWire ); } KSeqObject* KBoneSeqObject::Clone() { KBoneSeqObject *obj = new KBoneSeqObject; obj->SetRes( m_spResBone ); return obj; } K3DMatrix * KBoneSeqObject::GetBoneBaseTM() { if( m_spResBone != NULL ) return m_spResBone->GetBoneBaseTM(); else return NULL; } int KBoneSeqObject::GetBoneCount() { if( m_spResBone != NULL ) return m_spResBone->GetBoneCount(); else return 0; } void KBoneSeqObject::realizeTime() { if( m_spResBone == NULL) return; if ( m_dwRealizedTime != m_dwTime ) { if( m_bValidPrevBoneCache ) { float weight = (m_dwTime < 800) ? m_dwTime/800.f : 1.f; if(weight >= 1.f) m_bValidPrevBoneCache = false; if( m_bValidPrevBoneCache ) m_spResBone->CalcBoneTransforms( m_dwTime, m_pBoneCacheTM, m_pBoneCacheAniData, m_pPrevBoneCacheAniData, weight ); } else { m_spResBone->CalcBoneTransforms( m_dwTime, m_pBoneCacheTM, m_pBoneCacheAniData ); } } m_dwRealizedTime = m_dwTime; if( !m_bIsBoneDraw && !m_bIsAxisDraw ) return; if ( m_pMatAttach != NULL && m_pMatParent != NULL ) { K3DMatrix matTemp; K3DMatrixMultiply( matTemp, *m_pMatAttach, *m_pMatParent ); K3DMatrixMultiply( m_matResult, m_matLocal, matTemp ); } else if ( m_pMatParent != NULL ) K3DMatrixMultiply( m_matResult, m_matLocal, *m_pMatParent ); else m_matResult = m_matLocal; m_prWire.SetTransform( m_matResult ); m_prAxisWire.SetTransform( m_matResult ); // //View Vecotor 등 적용. // int nIndex; // K3DBone * pHeadBone = m_spResBone->GetBone("Head", nIndex); // if(pHeadBone) // { //// pHeadBone->SetViewVectorX( 180.f ); // } K3DMatrix * pBoneMatrix = m_pBoneCacheTM; m_prAxisWire.Clear(); m_prWire.Clear(); int n(0); for( int i(0); m_spResBone->GetBoneCount()>i; i++ ) { K3DBone * pBone = m_spResBone->GetBone(i); K3DBone * pBoneParent = pBone->GetParentBone(); if( m_bIsBoneDraw ) { if(pBoneParent) { K3DMatrix Mat1 = pBoneMatrix[pBone->GetIndex()]; K3DMatrix Mat2 = pBoneMatrix[pBoneParent->GetIndex()]; m_prWire.AddLine( Mat1.GetPosVector(), Mat2.GetPosVector(), KColor( 255, 255, 255, 255 ) ); } else { K3DMatrix Mat1 = pBoneMatrix[pBone->GetIndex()]; m_prWire.AddLine( Mat1.GetPosVector(), Mat1.GetPosVector(), KColor( 255, 255, 255, 255 ) ); } } //Bone 좌표 if( m_bIsAxisDraw ) { K3DMatrix Mat1 = pBoneMatrix[pBone->GetIndex()]; K3DVector vVectorX, vVectorY, vVectorZ; AxisCalculation( Mat1, vVectorX, vVectorY, vVectorZ ); m_prAxisWire.AddLine( Mat1.GetPosVector(), vVectorX, KColor(255,0,0,255) ); m_prAxisWire.AddLine( Mat1.GetPosVector(), vVectorY, KColor(0,255,0,255) ); m_prAxisWire.AddLine( Mat1.GetPosVector(), vVectorZ, KColor(0,0,255,255) ); } } } float KBoneSeqObject::GetHeadZ() { return m_spResBone->GetHeadZ(); } void KBoneSeqObject::GetHandLeft( K3DVector & pos ) { m_spResBone->GetHandLeft( pos ); } void KBoneSeqObject::GetHandRight( K3DVector & pos ) { m_spResBone->GetHandRight( pos ); } //좌우 void KBoneSeqObject::SetViewVectorX( float x, float y, float z ) { m_ViewVectorX = K3DVector( x, y, 0.f ); } //상하 void KBoneSeqObject::SetViewVectorZ( float x, float y, float z ) { m_ViewVectorZ = K3DVector( x, 0.f, z ); } //몸통 void KBoneSeqObject::SetBodyVector( float x, float y ) { m_BodyVector = K3DVector( x, y, 0.f ); } void *KBoneSeqObject::Perform( KID id, KArg& msg ) { _CID( GETBONEINFO ); _CID( GETBONEMATRIX ); _CID( GETBONEMATRIX2 ); _CID( GETBONEMATRIX3 ); _CID( GETCACHETM ); _CID( SETCACHETM ); _CID( GETVERSION ); _CID( GETBONENAMELIST ); if( id == id_GETBONEINFO ) { KMsgGET_BONEINFO *boneinfo = static_cast(&msg); boneinfo->nBoneCount = GetBoneCount(); boneinfo->dwMinTime = GetInterval().GetStart(); boneinfo->dwMaxTime = GetInterval().GetEnd(); return (void*)1; } else if( id == id_GETBONENAMELIST ) { KMsgGET_BONENAMELIST *bonenamelist = static_cast(&msg); if( m_spResBone ) { for( int i(0); GetBoneCount()>i; i++ ) { K3DBone* pBone = m_spResBone->GetBone(i); if( pBone ) { bonenamelist->vBoneNameList.push_back( pBone->GetName() ); bonenamelist->vBoneMatrixList.push_back( &m_pBoneCacheTM[i] ); } } } return (void*)1; } else if( id == id_GETBONEMATRIX ) { KMsgGET_BONEMATRIX *boneMat = static_cast(&msg); m_spResBone->GetBone( boneMat->strBoneName, boneMat->nBoneMatIndex ); if( boneMat->nBoneMatIndex != -1 ) { boneMat->pBoneMat = &m_pBoneCacheTM[boneMat->nBoneMatIndex]; } } else if( id == id_GETBONEMATRIX2) { KMsgGET_BONEMATRIX2 *boneMat = static_cast(&msg); boneMat->pBoneMat = GetBoneMatrix( boneMat->nDetailIndex ); } else if( id == id_GETBONEMATRIX3) { KMsgGET_BONEMATRIX3*boneMat = static_cast(&msg); if( boneMat->nBoneIndex >= 0 && boneMat->nBoneIndex < GetBoneCount() ) { boneMat->pBoneMat = &m_pBoneCacheTM[boneMat->nBoneIndex]; } } //else if( id == id_SETBONEINIT ) //{ //} else if( id == id_GETCACHETM ) { KMsgGET_GETCACHETM *cacheTM = static_cast(&msg); if( m_pBoneCacheTM ) { if( m_dwTime != 0 ) { //적용된 본 만 사용 가능 cacheTM->pCacheAniData = m_pBoneCacheAniData; cacheTM->nCount = m_nBoneCnt; } } } else if( id == id_SETCACHETM ) { KMsgGET_GETCACHETM *cacheTM = static_cast(&msg); if( cacheTM->bUseBlend == false || cacheTM->pCacheAniData == NULL ) { m_bValidPrevBoneCache = false; return NULL; } if( m_pBoneCacheTM && cacheTM->pCacheAniData && m_nBoneCnt == cacheTM->nCount ) { for( int i(0); m_nBoneCnt>i; i++ ) { m_pPrevBoneCacheAniData[i] = cacheTM->pCacheAniData[i]; } m_dwPrevBoneCacheTime=m_dwRealizedTime; m_bValidPrevBoneCache = true; } } else if( id == id_GETVERSION ) { KMsgGET_GETVERSION* pMsgVersion = static_cast< KMsgGET_GETVERSION* >( &msg ); if( pMsgVersion->dwVersion == ( DWORD ) -1 ) { if( m_spResBone != NULL ) pMsgVersion->dwVersion = m_spResBone->GetVersion(); } } return NULL; } K3DMatrix * KBoneSeqObject::GetBoneMatrix( int nDetail ) { switch(nDetail) { case DETAIL_HEAD : return m_pMatHead; case DETAIL_NECK : return m_pMatNeck; case DETAIL_BODY2 : return m_pMatBody2; case DETAIL_BODY1 : return m_pMatBody1; case DETAIL_PELVIS : return m_pMatPelvis; case DETAIL_LEFT_HAND : return m_pMatLeftHand; case DETAIL_RIGHT_HAND : return m_pMatRightHand; case DETAIL_LEFT_FIST : return m_pMatLeftFist; case DETAIL_RIGHT_FIST : return m_pMatRightFist; } return NULL; }