Пример #1
0
void SampleGameApp::UpdateInput(ezTime UpdateDiff)
{
  ezInputManager::Update(UpdateDiff);

  if (ezInputManager::GetInputActionState("Main", "CloseApp") == ezKeyState::Pressed)
    m_bActiveRenderLoop = false;

  float f;
  float fCamSpeed = 15.0f;
  const float fCamRotSpeed = 140.0f;

  if (ezInputManager::GetInputActionState("Game", "CamMoveFast", &f) != ezKeyState::Up)
    fCamSpeed *= 3;

  if (ezInputManager::GetInputActionState("Game", "CamRotateLeft", &f) != ezKeyState::Up)
    m_Camera.RotateGlobally(ezAngle(), ezAngle::Degree(+f * fCamRotSpeed), ezAngle());

  if (ezInputManager::GetInputActionState("Game", "CamRotateRight", &f) != ezKeyState::Up)
    m_Camera.RotateGlobally(ezAngle(), ezAngle::Degree(-f * fCamRotSpeed), ezAngle());

  if (ezInputManager::GetInputActionState("Game", "CamRotateUp", &f) != ezKeyState::Up)
    m_Camera.RotateLocally(ezAngle::Degree(+f * fCamRotSpeed), ezAngle(), ezAngle());

  if (ezInputManager::GetInputActionState("Game", "CamRotateDown", &f) != ezKeyState::Up)
    m_Camera.RotateLocally(ezAngle::Degree(-f * fCamRotSpeed), ezAngle(), ezAngle());

  if (ezInputManager::GetInputActionState("Game", "CamMoveLeft", &f) != ezKeyState::Up)
    m_Camera.MoveLocally(ezVec3(-f * fCamSpeed, 0, 0));

  if (ezInputManager::GetInputActionState("Game", "CamMoveRight", &f) != ezKeyState::Up)
    m_Camera.MoveLocally(ezVec3(+f * fCamSpeed, 0, 0));

  if (ezInputManager::GetInputActionState("Game", "CamMoveUp", &f) != ezKeyState::Up)
    m_Camera.MoveGlobally(ezVec3(0, +f * fCamSpeed, 0));

  if (ezInputManager::GetInputActionState("Game", "CamMoveDown", &f) != ezKeyState::Up)
    m_Camera.MoveGlobally(ezVec3(0, -f * fCamSpeed, 0));

  if (ezInputManager::GetInputActionState("Game", "CamMoveForwards", &f) != ezKeyState::Up)
    m_Camera.MoveLocally(ezVec3(0, 0, -f * fCamSpeed));

  if (ezInputManager::GetInputActionState("Game", "CamMoveBackwards", &f) != ezKeyState::Up)
    m_Camera.MoveLocally(ezVec3(0, 0, +f * fCamSpeed));

  if (ezInputManager::GetInputActionState("Game", "SelectUnit", &f) == ezKeyState::Pressed)
    SelectUnit();

  if (ezInputManager::GetInputActionState("Game", "SendUnit", &f) == ezKeyState::Pressed)
    SendUnit();

  if (ezInputManager::GetInputActionState("Game", "UnitLarger", &f) == ezKeyState::Pressed)
    RevealerComponent::g_fDefaultRadius += 1.0f;

  if (ezInputManager::GetInputActionState("Game", "UnitSmaller", &f) == ezKeyState::Pressed)
    RevealerComponent::g_fDefaultRadius -= 1.0f;

}
Пример #2
0
ezAngle ezCamera::GetFovX(float fAspectRatioWidthDivHeight) const
{
  if (m_Mode == PerspectiveFixedFovX)
    return ezAngle::Degree(m_fFovOrDim);

  if (m_Mode == PerspectiveFixedFovY)
    return ezAngle::Degree(m_fFovOrDim) * fAspectRatioWidthDivHeight;

  EZ_REPORT_FAILURE("You cannot get the camera FOV when it is not a perspective camera.");
  return ezAngle();
}
Пример #3
0
ezEditorInput ezConeAngleGizmo::DoMouseMoveEvent(QMouseEvent* e)
{
  if (!IsActiveInputContext())
    return ezEditorInput::MayBeHandledByOthers;

  const ezTime tNow = ezTime::Now();

  if (tNow - m_LastInteraction < ezTime::Seconds(1.0 / 25.0))
    return ezEditorInput::WasExclusivelyHandled;

  m_LastInteraction = tNow;

  const ezVec2I32 vNewMousePos = ezVec2I32(e->globalPos().x(), e->globalPos().y());
  const ezVec2I32 vDiff = vNewMousePos - m_LastMousePos;

  m_LastMousePos = UpdateMouseMode(e);

  const float fSpeed = 0.02f;
  const ezAngle aSpeed = ezAngle::Degree(1.0f);

  {
    m_Angle += vDiff.x * aSpeed;
    m_Angle -= vDiff.y * aSpeed;

    m_Angle = ezMath::Clamp(m_Angle, ezAngle(), ezAngle::Degree(179.0f));

    m_fAngleScale = ezMath::Tan(m_Angle * 0.5f);
  }

  // update the scale
  OnTransformationChanged(GetTransformation());

  ezGizmoEvent ev;
  ev.m_pGizmo = this;
  ev.m_Type = ezGizmoEvent::Type::Interaction;
  m_GizmoEvents.Broadcast(ev);

  return ezEditorInput::WasExclusivelyHandled;
}