• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Vec2i类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Vec2i的典型用法代码示例。如果您正苦于以下问题:C++ Vec2i类的具体用法?C++ Vec2i怎么用?C++ Vec2i使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Vec2i类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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

	}
}
开发者ID:ryohalon,项目名称:TeamProduction2,代码行数:37,代码来源:Unitenemy.cpp


示例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;
}
开发者ID:akva2,项目名称:ResInsight,代码行数:26,代码来源:cvfGeometryUtils.cpp


示例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;
}
开发者ID:eoma,项目名称:totem-edk,代码行数:7,代码来源:Vec2i.cpp


示例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;
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:34,代码来源:OSGITFImageFileType.cpp


示例5:

void Win32Wrapper::MyGetCursorPos(Vec2i& lpPoint) {
	POINT resultPoint;
	GetCursorPos(&resultPoint);
	lpPoint.x() = resultPoint.x;
	lpPoint.y() = resultPoint.y;
	
}
开发者ID:2bitdreamer,项目名称:SD6_Engine,代码行数:7,代码来源:Win32Wrapper.cpp


示例6: Check

bool CollisionMap::Check(Vec2i boss_pos_)
{ 
  if (collison_map[boss_pos_.x()][boss_pos_.y()] == 1)
  {
    return true;
  }
  return false;
}
开发者ID:ryo0306,项目名称:GameCreate_Team3,代码行数:8,代码来源:CollisionMap.cpp


示例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);
}
开发者ID:sommerbr,项目名称:Spellhack,代码行数:8,代码来源:Camera.cpp


示例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);
}
开发者ID:peperontino39,项目名称:blackwhite,代码行数:9,代码来源:Map.cpp


示例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());
}
开发者ID:VileLasagna,项目名称:WarpDrive,代码行数:10,代码来源:Sprite.cpp


示例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;
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:55,代码来源:OSGITFImageFileType.cpp


示例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);
}
开发者ID:akva2,项目名称:ResInsight,代码行数:57,代码来源:cvfOverlayNavigationCube.cpp


示例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;
}
开发者ID:doctorpangloss,项目名称:Roto,代码行数:12,代码来源:interModule.C


示例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()));
}
开发者ID:alesegdia,项目名称:thyknite,代码行数:12,代码来源:mapscreen.cpp


示例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;
	}
}
开发者ID:DrWindu,项目名称:usb_warrior,代码行数:15,代码来源:wall_component.cpp


示例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;
}
开发者ID:wangtianhang,项目名称:glest,代码行数:30,代码来源:ai_interface.cpp


示例16: CheckIfBeingAttacked

bool Snapshot::CheckIfBeingAttacked(Vec2i &pos, Field &field)
{
	fprintf(logs, "In check if being attacked....\n");
	if (aiInterface == NULL)
			fprintf(logs, " aiInterface is NULL\n");
	fflush(logs);
    int count= aiInterface->onSightUnitCount();
    const Unit *unit;
	int radius = baseRadius;
    for(int i=0; i<count; ++i){
        unit= aiInterface->getOnSightUnit(i);
        if(!aiInterface->isAlly(unit) && unit->isAlive()){
            pos= unit->getPos();
			field= unit->getCurrField();
            if(pos.dist(aiInterface->getHomeLocation())<radius)
	    {
                aiInterface->printLog(4, "Being attacked at pos "+intToStr(pos.x)+","+intToStr(pos.y)+"\n");
				fprintf(logs," Being attacked at pos  %d   %d \n"  , pos.x ,pos.y);
				fflush(logs);
				beingAttacked = 1;
                return true;
            }
        }
    }
	aiInterface->printLog(4, "Not  Being attacked  \n");
	fprintf(logs," Not  Being attacked  \n");
	fflush(logs);
    beingAttacked = 0;
    return false;

}
开发者ID:log-n,项目名称:Megaglest-AI,代码行数:31,代码来源:snapshot.cpp


示例17: Vec2i

Vec2 TheGame::GetMouseMovementSinceLastChecked()
{
	Vec2i centerCursorPos = Vec2i((int)(SCREEN_WIDTH/2.f), (int)(SCREEN_HEIGHT/2.f));
	Vec2i cursorPos;
	myWinWrapper.MyGetCursorPos( cursorPos );
	myWinWrapper.MySetCursorPos(centerCursorPos.x(), centerCursorPos.y());
	Vec2i mouseDeltaInts(cursorPos.x() - centerCursorPos.x(), cursorPos.y() - centerCursorPos.y());
	Vec2 mouseDeltas((float)mouseDeltaInts.x(), (float)mouseDeltaInts.y());
	return mouseDeltas;
}
开发者ID:2bitdreamer,项目名称:SD-_A3,代码行数:10,代码来源:theGame.cpp


示例18: min

	int LineSegment2x<int>::point_distance(const Vec2i &point)
	{
		int L = pow2(q.x - p.x) + pow2(q.y - p.y);
		int r = ((point.x - p.x)*(q.x - p.x) + (point.y - p.y)*(q.y - p.y)) / L;

		if (r <= 0 || r >= 1)
		{
			return min(point.distance(p), point.distance(q));
		}

		int s = ((p.y - point.y)*(q.x - p.x) - (p.x - point.x)*(q.y - p.y)) / L;

		s *= (int)(sqrt((float)L) + 0.5f);

		if (s < 0)
			s = -s;

		return s;
	}
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:19,代码来源:line_segment.cpp


示例19: oglRect

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool OverlayScalarMapperLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size)
{
    Recti oglRect(position, size.x(), size.y());

    OverlayColorLegendLayoutInfo layoutInViewPortCoords(oglRect.min(), Vec2ui(oglRect.width(), oglRect.height()));
    layoutInfo(&layoutInViewPortCoords);

    Vec2i legendBarOrigin = oglRect.min();
    legendBarOrigin.x() += static_cast<uint>(layoutInViewPortCoords.legendRect.min().x());
    legendBarOrigin.y() += static_cast<uint>(layoutInViewPortCoords.legendRect.min().y());

    Recti legendBarRect = Recti(legendBarOrigin, static_cast<uint>(layoutInViewPortCoords.legendRect.width()), static_cast<uint>(layoutInViewPortCoords.legendRect.height()));

    if ((oglXCoord > legendBarRect.min().x()) && (oglXCoord < legendBarRect.max().x()) &&
        (oglYCoord > legendBarRect.min().y()) && (oglYCoord < legendBarRect.max().y()))
    {
        return true;
    }

    return false;
}
开发者ID:PETECLAM,项目名称:ResInsight,代码行数:24,代码来源:cvfOverlayScalarMapperLegend.cpp


示例20: writeHeader

AviExporter::AviExporter(const String& fileName, Vec2i size, int fps)
:   m_file  (fileName, File::Create),
    m_size  (size),
    m_frame (size, ImageFormat::R8_G8_B8),
    m_fps   (fps)
{
    FW_ASSERT(size.min() > 0 && fps > 0);
    m_lineBytes  = (m_size.x * 3 + 3) & -4;
    m_frameBytes = m_lineBytes * m_size.y;
    m_numFrames  = 0;
    writeHeader();
}
开发者ID:flair2005,项目名称:indirect-light-field-reconstruction,代码行数:12,代码来源:AviExporter.cpp



注:本文中的Vec2i类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Vec3类代码示例发布时间:2022-05-31
下一篇:
C++ Vec2f类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap