本文整理汇总了C++中Vec2i类的典型用法代码示例。如果您正苦于以下问题:C++ Vec2i类的具体用法?C++ Vec2i怎么用?C++ Vec2i使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vec2i类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Vec2i
//****************************************************************
// セッター
//****************************************************************
void Unitenemy::SetDirection(Direction getdirection){
Vec2i speed = Vec2i(CHIPSIZE_X, CHIPSIZE_Y);
direction = getdirection;
if (env.isPushKey(GLFW_KEY_SPACE)){
#if(1)
switch (direction)
{
case Direction::NORTH :
unitlist->pos.y() += 1;
pos.y() += speed.y();
break;
case Direction::SOUTH:
unitlist->pos.y() -= 1;
pos.y() -= speed.y();
break;
case Direction::WEST :
unitlist->pos.x() += 1;
pos.x() -= speed.x();
break;
case Direction::EAST :
unitlist->pos.x() -= 1;
pos.x() += speed.x();
break;
}
#else if
if (env.isPushKey('W')){ pos.y() -= 1; }
if (env.isPushKey('S')){ pos.y() += 1; }
if (env.isPushKey('A')){ pos.x() -= 1; }
if (env.isPushKey('D')){ pos.x() += 1; }
#endif
}
}
示例2: project
bool GeometryUtils::project(const Mat4d& projectionMultViewMatrix, const Vec2i& viewportPosition, const Vec2ui& viewportSize, const Vec3d& point, Vec3d* out)
{
CVF_ASSERT(out);
Vec4d v = projectionMultViewMatrix * Vec4d(point, 1.0);
if (v.w() == 0.0f)
{
return false;
}
v.x() /= v.w();
v.y() /= v.w();
v.z() /= v.w();
// map to range 0-1
out->x() = v.x()*0.5 + 0.5;
out->y() = v.y()*0.5 + 0.5;
out->z() = v.z()*0.5 + 0.5;
// map to viewport
out->x() = out->x() * viewportSize.x() + viewportPosition.x();
out->y() = out->y() * viewportSize.y() + viewportPosition.y();
return true;
}
示例3: clampi
Vec2i Vec2i::clamp(const Vec2i &vec, int a, int b)
{
Vec2i C;
C.x() = clampi(vec.x(), a,b);
C.y() = clampi(vec.y(), a,b);
return C;
}
示例4:
bool TiledImageBlockAccessor::readBlockA16(Vec2i vSampleOrigin,
Int32 iTextureSize,
UInt16 *pTarget,
Int32 iTargetSizeBytes)
{
#if 0
UInt32 destIdx = 0;
UInt8 *pDst = (UInt8 *) pTarget;
Int32 xMin = vSampleOrigin.x();
Int32 xMax = vSampleOrigin.x() + iTextureSize;
Int32 yMin = vSampleOrigin.y();
Int32 yMax = vSampleOrigin.y() + iTextureSize;
for(UInt32 y = yMin; y < yMax; y++)
{
for(UInt32 x = xMin; x < xMax; x++)
{
for(UInt32 i = 0; i < 2; i++)
{
pDst[destIdx] = 0;
destIdx++;
}
}
destIdx += (iTextureSize - (xMax - xMin)) * 2;
}
#endif
return true;
}
示例5:
void Win32Wrapper::MyGetCursorPos(Vec2i& lpPoint) {
POINT resultPoint;
GetCursorPos(&resultPoint);
lpPoint.x() = resultPoint.x;
lpPoint.y() = resultPoint.y;
}
示例6: Check
bool CollisionMap::Check(Vec2i boss_pos_)
{
if (collison_map[boss_pos_.x()][boss_pos_.y()] == 1)
{
return true;
}
return false;
}
示例7: Vec2i
void Camera::CenterOnSector(Sector* sector)
{
Vec2i sectorOffsetFromRoomOrigin = Vec2i(sector->X(), sector->Y()); - sector->GetRoom()->OriginSector();
Vec2f sectorOriginInRoomSpace = Vec2f((float)sectorOffsetFromRoomOrigin.X() * kSectorTileWidth, (float)sectorOffsetFromRoomOrigin.Y() * kSectorTileHeight);
m_quad.SetLowerLeft(sectorOriginInRoomSpace);
}
示例8: selected
void Map::selected(Vec2i selected_pos){
drawBox(selected_pos.x() * static_cast<float>(BLOCKSIZE::WIDTH),
-selected_pos.y() * static_cast<float>(BLOCKSIZE::HEIGHT),
static_cast<float>(BLOCKSIZE::WIDTH),
static_cast<float>(BLOCKSIZE::HEIGHT),
10,
Color::yellow);
}
示例9: Draw
void Sprite::Draw()
{
if (current.X() == -1) {return;} //this method has been called before the sprite was updated for the first time. Ignore the mistake
int ax = sheets[animations[current.X()].first.X().X()]->getAdjust().X();
int ay = sheets[animations[current.X()].first.X().X()]->getAdjust().Y();
Vec2i apos;//the position adjusted by any offset this sheet might have.
apos.setX( (int)pos.X() + ax);
apos.setY( (int)pos.Y() + ay);
sheets[animations[current.X()].first.X().X()]->Blit(currentCell, (int)apos.X(), (int)apos.Y());
}
示例10: vNewSampleOrigin
bool TiledImageBlockAccessor::read2HBlocksA16(Int32 iLow,
Int32 iHeigh,
Vec2i vSampleOrigin,
Int32 iTextureSize,
Int16 *pTarget,
Int32 iTargetSizeBytes)
{
Vec2i vNewSampleOrigin(vSampleOrigin.x() - _vSampleDescs[iLow].x0,
vSampleOrigin.y() - _vSampleDescs[iLow].y0);
_vImages[iLow]->readBlockA16(vNewSampleOrigin,
iTextureSize,
pTarget,
iTargetSizeBytes);
_vI16Buffer.resize(iTextureSize * iTextureSize);
vNewSampleOrigin.setValues(0,
vSampleOrigin.y() - _vSampleDescs[iLow ].y0);
_vImages[iHeigh]->readBlockA16(vNewSampleOrigin,
iTextureSize,
&(_vI16Buffer[0]),
iTargetSizeBytes);
UInt32 destIdx = 0;
UInt32 srcIdx = 0;
Int32 xMin = vSampleOrigin.x();
Int32 xMax = vSampleOrigin.x() + iTextureSize;
Int32 yMin = vSampleOrigin.y();
Int32 yMax = vSampleOrigin.y() + iTextureSize;
for(Int32 y = yMin; y < yMax; y++)
{
srcIdx = (y - yMin) * iTextureSize;
for(Int32 x = xMin; x < xMax; x++)
{
if(x >= _vSampleDescs[iHeigh].x0)
{
pTarget[destIdx] = _vI16Buffer[srcIdx];
++srcIdx;
}
++destIdx;
}
}
return true;
}
示例11: render
//--------------------------------------------------------------------------------------------------
/// Set up camera/viewport and render
//--------------------------------------------------------------------------------------------------
void OverlayNavigationCube::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software, const Mat4d& viewMatrix)
{
if (size.x() <= 0 || size.y() <= 0)
{
return;
}
if (m_axis.isNull())
{
createAxisGeometry(software);
}
if (m_cubeGeos.size() == 0)
{
createCubeGeos();
// Create the shader for the cube geometry
ShaderProgramGenerator gen("CubeGeoShader", ShaderSourceProvider::instance());
gen.configureStandardHeadlightColor();
m_cubeGeoShader = gen.generate();
m_cubeGeoShader->linkProgram(oglContext);
}
// Position the camera far enough away to make the axis and the text fit within the viewport
Mat4d axisMatrix = viewMatrix;
axisMatrix.setTranslation(Vec3d(0, 0, -2.0));
// Setup camera
Camera cam;
cam.setProjectionAsPerspective(40.0, 0.05, 100.0);
cam.setViewMatrix(axisMatrix);
cam.setViewport(position.x(), position.y(), size.x(), size.y());
// Setup viewport
cam.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH);
cam.applyOpenGL();
// Do the actual rendering
// -----------------------------------------------
MatrixState matrixState(cam);
if (software)
{
renderAxisImmediateMode(oglContext, matrixState);
}
else
{
renderAxis(oglContext, matrixState);
}
renderCubeGeos(oglContext, software, matrixState);
renderAxisLabels(oglContext, software, matrixState);
}
示例12: getRange
bool InterModule::getRange(int& a, int& b) {
Vec2i range;
RangeDialog rd(NULL, a,b);
if (rd.exec() == QDialog::Accepted) {
range = rd.getRange();
a = range.x();
b = range.y();
return true;
}
else
return false;
}
示例13: m_game
MapScreen::MapScreen(ThyKniteGame *g)
: m_game(g)
{
//m_mapRenderer = std::make_shared<DebugMapRenderer>(RandomWalkerGenerator().generate(60, 60));
map(RandomWalkerGenerator().generate(60, 60));
m_mapRenderer = std::make_shared<TileMapRenderer>(map(), Assets::instance->tilesetSheet->getFrame(2) );
Vec2i fw = findFirstWalkable();
std::cout << fw << std::endl;
Vec2f player_pos( fw.x() * 16, fw.y() * 16 );
m_player.reset(new PlayerPawnMap(player_pos, map()));
}
示例14: Vec2
void WallComponent::setTiles(bool enable) {
Level& level = _obj->scene()->level();
Vec2 tileSize = level.tileMap().tileSize().template cast<float>();
Vec2i first = ((_obj->geom().pos.array() / tileSize.array()).matrix() + Vec2(.5, .5))
.template cast<int>();
int height = _obj->geom().box.sizes().y() / tileSize.y() + .5;
_state->game()->log("setTiles(", enable, "): ", first.transpose(), ", ", height);
Tile tile = enable? 774: 655;
for(unsigned i = 0; i < height; ++i) {
level.setTile(first.x(), first.y() + i, 0, tile);
if(tile == 774) tile = 838;
}
}
示例15: Vec2i
bool AiInterface::getNearestSightedResource(const ResourceType *rt, const Vec2i &pos, Vec2i &resultPos){
float tmpDist;
float nearestDist= infinity;
bool anyResource= false;
const Map *map= world->getMap();
for(int i=0; i<map->getW(); ++i){
for(int j=0; j<map->getH(); ++j){
Vec2i surfPos= Map::toSurfCoords(Vec2i(i, j));
//if explored cell
if(map->getSurfaceCell(surfPos)->isExplored(teamIndex)){
Resource *r= map->getSurfaceCell(surfPos)->getResource();
//if resource cell
if(r!=NULL && r->getType()==rt){
tmpDist= pos.dist(Vec2i(i, j));
if(tmpDist<nearestDist){
anyResource= true;
nearestDist= tmpDist;
resultPos= Vec2i(i, j);
}
}
}
}
}
return anyResource;
}