本文整理汇总了C++中InputState::pickResult方法的典型用法代码示例。如果您正苦于以下问题:C++ InputState::pickResult方法的具体用法?C++ InputState::pickResult怎么用?C++ InputState::pickResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState::pickResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: 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;
}
示例3: handleStartPlaneDrag
bool CreateBrushTool::handleStartPlaneDrag(InputState& inputState, Planef& plane, Vec3f& initialPoint) {
assert(m_brush == NULL);
Model::EditStateManager& editStateManager = document().editStateManager();
if (inputState.mouseButtons() != MouseButtons::MBLeft ||
inputState.modifierKeys() != ModifierKeys::MKNone ||
editStateManager.selectionMode() != Model::EditStateManager::SMNone)
return false;
Model::FaceHit* hit = static_cast<Model::FaceHit*>(inputState.pickResult().first(Model::HitType::FaceHit, true, m_filter));
if (hit != NULL) {
initialPoint = hit->hitPoint();
} else {
Renderer::Camera& camera = view().camera();
initialPoint = camera.defaultPoint(inputState.pickRay().direction);
}
plane = Planef(Vec3f::PosZ, initialPoint);
m_initialPoint = initialPoint;
updateBounds(m_initialPoint);
Preferences::PreferenceManager& prefs = Preferences::PreferenceManager::preferences();
Renderer::TextureRendererManager& textureRendererManager = document().sharedResources().textureRendererManager();
m_brushFigure = new Renderer::BrushFigure(textureRendererManager);
m_brushFigure->setFaceColor(prefs.getColor(Preferences::FaceColor));
m_brushFigure->setEdgeColor(prefs.getColor(Preferences::SelectedEdgeColor));
m_brushFigure->setOccludedEdgeColor(prefs.getColor(Preferences::OccludedSelectedEdgeColor));
m_brushFigure->setEdgeMode(Renderer::BrushFigure::EMRenderOccluded);
m_brush = new Model::Brush(document().map().worldBounds(), document().map().forceIntegerFacePoints(), m_bounds, document().mruTexture());
m_brushFigure->setBrush(*m_brush);
return true;
}
示例4: 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;
}
示例5: doGetNewClipPointPosition
bool doGetNewClipPointPosition(const InputState& inputState, Vec3& position) const {
const Model::Hit& hit = inputState.pickResult().query().pickable().type(Model::Brush::BrushHit).occluded().first();
if (!hit.isMatch())
return false;
Model::BrushFace* face = hit.target<Model::BrushFace*>();
const Grid& grid = m_tool->grid();
position = grid.snap(hit.hitPoint(), face->boundary());
return true;
}
示例6: doRender
void UVRotateTool::doRender(const InputState& inputState, Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch) {
if (!m_helper.valid())
return;
const Model::PickResult& pickResult = inputState.pickResult();
const Model::Hit& angleHandleHit = pickResult.query().type(AngleHandleHit).occluded().first();
const bool highlight = angleHandleHit.isMatch() || thisToolDragging();
renderBatch.addOneShot(new Render(m_helper, CenterHandleRadius, RotateHandleRadius, highlight));
}
示例7: 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);
}
示例8: handleRender
void RotateObjectsTool::handleRender(InputState& inputState, Renderer::Vbo& vbo, Renderer::RenderContext& renderContext) {
Model::EditStateManager& editStateManager = document().editStateManager();
if (editStateManager.selectedEntities().empty() && editStateManager.selectedBrushes().empty())
return;
Model::RotateHandleHit* hit = NULL;
if (m_rotateHandle.locked())
hit = m_rotateHandle.lastHit();
else
hit = static_cast<Model::RotateHandleHit*>(inputState.pickResult().first(Model::HitType::RotateHandleHit, true, view().filter()));
m_rotateHandle.render(hit, vbo, renderContext, m_angle);
}
示例9: 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());
}
示例10: handleStartDrag
bool CameraTool::handleStartDrag(InputState& inputState) {
if (inputState.mouseButtons() == MouseButtons::MBRight) {
if (inputState.modifierKeys() == ModifierKeys::MKAlt) {
Model::Hit* hit = inputState.pickResult().first(Model::HitType::ObjectHit, true, m_filter);
if (hit != NULL)
m_orbitCenter = hit->hitPoint();
else
m_orbitCenter = inputState.camera().defaultPoint();
m_orbit = true;
return true;
} else if (inputState.modifierKeys() == ModifierKeys::MKNone) {
return true;
}
} else if (inputState.mouseButtons() == MouseButtons::MBMiddle &&
(inputState.modifierKeys() == ModifierKeys::MKNone || inputState.modifierKeys() == ModifierKeys::MKAlt)) {
return true;
}
return false;
}
示例11: handleStartDrag
bool RotateObjectsTool::handleStartDrag(InputState& inputState) {
if (inputState.mouseButtons() != MouseButtons::MBLeft ||
inputState.modifierKeys() != ModifierKeys::MKNone)
return false;
Model::EditStateManager& editStateManager = document().editStateManager();
const Model::EntityList& entities = editStateManager.selectedEntities();
const Model::BrushList& brushes = editStateManager.selectedBrushes();
if (entities.empty() && brushes.empty())
return false;
Model::RotateHandleHit* hit = static_cast<Model::RotateHandleHit*>(inputState.pickResult().first(Model::HitType::RotateHandleHit, true, view().filter()));
if (hit == NULL)
return false;
Vec3f test = hit->hitPoint() - m_rotateHandle.position();
switch (hit->hitArea()) {
case Model::RotateHandleHit::HAXAxis:
m_axis = Vec3f::PosX;
m_invert = ((test.dot(Vec3f::PosX) > 0.0f) == (test.dot(Vec3f::PosY) > 0.0f));
break;
case Model::RotateHandleHit::HAYAxis:
m_axis = Vec3f::PosY;
m_invert = ((test.dot(Vec3f::PosX) > 0.0f) != (test.dot(Vec3f::PosY) > 0.0f));
break;
case Model::RotateHandleHit::HAZAxis:
m_axis = Vec3f::PosZ;
m_invert = false;
break;
}
m_startX = inputState.x();
m_startY = inputState.y();
m_angle = 0.0f;
m_center = m_rotateHandle.position();
m_rotateHandle.lock();
beginCommandGroup(Controller::Command::makeObjectActionName(wxT("Rotate"), entities, brushes));
return true;
}
示例12: updateEntityPosition
void CreateEntityTool::updateEntityPosition(InputState& inputState) {
assert(m_entity != NULL);
Utility::Grid& grid = document().grid();
Model::FaceHit* hit = static_cast<Model::FaceHit*>(inputState.pickResult().first(Model::HitType::FaceHit, true, view().filter()));
Vec3f delta;
if (hit == NULL) {
Vec3f newPosition = inputState.camera().defaultPoint(inputState.pickRay().direction);
const Vec3f& center = m_entity->bounds().center();
delta = grid.moveDeltaForEntity(center, document().map().worldBounds(), newPosition - center);
} else {
Model::Face& face = hit->face();
delta = grid.moveDeltaForEntity(face, m_entity->bounds(), document().map().worldBounds(), inputState.pickRay(), hit->hitPoint());
}
if (delta.null())
return;
m_entity->setProperty(Model::Entity::OriginKey, m_entity->origin() + delta, true);
m_entityFigure->invalidate();
}
示例13: doStartDrag
DragInfo doStartDrag(const InputState& inputState) {
if (inputState.modifierKeysDown(ModifierKeys::MKShift))
return DragInfo();
const Model::PickResult& pickResult = inputState.pickResult();
const Model::Hit& hit = pickResult.query().pickable().type(Model::Brush::BrushHit).occluded().first();
if (!hit.isMatch())
return DragInfo();
m_oldPolyhedron = m_tool->polyhedron();
const Model::BrushFace* face = Model::hitToFace(hit);
m_plane = face->boundary();
m_initialPoint = hit.hitPoint();
updatePolyhedron(m_initialPoint);
SurfaceDragRestricter* restricter = new SurfaceDragRestricter();
restricter->setPickable(true);
restricter->setType(Model::Brush::BrushHit);
restricter->setOccluded(true);
return DragInfo(restricter, new NoDragSnapper(), m_initialPoint);
}
示例14:
bool CreateComplexBrushToolController3D::doMouseDoubleClick(const InputState& inputState) {
if (!inputState.mouseButtonsDown(MouseButtons::MBLeft))
return false;
if (!inputState.checkModifierKeys(MK_No, MK_No, MK_No))
return false;
const Model::PickResult& pickResult = inputState.pickResult();
const Model::Hit& hit = pickResult.query().pickable().type(Model::Brush::BrushHit).occluded().first();
if (!hit.isMatch())
return false;
Polyhedron3 polyhedron = m_tool->polyhedron();
const Model::BrushFace* face = Model::hitToFace(hit);
const Model::BrushFace::VertexList vertices = face->vertices();
Model::BrushFace::VertexList::const_iterator it, end;
for (it = vertices.begin(), end = vertices.end(); it != end; ++it)
polyhedron.addPoint((*it)->position());
m_tool->update(polyhedron);
return true;
}
示例15: doStartMouseDrag
bool UVRotateTool::doStartMouseDrag(const InputState& inputState) {
assert(m_helper.valid());
if (!inputState.modifierKeysPressed(ModifierKeys::MKNone) ||
!inputState.mouseButtonsPressed(MouseButtons::MBLeft))
return false;
const Model::PickResult& pickResult = inputState.pickResult();
const Model::Hit& angleHandleHit = pickResult.query().type(AngleHandleHit).occluded().first();
if (!angleHandleHit.isMatch())
return false;
const Model::BrushFace* face = m_helper.face();
const Mat4x4 toFace = face->toTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true);
const Vec2f hitPointInFaceCoords(toFace * angleHandleHit.hitPoint());
m_initalAngle = measureAngle(hitPointInFaceCoords) - face->rotation();
MapDocumentSPtr document = lock(m_document);
document->beginTransaction("Rotate Texture");
return true;
}