void BulletOpenGLApplication::Keyboard(unsigned char key, int x, int y) {
	// This function is called by FreeGLUT whenever
	// generic keys are pressed down.
	switch(key) {
		// 'z' zooms in
	case 'z': ZoomCamera(+CAMERA_STEP_SIZE); break;
		// 'x' zoom out
	case 'x': ZoomCamera(-CAMERA_STEP_SIZE); break;
	case 'w':
		// toggle wireframe debug drawing
		m_pDebugDrawer->ToggleDebugFlag(btIDebugDraw::DBG_DrawWireframe);
		break;

	case 'b':
		// toggle AABB debug drawing
		m_pDebugDrawer->ToggleDebugFlag(btIDebugDraw::DBG_DrawAabb);
		break;
 	case 'd':
 		{
 			// create a temp object to store the raycast result
 			RayResult result;
 			// perform the raycast
 			if (!Raycast(m_cameraPosition, GetPickingRay(x, y), result))
 				return; // return if the test failed
 			// destroy the corresponding game object
 			DestroyGameObject(result.pBody);
 			break;
 		}
	}
}
	virtual void DestroyGameObject( const char* name )
	{
		IEntitySystem* pEntitySystem = PerModuleInterface::g_pSystemTable->pEntitySystem;
		IAUEntity* pEnt = pEntitySystem->Get(name);
		if (pEnt)
		{
			DestroyGameObject( pEnt->GetObject()->GetObjectId() );
		}
	}
Esempio n. 3
0
void NeoScene::DestroyGameObject(int goId, bool removeChild)
{
	std::unordered_map<int, GameObject*>::iterator goIter =
			list_gameObjects.find(goId);
	if (goIter != list_gameObjects.end())
	{
		GameObject*go = goIter->second;
		DestroyGameObject(go,removeChild);
	}
}
Esempio n. 4
0
void NeoScene::DestroyGameObject(GameObject* go, bool removeChild)
{
	if (removeChild)
	{
		std::set<GameObject*> childList = go->GetChidren();
		for (std::set<GameObject*>::iterator iter = childList.begin();
				iter != childList.end(); iter++)
		{
			DestroyGameObject(*iter , removeChild);
		}
	}
	list_gameObjects.erase(go->getId());
	delete go;
}