本文整理汇总了C++中InputState::scrollY方法的典型用法代码示例。如果您正苦于以下问题:C++ InputState::scrollY方法的具体用法?C++ InputState::scrollY怎么用?C++ InputState::scrollY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState::scrollY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleScroll
void CameraTool::handleScroll(InputState& inputState) {
if (inputState.modifierKeys() != ModifierKeys::MKNone &&
inputState.modifierKeys() != ModifierKeys::MKAlt)
return;
if (m_orbit) {
const Renderer::Camera& camera = inputState.camera();
Plane orbitPlane(camera.direction(), m_orbitCenter);
float maxForward = orbitPlane.intersectWithRay(Ray(camera.position(), camera.direction())) - 32.0f;
float forward = inputState.scrollY() * moveSpeed();
if (maxForward < 0.0f)
maxForward = 0.0f;
if (forward > maxForward)
forward = maxForward;
CameraMoveEvent cameraEvent;
cameraEvent.setForward(forward);
postEvent(cameraEvent);
} else {
CameraMoveEvent cameraEvent;
cameraEvent.setForward(inputState.scrollY() * moveSpeed());
cameraEvent.setRight(inputState.scrollX() * moveSpeed());
postEvent(cameraEvent);
}
}
示例2: handleScroll
void CameraTool::handleScroll(InputState& inputState) {
if (inputState.modifierKeys() != ModifierKeys::MKNone &&
inputState.modifierKeys() != ModifierKeys::MKAlt)
return;
if (m_orbit) {
const Renderer::Camera& camera = inputState.camera();
Planef orbitPlane(camera.direction(), m_orbitCenter);
float maxForward = orbitPlane.intersectWithRay(Rayf(camera.position(), camera.direction())) - 32.0f;
float forward = inputState.scrollY() * moveSpeed(false);
if (maxForward < 0.0f)
maxForward = 0.0f;
if (forward > maxForward)
forward = maxForward;
CameraMoveEvent cameraEvent;
cameraEvent.setForward(forward);
postEvent(cameraEvent);
} else {
Preferences::PreferenceManager& prefs = Preferences::PreferenceManager::preferences();
const Renderer::Camera& camera = inputState.camera();
const Vec3f moveDirection = prefs.getBool(Preferences::CameraMoveInCursorDir) ? inputState.pickRay().direction : camera.direction();
const float distance = inputState.scrollY() * moveSpeed(false);
const Vec3f moveVector = distance * moveDirection;
CameraMoveEvent cameraEvent;
cameraEvent.setForward(moveVector.dot(camera.direction()));
cameraEvent.setRight(moveVector.dot(camera.right()));
cameraEvent.setUp(moveVector.dot(camera.up()));
postEvent(cameraEvent);
}
}
示例3: pref
void CameraTool2D::doMouseScroll(const InputState& inputState) {
if (zoom(inputState)) {
const float speed = pref(Preferences::CameraMouseWheelInvert) ? -1.0f : 1.0f;
if (inputState.scrollY() != 0.0f) {
const Vec2f mousePos(static_cast<float>(inputState.mouseX()), static_cast<float>(inputState.mouseY()));
const Vec3f oldWorldPos = m_camera.unproject(mousePos.x(), mousePos.y(), 0.0f);
const float factor = 1.0f + inputState.scrollY() / 50.0f * speed;
m_camera.zoom(factor);
const Vec3f newWorldPos = m_camera.unproject(mousePos.x(), mousePos.y(), 0.0f);
const Vec3f delta = newWorldPos - oldWorldPos;
m_camera.moveBy(-delta);
}
}
}