//*************************************************************************************** // WORLD TRANSFORM MATRIX //*************************************************************************************** //Recursive function which multiplies by all of its children cml::matrix44f_c TransformComponent::GetWorldTransformMatrix() const { if (m_pParent) return m_pParent->GetWorldTransformMatrix() * GetTransformMatrix(); else return GetTransformMatrix(); }
void cGridMesh::Draw() { // Set Layout And Topology g_pD3DDC->IASetInputLayout(cInputLayouts::Simple); g_pD3DDC->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); // Set VertexBuffer And IndexBuffer UINT stride = sizeof(Vertex::Simple); UINT offset = 0; g_pD3DDC->IASetVertexBuffers(0, 1, &m_VB, &stride, &offset); g_pD3DDC->IASetIndexBuffer(m_IB, DXGI_FORMAT_R32_UINT, 0); // worldViewProj Çà·ÄÀ» ±¸ÇÑ´Ù. XMMATRIX world = XMLoadFloat4x4(&GetTransformMatrix()); XMMATRIX view = g_pCameraManager->GetView(); XMMATRIX proj = g_pCameraManager->GetProj(); XMMATRIX worldViewProj = world * view * proj; // ¼ÎÀÌ´õ¿¡ »ó¼ö°ª ¼³Á¤. cEffects::SimpleFX->SetWorldViewProj(worldViewProj); ID3DX11EffectTechnique* tech = cEffects::SimpleFX->ColorTech; D3DX11_TECHNIQUE_DESC techDesc; tech->GetDesc(&techDesc); for (UINT p = 0; p < techDesc.Passes; ++p) { tech->GetPassByIndex(p)->Apply(0, g_pD3DDC); // »öÀÎÀ» »ç¿ëÇؼ ±×¸°´Ù. g_pD3DDC->DrawIndexed(m_GridIndexCount, 0, 0); } HR(g_pD3DSC->Present(0, 0)); }
void GrGLNormalPathProcessor::setTransformData( const GrPrimitiveProcessor& primProc, int index, const SkTArray<const GrCoordTransform*, true>& coordTransforms, GrGLPathRendering* glpr, GrGLuint programID) { SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index]; int numTransforms = transforms.count(); for (int t = 0; t < numTransforms; ++t) { SkASSERT(transforms[t].fHandle.isValid()); const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix(), *coordTransforms[t]); if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { continue; } transforms[t].fCurrentValue = transform; const SeparableVaryingInfo& fragmentInput = fSeparableVaryingInfos[transforms[t].fHandle.handle()]; SkASSERT(transforms[t].fType == kVec2f_GrSLType || transforms[t].fType == kVec3f_GrSLType); unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3; glpr->setProgramPathFragmentInputTransform(programID, fragmentInput.fLocation, GR_GL_OBJECT_LINEAR, components, transform); } }
void CLocalSpaceEmitter::RenderParticles( CParticleRenderIterator *pIterator ) { const matrix3x4_t &mLocalToWorld = GetTransformMatrix(); const VMatrix &mModelView = ParticleMgr()->GetModelView(); const SimpleParticle *pParticle = (const SimpleParticle *)pIterator->GetFirst(); while ( pParticle ) { // Transform it Vector screenPos, worldPos; VectorTransform( pParticle->m_Pos, mLocalToWorld, worldPos ); // Correct viewmodel squashing if ( m_fFlags & FLE_VIEWMODEL ) { FormatViewModelAttachment( NULL, worldPos, false ); } TransformParticle( mModelView, worldPos, screenPos ); float sortKey = (int) screenPos.z; // Render it RenderParticle_ColorSizeAngle( pIterator->GetParticleDraw(), screenPos, UpdateColor( pParticle ), UpdateAlpha( pParticle ) * GetAlphaDistanceFade( screenPos, m_flNearClipMin, m_flNearClipMax ), UpdateScale( pParticle ), pParticle->m_flRoll ); pParticle = (const SimpleParticle *)pIterator->GetNext( sortKey ); } }
void CTransportUnit::Update() { CUnit::Update(); if (isDead) { return; } for (std::list<TransportedUnit>::iterator ti = transportedUnits.begin(); ti != transportedUnits.end(); ++ti) { CUnit* transportee = ti->unit; float3 relPiecePos; float3 absPiecePos; if (ti->piece >= 0) { relPiecePos = script->GetPiecePos(ti->piece); } else { relPiecePos = float3(0.0f, -1000.0f, 0.0f); } absPiecePos = pos + (frontdir * relPiecePos.z) + (updir * relPiecePos.y) + (rightdir * relPiecePos.x); transportee->mapSquare = mapSquare; if (unitDef->holdSteady) { // slave transportee orientation to piece if (ti->piece >= 0) { const CMatrix44f& transMat = GetTransformMatrix(true); const CMatrix44f& pieceMat = script->GetPieceMatrix(ti->piece); const CMatrix44f slaveMat = pieceMat * transMat; transportee->SetDirVectors(slaveMat); } } else { // slave transportee orientation to body transportee->heading = heading; transportee->updir = updir; transportee->frontdir = frontdir; transportee->rightdir = rightdir; } transportee->Move3D(absPiecePos, false); transportee->UpdateMidAndAimPos(); transportee->SetHeadingFromDirection(); // see ::AttachUnit if (transportee->stunned) { qf->MovedUnit(transportee); } } }
void cNTeapot::Render() { D3DXMATRIXA16 matR, matT; matT = *GetTransformMatrix(); D3DXMatrixRotationY(&matR, m_fAngle); D3DXMATRIXA16 matWorld = matR * matT; g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld); g_pD3DDevice->SetMaterial(&m_stMtl); g_pD3DDevice->SetTexture(0, NULL); m_pMesh->DrawSubset(0); }
void SceneLabState::Render(fplbase::Renderer* renderer) { camera_->set_viewport_resolution(vec2(renderer->window_size())); const auto camera = scene_lab_->GetCamera(); mat4 camera_transform = camera->GetTransformMatrix(); renderer->set_color(mathfu::kOnes4f); renderer->DepthTest(true); renderer->set_model_view_projection(camera_transform); world_->river_component.UpdateRiverMeshes(); world_->world_renderer->RenderWorld(*camera, *renderer, world_); }
BOOL obj_ZombieDummy::OnCreate() { parent::OnCreate(); anim_.Init(g_zombieBindSkeleton, g_zombieAnimPool, NULL, (DWORD)this); for(int i=0; i<3; i++) { ReloadZombiePart(i); } AnimSpeed = 1.0f; WalkSpeed = 0.0; Walking = 0; ApplyWalkSpeed = 0; WalkIdx = -1; SpawnPos = GetPosition(); r3dBoundBox bbox; bbox.InitForExpansion(); for (int i = 0; i < 3; ++i) { if (zombieParts[i]) bbox.ExpandTo(zombieParts[i]->localBBox); } SetBBoxLocal(bbox); if(sAnimSelected[0] == 0) r3dscpy(sAnimSelected, random(2) == 0 ? "Zombie_Idle_01.anm" : "Zombie_Idle_02.anm"); fAnimListOffset = 0; SwitchToSelectedAnim(); anim_.Update(0.001f, r3dPoint3D(0,0,0), GetTransformMatrix()); physSkeleton = AquireCacheSkeleton(); physSkeleton->linkParent(anim_.GetCurrentSkeleton(), GetTransformMatrix(), this, PHYSCOLL_NETWORKPLAYER) ; physSkeleton->SwitchToRagdoll(false); return TRUE; }
BOOL CXaraFileRectangle::WriteRectangleComplexReformed(BaseCamelotFilter * pFilter, NodeRegularShape * pShape) { BOOL ok; CamelotFileRecord Rec(pFilter,TAG_RECTANGLE_COMPLEX_REFORMED, TAG_RECTANGLE_COMPLEX_REFORMED_SIZE); ok = Rec.Init(); if (ok) ok = Rec.WriteCoordTrans(GetUTMajorAxis(pShape),0,0); if (ok) ok = Rec.WriteCoordTrans(GetUTMinorAxis(pShape),0,0); if (ok) ok = Rec.WriteMatrix(GetTransformMatrix(pShape)); if (ok) ok = Rec.WritePath(GetEdgePath(pShape)); if (ok) ok = pFilter->Write(&Rec); return ok; }
//----------------------------------------------------------------------------- // Purpose: Renders this region as a wireframe box. // Input : pRender - 3D Renderer. //----------------------------------------------------------------------------- void Box3D::RenderTool3D(CRender3D *pRender) { if ( IsTranslating() ) { VMatrix matrix = GetTransformMatrix(); pRender->BeginLocalTransfrom( matrix ); } else if (IsEmpty()) { return; } pRender->PushRenderMode( RENDER_MODE_FLAT ); pRender->SetDrawColor( GetRValue(m_clrBox), GetGValue(m_clrBox), GetBValue(m_clrBox) ); pRender->DrawBox( bmins, bmaxs ); pRender->PopRenderMode(); if ( IsTranslating() ) { pRender->EndLocalTransfrom(); if ( m_TranslateMode == modeMove || m_TranslateMode == modeRotate ) { Vector vec = m_vTranslationFixPoint; if ( m_TranslateMode == modeMove ) { TranslatePoint( vec ); } // draw 'X' pRender->PushRenderMode( RENDER_MODE_FLAT_NOZ ); pRender->SetHandleStyle( 7, CRender::HANDLE_CROSS ); pRender->SetHandleColor( GetRValue(Options.colors.clrToolDrag), GetGValue(Options.colors.clrToolDrag), GetBValue(Options.colors.clrToolDrag) ); pRender->DrawHandle( vec ); pRender->PopRenderMode(); } } else if ( m_bEnableHandles ) { RenderHandles3D( pRender, bmins, bmaxs ); }; }
void GrGLGeometryProcessor::setTransformData(const GrPrimitiveProcessor& primProc, const GrGLProgramDataManager& pdman, int index, const SkTArray<const GrCoordTransform*, true>& transforms) { SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[index]; int numTransforms = transforms.count(); for (int t = 0; t < numTransforms; ++t) { SkASSERT(procTransforms[t].fHandle.isValid()); const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix(), *transforms[t]); if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) { pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHandle(), transform); procTransforms[t].fCurrentValue = transform; } } }
BOOL CXaraFilePolygon::WritePolygonComplexReformed(BaseCamelotFilter * pFilter, NodeRegularShape * pShape) { BOOL ok; CamelotFileRecord Rec(pFilter,TAG_POLYGON_COMPLEX_REFORMED, TAG_POLYGON_COMPLEX_REFORMED_SIZE); ok = Rec.Init(); if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape)); if (ok) ok = Rec.WriteCoordTrans(GetUTMajorAxis(pShape),0,0); if (ok) ok = Rec.WriteCoordTrans(GetUTMinorAxis(pShape),0,0); if (ok) ok = Rec.WriteMatrix(GetTransformMatrix(pShape)); if (ok) ok = Rec.WritePath(GetEdgePath(pShape)); if (ok) ok = pFilter->Write(&Rec); return ok; }
void SceneLabState::Render(fplbase::Renderer* renderer) { camera_->set_viewport_resolution(vec2(renderer->window_size())); const auto camera = corgi_adapter_->GetCorgiCamera(); mat4 camera_transform = camera->GetTransformMatrix(); renderer->set_color(mathfu::kOnes4f); renderer->SetDepthFunction(fplbase::kDepthFunctionLess); renderer->set_model_view_projection(camera_transform); world_->river_component.UpdateRiverMeshes(); if (world_->RenderingOptionEnabled(kShadowEffect)) { world_->world_renderer->RenderShadowMap(*camera, *renderer, world_); } world_->world_renderer->RenderWorld(*camera, *renderer, world_); }
void NzSkeletalModel::AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const { const NzMatrix4f& transformMatrix = GetTransformMatrix(); unsigned int submeshCount = m_mesh->GetSubMeshCount(); for (unsigned int i = 0; i < submeshCount; ++i) { const NzSkeletalMesh* mesh = static_cast<const NzSkeletalMesh*>(m_mesh->GetSubMesh(i)); const NzMaterial* material = m_materials[mesh->GetMaterialIndex()]; NzMeshData meshData; meshData.indexBuffer = mesh->GetIndexBuffer(); meshData.primitiveMode = mesh->GetPrimitiveMode(); meshData.vertexBuffer = NzSkinningManager::GetBuffer(mesh, &m_skeleton); renderQueue->AddMesh(material, meshData, m_skeleton.GetAABB(), transformMatrix); } }
BOOL CXaraFileRectangle::WriteRectangleComplexStellatedReformed(BaseCamelotFilter * pFilter, NodeRegularShape * pShape) { BOOL ok; CamelotFileRecord Rec(pFilter,TAG_RECTANGLE_COMPLEX_STELLATED_REFORMED, TAG_RECTANGLE_COMPLEX_STELLATED_REFORMED_SIZE); ok = Rec.Init(); if (ok) ok = Rec.WriteCoordTrans(GetUTMajorAxis(pShape),0,0); if (ok) ok = Rec.WriteCoordTrans(GetUTMinorAxis(pShape),0,0); if (ok) ok = Rec.WriteMatrix(GetTransformMatrix(pShape)); if (ok) ok = Rec.WriteDOUBLE(GetStellationRadius(pShape)); if (ok) ok = Rec.WriteDOUBLE(GetStellationOffset(pShape)); if (ok) ok = Rec.WritePath(GetPrimaryEdgePath(pShape)); if (ok) ok = Rec.WritePath(GetSecondaryEdgePath(pShape)); if (ok) ok = pFilter->Write(&Rec); return ok; }
void GameObject::PrecalculateMatricesIgnoreSkinning( PrecalculatedMeshVSConsts* oConsts ) { r3dMesh *m = GetObjectLodMesh() ; r3dPoint3D *scale ; r3dPoint2D *texcScale ; if( m ) { scale = &m->unpackScale; texcScale = &m->texcUnpackScale ; } else { scale = 0 ; texcScale = 0 ; } r3dPrepareMeshVSConsts(*oConsts, GetTransformMatrix(), scale, texcScale, r3dRenderer->ViewMatrix, r3dRenderer->ViewProjMatrix ); }
void GameObject::PrecalculateMatrices() { r3dMesh *m = GetObjectLodMesh() ; r3dPoint3D *scale ; r3dPoint2D *texcScale ; if( m ) { scale = m->IsSkeletal() ? 0 : &m->unpackScale; texcScale = &m->texcUnpackScale ; } else { scale = 0 ; texcScale = 0 ; } r3dPrepareMeshVSConsts(preparedVSConsts, GetTransformMatrix(), scale, texcScale, r3dRenderer->ViewMatrix, r3dRenderer->ViewProjMatrix ); }
void GrGLLegacyPathProcessor::setTransformData( const GrPrimitiveProcessor& primProc, int index, const SkTArray<const GrCoordTransform*, true>& transforms, GrGLPathRendering* glpr, GrGLuint) { // We've hidden the texcoord index in the first entry of the transforms array for each // effect int texCoordIndex = fInstalledTransforms[index][0].fHandle.handle(); for (int t = 0; t < transforms.count(); ++t) { const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix(), *transforms[t]); GrGLPathRendering::PathTexGenComponents components = GrGLPathRendering::kST_PathTexGenComponents; if (transform.hasPerspective()) { components = GrGLPathRendering::kSTR_PathTexGenComponents; } glpr->enablePathTexGen(texCoordIndex++, components, transform); } }
BOOL CXaraFilePolygon::WritePolygonComplexRoundedStellatedReformed(BaseCamelotFilter * pFilter, NodeRegularShape * pShape) { BOOL ok; CamelotFileRecord Rec(pFilter,TAG_POLYGON_COMPLEX_ROUNDED_STELLATED_REFORMED, TAG_POLYGON_COMPLEX_ROUNDED_STELLATED_REFORMED_SIZE); ok = Rec.Init(); if (ok) ok = Rec.WriteUINT16(GetNumberOfSides(pShape)); if (ok) ok = Rec.WriteCoordTrans(GetUTMajorAxis(pShape),0,0); if (ok) ok = Rec.WriteCoordTrans(GetUTMinorAxis(pShape),0,0); if (ok) ok = Rec.WriteMatrix(GetTransformMatrix(pShape)); if (ok) ok = Rec.WriteDOUBLE(GetStellationRadius(pShape)); if (ok) ok = Rec.WriteDOUBLE(GetStellationOffset(pShape)); if (ok) ok = Rec.WriteDOUBLE(GetPrimaryCurvature(pShape)); if (ok) ok = Rec.WriteDOUBLE(GetSecondaryCurvature(pShape)); if (ok) ok = Rec.WritePath(GetPrimaryEdgePath(pShape)); if (ok) ok = Rec.WritePath(GetSecondaryEdgePath(pShape)); if (ok) ok = pFilter->Write(&Rec); return ok; }
BOOL obj_ZombieDummy::Update() { parent::Update(); const float TimePassed = r3dGetFrameTime(); if(WalkSpeed > 0.01) { r3dPoint3D pos = GetPosition(); pos.z += r3dGetFrameTime() * WalkSpeed * (Walking ? -1 : 0); if(pos.z < SpawnPos.z - 4) pos.z = SpawnPos.z + 4; SetPosition(pos); } #if ENABLE_RAGDOLL bool ragdoll = physSkeleton && physSkeleton->IsRagdollMode(); if (!ragdoll) #endif { D3DXMATRIX CharDrawMatrix; D3DXMatrixIdentity(&CharDrawMatrix); anim_.Update(TimePassed, r3dPoint3D(0,0,0), CharDrawMatrix); anim_.Recalc(); } if(physSkeleton) physSkeleton->syncAnimation(anim_.GetCurrentSkeleton(), GetTransformMatrix(), anim_); #if ENABLE_RAGDOLL if (ragdoll) { r3dBoundBox bbox = physSkeleton->getWorldBBox(); bbox.Org -= GetPosition(); SetBBoxLocal(bbox); } #endif return TRUE; }
void setTransformData(const GrPrimitiveProcessor& primProc, const GrGLSLProgramDataManager& pdman, int index, const SkTArray<const GrCoordTransform*, true>& coordTransforms) override { const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>(); SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index]; int numTransforms = transforms.count(); for (int t = 0; t < numTransforms; ++t) { SkASSERT(transforms[t].fHandle.isValid()); const SkMatrix& transform = GetTransformMatrix(pathProc.localMatrix(), *coordTransforms[t]); if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { continue; } transforms[t].fCurrentValue = transform; SkASSERT(transforms[t].fType == kVec2f_GrSLType || transforms[t].fType == kVec3f_GrSLType); unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3; pdman.setPathFragmentInputTransform(transforms[t].fHandle, components, transform); } }
void cCylinder::Draw() { //g_pD3DDC->RSSetState(cRenderStates::m_WireframeRS); // Set Layout And Topology g_pD3DDC->IASetInputLayout(cInputLayouts::Simple); g_pD3DDC->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); // Set VertexBuffer And IndexBuffer UINT stride = sizeof(Vertex::Simple); UINT offset = 0; g_pD3DDC->IASetVertexBuffers(0, 1, &m_VB, &stride, &offset); g_pD3DDC->IASetIndexBuffer(m_IB, DXGI_FORMAT_R32_UINT, 0); // worldViewProj 행렬을 구한다. XMMATRIX world = XMLoadFloat4x4(&GetTransformMatrix()); XMMATRIX view = g_pCameraManager->GetView(); XMMATRIX proj = g_pCameraManager->GetProj(); XMMATRIX worldViewProj = world * view * proj; // 셰이더에 상수값 설정. cEffects::SimpleFX->SetWorldViewProj(worldViewProj); ID3DX11EffectTechnique* tech = cEffects::SimpleFX->ColorTech; D3DX11_TECHNIQUE_DESC techDesc; tech->GetDesc(&techDesc); for (UINT p = 0; p < techDesc.Passes; ++p) { tech->GetPassByIndex(p)->Apply(0, g_pD3DDC); // 색인을 사용해서 그린다. g_pD3DDC->DrawIndexed(m_GridIndexCount, 0, 0); } HR(g_pD3DSC->Present(0, 0)); }
void FBXConverter::LoadSkin(FbxMesh* fbxMesh, std::vector<BoneConnector>& bcs, std::vector<Vertex>& vs) { vs.resize(fbxMesh->GetControlPointsCount()); auto skinCount = fbxMesh->GetDeformerCount(FbxDeformer::eSkin); for (auto skinInd = 0; skinInd < skinCount; skinInd++) { auto skin = (FbxSkin*)fbxMesh->GetDeformer(skinInd, FbxDeformer::eSkin); auto clusterCount = skin->GetClusterCount(); for (auto clusterInd = 0; clusterInd < clusterCount; clusterInd++) { auto cluster = skin->GetCluster(clusterInd); if (cluster->GetLink() == nullptr) continue; // ボーン取得 auto name = cluster->GetLink()->GetName(); FbxAMatrix m1, m2; cluster->GetTransformMatrix(m1); cluster->GetTransformLinkMatrix(m2); int32_t id = bcs.size(); BoneConnector connector; connector.Name = name; auto m2_inv = m2.Inverse(); auto m = m2_inv * m1; connector.OffsetMatrix = m; bcs.push_back(connector); auto indexCount = cluster->GetControlPointIndicesCount(); auto vindices = cluster->GetControlPointIndices(); auto vweights = cluster->GetControlPointWeights(); for (auto ind = 0; ind < indexCount; ind++) { Weight data; data.Index = id; data.Value = (float)vweights[ind]; vs[vindices[ind]].Weights.push_back(data); } } } // Calculate weight for (auto& v : vs) { if (v.Weights.size() == 0) { Weight w; w.Index = -1; w.Value = 1.0; v.Weights.push_back(w); v.Weights.push_back(Weight()); v.Weights.push_back(Weight()); v.Weights.push_back(Weight()); } else { v.Weights.push_back(Weight()); v.Weights.push_back(Weight()); v.Weights.push_back(Weight()); std::sort(v.Weights.begin(), v.Weights.end(), Weight()); float fSum = 0.0f; for (auto ind = 0; ind < 4; ind++) { fSum += v.Weights[ind].Value; } v.Weights[0].Value += 1.0f - fSum; v.Weights.resize(4); } } }
/* Finish capture and run registration */ void MainWindow::on_CapDone_Btn() { //disconnect pick callback m_3d_View->DisablePick(); std::vector<double*> temp_dst; if (m_3d_View->GetMarkerList().size() == 0) { double a1[] = { 176.286, 195.733, 90.0183 }; double a2[] = { 75.7988, 192.343, 88.1086 }; double a3[] = { 124.12, 139.966, 167.357 }; double a4[] = { 122.669, 40.1707, 116.375 }; temp_dst.push_back(a1); temp_dst.push_back(a2); temp_dst.push_back(a3); temp_dst.push_back(a4); } else { temp_dst = m_3d_View->GetMarkerList(); } //if (m_3d_View->GetMarkerList().size() != m_Marker_Capture->GetMarkerList().size()) //{ // std::cout << "Markers invalid" << std::endl; // m_3d_View->ClearMarkers(); // m_Marker_Capture->ClearMarkers(); //} // start registration here auto temp_src = m_Marker_Capture->GetMarkerList(); auto reg = vtkSmartPointer<vtkTrackingLandMarkRegistration>::New(); reg->SetSourcePoints(temp_src); reg->SetTargetPoints(temp_dst); reg->GenerateTransform(); auto res2 = reg->GetTransformMatrix(); std::cout << "Result" << std::endl; std::cout << "Error is: " << reg->EstimateRegistrationError() << std::endl; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) std::cout << res2->GetElement(i, j) << ","; std::cout << std::endl; } // a messagebox for user to accecpt or discard the error QMessageBox msgBox; msgBox.setWindowTitle("Register Box"); QString msg = "Accept the registration error:\n "; msg = msg + QString::number(reg->EstimateRegistrationError()); msgBox.setInformativeText(msg); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Discard); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); if (ret == QMessageBox::Yes) { m_3d_View->SetRegisterTransform(res2); //m_3d_View->SetLandMarks(temp_src,temp_dst); } else { m_Marker_Capture->ClearMarkers(); m_3d_View->ClearMarkers(); } }
void patchSkins(FbxNode* currentRoot, const std::map<std::string, FbxNode*>& animatedNodes, const std::string& prefix){ auto mesh = currentRoot->GetMesh(); if (mesh){ auto skinCount = mesh->GetDeformerCount(FbxDeformer::EDeformerType::eSkin); for (auto ix = 0; ix < skinCount; ++ix){ auto skin = (FbxSkin*) mesh->GetDeformer(ix, FbxDeformer::EDeformerType::eSkin); if (skin){ std::vector<FbxCluster*> replacements; auto clusterCount = skin->GetClusterCount(); for (auto clusterIx = 0; clusterIx < clusterCount; ++clusterIx){ auto cluster = skin->GetCluster(clusterIx); if (cluster){ auto linkNode = cluster->GetLink(); if (linkNode){ auto candidateName = prefix; candidateName.append(linkNode->GetName()); auto found = animatedNodes.find(candidateName); if (found != animatedNodes.end()){ FbxCluster* newCluster = FbxCluster::Create(currentRoot->GetScene(), ""); newCluster->SetLink(found->second); newCluster->SetLinkMode(cluster->GetLinkMode()); FbxAMatrix mat; newCluster->SetTransformAssociateModelMatrix(cluster->GetTransformAssociateModelMatrix(mat)); newCluster->SetAssociateModel(cluster->GetAssociateModel()); newCluster->SetTransformLinkMatrix(cluster->GetTransformLinkMatrix(mat)); newCluster->SetTransformMatrix(cluster->GetTransformMatrix(mat)); newCluster->SetTransformParentMatrix(cluster->GetTransformParentMatrix(mat)); auto indicesAndWeightsCount = cluster->GetControlPointIndicesCount(); for (auto ix = 0; ix < indicesAndWeightsCount; ++ix){ newCluster->AddControlPointIndex(cluster->GetControlPointIndices()[ix], cluster->GetControlPointWeights()[ix]); } replacements.push_back(newCluster); } } } } if (replacements.size() == clusterCount){ while (skin->GetClusterCount()>0){ auto oldCluster = skin->GetCluster(skin->GetClusterCount() - 1); skin->RemoveCluster(oldCluster); oldCluster->Destroy(); } for (auto c : replacements){ skin->AddCluster(c); } } else{ for (auto c : replacements){ c->Destroy(); } } } } } for (auto ix = 0; ix < currentRoot->GetChildCount(); ++ix){ patchSkins(currentRoot->GetChild(ix), animatedNodes, prefix); } }