案例位置:examples/Cuda/CodimensionalPD/CPD_ClothDrop
功能介绍:案例中展示了 CodimensionalPD 类的的基本使用。
案例说明:该案例主要用于模拟布料。布料的上面两个点被固定,在重力作用逐渐落下的效果。
std::shared_ptr<SceneGraph> scn = std::make_shared<SceneGraph>();
scn->setLowerBound(Vec3f(-1.5, -1, -1.5));
scn->setUpperBound(Vec3f(1.5, 3, 1.5));
scn->setGravity(Vec3f(0,-200,0));
auto cloth = scn->addNode(std::make_shared<CodimensionalPD<DataType3f>>(0.15, 120, 0.001, 0.0001));
//also try:
//auto cloth = scn->addNode(std::make_shared<CodimensionalPD<DataType3f>>(0.15, 1200, 0.001, 0.0001));
//auto cloth = scn->addNode(std::make_shared<CodimensionalPD<DataType3f>>(0.15, 12000, 0.001, 0.0001));
cloth->loadSurface(getAssetPath() + "cloth_shell/mesh_drop.obj");
auto custom = std::make_shared<ManualControl<DataType3f>>();
cloth->statePosition()->connect(custom->inPosition());
cloth->stateVelocity()->connect(custom->inVelocity());
cloth->stateFrameNumber()->connect(custom->inFrameNumber());
cloth->stateAttribute()->connect(custom->inAttribute());
cloth->animationPipeline()->pushModule(custom);
cloth->setSelfContact(false);
auto surfaceRendererCloth = std::make_shared<GLSurfaceVisualModule>();
surfaceRendererCloth->setColor(Color(1, 1, 1));
cloth->stateTriangleSet()->connect(surfaceRendererCloth->inTriangleSet());
cloth->graphicsPipeline()->pushModule(surfaceRendererCloth);
cloth->setVisible(true);