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


C++ ModelFactory::createCubeMesh方法代码示例

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


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

示例1: CreatePrismRectangleCube

void CreatePrismRectangleCube(SimpleTree& _rRoot, const Matrix44& _rTransformation)
{
	Entity* pPrismRectangleCube = new Entity();
	ModelFactory* pFactory = ModelFactory::getInstance();

	SimpleTree* pRootNode = new SimpleTree;
	pRootNode->setTransformation(_rTransformation);
	_rRoot.addChild(pRootNode);

	Model* pCube = pFactory->createCubeMesh(5.0f, Vector4(0.0f, 1.0f, 0.0f, 1.0f));
	pCube->setMaterial(CreatePrismRectangleCubeModelMaterial());
	pPrismRectangleCube->addComponent(pCube);
	pCube->setEntity(pPrismRectangleCube);

	SimpleTree* pCubeNode = new SimpleTree;
	pCubeNode->setModel(pCube);
	pRootNode->addChild(pCubeNode);

	Body* pCubeBody = PhysicsFactory::getInstance()->createBody(CreateObstacleBodyMaterial(), pCube,
		pCubeNode->getAbsoluteTransformation(), false);
	//static_cast<BulletBody*>(pCubeBody)->setNode(pCubeNode);
	static_cast<PhysXBody*>(pCubeBody)->setNode(pCubeNode);
	pPrismRectangleCube->addComponent(pCubeBody);
	pCubeBody->setEntity(pPrismRectangleCube);

	//Model* pSquare0 = pFactory->createSquareMesh(5.0f, Vector4(1.0f, 1.0f, 0.0f, 1.0f), true);
	Model* pSquare0 = pFactory->createBoxMesh(5.0f, 5.0f, 0.1f, Vector4(1.0f, 1.0f, 0.0f, 1.0f), true);
	pSquare0->setMaterial(CreatePrismRectangleCubeModelMaterial());
	pPrismRectangleCube->addComponent(pSquare0);
	pSquare0->setEntity(pPrismRectangleCube);

	SimpleTree* pSquare0Node = new SimpleTree;
	//getTranslation3(pSquare0Node->getTransformation()).Y() = 5.0f;
	getTranslation3(pSquare0Node->getTransformation()).Y() = 4.9f;
	getTranslation3(pSquare0Node->getTransformation()).Z() = 10.0f;
	pSquare0Node->setModel(pSquare0);
	pRootNode->addChild(pSquare0Node);

	Body* pSquare0Body = PhysicsFactory::getInstance()->createBody(CreateObstacleBodyMaterial(), pSquare0,
		pSquare0Node->getAbsoluteTransformation(), false);
	//static_cast<BulletBody*>(pSquare0Body)->setNode(pSquare0Node);
	static_cast<PhysXBody*>(pSquare0Body)->setNode(pSquare0Node);
	pPrismRectangleCube->addComponent(pSquare0Body);
	pSquare0Body->setEntity(pPrismRectangleCube);

	Model* pPrism0 = pFactory->createPrismMesh(5.0f, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
	pPrism0->setMaterial(CreatePrismRectangleCubeModelMaterial());
	pPrismRectangleCube->addComponent(pPrism0);
	pPrism0->setEntity(pPrismRectangleCube);

	SimpleTree* pPrism0Node = new SimpleTree;
	rotate(pPrism0Node->getTransformation(), Math::PI, Vector4(0.0f, 1.0f, 0.0f, 1.0f));
	getTranslation3(pPrism0Node->getTransformation()).Z() = 20.0f;
	pPrism0Node->setModel(pPrism0);
	pRootNode->addChild(pPrism0Node);

	Body* pPrism0Body = PhysicsFactory::getInstance()->createBody(CreateObstacleBodyMaterial(), pPrism0,
		pPrism0Node->getAbsoluteTransformation(), false);
	//static_cast<BulletBody*>(pPrism0Body)->setNode(pPrism0Node);
	static_cast<PhysXBody*>(pPrism0Body)->setNode(pPrism0Node);
	pPrismRectangleCube->addComponent(pPrism0Body);
	pPrism0Body->setEntity(pPrismRectangleCube);

	//Model* pSquare1 = pFactory->createSquareMesh(5.0f, Vector4(1.0f, 1.0f, 0.0f, 1.0f), true);
	Model* pSquare1 = pFactory->createBoxMesh(5.0f, 5.0f, 0.1f, Vector4(1.0f, 1.0f, 0.0f, 1.0f), true);
	pSquare1->setMaterial(CreatePrismRectangleCubeModelMaterial());
	pPrismRectangleCube->addComponent(pSquare1);
	pSquare1->setEntity(pPrismRectangleCube);

	SimpleTree* pSquare1Node = new SimpleTree;
	//getTranslation3(pSquare1Node->getTransformation()).Y() = 5.0f;
	getTranslation3(pSquare1Node->getTransformation()).Y() = 4.9f;
	getTranslation3(pSquare1Node->getTransformation()).Z() = -10.0f;
	pSquare1Node->setModel(pSquare1);
	pRootNode->addChild(pSquare1Node);

	Body* pSquare1Body = PhysicsFactory::getInstance()->createBody(CreateObstacleBodyMaterial(), pSquare1,
		pSquare1Node->getAbsoluteTransformation(), false);
	//static_cast<BulletBody*>(pSquare1Body)->setNode(pSquare1Node);
	static_cast<PhysXBody*>(pSquare1Body)->setNode(pSquare1Node);
	pPrismRectangleCube->addComponent(pSquare1Body);
	pSquare1Body->setEntity(pPrismRectangleCube);

	Model* pPrism1 = pFactory->createPrismMesh(5.0f, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
	pPrism1->setMaterial(CreatePrismRectangleCubeModelMaterial());
	pPrismRectangleCube->addComponent(pPrism1);
	pPrism1->setEntity(pPrismRectangleCube);

	SimpleTree* pPrism1Node = new SimpleTree;
	getTranslation3(pPrism1Node->getTransformation()).Z() = -20.0f;
	pPrism1Node->setModel(pPrism1);
	pRootNode->addChild(pPrism1Node);

	Body* pPrism1Body = PhysicsFactory::getInstance()->createBody(CreateObstacleBodyMaterial(), pPrism1,
		pPrism1Node->getAbsoluteTransformation(), false);
	//static_cast<BulletBody*>(pPrism1Body)->setNode(pPrism1Node);
	static_cast<PhysXBody*>(pPrism1Body)->setNode(pPrism1Node);
	pPrismRectangleCube->addComponent(pPrism1Body);
	pPrism1Body->setEntity(pPrismRectangleCube);

//.........这里部分代码省略.........
开发者ID:roosen5,项目名称:media-design-school,代码行数:101,代码来源:Scene.cpp


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