示例#1
0
void ATheHUD::RenderPortrait()
{
  // Draws the portrait of the first selected object
  if( Selected.size() )
  {
    AGameObject* selected = *Selected.begin();
    // Portrait: render last-clicked object to texture zoom back by radius of bounding sphere of clicked object
    FVector camDir( .5f, .5f, -FMath::Sqrt( 2.f ) );
    RenderScreen( rendererIcon, selected->Pos, selected->HitBoundsCylindricalRadius(), camDir );
  }
}
	void PlayerController::Update()
	{
		m_camera.Update();

		if(m_selectedObject)
		{
			Vector3Df camDir(0.0f, 0.0f, -1.0f);
			camDir = m_camera.GetGLViewMatrix().GetTranspose().TransformRotation(camDir);

			m_selectedObject->GetRigidBody().SetPosition(m_camera.GetPosition() + camDir * 50.0f);
			m_selectedObject->GetRigidBody().SetAwakeState(true);
		}
	}
	void PlayerController::KeyDown(int key) 
	{
		if(key == GLFW_KEY_MINUS)
		{
			CollisionPhysicsObject* sphere = m_gameWorld.CreateNewSphere();
			sphere->SetPosition(m_camera.GetPosition());

			Vector3Df camDir(0.0f, 0.0f, -1.0f);
			camDir = m_camera.GetGLViewMatrix().GetTranspose().TransformRotation(camDir);

			sphere->GetRigidBody().AddVelocity(camDir * 300.0f);
		}
		else if(key == GLFW_KEY_EQUAL)
		{
			CollisionPhysicsObject* cube = m_gameWorld.CreateNewCube();
			cube->SetPosition(m_camera.GetPosition());
			cube->GetRigidBody().SetOrientation(Quaternion(Vector3Dd(0.0, 0.9, 0.1), rand()));

			Vector3Df camDir(0.0f, 0.0f, -1.0f);
			camDir = m_camera.GetGLViewMatrix().GetTranspose().TransformRotation(camDir);

			cube->GetRigidBody().AddVelocity(camDir * 300.0f);
		}
	}