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


C++ Body::Init方法代码示例

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


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

示例1: GenMoonDemo

void GenMoonDemo()
{
	NUM_BODIES = 3;
	Body* earth;
	Body* moon;
	Body* theSun = new Body(.5f, Vector3(0, 0, 0), Vector3(0,0,0), SUN, program);
	theSun->Init();

	bodies = std::vector<Body*>();
	bodies.push_back(theSun);

	earth = new Body(.05f, Vector3(0, 0, 0), Vector3(0,0,0), PLANET, program);
	float semiMajLMult = 1;
	float minRadius = 10;
	earth->SetOrbit(*theSun, 
		minRadius, 
		Vector3(((rand() % 200 + 1) - 100)*.001f, ((rand() % 200 + 1) - 100)*.001f, ((rand() % 200 + 1) - 100)*.001f), 
		0, 
		semiMajLMult);
	earth->Init();
	bodies.push_back(earth);

	moon = new Body(.01f, Vector3(0, 0, 0), Vector3(0,0,0), ASTEROID, program);
	semiMajLMult = 1;
	minRadius = earth->radius + moon->radius;
	moon->SetOrbit(*earth, 
		minRadius*2, 
		Vector3(((rand() % 200 + 1) - 100)*.001f, ((rand() % 200 + 1) - 100)*.001f, ((rand() % 200 + 1) - 100)*.001f), 
		0, 
		semiMajLMult);
	moon->Init();
	bodies.push_back(moon);
}
开发者ID:jacobburdecki,项目名称:orbits,代码行数:33,代码来源:Source.cpp

示例2: GenTwoBody

// No leaks
void GenTwoBody()
{
	NUM_BODIES = 2;

	bodies.clear();
	
	Body* x = new Body(1.0f, Vector3(-5.0f, 0.0f, 0.0f), Vector3(0.0f, 0.0f, 0.0f), PLANET, program);
	x->Init();
	bodies.push_back(x);

	Body* y = new Body(1.0f, Vector3(5.0f, 0.0f, 0.0f), Vector3(0.f, 0.001f, -0.005f), PLANET, program);
	y->Init();
	bodies.push_back(y);
}
开发者ID:jacobburdecki,项目名称:orbits,代码行数:15,代码来源:Source.cpp

示例3: Load

void BodyList::Load(const std::string & name)
{
  std::string dir = Config::GetInstance()->GetDataDir() + PATH_SEPARATOR + "body" + PATH_SEPARATOR + name + PATH_SEPARATOR;
  std::string fn = dir + CONFIG_FN;

  XmlReader doc;
  if (!doc.Load(fn)) {
    std::cerr << "Unable to find file " << fn << std::endl;
    return;
  }

  Body * body = new Body(doc.GetRoot(), dir);
  body->Init();
  list[name] = body;
}
开发者ID:Arnaud474,项目名称:Warmux,代码行数:15,代码来源:body_list.cpp

示例4: GenSystem

// No leaks
void GenSystem()
{
	NUM_BODIES = 8;
	Body* p1;
	Body* theSun = new Body(3, Vector3(0, 0, 0), Vector3(0,0,0), SUN, program);
	theSun->Init();
	bodies.push_back(theSun);

	for(int i = 1; i < NUM_BODIES; i++)
	{
		float rankScalar = static_cast<float>(i * 0.1f); // further away a planet is, higher the value

		p1 = new Body((.2f) + ((rand() % 10 + 1) - (5-rankScalar*2.f))*.015f, Vector3(0, 0, 0), Vector3(0,0,0), PLANET, program);
		//p1 = new Body((.2f) + ((rand() % 10 + 1))*.01f, Vector3(0, 0, 0), Vector3(0,0,0), PLANET, program);
		bodies.push_back(p1);
		int semiMajLMult = (rand() % 4 + 1);
		if(semiMajLMult <= 4)
		{
			semiMajLMult = 1;
		}
		else
		{
			semiMajLMult -= 3; // from 0->1
			semiMajLMult *= 4; // from 0->4
			semiMajLMult += 1; // from 1->5
		}
		
		float minRadius;
		if (i > 1)
			minRadius = Vector3::dist(theSun->pos, bodies[i - 1]->pos) + bodies[i-1]->radius + p1->radius;
		else
			minRadius = theSun->radius + p1->radius;

		p1->SetOrbit(*theSun, 
			minRadius + (rand() % 10 + 1)*(rankScalar), 
			Vector3(((rand() % 200 + 1) - 100)*.001f, .9f + ((rand() % 200 + 1) - 100)*.001f, ((rand() % 200 + 1) - 100)*.001f), 
			0, 
			semiMajLMult);
		p1->Init();

		// Clean up
		p1 = nullptr;
	}
	// Clean up
	theSun = nullptr;
}
开发者ID:jacobburdecki,项目名称:orbits,代码行数:47,代码来源:Source.cpp


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