User Tools

Site Tools

Urban Games

modding:landscapeassets

Landscape Assets

The terrain generators use some specialized assets like trees and rocks to decorate the generated landscape. They are generic models with a special metadata block to recognize them as tree or rock.

Metadata

There are several additional metadata blocks for trees and rocks:

function data()
return {
  -- bounding box
  -- collider
  -- lods
  metadata = {
    order = { 
      value = -1000 + 2, 
    },
    autoGroundTex = {
      categories = { "forestTree", }
    },
    category = {
      categories = { "tree", },
    },
    categoryList = {
      categories = { "broadleaf", "large", "plains", "town", "temperate.clima.lua"  },
    },
    description = {
      description = _("Place trees individually or with a brush."),
      icon = "ui/construction/asset/temperate/european_linden.tga",
      name = _("European linden"),
    },
 
    tree = { },
    -- or
    rock = { },
 
  },
  version = 1,
}
end

The blocks have different purposes:

  • order block is used for the sorting in the asset menu.
  • autoGroundTex is a list of references to categories set in some auto ground textures (see below). The asset counts for every of these categories.
  • category is used for the asset category filter in the asset menu (similar to construction categories).
  • categoryList is a list of categories that are used in the terrain generation process. Entries that equal the filename of a climate are used to assign the model to a certain climate.
  • description block has a translatable name and description string for the asset menu. It is possible to add a custom reference to a ui icon relative to res/textures/ here too.

To mark a model as a tree, the empty tree block has to be set. To mark a model as a rock, the empty rock block has to be set. All trees and rocks are available in the according mixed brush tool too.

Auto Ground Textures

The terrain around trees is automatically textured with a ground texture depeding on the density of tree or rock models. These ground textures are defined in .lua files in the res/config/auto_ground_tex/ folder:

function data()
return {
  category = "auto.model.tree",         -- "auto.model.rock"
  gridSize = 18.0,
  countFrom = 2,
  countTo = 5,
  groundTex = "forest_floor.lua",       -- e.g. "rock_ground_medium_brown_grass.lua"
  individual = true,
  individualCategory = "forestTree",    -- e.g. "rockSandstoneMedium"
}
end

The properties are as follows:

  • category is an identifier for the purpose of this auto ground texture. It is “auto.model.tree” for trees and “auto.model.rock” for rocks. The assets are assigned to one or more of these categories and count for these.
  • gridSize is the grid size for the count grid of this auto ground texture. The assets that have the category set are counted in each of the grid cells.
  • countFrom is the minimum number of instances that has to be counted in a cell to get the texture displayed.
  • countTo is the maximum number of instances that has to be counted in a cell to get the texture displayed.
  • groundTex is a reference to the ground texture that should be displayed. It is relative to res/config/ground_texture/.
  • individual is a boolean value. If set to true this ground texture is used around individual models (like roots of a tree) instead of big patches between several of them.
  • individualCategory is a category that can be referenced from tree/rock models (see above) to be used for them as ground texture.

UI icons

The trees and rocks are available to be build in the asset menu. Therefore they need suitable ui icons. The icons lay in res/textures/ui/construction/asset/ and respective subfolders analogue to the .mdl files. The filenames usually are:

  • <mdl-name>.tga if they have the standard height of 75 pixels.
  • <mdl-name>@2.tga if they have the doubled resolution with a height of 150 pixels.


modding/landscapeassets.txt · Last modified: 2020/06/09 12:02 by yoshi