After working with OSM as part of the Mission-X plugin, I was curious "Why not use its data to construct a 3D building" ?
Now I'm not deceiving my self as if the building will have the exact look, shape and texture, but I was thinking, if I can get the building "nodes", I can construct some form of a building perimeter, and from it "construct" the walls and maybe in the future a roof.
My idea was, If I could take the Overpass output:
Then I'll probably be able to make a cube out of it, like this:
This proof of concept, seems to work quite nice, but not without its challenges.
Currently we achieve all these, using two python scripts, The first script is the main one and the second script is called from "blender".
For now we should be able to:
- Define the source of the osm data, can be a local json file saved from overpass, or an overpass "bbox" defined by the designer.
- Convert the custom WaveFront ".obj" file to valid one using Blender.
Blender also calculates the Vertex Normal of the cubical shape, so lighting will be reflected correctly on the cubical shape. - The "custom blender script" will set "blender2xplane" add-on to have the minimal requirements to export it (name and textures).
Once that is done, it will have to save the project and then export to a OBJ8 file at the same directory. - Last, the script will:
- Copy all "obj8" processed files to a destination defined by the designer (probably custom scenery folder"
- prepare a "dsf text" file that contains all the processed objects, and will call "DSFTool" to convert the "dsf text" file into a valid "dsf" file format so we could import it in WED.
- Copy all "obj8" processed files to a destination defined by the designer (probably custom scenery folder"
Once all these steps are done, you should be able to open WED and import the "custom dsf" file created in the last step.
Here are some images to illustrate how it should look:
The image on the left display the area we query data for and
The image on he right shows in green "x" the location of 3D object "buildings" that were imported into WED.
If we will zoom in, we can see were there was good information and were not.
The final fixes should be done in conjunction with inside X-Plane 3D world.
The centre image, shows the area around Ilaga airport.
You can spot that there are not many "bluish" boxes, which mean that for this area the "overpass" data is lacking.
The right image, is a zoom of the centre image, were you can see the lack of building information, but were there is information, you can see that the overall look of the building is quite good (shape wise).
Challanges
- The success of the script is highly dependent on the quality of the data in the Overpass server.
- The placement and heading of the buildings is not calculated. The coordination is taken from the first vertices of the building and the rotation is always 0.0, so manual adjustment should take place.
- Textures, the elephant in the room, is something that needs to be addressed to have a more plausible look, This is a challenging project in it self, since we need to do a UV mapping and place all "faces" correctly on the texture itself.
- All buildings are "flat roof", we need some more diversity, maybe in later revisions of the script.
I would argue that the main idea of the script, for now, is to add some building clutter in areas were X-Plane fail to add them. Maybe you want a better representation of building with your orthophoto and you don't want to see X-Plane own buildings, last, it might be that the script will be the base of a custom area, so the basic shapes will be ready and you will pick ~10-30 different shapes that you will then manually place.