本文整理汇总了C++中InputState类的典型用法代码示例。如果您正苦于以下问题:C++ InputState类的具体用法?C++ InputState怎么用?C++ InputState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InputState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
bool
TextWindowHandler::handleKey(const InputEvent &e) {
DisplayWindow * d;
e.fprint( stderr );
InputState * wimp = _wm->wimp();
wimp->setEvent(e);
bool ret = false;
if (wimp->ctrlDown ) {
bool ret = true;
switch ( wimp->lastKey ) {
case KEY_CTRL_N:
fprintf(stderr,"Make new window\n");
d = new DisplayWindow();
d->setContent(new TextContent());
_wm->addWindow(d);
d->moveto(wimp->lastPos[0], wimp->lastPos[1] );
break;
case KEY_CTRL_F:
case KEY_CTRL_O: //create new window and pass the call down...
if ( !_wm->top()) {
DirScanner dr;
fileData * f = dr.openFileDialog();
fileData * nf = f;
int c = 0;
while ( nf ) {
EM_log( CK_LOG_INFO, "(audicle) opening file %d : %s", c, nf->fileName.c_str());
d = new DisplayWindow();
TextContent * ntext = new TextContent();
ntext->open((char*)nf->fileName.c_str());
d->setContent(ntext);
Point2D np = wimp->lastPos + Point2D(0.03, -0.03 ) * (double)c;
d->moveto(np[0], np[1] );
_wm->addWindow(d);
_wm->setTopWindow(d);
c++;
nf = nf->next;
}
}
break;
default:
ret = false;
}
}
return ret;
}
示例2: doStartMouseDrag
bool ResizeBrushesToolController::doStartMouseDrag(const InputState& inputState) {
if (!handleInput(inputState))
return false;
const bool split = inputState.modifierKeysDown(ModifierKeys::MKCtrlCmd);
if (m_tool->beginResize(inputState.pickResult(), split)) {
updateDragFaces(inputState);
return true;
}
return false;
}
示例3: OnUpdate
void MenuView::OnUpdate(const float dt) {
InputState inputState;
mCommon->getInputState(&inputState);
accumulatorKeyPress -= dt;
if (accumulatorKeyPress <= 0) {
accumulatorKeyPress = 0;
}
if (inputState.isDown(Button::BUTTON_MOUSELEFT) && accumulatorKeyPress == 0) {
mModel->CheckInput(Vec2(inputState.mMouseX, inputState.mMouseY));
accumulatorKeyPress = delayKeyPress;
}
}
示例4: DragInfo
RestrictedDragPolicy::DragInfo ClipToolController::MoveClipPointPart::doStartDrag(const InputState& inputState) {
if (inputState.mouseButtons() != MouseButtons::MBLeft ||
inputState.modifierKeys() != ModifierKeys::MKNone)
return DragInfo();
Vec3 initialPoint;
if (!m_callback->tool()->beginDragPoint(inputState.pickResult(), initialPoint))
return DragInfo();
DragRestricter* restricter = m_callback->createDragRestricter(inputState, initialPoint);
DragSnapper* snapper = m_callback->createDragSnapper(inputState);
return DragInfo(restricter, snapper, initialPoint);
}
示例5: doGetNewClipPointPosition
bool doGetNewClipPointPosition(const InputState& inputState, Vec3& position) const {
const Renderer::Camera& camera = inputState.camera();
const Vec3 viewDir = camera.direction().firstAxis();
const Ray3& pickRay = inputState.pickRay();
const Vec3 defaultPos = m_tool->defaultClipPointPos();
const FloatType distance = pickRay.intersectWithPlane(viewDir, defaultPos);
if (Math::isnan(distance))
return false;
position = pickRay.pointAtDistance(distance);
const Grid& grid = m_tool->grid();
position = grid.snap(position);
return true;
}
示例6: handleResetPlane
void CreateBrushTool::handleResetPlane(InputState& inputState, Planef& plane, Vec3f& initialPoint) {
float distance = plane.intersectWithRay(inputState.pickRay());
if (Math<float>::isnan(distance))
return;
initialPoint = inputState.pickRay().pointAtDistance(distance);
if (inputState.modifierKeys() == ModifierKeys::MKAlt) {
Vec3f planeNorm = inputState.pickRay().direction;
planeNorm[2] = 0.0f;
planeNorm.normalize();
plane = Planef(planeNorm, initialPoint);
} else {
plane = Planef::horizontalDragPlane(initialPoint);
}
}
示例7: doPick
void ResizeBrushesToolController::doPick(const InputState& inputState, Model::PickResult& pickResult) {
if (handleInput(inputState)) {
const Model::Hit hit = doPick(inputState.pickRay(), pickResult);
if (hit.isMatch())
pickResult.addHit(hit);
}
}
示例8: performCopy
bool SetBrushFaceAttributesTool::performCopy(const InputState& inputState, const bool applyToBrush) {
if (!applies(inputState))
return false;
MapDocumentSPtr document = lock(m_document);
const Model::BrushFaceList& selectedFaces = document->selectedBrushFaces();
if (selectedFaces.size() != 1)
return false;
const Model::Hit& hit = inputState.pickResult().query().pickable().type(Model::Brush::BrushHit).occluded().first();
if (!hit.isMatch())
return false;
Model::BrushFace* source = selectedFaces.front();
Model::BrushFace* targetFace = Model::hitToFace(hit);
Model::Brush* targetBrush = targetFace->brush();
const Model::BrushFaceList targetList = applyToBrush ? targetBrush->faces() : Model::BrushFaceList(1, targetFace);
const Transaction transaction(document);
document->deselectAll();
document->select(targetList);
if (copyAttributes(inputState))
document->setFaceAttributes(source->attribs());
else
document->setTexture(source->texture());
document->deselectAll();
document->select(source);
return true;
}
示例9: getHelpVectors
Vec3::List getHelpVectors(const InputState& inputState) const {
const Model::Hit& hit = inputState.pickResult().query().pickable().type(Model::Brush::BrushHit).occluded().first();
assert(hit.isMatch());
Model::BrushFace* face = Model::hitToFace(hit);
return selectHelpVectors(face, hit.hitPoint());
}
示例10: 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);
}
}
}
示例11: doStartMove
MoveObjectsToolController::MoveInfo MoveObjectsToolController::doStartMove(const InputState& inputState) {
if (!inputState.modifierKeysPressed(ModifierKeys::MKNone) &&
!inputState.modifierKeysPressed(ModifierKeys::MKAlt) &&
!inputState.modifierKeysPressed(ModifierKeys::MKCtrlCmd) &&
!inputState.modifierKeysPressed(ModifierKeys::MKCtrlCmd | ModifierKeys::MKAlt))
return MoveInfo();
const Model::PickResult& pickResult = inputState.pickResult();
const Model::Hit& hit = pickResult.query().pickable().type(Model::Group::GroupHit | Model::Entity::EntityHit | Model::Brush::BrushHit).selected().first();
if (!hit.isMatch())
return MoveInfo();
if (!m_tool->startMove(inputState))
return MoveInfo();
return MoveInfo(hit.hitPoint());
}
示例12: SendCommand
void NetworkClient::SendCommand(InputState & _inputState)
{
if (networkState == NetworkState::WELCOMED)
{
clock_t time = clock();
if (time > timeOfLastMove + FREQUENCY_SENDING_COMMANDS)
{
if (_inputState.GetXs() != 0)
{
std::string message = std::string(HEADER_TRYPOSITION) + "_" + /*std::to_string(id) + "_" + */std::to_string(_inputState.GetXs());
_inputState.Reset();
Send(message);
}
timeOfLastMove = time;
}
}
}
示例13: onInput
void EntitiesEditor::onInput(const InputState &state) {
auto mouse_pos = state.mousePos() - clippedRect().min;
computeCursor(mouse_pos, mouse_pos, state.isKeyPressed(InputKey::lshift));
if(state.isKeyDown('s')) {
m_mode = Mode::selecting;
sendEvent(this, Event::button_clicked, m_mode);
}
if(state.isKeyDown('p')) {
m_mode = Mode::placing;
sendEvent(this, Event::button_clicked, m_mode);
}
if(m_proto) {
int inc = 0;
if(state.isKeyDown(InputKey::left)) inc = -1;
if(state.isKeyDown(InputKey::right)) inc = 1;
int dir_count = m_proto->sprite().dirCount(0);
if(inc && dir_count)
m_proto_angle = (m_proto_angle + inc + dir_count) % dir_count;
m_proto->setDirAngle(constant::pi * 2.0f * (float)m_proto_angle / float(dir_count));
}
if(state.isKeyPressed(InputKey::del)) {
for(int i = 0; i < (int)m_selected_ids.size(); i++)
m_entity_map.remove(m_selected_ids[i]);
m_selected_ids.clear();
}
m_view.update(state);
}
示例14: update
void update(const Window::WindowState& windowState, const InputState& inputState, f32 timeStep) override {
if (m_viewportRect != windowState.rect) {
m_viewportRect = windowState.rect;
//glViewport(0, 0, m_viewportRect.width, m_viewportRect.height);
}
if (inputState.keyPressed(GLFW_KEY_ESCAPE)) {
m_engine->stop();
}
}
示例15: doStartDrag
DragInfo doStartDrag(const InputState& inputState) {
if (!inputState.modifierKeysDown(ModifierKeys::MKShift))
return DragInfo();
if (!m_tool->polyhedron().polygon())
return DragInfo();
m_oldPolyhedron = m_tool->polyhedron();
const Polyhedron3::FaceHit hit = m_oldPolyhedron.pickFace(inputState.pickRay());
const Vec3 origin = inputState.pickRay().pointAtDistance(hit.distance);
const Vec3 direction = hit.face->normal();
const Line3 line(origin, direction);
m_dragDir = line.direction;
return DragInfo(new LineDragRestricter(line), new NoDragSnapper(), origin);
}