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


C++ EntityManager::add方法代码示例

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


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

示例1: main

int main(int argc, char** argv)
{
	EntityManager *em = new EntityManager();

	SphereDetectionComponent* dcCam = new SphereDetectionComponent(1);
	StateComponent* scCam = new StateComponent();
	PhysicComponent* pcCam = new PhysicComponent(dcCam, scCam);
	mat4 projection = glm::perspective(70.0*M_PI / 180.0, 16.0 / 9.0, 0.1, 100.0);
	Camera* cam = new Camera(projection, pcCam);


	SphereDetectionComponent* dc1 = new SphereDetectionComponent(1);
	StateComponent* sc1 = new StateComponent();
	PhysicComponent* pc1 = new PhysicComponent(dc1, sc1);
	GraphicComponent* gc1 = new GraphicComponent();
	Entity* en1 = new Entity(gc1, pc1);
	em->add(en1);

	SphereDetectionComponent* dc2 = new SphereDetectionComponent(1);
	StateComponent* sc2 = new StateComponent();
	PhysicComponent* pc2 = new PhysicComponent(dc2, sc2);
	GraphicComponent* gc2 = new GraphicComponent();
	Entity* en2 = new Entity(gc2, pc2);
	em->add(en2);


	SphereDetectionComponent* dc3 = new SphereDetectionComponent(1);
	StateComponent* sc3 = new StateComponent();
	PhysicComponent* pc3 = new PhysicComponent(dc3, sc3);
	GraphicComponent* gc3 = new GraphicComponent();
	Entity* en3 = new Entity(gc3, pc3);
	em->add(en3);



	for (int i = 0; i < 100; i++)
	{
		en2->getPhysicComponent()->getStateComponent()->setPosition(vec3(0, 0, 5-(float)i/2.0));
		en3->getPhysicComponent()->getStateComponent()->setPosition(vec3(0, 3 - (float)i / 4.0,0));

		em->collision();
		em->update();

		std::set<Contact*> contact_en1 = en1->getPhysicComponent()->getContact();

		int j = 0;
		cout << "frame n " << i << endl;
		for (std::set<Contact*>::iterator it = contact_en1.begin(); it != contact_en1.end(); it++)
		{
			j++;
			cout << "Contact du solide 1 :" << endl;
			cout << "Contact n " << j << " Xpos = " << (*it)->position.x << " Ypos = " << (*it)->position.y << " Zpos = " << (*it)->position.z << endl;
			cout << "Contact n " << j << " Xnor = " << (*it)->normal.x << " Ynor = " << (*it)->normal.y << " Znor = " << (*it)->normal.z << endl;
		}

		cout << endl;

	}


	system("PAUSE");

}
开发者ID:Ruddle,项目名称:Bismuth,代码行数:63,代码来源:Main_Test_Physique.cpp


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