案例位置:examples/Cuda/CodimensionalPD/CPD_ClothOnTable
功能介绍:案例中展示了 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/table/table.obj");
auto cloth = scn->addNode(std::make_shared<CodimensionalPD<DataType3f>>(0.3,8000,0.003,7e-4));
//also try:
//auto cloth = scn->addNode(std::make_shared<CodimensionalPD<DataType3f>>(0.3, 8000, 0.03,7e-4));
//auto cloth = scn->addNode(std::make_shared<CodimensionalPD<DataType3f>>(0.3, 8000, 0.3,7e-4));
//auto cloth = scn->addNode(std::make_shared<CodimensionalPD<DataType3f>>(0.3, 8000, 0.0,7e-4));
cloth->loadSurface(getAssetPath() + "cloth_shell/mesh40k_1_h90.obj");
cloth->connect(boundary->importTriangularSystems());
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.8, 0.8, 0.8));
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);