本文整理汇总了C++中Vector2i类的典型用法代码示例。如果您正苦于以下问题:C++ Vector2i类的具体用法?C++ Vector2i怎么用?C++ Vector2i使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vector2i类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dragMiddle
void FlyingModeManipulator::dragMiddle(
const Vector2i& to,
const Vector2i& from )
{
Viewport& viewport = _window.getViewPort();
const float x = ( to.x() - from.x( )) * _window.getMotionSpeed();
const float y = ( to.y() - from.y( )) * _window.getMotionSpeed();
viewport.translate( Vector3f( x, y , 0.f ), true );
}
开发者ID:helloweishi,项目名称:Brayns,代码行数:9,代码来源:FlyingModeManipulator.cpp
示例2: dragLeft
void FlyingModeManipulator::dragLeft(
const Vector2i& to,
const Vector2i& from )
{
const float du = ( to.x() - from.x( )) * _window.getRotateSpeed();
const float dv = ( to.y() - from.y( )) * _window.getRotateSpeed();
Viewport& viewport = _window.getViewPort();
viewport.rotate( viewport.getPosition(), du, dv, true );
}
开发者ID:helloweishi,项目名称:Brayns,代码行数:9,代码来源:FlyingModeManipulator.cpp
示例3: dragRight
void FlyingModeManipulator::dragRight(
const Vector2i& to,
const Vector2i& from )
{
const float fwd = -( to.y() - from.y( )) * _window.getMotionSpeed();
Viewport& viewport = _window.getViewPort();
const Vector3f dir( 0.f, 0.f , 1.f );
viewport.translate( dir*fwd, false );
}
开发者ID:helloweishi,项目名称:Brayns,代码行数:9,代码来源:FlyingModeManipulator.cpp
示例4: Vector2i
bool Font::FontTexture::findEmpty(const Vector2i& size, Vector2i& cursor_out)
{
if(size.x() >= textureSize.x() || size.y() >= textureSize.y())
return false;
if(writePos.x() + size.x() >= textureSize.x() &&
writePos.y() + rowHeight + size.y() + 1 < textureSize.y())
{
// row full, but it should fit on the next row
// move cursor to next row
writePos = Vector2i(0, writePos.y() + rowHeight + 1); // leave 1px of space between glyphs
rowHeight = 0;
}
if(writePos.x() + size.x() >= textureSize.x() ||
writePos.y() + size.y() >= textureSize.y())
{
// nope, still won't fit
return false;
}
cursor_out = writePos;
writePos[0] += size.x() + 1; // leave 1px of space between glyphs
if(size.y() > rowHeight)
rowHeight = size.y();
return true;
}
开发者ID:RetroPie,项目名称:EmulationStation,代码行数:29,代码来源:Font.cpp
示例5: nvgFontSize
Vector2i Window::preferredSize(NVGcontext *ctx) const {
Vector2i result = Widget::preferredSize(ctx);
nvgFontSize(ctx, 18.0f);
nvgFontFace(ctx, "sans-bold");
float bounds[4];
nvgTextBounds(ctx, 0, 0, mTitle.c_str(), nullptr, bounds);
return result.cwiseMax(Vector2i(
bounds[2]-bounds[0] + 20, bounds[3]-bounds[1]
));
}
开发者ID:Nuos,项目名称:crawler,代码行数:12,代码来源:window.cpp
示例6: storageImplementationDefault
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, AbstractTexture::InternalFormat internalFormat, const Vector2i& size) {
bindInternal();
/** @todo Re-enable when extension wrangler is available for ES2 */
#ifndef MAGNUM_TARGET_GLES2
glTexStorage2D(target, levels, GLenum(internalFormat), size.x(), size.y());
#else
//glTexStorage2DEXT(target, levels, GLenum(internalFormat), size.x(), size.y());
static_cast<void>(target);
static_cast<void>(levels);
static_cast<void>(internalFormat);
static_cast<void>(size);
#endif
}
开发者ID:JanDupal,项目名称:magnum,代码行数:13,代码来源:AbstractTexture.cpp
示例7: aspectRatioFix
template<UnsignedInt dimensions, class T> typename DimensionTraits<dimensions, T>::MatrixType aspectRatioFix(AspectRatioPolicy aspectRatioPolicy, const Math::Vector2<T>& projectionScale, const Vector2i& viewport) {
/* Don't divide by zero / don't preserve anything */
if(projectionScale.x() == 0 || projectionScale.y() == 0 || viewport.x() == 0 || viewport.y() == 0 || aspectRatioPolicy == AspectRatioPolicy::NotPreserved)
return {};
Math::Vector2<T> relativeAspectRatio = Math::Vector2<T>(viewport)*projectionScale;
/* Extend on larger side = scale larger side down
Clip on smaller side = scale smaller side up */
return Camera<dimensions, T>::aspectRatioScale(
(relativeAspectRatio.x() > relativeAspectRatio.y()) == (aspectRatioPolicy == AspectRatioPolicy::Extend) ?
Vector2(relativeAspectRatio.y()/relativeAspectRatio.x(), T(1.0)) :
Vector2(T(1.0), relativeAspectRatio.x()/relativeAspectRatio.y()));
}
开发者ID:respu,项目名称:magnum,代码行数:14,代码来源:AbstractCamera.hpp
示例8: aspectRatioFix
template<UnsignedInt dimensions, class T> MatrixTypeFor<dimensions, T> aspectRatioFix(AspectRatioPolicy aspectRatioPolicy, const Math::Vector2<T>& projectionScale, const Vector2i& viewport) {
/* Don't divide by zero / don't preserve anything */
if(projectionScale.x() == 0 || projectionScale.y() == 0 || viewport.x() == 0 || viewport.y() == 0 || aspectRatioPolicy == AspectRatioPolicy::NotPreserved)
return {};
CORRADE_INTERNAL_ASSERT((projectionScale > Math::Vector2<T>(0)).all() && (viewport > Vector2i(0)).all());
Math::Vector2<T> relativeAspectRatio = Math::Vector2<T>(viewport)*projectionScale;
/* Extend on larger side = scale larger side down
Clip on smaller side = scale smaller side up */
return MatrixTypeFor<dimensions, T>::scaling(Math::Vector<dimensions, T>::pad(
(relativeAspectRatio.x() > relativeAspectRatio.y()) == (aspectRatioPolicy == AspectRatioPolicy::Extend) ?
Math::Vector2<T>(relativeAspectRatio.y()/relativeAspectRatio.x(), T(1)) :
Math::Vector2<T>(T(1), relativeAspectRatio.x()/relativeAspectRatio.y()), T(1)));
}
开发者ID:GYGit,项目名称:magnum,代码行数:15,代码来源:Camera.hpp
示例9: SetWindowLongPtr
void Application::toggleFullScreen ()
{
if (fullscreen)
{
#ifdef _WIN32
SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE);
SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
// ShowWindow(hWnd, SW_SHOWNORMAL);
#endif
}
else
{
#ifdef _WIN32
SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
// ShowWindow(hWnd, SW_SHOWMAXIMIZED);
#endif
}
fullscreen = !fullscreen;
// Set the size.
#ifdef _WIN32
RECT rect;
GetClientRect(hWnd, &rect);
size.set(rect.right, rect.bottom); // left and top are always 0.
#endif
screenToNDC = Transform::screenToNDC<float>(size);
if (widget != 0)
{
widget->setBounds(Box2i::minSize(Vector2i::zero(), size));
}
}
开发者ID:fiddleplum,项目名称:kit,代码行数:33,代码来源:Win32Application.cpp
示例10: wndProc
LRESULT WINAPI wndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CREATE:
::hWnd = hWnd;
break;
case WM_CLOSE:
onClose();
break;
case WM_SIZE:
{
int newWidth = LOWORD(lParam);
int newHeight = HIWORD(lParam);
size.set(newWidth, newHeight);
screenToNDC = Transform::screenToNDC<float>(size);
if (widget != 0)
{
widget->setBounds(Box2i::minSize(Vector2i::zero(), size));
}
}
break;
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
if (wParam == VK_RETURN && (lParam & 0xffff) == 1 && GetKeyState(VK_MENU) < 0) // alt-enter
{
Application::toggleFullScreen();
}
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
开发者ID:fiddleplum,项目名称:kit,代码行数:34,代码来源:Win32Application.cpp
示例11: unproject
Eigen::Vector3f unproject(const Eigen::Vector3f &win,
const Eigen::Matrix4f &model,
const Eigen::Matrix4f &proj,
const Vector2i &viewportSize) {
Eigen::Matrix4f Inverse = (proj * model).inverse();
Eigen::Vector4f tmp;
tmp << win, 1;
tmp(0) = tmp(0) / viewportSize.x();
tmp(1) = tmp(1) / viewportSize.y();
tmp = tmp.array() * 2.0f - 1.0f;
Eigen::Vector4f obj = Inverse * tmp;
obj /= obj(3);
return obj.head(3);
}
开发者ID:nickolasrossi,项目名称:nanogui,代码行数:17,代码来源:glutil.cpp
示例12: calcInverseTransformation
Matrix3f NNUtilities::calcInverseTransformation(const Vector2i& center, const Vector2i& inSize, const Vector2i& outSize, const Angle rotation)
{
const Vector2i upperLeft = (center.array() - inSize.array() / 2).matrix();
const Vector2f transformationFactor = (inSize.cast<float>().array() / outSize.cast<float>().array()).matrix();
//float sin = std::sin(rotation);
//float cos = std::cos(rotation);
Matrix3f inverseTransformation; //TODO check rotation
inverseTransformation(0, 0) = transformationFactor.x();// *cos;
inverseTransformation(0, 1) = 0;// transformationFactor.x() * (-sin);
inverseTransformation(1, 0) = 0;// transformationFactor.y() * sin;
inverseTransformation(1, 1) = transformationFactor.y();// *cos;
inverseTransformation(0, 2) = upperLeft.x();// +outSize.x() * (1 - cos + sin) / 2 * transformationFactor.x();
inverseTransformation(1, 2) = upperLeft.y();// +outSize.y() * (1 - sin - cos) / 2 * transformationFactor.y();
return inverseTransformation;
}
开发者ID:bhuman,项目名称:BHumanCodeRelease,代码行数:17,代码来源:NNUtilities.cpp
示例13: dim
void CompoundUpdateOutputVisitor::_generateTiles(TileQueue* queue,
Compound* compound)
{
const Vector2i& tileSize = queue->getTileSize();
const PixelViewport& pvp = compound->getInheritPixelViewport();
if (!pvp.hasArea())
return;
const Vector2i dim(pvp.w / tileSize.x() + ((pvp.w % tileSize.x()) ? 1 : 0),
pvp.h / tileSize.y() + ((pvp.h % tileSize.y()) ? 1 : 0));
std::vector<Vector2i> tiles;
tiles.reserve(dim.x() * dim.y());
tiles::generateZigzag(tiles, dim);
_addTilesToQueue(queue, compound, tiles);
}
开发者ID:eile,项目名称:Equalizer,代码行数:17,代码来源:compoundUpdateOutputVisitor.cpp
示例14: mouseDragEvent
bool Slider::mouseDragEvent(const Vector2i &p, const Vector2i & /* rel */,
int /* button */, int /* modifiers */) {
if (!mEnabled)
return false;
mValue = std::min(std::max((p.x() - mPos.x()) / (float) mSize.x(), (float) 0.0f), (float) 1.0f);
if (mCallback)
mCallback(mValue);
return true;
}
开发者ID:GuilhermeAlanJohann,项目名称:nanogui-sdl,代码行数:9,代码来源:slider.cpp
示例15: PutSpace
Layout LayoutStack::PutSpace(Vector2i size)
{
auto& b = stack.back();
Layout l = b.getNext(b.grow);
if (l.fill == Dir::Down || l.fill == Dir::Up)
{
l.across = size.x();
l.maxFill = size.y();
}
else
{
l.across = size.y();
l.maxFill = size.x();
}
b.putNext(l);
return l;
}
开发者ID:danielkeller,项目名称:Violet,代码行数:18,代码来源:Layout.cpp
示例16: project
Eigen::Vector3f project(const Eigen::Vector3f &obj,
const Eigen::Matrix4f &model,
const Eigen::Matrix4f &proj,
const Vector2i &viewportSize) {
Eigen::Vector4f tmp;
tmp << obj, 1;
tmp = model * tmp;
tmp = proj * tmp;
tmp = tmp.array() / tmp(3);
tmp = tmp.array() * 0.5f + 0.5f;
tmp(0) = tmp(0) * viewportSize.x();
tmp(1) = tmp(1) * viewportSize.y();
return tmp.head(3);
}
开发者ID:nickolasrossi,项目名称:nanogui,代码行数:18,代码来源:glutil.cpp
示例17: mouseButtonEvent
bool Window::mouseButtonEvent(const Vector2i &p, int button, bool down, int modifiers) {
if (Widget::mouseButtonEvent(p, button, down, modifiers))
return true;
if (button == GLFW_MOUSE_BUTTON_1) {
mDrag = down && (p.y() - mPos.y()) < mTheme->mWindowHeaderHeight;
return true;
}
return false;
}
开发者ID:AlwaysGeeky,项目名称:nanogui,代码行数:9,代码来源:window.cpp
示例18: setUniformValue
bool ShaderProgram::setUniformValue(const std::string& name, const Vector2i& v)
{
GLint location = static_cast<GLint>(findUniform(name));
if (location == -1) {
m_error = "Could not set uniform " + name + ". No such uniform.";
return false;
}
glUniform2iv(location, 1, v.data());
return true;
}
开发者ID:OpenChemistry,项目名称:avogadrolibs,代码行数:10,代码来源:shaderprogram.cpp
示例19: deliverPoint
void AutomaticCameraCalibratorHandlerInsertion::deliverPoint(const Vector2i& point, bool upper, bool deletionRequired)
{
if(!deletionRequired)
{
std::stringstream line1;
line1 << "set module:AutomaticCameraCalibrator:insertionCurrentCamera " << (upper ? "upper;" : "lower;");
robotConsole->handleConsole(line1.str());
std::stringstream line2;
line2 << "set module:AutomaticCameraCalibrator:insertionPoint x = ";
line2 << point.x();
line2 << "; y = ";
line2 << point.y();
line2 << ";";
robotConsole->handleConsole(line2.str());
std::stringstream line3;
line3 << "dr module:AutomaticCameraCalibrator:insertPoint";
robotConsole->handleConsole(line3.str());
}
}
开发者ID:weilandetian,项目名称:Yoyo,代码行数:19,代码来源:AutomaticCameraCalibratorHandlerInsertion.cpp
示例20: mouseButtonEvent
bool Slider::mouseButtonEvent(const Vector2i &p, int /* button */, bool down, int /* modifiers */) {
if (!mEnabled)
return false;
mValue = std::min(std::max((p.x() - mPos.x()) / (float) mSize.x(), (float) 0.0f), (float) 1.0f);
if (mCallback)
mCallback(mValue);
if (mFinalCallback && !down)
mFinalCallback(mValue);
return true;
}
开发者ID:GuilhermeAlanJohann,项目名称:nanogui-sdl,代码行数:10,代码来源:slider.cpp
注:本文中的Vector2i类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论