当前位置: 首页>>代码示例>>C++>>正文


C++ TerrainTile类代码示例

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


在下文中一共展示了TerrainTile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setTerrain

void Garden::setTerrain(TerrainTile &terrain)
{
  terrain.reset();
  terrain.setOverlay(this);
  terrain.setBuilding(true);
  terrain.setGarden(true);
}
开发者ID:pufik6666,项目名称:opencaesar3,代码行数:7,代码来源:building.cpp

示例2: setTerrain

void Garden::setTerrain(TerrainTile &terrain)
{
  terrain.reset();
  terrain.setOverlay(this);
  terrain.setBuilding(true); // are gardens buildings or not???? try to investigate from original game
  terrain.setGarden(true);
}
开发者ID:Ilgrim,项目名称:opencaesar3,代码行数:7,代码来源:oc3_building.cpp

示例3: GetTile

uint8 TerrainHolder::GetLiquidType(float x, float y)
{
    TerrainTile* tile = GetTile(x, y);

    if (tile == NULL)
        return 0;
    uint8 rv = tile->m_map.GetLiquidType(x, y);
    tile->DecRef();
    return rv;
}
开发者ID:AscEmu,项目名称:AscEmu_TBC,代码行数:10,代码来源:TerrainMgr.cpp

示例4: setTerrain

