void FBXSceneInstance::InitInstance() { // Bounding Box m_BoundingBox = mScene->m_BoundingBox; // Models for(unsigned int i = 0; i < mScene->GetModelCount(); i++) { Model* srcModel = mScene->GetModel(i); m_Models.Add(srcModel->GetName(), new Model(srcModel)); } // Copy Skeleton if ( mScene->GetSkeleton() ) { Skeleton* newSkeleton = new Skeleton(); for( unsigned int x = 0; x < mScene->GetSkeleton()->GetBoneCount(); ++x ) { SkeletonBone* sourceBone = mScene->GetSkeleton()->GetSkeletonBone(x); SkeletonBone* targetBone = new SkeletonBone( sourceBone->GetName(), sourceBone->GetParentBoneIndex(), newSkeleton); newSkeleton->AddSkeletonBone( targetBone ); } newSkeleton->BuildBoneHierarchy(); for( unsigned int x = 0; x < newSkeleton->GetBoneCount(); ++x ) { SkeletonBone* sourceBone = mScene->GetSkeleton()->GetSkeletonBone(x); SkeletonBone* targetBone = newSkeleton->GetSkeletonBone(x); targetBone->SetBindPoseTransform2(sourceBone->GetBindPoseTransform2()); targetBone->SetBoneReferenceTransform2(sourceBone->GetBoneReferenceTransform2()); targetBone->m_AnimationKeyFrames = sourceBone->m_AnimationKeyFrames; targetBone->SetBoundingBoxData(sourceBone->m_AABB); } // Update My Skeleton m_pSkeleton = newSkeleton; // Update My Animation m_pAnimationController = new AnimationController(mScene->m_pAnimationController); } // Curves m_Curves = &mScene->m_Curves; }
void FBXScene::ProcessSkeleton(FbxNode* pNode) { FbxSkeleton* pFBXSkeleton = pNode->GetSkeleton(); if( !pFBXSkeleton ) return; if( !m_pSkeleton ) { m_pSkeleton = new Skeleton(); } int nParentBoneIndex = -1; FbxNode* pParentNode = pNode->GetParent(); if( pParentNode ) nParentBoneIndex = m_pSkeleton->FindBoneIndex(pParentNode->GetName()); SkeletonBone* pSkeletonBone = new SkeletonBone( pNode->GetName(), nParentBoneIndex, m_pSkeleton ); m_pSkeleton->AddSkeletonBone(pSkeletonBone); int boneIndex = m_pSkeleton->FindBoneIndex(pNode->GetName()); pSkeletonBone->SetBoneIndex(boneIndex); printf("BONE: %s\n", pSkeletonBone->GetName()); }