// Renders the element's border, if it has one. void ElementBorder::RenderBorder() { if (border_dirty) { border_dirty = false; GenerateBorder(); } geometry.Render(element->GetAbsoluteOffset(Box::BORDER)); }
void CMapGen::GenerateMap() { if (!m_pLayers->MineTeeLayer()) return; dbg_msg("MapGen", "Generating '%s' map...", g_Config.m_SvMapGenerationSize); int MineTeeLayerSize = m_pLayers->MineTeeLayer()->m_Width*m_pLayers->MineTeeLayer()->m_Height; // clear map, but keep background, envelopes etc for(int i = 0; i < MineTeeLayerSize; i++) { int x = i%m_pLayers->MineTeeLayer()->m_Width; ivec2 TilePos(x, (i-x)/m_pLayers->MineTeeLayer()->m_Width); // clear the different layers m_pCollision->ModifTile(TilePos, m_pLayers->GetMineTeeGroupIndex(), m_pLayers->GetMineTeeLayerIndex(), 0, 0); m_pCollision->ModifTile(TilePos, m_pLayers->GetMineTeeGroupIndex(), m_pLayers->GetMineTeeFGLayerIndex(), 0, 0); m_pCollision->ModifTile(TilePos, m_pLayers->GetMineTeeGroupIndex(), m_pLayers->GetMineTeeBGLayerIndex(), 0, 0); } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* ~~~ Generate the world ~~~ */ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~ */ // terrain GenerateBasicTerrain(); // ores GenerateOre(CBlockManager::COAL_ORE, 200.0f, COAL_LEVEL, 50, 4); GenerateOre(CBlockManager::IRON_ORE, 320.0f, IRON_LEVEL, 30, 2); GenerateOre(CBlockManager::GOLD_ORE, 350.0f, GOLD_LEVEL, 15, 2); GenerateOre(CBlockManager::DIAMOND_ORE, 680.0f, DIAMOND_LEVEL, 15, 1); // /ores1 GenerateCaves(); GenerateWater(); // vegetation GenerateFlowers(); GenerateMushrooms(); GenerateTrees(); // misc GenerateBorder(); // as long as there are no infinite (chunked) maps // Performance GenerateSkip(); }
// Generates the border geometry for the element. void ElementBorder::GenerateBorder() { int num_edges = 0; for (int i = 0; i < element->GetNumBoxes(); ++i) { const Box& box = element->GetBox(i); for (int j = 0; j < 4; j++) { if (box.GetEdge(Box::BORDER, (Box::Edge) j) > 0) num_edges++; } } std::vector< Vertex >& vertices = geometry.GetVertices(); std::vector< Index >& indices = geometry.GetIndices(); Index index_offset = 0; vertices.resize(4 * num_edges); indices.resize(6 * num_edges); if (num_edges > 0) { Vertex* raw_vertices = &vertices[0]; Index* raw_indices = &indices[0]; Colourb border_colours[4]; border_colours[0] = element->GetProperty(BORDER_TOP_COLOR)->value.Get< Colourb >(); border_colours[1] = element->GetProperty(BORDER_RIGHT_COLOR)->value.Get< Colourb >(); border_colours[2] = element->GetProperty(BORDER_BOTTOM_COLOR)->value.Get< Colourb >(); border_colours[3] = element->GetProperty(BORDER_LEFT_COLOR)->value.Get< Colourb >(); for (int i = 0; i < element->GetNumBoxes(); ++i) GenerateBorder(raw_vertices, raw_indices, index_offset, element->GetBox(i), border_colours); } geometry.Release(); }