|
|
| Line 150: |
Line 150: |
| You know some python? Or you're keen on writing docs? Or just want to use osm2city, but got stuck somewhere? Contact radi on the FG forum. | | You know some python? Or you're keen on writing docs? Or just want to use osm2city, but got stuck somewhere? Contact radi on the FG forum. |
| None of the above? Take [[Howto:Create_textures_from_photos|pictures]] of buildings where you live! I'm especially interested in south-east asian style architecture, as I'm planning to populate Hong Kong Kai Tak (VHXX) in the future. | | None of the above? Take [[Howto:Create_textures_from_photos|pictures]] of buildings where you live! I'm especially interested in south-east asian style architecture, as I'm planning to populate Hong Kong Kai Tak (VHXX) in the future. |
|
| |
| == Textures ==
| |
|
| |
| This section gives some general info about textures with osm2city. It also describes how to create your own facade textures.
| |
|
| |
| Since you could have a number of cities generated by osm2city which would share textures, currently all textures reside in the folder /some/place/tex/. An actual scenery folder, say, Objects/w130n30/w123n37/ will have a link to /some/place/tex. The .ac objects inside Objects/w130n30/w123n37/ will then e.g. load a texture tex/facade.png The tex/ folder is included in the LOWI download.
| |
|
| |
| === Registering your own textures ===
| |
|
| |
| Textures must be registered in textures.py. Currently we use facade textures and roof textures. Since some facade textures might not match with some roof textures, we use a mechanism of provides=[] and requires=[] features: A texture could require a black roof, while providing a modern, commercial facade.
| |
|
| |
| Example entry in textures.py:
| |
|
| |
| <code>
| |
| facades.append(Texture('tex/DSCF9495_pow2',<br>
| |
| 14, [585, 873, 1179, 1480, 2048], True,<br>
| |
| 19.4, [274, 676, 1114, 1542, 2048], False, True,<br>
| |
| requires=['roof:color:black'],<br>
| |
| provides=['shape:residential','age:old','compat:roof-flat','compat:roof-gable']))<br>
| |
| </code>
| |
|
| |
| This registeres a file tex/DSCF9495_pow2. The extention .png is added automatically when writing the .ac file, so make sure you use only .png textures.
| |
|
| |
| The second line in the above example says the texture
| |
| * is 14m wide
| |
| * can be split at u = 585, 873, ... 2048 px, where u is the horizontal coordinate. The last value 2048 of this list also gives the width in px. Note that the .ac file uses nondimensionalized coordinates (0 ... 1). Internally, all coordinates are divided by the last value. Therefore, when preparing the textures, you can work with the highest resolution possible and register those numbers, then downscale the texture for actual flightgear use. Once the next generation of graphics cards arrives you just replace the textures with higher resolution ones.
| |
| * the texture can repeat in horizontal direction
| |
|
| |
| The third line gives the same information for the vertical direction:
| |
| * 19.4m height
| |
| * can split at 274, 676, ... 2048px,
| |
| * the texture cannot repeat in vertical direction
| |
| * the texture has a roof section (I've forgotten what this actually means, will have to check...)
| |
|
| |
| The fourth and fifth line state compatibility with other textures: This facade texture requires a black roof. It provides an old-aged, residential facade, and is compatible with both flat and gable roofs.
| |
|
| |
|
| |
| === Assigning specific textures ===
| |
| '''NB: line numbers might be outdated, but the principle still applies'''
| |
|
| |
| Currently, the textures are assigned somewhat randomly to the buildings. Support for specific textures is not implemented yet. But with some python knowledge, you could code that yourself.
| |
|
| |
| To use specific textures for specific types of buildings, you would have to read the building type from the OSM file. OSM parsing is done in the ways method (osm2city.py, line 145) of the class wayExtract(object). Check lines 160-165, you would probably need something similar to process your type tag. Then in line 176, a building object is created
| |
| building = Building(osm_id, tags, _refs, _name, _height, _levels)
| |
| You would pass your type tag to the building class here, and of course extend the Building class (starting at line 102) to store that tag.
| |
|
| |
| Finally, in building_lib.py, around line 425:
| |
| b.facade_texture = facades.find_matching(requires, b.height)
| |
| This decides which facade texture is used for a building. b is an instance of the class Building. You could pass here the b.type tag, then extend the find_matching method to find a texture matching that tag.
| |
|
| |
|
| == Related == | | == Related == |