案例位置:examples/Cuda/CodimensionalPD/GL_ClothWithCollision
功能介绍:案例中展示了 CodimensionalPD 类的的基本使用。
案例说明:该案例主要用于模拟布料。布料在重力作用下,从空中掉落到静态球体,并形成褶皱的过程。
std::shared_ptr<SceneGraph> scn = std::make_shared<SceneGraph>();
scn->setLowerBound(Vec3f(-1.5, 0, -1.5));
scn->setUpperBound(Vec3f(1.5, 3, 1.5));
auto object = scn->addNode(std::make_shared<StaticTriangularMesh<DataType3f>>());
object->varFileName()->setValue(getAssetPath() + "cloth_shell/model_ball.obj");
auto boundary = scn->addNode(std::make_shared<VolumeBoundary<DataType3f>>());
boundary->loadCube(Vec3f(-1.5,0,-1.5), Vec3f(1.5,3,1.5), 0.005f, true);
//boundary->loadShpere(Vec3f(0.5, 0.6f, 0.5), 0.15f, 0.005f, false, true);
boundary->loadSDF(getAssetPath() + "cloth_shell/model_sdf.sdf");
auto cloth = scn->addNode(std::make_shared<CodimensionalPD<DataType3f>>(0.15f,2e1f,0.0f));
cloth->loadSurface(getAssetPath() + "cloth_shell/mesh_120.obj");
cloth->connect(boundary->importTriangularSystems());
cloth->setDt(0.001f);
cloth->setGrad_ite_eps(1e-4);
cloth->setMaxIteNumber(10);
cloth->setAccelerated(true);
auto surfaceRendererCloth = std::make_shared<GLSurfaceVisualModule>();
surfaceRendererCloth->setColor(Color(0.4,0.4,1.0));
auto surfaceRenderer = std::make_shared<GLSurfaceVisualModule>();
surfaceRenderer->setColor(Color(0.4,0.4,0.4));
surfaceRenderer->varUseVertexNormal()->setValue(true);
cloth->stateTriangleSet()->connect(surfaceRendererCloth->inTriangleSet());
object->stateTriangleSet()->connect(surfaceRenderer->inTriangleSet());
cloth->graphicsPipeline()->pushModule(surfaceRendererCloth);
object->graphicsPipeline()->pushModule(surfaceRenderer);
cloth->setVisible(true);
object->setVisible(true);