塑性材料

1、塑性材料

案例位置examples/Cuda/Tutorials/GL_Cloth

功能介绍:该案例主要用于测试塑性材料仿真功能。案例展示了 ElastoplasticBody 类的的基本使用。塑性材料在发生小应变时,材料性质基本为线弹性,弹性模量为常数;当应力超过屈服应力后,刚度会显著下降。

案例说明:案例中展示了塑性材料从空中掉落,发生塑性变形的运动过程。

2、程序实现

接下来介绍案例的实现过程:

  • 创建场景图:
	std::shared_ptr<SceneGraph> scn = std::make_shared<SceneGraph>();
  • 创建一个塑性节点:
 	//Create a elastoplastic object
	auto elastoplasticBody = scn->addNode(std::make_shared<ElastoplasticBody<DataType3f>>());	

	elastoplasticBody->setVisible(false);
  	elastoplasticBody->loadParticles(Vec3f(-1.1), Vec3f(1.15), 0.1);
	elastoplasticBody->scale(0.05);
	elastoplasticBody->translate(Vec3f(0.3, 0.2, 0.5));
  • 对塑性节点创建表面网格及渲染节点:
	//Create a surface mesh loader
	auto surfaceMeshLoader = scn->addNode(std::make_shared<SurfaceMeshLoader<DataType3f>>());
	surfaceMeshLoader->varFileName()->setValue(getAssetPath() + "standard/standard_cube20.obj");
	surfaceMeshLoader->varScale()->setValue(Vec3f(0.05f));
	surfaceMeshLoader->varLocation()->setValue(Vec3f(0.3, 0.2, 0.5));

	//Create a topology mapper
	auto topoMapper = scn->addNode(std::make_shared<PointSetToTriangleSet<DataType3f>>());

	auto outTop = elastoplasticBody->statePointSet()->promoteOuput();
 	outTop->connect(topoMapper->inPointSet());
	surfaceMeshLoader->outTriangleSet()->connect(topoMapper->inInitialShape());

	auto surfaceVisualizer = scn->addNode(std::make_shared<GLSurfaceVisualNode<DataType3f>>());
	topoMapper->outShape()->connect(surfaceVisualizer->inTriangleSet());
  • 创建另一个塑性节点:
 	//Create a elastoplastic object
	auto elasticBody = scn->addNode(std::make_shared<ElasticBody<DataType3f>>());
	elasticBody->setVisible(false);
	elasticBody->loadParticles(Vec3f(-1.1), Vec3f(1.15), 0.1);
	elasticBody->scale(0.05);
	elasticBody->translate(Vec3f(0.5, 0.2, 0.5));

	auto surfaceMeshLoader2 = scn->addNode(std::make_shared<SurfaceMeshLoader<DataType3f>>());
	surfaceMeshLoader2->varFileName()->setValue(getAssetPath() + "standard/standard_cube20.obj");
	surfaceMeshLoader2->varScale()->setValue(Vec3f(0.05f));
	surfaceMeshLoader2->varLocation()->setValue(Vec3f(0.5, 0.2, 0.5));
  • 对塑性节点创建表面网格及渲染节点:
	auto topoMapper2 = scn->addNode(std::make_shared<PointSetToTriangleSet<DataType3f>>());

	auto outTop2 = elasticBody->statePointSet()->promoteOuput();
	outTop2->connect(topoMapper2->inPointSet());
	surfaceMeshLoader2->outTriangleSet()->connect(topoMapper2->inInitialShape());

	auto surfaceVisualizer2 = scn->addNode(std::make_shared<GLSurfaceVisualNode<DataType3f>>());
	topoMapper2->outShape()->connect(surfaceVisualizer2->inTriangleSet());
  • 创建固体边界:
	auto boundary = scn->addNode(std::make_shared<StaticBoundary<DataType3f>>());
	boundary->loadCube(Vec3f(0), Vec3f(1), 0.005, true);
	elastoplasticBody->connect(boundary->importParticleSystems());
	elasticBody->connect(boundary->importParticleSystems());