当前位置: 首页>>代码示例>>C++>>正文


C++ ChSharedPtr::GetMaterialSurface方法代码示例

本文整理汇总了C++中ChSharedPtr::GetMaterialSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ ChSharedPtr::GetMaterialSurface方法的具体用法?C++ ChSharedPtr::GetMaterialSurface怎么用?C++ ChSharedPtr::GetMaterialSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ChSharedPtr的用法示例。


在下文中一共展示了ChSharedPtr::GetMaterialSurface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: create_items

void create_items(ChIrrAppInterface& application) 
{
	// Create some spheres in a vertical stack

	bool do_wall = false;
	bool do_stack = true;
	bool do_oddmass = true;
	bool do_spheres = true;
	bool do_heavyonside = true;
	

	double sphrad = 0.2;
	double dens= 1000;
	double sphmass = dens * (4./3.) * CH_C_PI * pow(sphrad,3);
	double sphinertia = (2./5.) * sphmass * pow(sphrad,2);

	if (do_stack)
	{
		int nbodies = 15;

		double totmass= 0;
		double level  = 0;
		double sphrad_base = 0.2;
		double oddfactor = 100;

		for (int bi = 0; bi < nbodies; bi++)  // N. of vert. bricks
		{ 
			double sphrad = sphrad_base;
			if (do_oddmass && bi==(nbodies-1))
				sphrad = sphrad*pow(oddfactor, 1./3.);
			double dens= 1000;

			ChSharedPtr<ChBody> mrigidBody;

			if (do_spheres)
			{
				mrigidBody = ChSharedPtr<ChBodyEasySphere>(new ChBodyEasySphere(
											sphrad,		// radius
											dens,		// density
											true,		// collide enable?
											true));		// visualization?
				mrigidBody->SetPos(ChVector<>(0.5, sphrad+level, 0.7));
        mrigidBody->AddAsset(ChSharedPtr<ChTexture>(new ChTexture(GetChronoDataFile("bluwhite.png"))));

				application.GetSystem()->Add(mrigidBody);
			}
			else
			{
				mrigidBody = ChSharedPtr<ChBodyEasyBox>(new ChBodyEasyBox(
											sphrad,sphrad,sphrad, // x,y,z size
											dens,		// density
											true,		// collide enable?
											true));		// visualization?
				mrigidBody->SetPos(ChVector<>(0.5, sphrad+level, 0.7));
        mrigidBody->AddAsset(ChSharedPtr<ChTexture>(new ChTexture(GetChronoDataFile("cubetexture_bluwhite.png"))));

				application.GetSystem()->Add(mrigidBody);
			}

      mrigidBody->GetMaterialSurface()->SetFriction(0.5f);
      mrigidBody->GetMaterialSurface()->SetRestitution(0.0f);

			mspheres.push_back(mrigidBody);

			level   +=sphrad*2;
			totmass +=mrigidBody->GetMass();
		}

		GetLog() << "Expected contact force at bottom F=" << (totmass *application.GetSystem()->Get_G_acc().y)  << "\n";
	}

	if (do_wall)
		for (int ai = 0; ai < 1; ai++)  // N. of walls
		{ 
			for (int bi = 0; bi < 10; bi++)  // N. of vert. bricks
			{ 
				for (int ui = 0; ui < 15; ui++)  // N. of hor. bricks
				{ 
					ChSharedPtr<ChBodyEasyBox> mrigidWall (new ChBodyEasyBox(
											3.96,2,4,		// radius
											dens,		// density
											true,		// collide enable?
											true));		// visualization?
					mrigidWall->SetPos(ChVector<>(-8+ui*4.0+2*(bi%2),  1.0+bi*2.0, -5+ ai*6));
          mrigidWall->GetMaterialSurface()->SetFriction(0.4f);
          mrigidWall->AddAsset(ChSharedPtr<ChTexture>(new ChTexture(GetChronoDataFile("cubetexture_bluwhite.png"))));

					application.GetSystem()->Add(mrigidWall);
				}
			}
		}

	if (do_heavyonside)
	{
		double sphrad = 0.2;
		double dens= 1000;
		double hfactor = 100;

		ChSharedPtr<ChBodyEasySphere> mrigidHeavy(new ChBodyEasySphere(
											sphrad,		 // radius
//.........这里部分代码省略.........
开发者ID:globus000,项目名称:cew,代码行数:101,代码来源:demo_convergence.cpp


注:本文中的ChSharedPtr::GetMaterialSurface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。