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


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

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


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

示例1: Reset

	void BilliardsDemo::Reset()
	{
		Model* model;
		Body* body;

		// Balls
		float r, g, b;
		for (int i = 0; i < 5; i++)
		{
			for (int j = 0; j < i + 1; j++)
			{
				r = glm::linearRand(0.0f, 1.0f);
				g = glm::linearRand(0.0f, 1.0f);
				b = glm::linearRand(0.0f, 1.0f);
				model = new Sphere(glm::vec3(r, g, b));
				glm::vec3 scale = glm::vec3(1);
				glm::vec3 position = glm::vec3((-i + 2 * j), 3, -1.73*i);
			    glm::quat orientation = glm::quat(1, 0, 0, 0);
				body = new Body(position, orientation, scale);
				body->SetCollider(new SphereCollider(body, scale.x));
				objects.push_back(new Object(model, body));
			}
		}
		model = new Sphere(glm::vec3(1));
	    glm::vec3 scale = glm::vec3(1);
		glm::vec3 position = glm::vec3(0, 3, 16);
		glm::quat orientation = glm::quat(1, 0, 0, 0);
		body = new Body(position, orientation, scale);
		body->SetMass(125);
		body->SetCollider(new SphereCollider(body, scale.x));
		body->SetVelocity(glm::vec3(0, 0, -50));
		objects.push_back(new Object(model, body));
	}
开发者ID:rahul-meda,项目名称:Nitro,代码行数:33,代码来源:BilliardsDemo.cpp

示例2: OnInit

	void BilliardsDemo::OnInit(GLFWwindow* window)
	{
		Scene::OnInit(window);

		Model* model;
		Body* body;

		// Table
		model = new Cube(glm::vec3(0, 0.7, 0));
		glm::vec3 position = glm::vec3(0,1,0);
		glm::vec3 scale = glm::vec3(10, 1, 25);
		glm::quat orientation = glm::quat(1,0,0,0);
		body = new Body(position, orientation, scale);
		body->SetCollider(new BoxCollider(body, scale));
		body->SetStatic();
		objects.push_back(new Object(model, body));
		model = new Cube(glm::vec3(0, 1, 0));
		position = glm::vec3(-10, 1, 0);
		scale = glm::vec3(1, 4, 25);
		orientation = glm::quat(1, 0, 0, 0);
		body = new Body(position, orientation, scale);
		body->SetCollider(new BoxCollider(body, scale));
		body->SetStatic();
		objects.push_back(new Object(model, body));
		model = new Cube(glm::vec3(0, 1, 0));
		position = glm::vec3(10, 1, 0);
		scale = glm::vec3(1, 4, 25);
		orientation = glm::quat(1, 0, 0, 0);
		body = new Body(position, orientation, scale);
		body->SetCollider(new BoxCollider(body, scale));
		body->SetStatic();
		objects.push_back(new Object(model, body));
		model = new Cube(glm::vec3(0, 1, 0));
		position = glm::vec3(0, 1, -25);
		scale = glm::vec3(10, 4, 1);
		orientation = glm::quat(1, 0, 0, 0);
		body = new Body(position, orientation, scale);
		body->SetCollider(new BoxCollider(body, scale));
		body->SetStatic();
		objects.push_back(new Object(model, body));
		model = new Cube(glm::vec3(0, 1, 0));
		position = glm::vec3(0, 1, 25);
		scale = glm::vec3(10, 4, 1);
		orientation = glm::quat(1, 0, 0, 0);
		body = new Body(position, orientation, scale);
		body->SetCollider(new BoxCollider(body, scale));
		body->SetStatic();
		objects.push_back(new Object(model, body));

		Reset();
	}
开发者ID:rahul-meda,项目名称:Nitro,代码行数:51,代码来源:BilliardsDemo.cpp


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