本文整理汇总了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_;
}
}
示例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);
}
}
示例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);
//.........这里部分代码省略.........
示例4: Initialize
GRAPHICSDLL_API void CameraController::Initialize()
{
Input* input = (Input*)Engine::GetCore()->GetSystem(ST_Input);
InputHandler* handler = input->GetHandler();
}