void CStudioPhysics::Load( MDLHandle_t mdlHandle ) { m_MDLHandle = mdlHandle; LoadPhysicsProperties(); vcollide_t *pVCollide = GetVCollide( ); if ( !pVCollide ) { m_pList = NULL; m_listCount = 0; return; } m_pList = new CPhysmesh[pVCollide->solidCount]; m_listCount = pVCollide->solidCount; int i; for ( i = 0; i < pVCollide->solidCount; i++ ) { m_pList[i].Clear(); m_pList[i].m_vertCount = physcollision->CreateDebugMesh( pVCollide->solids[i], &m_pList[i].m_pVerts ); m_pList[i].m_pCollisionModel = physcollision->CreateQueryModel( pVCollide->solids[i] ); } ParseKeydata(); CStudioHdr studioHdr( g_pMDLCache->GetStudioHdr( mdlHandle ), g_pMDLCache ); for ( i = 0; i < pVCollide->solidCount; i++ ) { CPhysmesh *pmesh = m_pList + i; int boneIndex = FindBoneIndex( &studioHdr, pmesh->m_boneName ); if ( boneIndex < 0 ) continue; if ( pmesh->m_constraint.parentIndex >= 0 ) { CPhysmesh *pparent = m_pList + pmesh->m_constraint.parentIndex; int parentIndex = FindBoneIndex( &studioHdr, pparent->m_boneName ); Studio_CalcBoneToBoneTransform( &studioHdr, boneIndex, parentIndex, pmesh->m_matrix ); } else { MatrixInvert( studioHdr.pBone(boneIndex)->poseToBone, pmesh->m_matrix ); } } // doesn't have a root bone? Make it the first bone if ( !m_edit.rootName[0] ) { strcpy( m_edit.rootName, m_pList[0].m_boneName ); } }
DWORD CActorInstance::AttachEffectByID(DWORD dwParentPartIndex, const char * c_pszBoneName, DWORD dwEffectID, const D3DXVECTOR3 * c_pv3Position) { TAttachingEffect ae; ae.iLifeType = EFFECT_LIFE_INFINITE; ae.dwEndTime = 0; ae.dwModelIndex = dwParentPartIndex; ae.dwEffectIndex = CEffectManager::Instance().GetEmptyIndex(); ae.isAttaching = TRUE; if (c_pv3Position) { D3DXMatrixTranslation(&ae.matTranslation, c_pv3Position->x, c_pv3Position->y, c_pv3Position->z); } else { D3DXMatrixIdentity(&ae.matTranslation); } CEffectManager& rkEftMgr=CEffectManager::Instance(); rkEftMgr.CreateEffectInstance(ae.dwEffectIndex, dwEffectID); if (c_pszBoneName) { int iBoneIndex; if (!FindBoneIndex(dwParentPartIndex,c_pszBoneName, &iBoneIndex)) { ae.iBoneIndex = -1; //Tracef("Cannot get Bone Index\n"); //assert(false && "Cannot get Bone Index"); } else { ae.iBoneIndex = iBoneIndex; } } else { ae.iBoneIndex = -1; } m_AttachingEffectList.push_back(ae); return ae.dwEffectIndex; }
void CActorInstance::RefreshActorInstance() { if (!m_pkCurRaceData) { TraceError("void CActorInstance::RefreshActorInstance() - m_pkCurRaceData=NULL"); return; } // This is Temporary place before making the weapon detection system // Setup Collison Detection Data m_BodyPointInstanceList.clear(); //m_AttackingPointInstanceList.clear(); m_DefendingPointInstanceList.clear(); // Base for (DWORD i = 0; i < m_pkCurRaceData->GetAttachingDataCount(); ++i) { const NRaceData::TAttachingData * c_pAttachingData; if (!m_pkCurRaceData->GetAttachingDataPointer(i, &c_pAttachingData)) continue; switch (c_pAttachingData->dwType) { case NRaceData::ATTACHING_DATA_TYPE_COLLISION_DATA: { const NRaceData::TCollisionData * c_pCollisionData = c_pAttachingData->pCollisionData; TCollisionPointInstance PointInstance; if (NRaceData::COLLISION_TYPE_ATTACKING == c_pCollisionData->iCollisionType) continue; if (!CreateCollisionInstancePiece(CRaceData::PART_MAIN, c_pAttachingData, &PointInstance)) continue; switch (c_pCollisionData->iCollisionType) { case NRaceData::COLLISION_TYPE_ATTACKING: //m_AttackingPointInstanceList.push_back(PointInstance); break; case NRaceData::COLLISION_TYPE_DEFENDING: m_DefendingPointInstanceList.push_back(PointInstance); break; case NRaceData::COLLISION_TYPE_BODY: m_BodyPointInstanceList.push_back(PointInstance); break; } } break; case NRaceData::ATTACHING_DATA_TYPE_EFFECT: // if (!m_bEffectInitialized) // { // DWORD dwCRC; // StringPath(c_pAttachingData->pEffectData->strFileName); // dwCRC = GetCaseCRC32(c_pAttachingData->pEffectData->strFileName.c_str(),c_pAttachingData->pEffectData->strFileName.length()); // // TAttachingEffect ae; // ae.iLifeType = EFFECT_LIFE_INFINITE; // ae.dwEndTime = 0; // ae.dwModelIndex = 0; // ae.dwEffectIndex = CEffectManager::Instance().GetEmptyIndex(); // ae.isAttaching = TRUE; // CEffectManager::Instance().CreateEffectInstance(ae.dwEffectIndex, dwCRC); // // if (c_pAttachingData->isAttaching) // { // int iBoneIndex; // if (!FindBoneIndex(0,c_pAttachingData->strAttachingBoneName.c_str(), &iBoneIndex)) // { // Tracef("Cannot get Bone Index\n"); // assert(false/*Cannot get Bone Index*/); // } // // ae.iBoneIndex = iBoneIndex; // } // else // { // ae.iBoneIndex = -1; // } // // m_AttachingEffectList.push_back(ae); // } if (c_pAttachingData->isAttaching) { AttachEffectByName(0, c_pAttachingData->strAttachingBoneName.c_str(), c_pAttachingData->pEffectData->strFileName.c_str()); } else { AttachEffectByName(0, 0, c_pAttachingData->pEffectData->strFileName.c_str()); } break; case NRaceData::ATTACHING_DATA_TYPE_OBJECT: break; default: assert(false/*NOT_IMPLEMENTED*/); break; } } for (DWORD j = 0; j < CRaceData::PART_MAX_NUM; ++j) { if (0 == m_adwPartItemID[j]) continue; CItemData * pItemData; if (!CItemManager::Instance().GetItemDataPointer(m_adwPartItemID[j], &pItemData)) return; for (DWORD k = 0; k < pItemData->GetAttachingDataCount(); ++k) { const NRaceData::TAttachingData * c_pAttachingData; if (!pItemData->GetAttachingDataPointer(k, &c_pAttachingData)) continue; switch(c_pAttachingData->dwType) { case NRaceData::ATTACHING_DATA_TYPE_COLLISION_DATA: { const NRaceData::TCollisionData * c_pCollisionData = c_pAttachingData->pCollisionData; // FIXME : 첫번째 인자는 Part의 번호다. // Base는 무조건 0인가? - [levites] TCollisionPointInstance PointInstance; if (NRaceData::COLLISION_TYPE_ATTACKING == c_pCollisionData->iCollisionType) continue; if (!CreateCollisionInstancePiece(j, c_pAttachingData, &PointInstance)) continue; switch (c_pCollisionData->iCollisionType) { case NRaceData::COLLISION_TYPE_ATTACKING: //m_AttackingPointInstanceList.push_back(PointInstance); break; case NRaceData::COLLISION_TYPE_DEFENDING: m_DefendingPointInstanceList.push_back(PointInstance); break; case NRaceData::COLLISION_TYPE_BODY: m_BodyPointInstanceList.push_back(PointInstance); break; } } break; case NRaceData::ATTACHING_DATA_TYPE_EFFECT: if (!m_bEffectInitialized) { DWORD dwCRC; StringPath(c_pAttachingData->pEffectData->strFileName); dwCRC = GetCaseCRC32(c_pAttachingData->pEffectData->strFileName.c_str(),c_pAttachingData->pEffectData->strFileName.length()); TAttachingEffect ae; ae.iLifeType = EFFECT_LIFE_INFINITE; ae.dwEndTime = 0; ae.dwModelIndex = j; ae.dwEffectIndex = CEffectManager::Instance().GetEmptyIndex(); ae.isAttaching = TRUE; CEffectManager::Instance().CreateEffectInstance(ae.dwEffectIndex, dwCRC); int iBoneIndex; if (!FindBoneIndex(j,c_pAttachingData->strAttachingBoneName.c_str(), &iBoneIndex)) { Tracef("Cannot get Bone Index\n"); assert(false/*Cannot get Bone Index*/); } Tracef("Creating %p %d %d\n", this, j,k); ae.iBoneIndex = iBoneIndex; m_AttachingEffectList.push_back(ae); } break; case NRaceData::ATTACHING_DATA_TYPE_OBJECT: break; default: assert(false/*NOT_IMPLEMENTED*/); break; } } } m_bEffectInitialized = true; }