Search code examples
javalwjgl

Adding Buildings after Drawing Roads using L Systems


I'm creating a procedurally generated city and I'm having trouble with the logic behind adding buildings after the L System has added all of the roads.

I've done a lot of research as this is my final year project but unfortunately can't find a lot on adding buildings in, but more about adding roads.

My program uses L Systems to draw each road and when intersecting another road or changes direction it adds the road to an undirected planar graph. The roads added are just lines at the moment and don't have width yet as I would like to get the underlying logic of adding buildings sorted before adding this in. Roads drawn by the L System will be at randomised angles, not right angles.

My original method to find where to place the buildings was to rotate clockwise around the graph to find the polygons within the roads, then add the buildings inside the polygons found. I currently can't seem to get this working due to roads that are dead ends and moving around a graph clockwise doesn't seem to produce correct results.

The main problem is that a building placed at the intersection of a road could overlap the road. I would like the buildings to be placed somewhat similar to the game Subversion.

If there are any other methods to what I have tried I would love to hear your ideas.

Any help will be much appreciated.


Solution

  • Your problem is located at

    " then add the buildings inside the polygons found. I currently can't seem to get this working and it also has issues with if the road is a dead end. "

    Geometrically speaking yu should be able to define a polygon and see if the base of the building fits into that polygon.

    Either using the java polygons or do it yourself

    Specifically what goes wrong will get you specific answers