案例位置:examples/Cuda/CodimensionalPD/CPD_RotateCylinder
功能介绍:案例中展示了 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->setMaxIteNumber(10);
cloth->setGrad_ite_eps(0);
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);