[Closed] Creating a Roof using the Straight Skeleton algorithm
Hi,
I want to create a roof from a building footprint using the Straight Skeleton Algorithm as proposed in this article: http://wscg.zcu.cz/wscg2003/Papers_2003/G67.pdf
I wonder if this could be possible with MaxScript. Does anyone ever tried this? To me, the algorithm appears very difficult to implement and there are different approaches to generate the Straight Skeleton (e.g. this article shows some different algorithms: http://www.ics.uci.edu/~eppstein/projects/pairs/Talks/VoronoiWorkshop.pdf ).
But maybe there are different ways to create a simple hip roof from the building’s footprint? Are there any possibilities with MaxScript I can use to solve this problems?
Thanks,
Christian
cool papers!
thanks for the link!
I think you should be able to solve this with maxscript as long as it is math.
Georg
Max script has an excelent set of functions for dealing with math so I can’t see why you couldn’t. If you understand it then you should be able to port it over to MXS.
Actually, I’m not really sure if I want to write this script because this algorithm is very complex and debugging a MaxScript is really tedious (I’m a C# programmer and don’t have that much experience in MaxScript). But maybe we could write this together…?
Basically the algorithm creates a hip roof with a constant slope and works like this:
- From each vertex of the building footprint draw a line inside the polygon (this is done in 2d, the height will be calculated by the slope and the distance to the border of the polygon)
- If two lines crosses each other, connect them by creating a new vertex and start a new line
- If a vertex crosses a line, intersect the line with a new vertex and connect both vertices
The third case will not occure when using a convex polygon.
There’s even a JavaApplet available that shows the algorithm working at http://www.sable.mcgill.ca/~dbelan2/roofs/roofs.html (you need to scroll down.)
You can even extend the algorithm to create mansard, gable and other roof types, or roofs with a variable slope but a constant height. Even roofs on houses with patios are possible, that is, footprint polygons with holes as shown by Petr Felkel and Stepan Obdrzalek in their paper: graphics.cs.msu.su/library/SCCG/1998/felkel.ps.gz (they are, as far as I know, the actual inventors of the Straight Skeleton)
The only implementation I know is from in the CGAL Open Source Project and is described here: http://www.cgal.org/Manual/3.2/doc_html/cgal_manual/Straight_skeleton_2/Chapter_main.html
Unfortunately, the algorithm needs to be extended in order to create “real” roofs, because it works only fine on simple building footprints (a simple rectangle for example). More complex polygons will soon lead to artefacts or other unexpected behaviour. It’s not that difficult to draw a polygon in the JavaApplet that kills the whole application.
Also, as shown in the first article, most buildings with a complex footprint don’t have a single roof model applied. The roof actually consists of two or more sub-models that are combined. So I think, that an implemention needs to have different parameters to let the artist some desisions on how the roof will be created. You also need to specify the slope or height, the type of the roof and if or where the gables are created.
As I said, this script is not written in a few days…
If you’re not tired and even want to read more, you can find a collection of articles here: http://www.vterrain.org/Culture/BldCity/Roof/index.html
Christian