Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
26 June 2017 at 13:01 in reply to: [SOLVED] A Problem About How to Move A Fixed Rigid Object in C++ Project? #9366wq57fanBlocked
Hi Hugo,
I tried your way, and it works in Modeler.However, in my C++ project, there are two main problems existing:
1.The rigid body cannot detect the collision.
2.The rigid body cannot fall down with gravity.
Here is a part of my code:
nodeFixed = chain->createChild("Fixed"); sofa::component::odesolver::EulerImplicitSolver::SPtr solver = sofa::core::objectmodel::New<sofa::component::odesolver::EulerImplicitSolver>(); solver->setName("Euler Implicit"); solver->f_rayleighStiffness.setValue(0.1); solver->f_rayleighMass.setValue(0.1); nodeFixed->addObject(solver); typedef sofa::component::linearsolver::CGLinearSolver< sofa::component::linearsolver::GraphScatteredMatrix, sofa::component::linearsolver::GraphScatteredVector> CGLinearSolverGraph; CGLinearSolverGraph::SPtr linear = sofa::core::objectmodel::New<CGLinearSolverGraph>(); linear->setName("Conjugate Gradient"); //solver->setName("Conjugate Gradient"); linear->f_maxIter.setValue(25); //iteration maxi for the CG linear->f_smallDenominatorThreshold.setValue(1e-05); linear->f_tolerance.setValue(1e-05); nodeFixed->addObject(linear); sofa::component::loader::MeshGmshLoader::SPtr loaderRigid = sofa::core::objectmodel::New<sofa::component::loader::MeshGmshLoader>(); loaderRigid->setName("Msh Loader"); loaderRigid->setFilename(sofa::helper::system::DataRepository.getFile("mesh/liver.msh")); loaderRigid->load(); nodeFixed->addObject(loaderRigid); dofRigid = sofa::core::objectmodel::New<MechanicalObjectRigid3>(); dofRigid->setName("Fixed Object"); dofRigid->setSrc("@"+loaderRigid->getName(), loaderRigid.get()); dofRigid->setTranslation(0,0,0); dofRigid->setRotation(0,0,0); nodeFixed->addObject(dofRigid); UniformMassRigid3::SPtr uniMassFixed = sofa::core::objectmodel::New<UniformMassRigid3>(); uniMassFixed->setName("Uni Mass"); uniMassFixed->setMass(1); uniMassFixed->setTotalMass(1); nodeFixed->addObject(uniMassFixed); sofa::component::container::Node* nodeFixedVisual = nodeFixed->createChild("Visual"); visualFixed = sofa::core::objectmodel::New<sofa::component::visualmodel::OglModel>(); visualFixed->setName("visual"); visualFixed->setFilename(sofa::helper::system::DataRepository.getFile(visualModelName1)); visualFixed->setColor("gray"); visualFixed->setTranslation(0,0,0); visualFixed->setRotation(0,0,0); nodeFixedVisual->addObject(visualFixed); visualModel[0] = visualFixed.get(); const std::string refVisual3 = "@" + visualFixed->getName(); //output const std::string refDof3 = "@../" + dofRigid->getName(); //input RigidMappingRigid3d_to_Ext3f::SPtr mapping5 = sofa::core::objectmodel::New<RigidMappingRigid3d_to_Ext3f>(); mapping5->setModels(dofRigid.get(), visualFixed.get()); mapping5->setName("Mapping Visual"); mapping5->setPathInputObject(refDof3); mapping5->setPathOutputObject(refVisual3); nodeFixedVisual->addObject(mapping5);
I don’t know that if it is because some of my parameters are wrong.
Thanks for your help.
wq57fanBlockedThank you!
I’m learning now, i will pay attention to the updating! -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)