案例位置:examples/Cuda/CodimensionalPD/CPD_ShootingCloth
功能介绍:案例中展示了 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));
auto cloth = scn->addNode(std::make_shared<CodimensionalPD<DataType3f>>(0.15, 120, 0.001, 0.0005));
cloth->loadSurface(getAssetPath() + "cloth_shell/cylinder400.obj");
cloth->loadSurface(getAssetPath() + "cloth_shell/shootingCloth.obj");
cloth->connect(boundary->importTriangularSystems());
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);
auto surfaceRendererCloth = std::make_shared<GLSurfaceVisualModule>();
surfaceRendererCloth->setColor(Color(1,1,1));
cloth->stateTriangleSet()->connect(surfaceRendererCloth->inTriangleSet());
cloth->graphicsPipeline()->pushModule(surfaceRendererCloth);
cloth->setVisible(true);