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


C++ Spatial::AttachController方法代码示例

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


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

示例1: LoadAndInitializeScene

//----------------------------------------------------------------------------
Node* Game::LoadAndInitializeScene()
{
	Importer importer("Data/Scene/");
	Node* pScene = importer.LoadSceneFromXml("Scene.xml", mspPhysicsWorld);
	if (!pScene)
	{
		return NULL;
	}

	NodeCamera* pCameraNode = pScene->FindChild<NodeCamera>();
	WIRE_ASSERT(pCameraNode /* No Camera in scene.xml */);
	mspSceneCamera = pCameraNode->Get();
	mSortingCuller.SetCamera(mspSceneCamera);

	// The maximum number of objects that are going to be culled is the
	// number of objects we imported. If we don't set the size of the set now,
	// the culler will dynamically increase it during runtime. This is not
	// a big deal, however it is better to avoid memory allocations during the
	// render loop.
	UInt renderObjectCount = importer.GetStatistics()->RenderObjectCount;
	mSortingCuller.SetMaxQuantity(renderObjectCount);

	// Create and configure probe robot controller
	SpatialPtr spRedHealthBar = mspGUI->FindChild("RedHealthBar");
	WIRE_ASSERT(spRedHealthBar /* No RedHealthBar in GUI.xml */);

	Node* pProbeRobotSpatial = DynamicCast<Node>(pScene->FindChild("Probe Robot"));
	WIRE_ASSERT(pProbeRobotSpatial /* No Probe Robot in Scene.xml */);

	// Detach red energy/health bar and attach it robot probe as a billboard
	NodeBillboard* pBillboard = WIRE_NEW NodeBillboard;
	pProbeRobotSpatial->AttachChild(pBillboard);
	Node* pParent = DynamicCast<Node>(spRedHealthBar->GetParent());
	WIRE_ASSERT(pParent);
	pParent->DetachChild(spRedHealthBar);
	pBillboard->AttachChild(spRedHealthBar);

	Spatial* pPlayerSpatial = pScene->FindChild("Player");
	WIRE_ASSERT(pPlayerSpatial /* No Player in Scene.xml */);

	mspProbeRobot = WIRE_NEW ProbeRobot(mspPhysicsWorld, pPlayerSpatial,
		spRedHealthBar);
	pProbeRobotSpatial->AttachController(mspProbeRobot);

	// Create and configure player controller
	mspPlayer = WIRE_NEW Player(mspSceneCamera, mspPhysicsWorld);
	pPlayerSpatial->AttachController(mspPlayer);

 	Spatial* pPlatform = pScene->FindChild("Platform");
  	WIRE_ASSERT(pPlatform /* Platform object missing in scene */);
  	pPlatform->AttachController(WIRE_NEW Elevator(mspPhysicsWorld));

	pScene->Bind(GetRenderer());
	pScene->WarmUpRendering(GetRenderer());

	return pScene;
}
开发者ID:alanhaugen,项目名称:wire3d,代码行数:58,代码来源:Game.cpp


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