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


C++ Input::GetHandler方法代码示例

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


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

示例1: Update

  void Graphics::Update(float dt)
  {
    recompile_timer_ += dt;
    if(recompile_timer_ > 2.0f)
    {
      RecompileShaders();
      recompile_timer_ = 0.0f;
    }
    
    particle_manager_->Update(dt);
    camera_->Orient();
    Render();

    Input* input = (Input*) Engine::GetCore()->GetSystem(ST_Input);
    InputHandler* handler = input->GetHandler();
    if(handler->Check("UIToggle"))
    {
      draw_ui_ = !draw_ui_;
    }

  }
开发者ID:Marktopus,项目名称:WickedSickSingle,代码行数:21,代码来源:Graphics.cpp

示例2: Update

  void ModelComponent::Update(float dt)
  {
    Graphics* gSys = (Graphics*)Engine::GetCore()->GetSystem(ST_Graphics);
    gSys->AddDebugModel(this);

    Input* input = (Input*) Engine::GetCore()->GetSystem(ST_Input);
    InputHandler* handler = input->GetHandler();
    Transform* tr = (Transform*)GetSibling(CT_Transform);
    PhysicsComponent* phys = (PhysicsComponent*) GetSibling(CT_PhysicsComponent);
    if(handler->Check("MoveRight"))
    {
      tr->SetPosition(tr->GetPosition() + Vector3(1.0f,0.0f,0.0f) * dt);
      phys->Reset();
    }
    Model* newModel = gSys->GetModel(model_);
    if(newModel && base_ != newModel)
    {
      base_->RemoveInstance(this);
      base_ = newModel;
      base_->AddInstance(this);
    }


  }
开发者ID:Marktopus,项目名称:WickedSickSingle,代码行数:24,代码来源:ModelComponent.cpp

示例3: Update

  GRAPHICSDLL_API void CameraController::Update(float dt)
  {
    Input* input = (Input*)Engine::GetCore()->GetSystem(ST_Input);
    InputHandler* handler = input->GetHandler();

    
    if (handler->Check("Rotate"))
    {
      if(last_mouse_pos_ == Vector2i(-1, -1))
      {
        last_mouse_pos_ = handler->GetMousePos();
      }
      else if(handler->GetMousePos() != last_mouse_pos_)
      {
        Vector2i curPos = handler->GetMousePos();
        Vector2 amountToRotate = (curPos - last_mouse_pos_).to_f() * dt;
        CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
        Vector3 lookAt = cameraComp->GetLookAt();
        Transform* tr = (Transform*)GetSibling(CT_Transform);
        Vector3 view = lookAt - tr->GetPosition();
        view.Normalize();
        
        
        view = RotateAround(Vector3(0, 1, 0), amountToRotate.x, view);
        view.Normalize();
        Vector3 right = Vector3(0,1,0).Cross(view);
        right.Normalize();
        view = RotateAround(right, amountToRotate.y, view);

        
        lookAt = (tr->GetPosition() + view);


        cameraComp->SetLookAt(lookAt);
        last_mouse_pos_ = Vector2i(-1, -1);
      }
    }
    else if(handler->Check("Move"))
    {
      if (last_mouse_pos_ == Vector2i(-1, -1))
      {
        last_mouse_pos_ = handler->GetMousePos();
      }
      else if (handler->GetMousePos() != last_mouse_pos_)
      {
        Vector2i curPos = handler->GetMousePos();
        Vector2 amountToMove = (curPos - last_mouse_pos_).to_f() * dt;
        CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
        Vector3 lookAt = cameraComp->GetLookAt();
        Transform* tr = (Transform*)GetSibling(CT_Transform);

        Vector3 view = lookAt - tr->GetPosition();
        view.Normalize();
        Vector3 right = Vector3(0.0f,1.0f,0.0f).Cross(view);
        right.Normalize();
        Vector3 up = view.Cross(right);
        up.Normalize();

        Vector3 pos = tr->GetPosition();
        amountToMove *= 5.0f;
        pos += right * -amountToMove.x;
        pos += up * amountToMove.y;

        lookAt += right * -amountToMove.x;
        lookAt += up * amountToMove.y;
        tr->SetPosition(pos);
        cameraComp->SetLookAt(lookAt);

        last_mouse_pos_ = Vector2i(-1, -1);
      }
    }
    else if (handler->Check("ZoomIn"))
    {
      CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
      Vector3 lookAt = cameraComp->GetLookAt();
      Transform* tr = (Transform*)GetSibling(CT_Transform);
      Vector3 view = lookAt - tr->GetPosition();
      view.Normalize();
      view *= dt;
      tr->SetPosition(tr->GetPosition() += view );
      cameraComp->SetLookAt(lookAt += view );
      
    }
    else if (handler->Check("ZoomOut"))
    {
      CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
      Vector3 lookAt = cameraComp->GetLookAt();
      Transform* tr = (Transform*)GetSibling(CT_Transform);
      Vector3 view = lookAt - tr->GetPosition();
      view.Normalize();
      view *= dt;
      tr->SetPosition(tr->GetPosition() -= view);
      cameraComp->SetLookAt(lookAt -= view);

    }
    else if (handler->GetScrollPos())
    {
      CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
      Vector3 lookAt = cameraComp->GetLookAt();
      Transform* tr = (Transform*)GetSibling(CT_Transform);
//.........这里部分代码省略.........
开发者ID:Marktopus,项目名称:WickedSickEngine,代码行数:101,代码来源:CameraController.cpp

示例4: Initialize

 GRAPHICSDLL_API void CameraController::Initialize()
 {
   Input* input = (Input*)Engine::GetCore()->GetSystem(ST_Input);
   InputHandler* handler = input->GetHandler();
   
 }
开发者ID:Marktopus,项目名称:WickedSickEngine,代码行数:6,代码来源:CameraController.cpp


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