void Building::setTerrain(TerrainTile &terrain)
{
  // here goes the problem
  // when we reset tile, we delete information
  // about it's original information
  // try to fix
  bool isMeadow = terrain.isMeadow();
  terrain.reset();
  terrain.setOverlay(this);
  terrain.setBuilding(true);
  terrain.setMeadow(isMeadow);
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:12,代码来源:oc3_building.cpp

示例5: drawWater

void drawWater(float maxX,float maxY,float minX,float minY){
    TerrainTile water;
    water.red = 0;
    water.green = 0;
    water.blue = .1;
    water.alpha = .8;
    water.z1 = 0; water.z2 = 0; water.z3 = 0; water.z4 = 0;
    water.x=minX;
    water.y=minY;
    water.xMax =maxX;
    water.yMax =maxY;
    water.drawTile();
    
}
开发者ID:mmcglynn45,项目名称:NDFlightSim2.0,代码行数:14,代码来源:main.cpp

示例6: UpdateInfoLayer

void TerrainMap::UpdateInfoLayer(int LayerChangeIndex)
{
    TerrainTile *Temp = NULL;
    for (int x = 0; x < m_MapSizeX; x++)
    {
        for (int y = 0; y < m_MapSizeY; y++)
        {
            Temp = &m_Map[LayerChangeIndex]->Get_Tile(Vec2i(x, y));
            if (Temp->Get_Collidable())
            {
                m_InfoLayer[x][y] = Temp;
            }
        }
    }
}
开发者ID:Shpinxis,项目名称:hack-n-slash,代码行数:15,代码来源:TerrainMap.cpp

示例7: Group

TerrainTile::TerrainTile(const TerrainTile& terrain,const osg::CopyOp& copyop):
    Group(terrain,copyop),
    _terrain(0),
    _dirtyMask(NOT_DIRTY),
    _hasBeenTraversal(false),
    _elevationLayer(terrain._elevationLayer),
    _colorLayers(terrain._colorLayers),
    _requiresNormals(terrain._requiresNormals),
    _treatBoundariesToValidDataAsDefaultValue(terrain._treatBoundariesToValidDataAsDefaultValue),
    _blendingPolicy(terrain._blendingPolicy)
{
    if (terrain.getTerrainTechnique())
    {
        setTerrainTechnique(dynamic_cast<TerrainTechnique*>(terrain.getTerrainTechnique()->clone(osg::CopyOp::SHALLOW_COPY)));
    }
}
开发者ID:AlexBobkov,项目名称:OpenSceneGraph,代码行数:16,代码来源:TerrainTile.cpp

示例8: Sheetposition

TerrainTile Level::convert_byte(int y, int x, unsigned char byte){
	float sheet_width = 914.0f;
	float sheet_height = 936.0f;
	TerrainTile tile;
	//tile.exists = false;
	if (byte == (unsigned char)1){
		//"stoneCenter.png" x="144" y="576" width="70" height="70"
		Sheetposition position = Sheetposition(144.0f, 576.0f, 70.0f, 70.0f, tilesize, sheet_width, sheet_height);
		tile = TerrainTile(x*tilesize + tilesize/2, y*tilesize +tilesize/2, tile_texture, position, program);
		tile.set_behaviors(true, true, true, true);
		tile.set_exists(true);
		tile.set_hitbox(tilesize, tilesize);

	}
	else if (byte == (unsigned char)2){
		//"stoneMid.png" x="72" y="432" width="70" height="70"
		Sheetposition position = Sheetposition(72.0f, 432.0f, 70.0f, 70.0f, tilesize, sheet_width, sheet_height);
		tile = TerrainTile(x * tilesize + tilesize /2, y*tilesize + tilesize /2, tile_texture, position, program);
		tile.set_behaviors(true, true , true, true);
		tile.set_exists(true);
		tile.set_hitbox(tilesize, tilesize);

	}
	return tile;
}
开发者ID:sja353,项目名称:Games-Class-2,代码行数:25,代码来源:Level.cpp

示例9: canBePlacedAtPixelPos

//Returns true if can be placed at this position
bool World::canBePlacedAtPixelPos(sf::Vector2i _pos){

	//If out of bounds, return false immediately
	if (_pos.x >= getDimensionsInPixels().x || _pos.y >= getDimensionsInPixels().y ||
		_pos.x <= 0 || _pos.y <= 0){

		return false;
	}

    TerrainTile* here = terrainLayer[indexAtPixelPos(_pos)].get();

	if (here->getUnit() == nullptr){
		return true;
	}
	else{
		return false;
	}
}
开发者ID:eggw,项目名称:xviii,代码行数:19,代码来源:World.cpp

示例10: canBePlacedAtCartesianPos

bool World::canBePlacedAtCartesianPos(sf::Vector2i _pos){

	//If out of bounds, return false immediately
	if (_pos.x > getDimensions().x - 1 || _pos.y > getDimensions().y - 1 ||
		_pos.x < 0 || _pos.y < 0){

		return false;
	}

	TerrainTile* here = terrainLayer[indexAtCartesianPos(_pos)].get();

	if (here->getUnit() == nullptr){
		return true;
	}
	else{
		return false;
	}
}
开发者ID:eggw,项目名称:xviii,代码行数:18,代码来源:World.cpp

示例11: InitInfoLayer

void TerrainMap::InitInfoLayer()
{
    m_InfoLayer.resize(m_MapSizeX, std::vector<TerrainTile*>(m_MapSizeY, NULL));

    TerrainTile *Temp = NULL;

    for (int i = 0; i < m_Map.size(); i++)
    {
        for (int x = 0; x < m_MapSizeX; x++)
        {
            for (int y = 0; y < m_MapSizeY; y++)
            {
                Temp = &m_Map[i]->Get_Tile(Vec2i(x, y));

                if (Temp->Get_Collidable())
                {
                    m_InfoLayer[x][y] = Temp;
                }
            }
        }
    }
}
开发者ID:Shpinxis,项目名称:hack-n-slash,代码行数:22,代码来源:TerrainMap.cpp

示例12: lock

void Terrain::traverse(osg::NodeVisitor& nv)
{
    if (nv.getVisitorType()==osg::NodeVisitor::UPDATE_VISITOR)
    {
        // need to check if any TerrainTechniques need to have their update called on them.
        osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
        if (uv)
        {
            OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
            for(TerrainTileSet::iterator itr = _updateTerrainTileSet.begin();
                itr != _updateTerrainTileSet.end();
                ++itr)
            {
                TerrainTile* tile = *itr;
                tile->traverse(nv);
            }
            _updateTerrainTileSet.clear();
        }
    }

    Group::traverse(nv);
}
开发者ID:dev2dev,项目名称:OpenSceneGraph-port-to-IOS,代码行数:22,代码来源:Terrain.cpp

示例13: TerrainTile

TerrainTile *
ctb::TerrainTiler::createTile(const TileCoordinate &coord) const {
  // Get a terrain tile represented by the tile coordinate
  TerrainTile *terrainTile = new TerrainTile(coord);
  GDALTile *rasterTile = createRasterTile(coord); // the raster associated with this tile coordinate
  GDALRasterBand *heightsBand = rasterTile->dataset->GetRasterBand(1);

  // Copy the raster data into an array
  float rasterHeights[TerrainTile::TILE_CELL_SIZE];
  if (heightsBand->RasterIO(GF_Read, 0, 0, TILE_SIZE, TILE_SIZE,
                            (void *) rasterHeights, TILE_SIZE, TILE_SIZE, GDT_Float32,
                            0, 0) != CE_None) {
    throw CTBException("Could not read heights from raster");
  }

  delete rasterTile;

  // Convert the raster data into the terrain tile heights.  This assumes the
  // input raster data represents meters above sea level. Each terrain height
  // value is the number of 1/5 meter units above -1000 meters.
  // TODO: try doing this using a VRT derived band:
  // (http://www.gdal.org/gdal_vrttut.html)
  for (unsigned short int i = 0; i < TerrainTile::TILE_CELL_SIZE; i++) {
    terrainTile->mHeights[i] = (i_terrain_height) ((rasterHeights[i] + 1000) * 5);
  }

  // If we are not at the maximum zoom level we need to set child flags on the
  // tile where child tiles overlap the dataset bounds.
  if (coord.zoom != maxZoomLevel()) {
    CRSBounds tileBounds = mGrid.tileBounds(coord);

    if (! (bounds().overlaps(tileBounds))) {
      terrainTile->setAllChildren(false);
    } else {
      if (bounds().overlaps(tileBounds.getSW())) {
        terrainTile->setChildSW();
      }
      if (bounds().overlaps(tileBounds.getNW())) {
        terrainTile->setChildNW();
      }
      if (bounds().overlaps(tileBounds.getNE())) {
        terrainTile->setChildNE();
      }
      if (bounds().overlaps(tileBounds.getSE())) {
        terrainTile->setChildSE();
      }
    }
  }

  return terrainTile;
}
开发者ID:Nuos,项目名称:cesium-terrain-builder,代码行数:51,代码来源:TerrainTiler.cpp

示例14: getWeatherUnitViewDistance

bool World::calculateViewDistance(UnitTile* unit, TerrainTile* target, bool randomisePerceivedPositions){
    //IMPORTANT:
    //Due to the fact that Tile::getCartesianPos() bases its result on the physical location of the sprite,
    //which for units can be in disagreement with its real position, we use getTruePosition() instead.

    bool enemyFound{false};

    sf::Vector2i currentPos = target->getCartesianPos();

    int unitViewDistance = unit->getDefaultUnitViewDistance() - getWeatherUnitViewDistance();
    int flagViewDistance = unit->getDefaultFlagViewDistance() - getWeatherFlagViewDistance();


    if(getIsNighttime()){
        unitViewDistance /= 2;
        flagViewDistance /= 2;
    }

    if(unitViewDistance < 1){
        unitViewDistance = 1;
    }
    if(flagViewDistance < 1){
        flagViewDistance = 1;
    }

    unit->setCurrentUnitViewDistance(unitViewDistance);
    unit->setCurrentFlagViewDistance(flagViewDistance);

    Player* owner = unit->getPlayer();

    for (int y{-1 * unitViewDistance}; y <= unitViewDistance; ++y){
        for(int x{-1 * unitViewDistance}; x <= unitViewDistance; ++x){

            sf::Vector2i adjacentPos{currentPos.x + x, currentPos.y + y};

            TerrainTile* terrainHere = terrainAtCartesianPos(adjacentPos);

            if(terrainHere == nullptr){
                continue;
            }

            UnitTile* targetUnit = terrainHere->getUnit();
            visibleTiles.insert(terrainHere);

            if (targetUnit != nullptr){
                if(targetUnit->getPlayer() != owner){

                    if(!targetUnit->drawUnit){
                        enemyFound = true;
                        targetUnit->drawUnit = true;
                    }

                    targetUnit->updateStats(randomisePerceivedPositions);
                }
            }
        }
    }

    for (int y{-1 * flagViewDistance}; y <= flagViewDistance; ++y){
        for(int x{-1 * flagViewDistance}; x <= flagViewDistance; ++x){

            sf::Vector2i adjacentPos{currentPos.x + x, currentPos.y + y};

            TerrainTile* terrainHere = terrainAtCartesianPos(adjacentPos);

            if(terrainHere == nullptr){
                continue;
            }

            UnitTile* targetUnit = terrainHere->getUnit();

            if (targetUnit != nullptr){
                if(targetUnit->getPlayer() != owner){
                    targetUnit->drawFlag = true;
                    targetUnit->updateStats(randomisePerceivedPositions);
                }
            }
        }
    }

    return enemyFound;

}
开发者ID:eggw,项目名称:xviii,代码行数:83,代码来源:World.cpp

示例15: Update

PLAYER_UPDATE_STATE Player::Update(float delta_, Goal* goal_, std::vector<Bullet> bullets_, std::set<TerrainTile*> monitoredTiles_)
{
	playerWaitTimer += delta_;
	animationTimer += delta_;

	//set animation
	if (animationTimer > 0.6f)
	{
		animationTimer = 0.0f;
		animSwitch++;

		if (animSwitch % 2 == 0)
		{
			playerTexture = textures[0];
		}
		else
		{
			playerTexture = textures[1];
		}
	}




	if (spotted && behaviour != FLEE)
	{
		cout << "behaviour == FLEE" << endl;
		behaviour = FLEE;
		navigationList.clear();
		
		spotted = false;
	}

	//update player on normal path 
	//while the navigationList is not empty. 
	if (navigationList.empty() && behaviour == SEEK)
	{
		//		//convert click location to tile
		TerrainTile* dstTile = terrain->TileAtMouseCoords(goal_->Pos());

		//convert player location to tile
		TerrainTile* playerTile = terrain->TileAtMouseCoords(static_cast<int>(pos.x), static_cast<int>(pos.y));

		//		//get the vector of tiles to nav to 
		navigationList = terrain->ShortestPath(playerTile, dstTile, monitoredTiles_);
	}

	if (navigationList.empty() && behaviour == FLEE)
	{
		TerrainTile* playerTile = terrain->TileAtMouseCoords(static_cast<int>(pos.x), static_cast<int>(pos.y));
		//get a new path from terrain to get away from enemy
		navigationList = terrain->ClosestUnmonitoredTile(playerTile, monitoredTiles_);

		//is current tile monitored? 
		if (std::find(monitoredTiles_.begin(), monitoredTiles_.end(), playerTile) == monitoredTiles_.end())
		{
			behaviour = SEEK;
		}
	}

	////wait for x seconds
	//if (navigationList.empty() && behaviour == FLEE)
	//{
	//	cout << "behaviour == WAIT" << endl;
	//	behaviour = WAIT;
	//}

	//if (behaviour == WAIT)
	//{
	//	
	//	if (playerWaitTimer > 0.1f)
	//	{			
	//		playerWaitTimer = 0.0f;
	//		cout << "behaviour == SEEK" << endl;
	//		behaviour = SEEK;
	//	}
	//}

	if (!navigationList.empty())
	{
		//if ( behaviour != WAIT )
		//{
			//get the next node and move towards it
			TerrainTile* nextNode = navigationList[navigationList.size() - 1];
			Vector2 nextNodePos = nextNode->Pos();

			//if reached pop it off the top
			if ((pos - nextNode->Pos()).GetMagnitude() < 1.0f)
			{
				pos = nextNode->Pos();
				navigationList.erase(navigationList.end() - 1);
				navigationList.clear();
			}
			else
			{
				int currentTerrainCost = 1;
				if ((pos - nextNode->Pos()).GetMagnitude() < TILE_SIZE * 0.5f)
				{
					currentTerrainCost = nextNode->Cost();
				}
//.........这里部分代码省略.........
开发者ID:rad-corps,项目名称:Offline,代码行数:101,代码来源:Player.cpp


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