本文整理汇总了C++中Input::GetMouseMove方法的典型用法代码示例。如果您正苦于以下问题:C++ Input::GetMouseMove方法的具体用法?C++ Input::GetMouseMove怎么用?C++ Input::GetMouseMove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::GetMouseMove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MoveCamera
void RenderToTexture::MoveCamera(float timeStep)
{
// Do not move if the UI has a focused element (the console)
if (GetSubsystem<UI>()->GetFocusElement())
return;
Input* input = GetSubsystem<Input>();
// Movement speed as world units per second
const float MOVE_SPEED = 20.0f;
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if (input->GetKeyDown('W'))
cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
if (input->GetKeyDown('S'))
cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
if (input->GetKeyDown('A'))
cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
if (input->GetKeyDown('D'))
cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
}
示例2: MoveCamera
void SignedDistanceFieldText::MoveCamera(float timeStep)
{
// Do not move if the UI has a focused element (the console)
if (GetContext()->m_UISystem.get()->GetFocusElement())
return;
Input* input = GetContext()->m_InputSystem.get();
// Movement speed as world units per second
const float MOVE_SPEED = 20.0f;
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
// Use the Translate() function (default local space) to move relative to the node's orientation.
if (input->GetKeyDown(KEY_W))
cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_S))
cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_A))
cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_D))
cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
}
示例3: MoveCamera
void DynamicGeometry::MoveCamera(float timeStep)
{
Input* input = GetSubsystem<Input>();
// Movement speed as world units per second
const float MOVE_SPEED = 20.0f;
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if (input->GetKeyDown(KEY_W))
cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_S))
cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_A))
cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_D))
cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
}
示例4: MoveCamera
void World::MoveCamera(float timeStep)
{
static float yaw_ = 0.0f;
static float pitch_ = 0.0f;
Input* input = context->GetSubsystem<Input>();
const float MOVE_SPEED = 20.0f;
const float MOUSE_SENSITIVITY = 0.1f;
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
camera.node->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
Quaternion camRotation = camera.node->GetWorldRotation();
camRotation.z_ = 0.0f;
Vector3 dir = Vector3::ZERO;
if (input->GetKeyDown('W'))
dir += Vector3::FORWARD;
if (input->GetKeyDown('S'))
dir += Vector3::BACK;
if (input->GetKeyDown('A'))
dir += Vector3::LEFT;
if (input->GetKeyDown('D'))
dir += Vector3::RIGHT;
if (input->GetKeyDown(KEY_SPACE))
{
dir += Vector3::UP;
}
if (dir.Length() > 0)
{
Vector3 curVel = player.body->GetLinearVelocity();
if (curVel.Length() < 5.0f)
{
float multipler = 1.0f;
//if (input->GetQualifierDown(KEY_SHIFT))
if (input->GetKeyDown(KEY_LSHIFT))
{
multipler = 2.0f;
}
player.body->SetLinearVelocity(multipler * 200.0f * (camRotation * dir) * timeStep);
}
}
}
示例5: MoveCamera
void Physics::MoveCamera(float timeStep)
{
// Do not move if the UI has a focused element (the console)
if (GetSubsystem<UI>()->GetFocusElement())
return;
Input* input = GetSubsystem<Input>();
// Movement speed as world units per second
const float MOVE_SPEED = 20.0f;
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if (input->GetKeyDown(KEY_W))
cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_S))
cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_A))
cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_D))
cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
// "Shoot" a physics object with left mousebutton
if (input->GetMouseButtonPress(MOUSEB_LEFT))
SpawnObject();
// Check for loading/saving the scene. Save the scene to the file Data/Scenes/Physics.xml relative to the executable
// directory
if (input->GetKeyPress(KEY_F5))
{
File saveFile(context_, GetSubsystem<FileSystem>()->GetProgramDir() + "Data/Scenes/Physics.xml", FILE_WRITE);
scene_->SaveXML(saveFile);
}
if (input->GetKeyPress(KEY_F7))
{
File loadFile(context_, GetSubsystem<FileSystem>()->GetProgramDir() + "Data/Scenes/Physics.xml", FILE_READ);
scene_->LoadXML(loadFile);
}
// Toggle physics debug geometry with space
if (input->GetKeyPress(KEY_SPACE))
drawDebug_ = !drawDebug_;
}
示例6: Clamp
void SceneView3D::MoveCamera(float timeStep)
{
if (!enabled_)
return;
Input* input = GetSubsystem<Input>();
// Movement speed as world units per second
float MOVE_SPEED = 20.0f;
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.2f;
if (input->GetKeyDown(KEY_LSHIFT) || input->GetKeyDown(KEY_RSHIFT))
MOVE_SPEED *= 3.0f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
if (input->GetMouseButtonDown(MOUSEB_RIGHT))
{
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
// Not working on OSX
//input->SetMouseMode(MM_RELATIVE);
}
else
{
// Not working on OSX
/*
if (input->GetMouseMode() != MM_ABSOLUTE)
input->SetMouseMode(MM_ABSOLUTE);
*/
}
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
//Vector3 pos = cameraNode_->GetWorldPosition();
//Quaternion q = cameraNode_->GetWorldRotation();
//LOGINFOF("%f %f %f : %f %f %f %f", pos.x_, pos.y_, pos.z_, q.x_, q.y_, q.z_, q.w_ );
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
// Use the Translate() function (default local space) to move relative to the node's orientation.
if (input->GetKeyDown('W'))
cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
if (input->GetKeyDown('S'))
cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
if (input->GetKeyDown('A'))
cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
if (input->GetKeyDown('D'))
cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
}
示例7: MoveCamera
void Navigation::MoveCamera(float timeStep)
{
// Right mouse button controls mouse cursor visibility: hide when pressed
UI* ui = GetSubsystem<UI>();
Input* input = GetSubsystem<Input>();
ui->GetCursor()->SetVisible(!input->GetMouseButtonDown(MOUSEB_RIGHT));
// Do not move if the UI has a focused element (the console)
if (ui->GetFocusElement())
return;
// Movement speed as world units per second
const float MOVE_SPEED = 20.0f;
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
// Only move the camera when the cursor is hidden
if (!ui->GetCursor()->IsVisible())
{
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
}
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if (input->GetKeyDown('W'))
cameraNode_->TranslateRelative(Vector3::FORWARD * MOVE_SPEED * timeStep);
if (input->GetKeyDown('S'))
cameraNode_->TranslateRelative(Vector3::BACK * MOVE_SPEED * timeStep);
if (input->GetKeyDown('A'))
cameraNode_->TranslateRelative(Vector3::LEFT * MOVE_SPEED * timeStep);
if (input->GetKeyDown('D'))
cameraNode_->TranslateRelative(Vector3::RIGHT * MOVE_SPEED * timeStep);
// Set route start/endpoint with left mouse button, recalculate route if applicable
if (input->GetMouseButtonPress(MOUSEB_LEFT))
SetPathPoint();
// Add or remove objects with middle mouse button, then rebuild navigation mesh partially
if (input->GetMouseButtonPress(MOUSEB_MIDDLE))
AddOrRemoveObject();
// Toggle debug geometry with space
if (input->GetKeyPress(KEY_SPACE))
drawDebug_ = !drawDebug_;
}
示例8: Update
void DebugCameraController::Update(float timeStep)
{
// Do not move if the UI has a focused element
if (GetUI()->GetFocusElement())
return;
// Do not move if interacting with UI controls
if (GetSystemUI()->IsAnyItemActive())
return;
Input* input = GetInput();
// Movement speed as world units per second
float moveSpeed_ = speed_;
if (input->GetKeyDown(KEY_SHIFT))
{
moveSpeed_ *= 2;
if (input->GetKeyPress(KEY_KP_PLUS))
speed_ += 1.f;
else if (input->GetKeyPress(KEY_KP_MINUS))
speed_ -= 1.f;
}
if (input->GetMouseButtonDown(MOUSEB_RIGHT))
{
IntVector2 delta = input->GetMouseMove();
if (input->IsMouseVisible() && delta != IntVector2::ZERO)
input->SetMouseVisible(false);
auto yaw = GetNode()->GetRotation().EulerAngles().x_;
if ((yaw > -90.f && yaw < 90.f) || (yaw <= -90.f && delta.y_ > 0) || (yaw >= 90.f && delta.y_ < 0))
GetNode()->RotateAround(Vector3::ZERO, Quaternion(mouseSensitivity_ * delta.y_, Vector3::RIGHT), TS_LOCAL);
GetNode()->RotateAround(GetNode()->GetPosition(), Quaternion(mouseSensitivity_ * delta.x_, Vector3::UP), TS_WORLD);
}
else if (!input->IsMouseVisible())
input->SetMouseVisible(true);
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if (input->GetKeyDown(KEY_W))
GetNode()->Translate(Vector3::FORWARD * moveSpeed_ * timeStep);
if (input->GetKeyDown(KEY_S))
GetNode()->Translate(Vector3::BACK * moveSpeed_ * timeStep);
if (input->GetKeyDown(KEY_A))
GetNode()->Translate(Vector3::LEFT * moveSpeed_ * timeStep);
if (input->GetKeyDown(KEY_D))
GetNode()->Translate(Vector3::RIGHT * moveSpeed_ * timeStep);
}
示例9: if
void DebugCameraController2D::Update(float timeStep)
{
// Do not move if the UI has a focused element
if (GetUI()->GetFocusElement())
return;
// Do not move if interacting with UI controls
if (GetSystemUI()->IsAnyItemActive())
return;
Input* input = GetInput();
// Movement speed as world units per second
float moveSpeed_ = speed_;
if (input->GetKeyDown(KEY_SHIFT))
{
moveSpeed_ *= 2;
if (input->GetKeyPress(KEY_KP_PLUS))
speed_ += 1.f;
else if (input->GetKeyPress(KEY_KP_MINUS))
speed_ -= 1.f;
}
if (input->GetMouseButtonDown(MOUSEB_RIGHT))
{
IntVector2 delta = input->GetMouseMove();
if (input->IsMouseVisible() && delta != IntVector2::ZERO)
input->SetMouseVisible(false);
GetNode()->Translate2D(Vector2{(float)delta.x_ * -1.f, (float)delta.y_} * moveSpeed_ * timeStep);
}
else if (!input->IsMouseVisible())
input->SetMouseVisible(true);
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if (input->GetKeyDown(KEY_W))
GetNode()->Translate(Vector3::UP * moveSpeed_ * timeStep);
if (input->GetKeyDown(KEY_S))
GetNode()->Translate(Vector3::DOWN * moveSpeed_ * timeStep);
if (input->GetKeyDown(KEY_A))
GetNode()->Translate(Vector3::LEFT * moveSpeed_ * timeStep);
if (input->GetKeyDown(KEY_D))
GetNode()->Translate(Vector3::RIGHT * moveSpeed_ * timeStep);
}
示例10: HandleSceneUpdate
void CameraMaster::HandleSceneUpdate(StringHash /* eventType */, VariantMap &eventData)
{
using namespace Update;
//Take the frame time step, which is stored as a double
double timeStep = eventData[P_TIMESTEP].GetFloat();
//Movement speed as world units per second
const double MOVE_SPEED = 2000.0;
//Mouse sensitivity as degrees per pixel
const double MOUSE_SENSITIVITY = 0.1;
//Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees. Only move the camera when the cursor is hidden.
Input* input = GetSubsystem<Input>();
IntVector2 mouseMove = input->GetMouseMove();
yawDelta_ = 0.5*(yawDelta_ + MOUSE_SENSITIVITY * mouseMove.x_);
pitchDelta_ = 0.5*(pitchDelta_ + MOUSE_SENSITIVITY * mouseMove.y_);
yaw_ += yawDelta_;
pitch_ += pitchDelta_;
pitch_ = Clamp(pitch_, -89.0, 89.0);
//Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
translationNode_->SetRotation(Quaternion(0.0f, 0.0f, 0.0f));
rotationNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
//Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
Vector3 camForce = Vector3::ZERO;
if (input->GetKeyDown('W')) camForce += Scale(rotationNode_->GetDirection(), Vector3(1.0f,0.0f,1.0f) ).Normalized();
if (input->GetKeyDown('S')) camForce += Scale(rotationNode_->GetDirection(), Vector3(-1.0f,0.0f,-1.0f) ).Normalized();
if (input->GetKeyDown('D')) camForce += Scale(rotationNode_->GetRight(), Vector3(1.0f,0.0f,1.0f) ).Normalized();
if (input->GetKeyDown('A')) camForce += Scale(rotationNode_->GetRight(), Vector3(-1.0f,0.0f,-1.0f) ).Normalized();
if (input->GetKeyDown('E')) camForce += Vector3::UP;
if (input->GetKeyDown('Q') && translationNode_->GetPosition().y_ > 1.0f) camForce += Vector3::DOWN;
camForce = camForce.Normalized() * MOVE_SPEED * timeStep;
if ( forceMultiplier < 8.0 && (input->GetKeyDown(KEY_LSHIFT)||input->GetKeyDown(KEY_RSHIFT)) ) {
forceMultiplier += 0.23;
} else forceMultiplier = pow(forceMultiplier, 0.75);
rigidBody_->ApplyForce( (forceMultiplier * camForce) - (2.3f * rigidBody_->GetLinearVelocity()) );
if (translationNode_->GetPosition().y_ < 1.0f)
{
translationNode_->SetPosition(Vector3(translationNode_->GetPosition().x_, 1.0f, translationNode_->GetPosition().z_));
rigidBody_->SetLinearVelocity(Vector3(rigidBody_->GetLinearVelocity().x_, 0.0f, rigidBody_->GetLinearVelocity().z_));
}
}
示例11: MoveCamera
void MultipleViewports::MoveCamera(float timeStep)
{
// Do not move if the UI has a focused element (the console)
if (GetSubsystem<UI>()->GetFocusElement())
return;
Input* input = GetSubsystem<Input>();
// Movement speed as world units per second
const float MOVE_SPEED = 20.0f;
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if (input->GetKeyDown('W'))
cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
if (input->GetKeyDown('S'))
cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
if (input->GetKeyDown('A'))
cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
if (input->GetKeyDown('D'))
cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
// Toggle post processing effects on the front viewport. Note that the rear viewport is unaffected
RenderPath* effectRenderPath = GetSubsystem<Renderer>()->GetViewport(0)->GetRenderPath();
if (input->GetKeyPress('B'))
effectRenderPath->ToggleEnabled("Bloom");
if (input->GetKeyPress('F'))
effectRenderPath->ToggleEnabled("FXAA2");
// Toggle debug geometry with space
if (input->GetKeyPress(KEY_SPACE))
drawDebug_ = !drawDebug_;
}
示例12: Clamp
void Urho3DTemplate::MoveCamera(float timeStep)
{
//Right mouse button controls mouse cursor visibility: hide when pressed
UI* ui = GetSubsystem<UI>();
Input* input = GetSubsystem<Input>();
ui->GetCursor()->SetVisible(!input->GetMouseButtonDown(MOUSEB_RIGHT));
//Do not move if the UI has a focused element (the console)
if (ui->GetFocusElement())
return;
//Movement speed as world units per second
const float MOVE_SPEED = 20.0f;
//Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
//Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees. Only move the camera when the cursor is hidden.
if (!ui->GetCursor()->IsVisible())
{
IntVector2 mouseMove = input->GetMouseMove();
cameraYaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
cameraPitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
cameraPitch_ = Clamp(cameraPitch_, -90.0f, 90.0f);
//Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(cameraPitch_, cameraYaw_, 0.0f));
}
//Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if (input->GetKeyDown('W'))
cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
if (input->GetKeyDown('S'))
cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
if (input->GetKeyDown('A'))
cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
if (input->GetKeyDown('D'))
cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
//Add or remove objects with left mouse button
if (input->GetMouseButtonPress(MOUSEB_LEFT))
AddOrRemoveObject();
}
示例13: CameraViewRotate
void UrhoQuickStart::CameraViewRotate(float timeStep)
{
Input* input = GetSubsystem<Input>();
// Movement speed as world units per second
const float MOVE_SPEED = 800.0f;
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
//yaw_ = Clamp(yaw_, -720.0f, 720.0f);
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetWorldRotation(Quaternion(pitch_, yaw_, 0.0f));
}
示例14: MoveCamera
void SceneReplication::MoveCamera()
{
// Right mouse button controls mouse cursor visibility: hide when pressed
UI* ui = GetSubsystem<UI>();
Input* input = GetSubsystem<Input>();
ui->GetCursor()->SetVisible(!input->GetMouseButtonDown(MOUSEB_RIGHT));
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch and only move the camera
// when the cursor is hidden
if (!ui->GetCursor()->IsVisible())
{
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, 1.0f, 90.0f);
}
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
// Only move the camera / show instructions if we have a controllable object
bool showInstructions = false;
if (clientObjectID_)
{
Node* ballNode = scene_->GetNode(clientObjectID_);
if (ballNode)
{
const float CAMERA_DISTANCE = 5.0f;
// Move camera some distance away from the ball
cameraNode_->SetPosition(ballNode->GetPosition() + cameraNode_->GetRotation() * Vector3::BACK * CAMERA_DISTANCE);
showInstructions = true;
}
}
instructionsText_->SetVisible(showInstructions);
}
示例15: MoveCamera
void Water::MoveCamera(float timeStep)
{
// Do not move if the UI has a focused element (the console)
if (GetContext()->m_UISystem.get()->GetFocusElement())
return;
Input* input = GetContext()->m_InputSystem.get();
// Movement speed as world units per second
const float MOVE_SPEED = 20.0f;
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if (input->GetKeyDown(KEY_W))
cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_S))
cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_A))
cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_D))
cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
// In case resolution has changed, adjust the reflection camera aspect ratio
Graphics* graphics = GetContext()->m_Graphics.get();
Camera* reflectionCamera = reflectionCameraNode_->GetComponent<Camera>();
reflectionCamera->SetAspectRatio((float)graphics->GetWidth() / (float)graphics->GetHeight());
}