本文整理汇总了C++中InputState::pickRay方法的典型用法代码示例。如果您正苦于以下问题:C++ InputState::pickRay方法的具体用法?C++ InputState::pickRay怎么用?C++ InputState::pickRay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState::pickRay方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例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: 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);
}
示例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: doMouseDrag
bool UVRotateTool::doMouseDrag(const InputState& inputState) {
assert(m_helper.valid());
Model::BrushFace* face = m_helper.face();
const Plane3& boundary = face->boundary();
const Ray3& pickRay = inputState.pickRay();
const FloatType curPointDistance = pickRay.intersectWithPlane(boundary.normal, boundary.anchor());
const Vec3 curPoint = pickRay.pointAtDistance(curPointDistance);
const Mat4x4 toFaceOld = face->toTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true);
const Mat4x4 toWorld = face->fromTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true);
const Vec2f curPointInFaceCoords(toFaceOld * curPoint);
const float curAngle = measureAngle(curPointInFaceCoords);
const float angle = curAngle - m_initalAngle;
const float snappedAngle = Math::correct(snapAngle(angle), 4, 0.0f);
const Vec2f oldCenterInFaceCoords = m_helper.originInFaceCoords();
const Vec3 oldCenterInWorldCoords = toWorld * Vec3(oldCenterInFaceCoords);
Model::ChangeBrushFaceAttributesRequest request;
request.setRotation(snappedAngle);
MapDocumentSPtr document = lock(m_document);
document->setFaceAttributes(request);
// Correct the offsets and the position of the rotation center.
const Mat4x4 toFaceNew = face->toTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true);
const Vec2f newCenterInFaceCoords(toFaceNew * oldCenterInWorldCoords);
m_helper.setOrigin(newCenterInFaceCoords);
const Vec2f delta = (oldCenterInFaceCoords - newCenterInFaceCoords) / face->scale();
const Vec2f newOffset = (face->offset() + delta).corrected(4, 0.0f);
request.clear();
request.setOffset(newOffset);
document->setFaceAttributes(request);
return true;
}
示例7: 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();
}
示例8: doPick
void UVRotateTool::doPick(const InputState& inputState, Model::PickResult& pickResult) {
if (!m_helper.valid())
return;
const Model::BrushFace* face = m_helper.face();
const Mat4x4 fromFace = face->fromTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true);
const Plane3& boundary = face->boundary();
const Mat4x4 toPlane = planeProjectionMatrix(boundary.distance, boundary.normal);
const Ray3& pickRay = inputState.pickRay();
const FloatType distance = pickRay.intersectWithPlane(boundary.normal, boundary.anchor());
assert(!Math::isnan(distance));
const Vec3 hitPoint = pickRay.pointAtDistance(distance);
const Vec3 originOnPlane = toPlane * fromFace * Vec3(m_helper.originInFaceCoords());
const Vec3 hitPointOnPlane = toPlane * hitPoint;
const float zoom = m_helper.cameraZoom();
const FloatType error = std::abs(RotateHandleRadius / zoom - hitPointOnPlane.distanceTo(originOnPlane));
if (error <= RotateHandleWidth / zoom)
pickResult.addHit(Model::Hit(AngleHandleHit, distance, hitPoint, 0, error));
}
示例9: 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);
}
}
示例10:
void CreateEntityToolController3D::doUpdateEntityPosition(const InputState& inputState) {
m_tool->updateEntityPosition3D(inputState.pickRay(), inputState.pickResult());
}
示例11: handlePick
void RotateObjectsTool::handlePick(InputState& inputState) {
Model::RotateHandleHit* hit = m_rotateHandle.pick(inputState.pickRay());
if (hit != NULL)
inputState.pickResult().add(hit);
}
示例12: doMouseDrag
bool ResizeBrushesToolController::doMouseDrag(const InputState& inputState) {
return m_tool->resize(inputState.pickRay(), inputState.camera());
}
示例13: doPick
void ClipToolController::doPick(const InputState& inputState, Model::PickResult& pickResult) {
m_tool->pick(inputState.pickRay(), inputState.camera(), pickResult);
}