Monday, November 12, 2012

So how does it work?

In the previous posts I've described what my aim is. Today I'd like to start describing how I'm going to do it.

As I have mentioned the technique for procedural generation is based on the paper 
Procedural Modeling of Buildings and the very basics are nicely explained in the post on procworld so please have a look.


The key thoughts for our method, that are really important to grab before moving on, are top-down description of building structure and reusing of once defined elements.

The top-down descriptions means that you start the description from the most general object and you define complete structure by using special actions and other increasingly more specific objects. So to conclude top-down term is just the good old divide complex problems into simple ones.

For example if you wished to describe a simple tower-like structure (see the picture below)
you would say that the tower consists of a roof and the rest of the building - lets call it a tower body. Then you could say the roof is a cone and that tower body is a cylinder. VoilĂ ! We have a little ugly tower.

The top-down description of a simple tower.

Tower
├── TowerBody
│     └── cylinder
└── Roof

        └── cone

The other essential thought is reusing. If you are describing a building you often find patterns - elements of a building that are not only common between different buildings, but they are often shared among different parts of the same building. Such pattern can be a brick wall - you describe the layout of bricks just once and reuse it many times for different structures. This complies the principle used in software engineering, Don't Repeat Yourself (DRY).

The tool that employs both top-down and reusing principles is called a formal grammar. Formal grammars are quite a topic in informatics and I won't try to go to any detail about it at least for now. I hope we can go with a simple notion that grammars are kind of rewriting system that basically consists of a set of objects and on operation defined on those objects - we'll call the operation a rule.

Now let's see some examples. There are 3 numbered grammar rules with translation for human beings:-) and just for curious ones the actual rules that were used for generation of the tower in the picture - just to outline some pesky implementation details.

  1. Tower -> split(TowerBody, Roof)
    •  "devide scope between tower body and roof"
    • Tower
    • Rule('Tower', "split('Z', ['2','1'], ['TowerBody', 'Roof'])" )
  2. TowerBody ->cylinder
    •  "display TowerBody as cylinder".
    •  Rule('TowerBody', "I('ngon', {'n':12})")
  3. Roof -> cone
    •  "display Roof as cone"
    •  Rule('Roof', "I('cone', {'n':36})")  

I think it's enough for today. Next time we are going to have a closer look on how the implementation of grammar works.
A bit more complex tower

Wednesday, November 7, 2012

So what is this project about? - part 2

In the previous post I've introduced the main features FAID should be build up to. I've also mentioned basic outline of work-flow and briefly described sources I drew my knowledge and inspiration from.

Today I'd like to finish the introduction stuff and pave my way to something more techy.

Why do I think it's a good idea to write FAID as a Blender plugin?

 

Well, I didn't thought so from beginning. I started from a scratch writing my pure C++ OpenGL application. Soon I was having a pretty long list of decisions to make, or worse, essential stuff I needed to implement but I wasn't interested in doing so;-)
Some examples are:
  • vector algebra lib
  • GUI lib
  • camera and lights
  • saving of rendered images
  • real-time scene editing
  • and many, many others...
So I've tried a bit of some good old out of box thinking and it came to me as a good idea to use Blender. Blender supports scripting in python and provides a really nice toolbox to boost up the development.
Well, there's one more reason. I guess there's bigger chance that somebody will ever use this as a plug-in to their favorite modeling software than some stand alone app with questionable integration into their workflow.

What will FAID be capable of and what would be nice to have?

 

Essentials of FAID funcionality will be:
  • High detailed stone walls build up from stone-like looking elements (unlike those on screenshots from previous post).
  • Procedurally generated objects like doors, windows and bars eliminating the artifacts introduced by scaling (because the objects fit perfectly). Other advantage comes from randomness built into the process of object generation which breaks the potential uniformity caused of repeated use of artist premade models. 
  • Complete building exterior (facades and roof).
  • Set of rules for a few basic types of medieval structures employing randomness to provide heterogeneity coming from an other source then just demanded dimensions.
Stuff that would be nice and possible to have but comes with lower priority:
  • non rectangular floor-plans
  • mosaic pane into windows
  • basic inner structure (floors and stairs or ladders to keep whole building connected)
  • checking tool for rules of shape grammar
  • walls made of other materials than stone
  • reducing number of polygons by generating structures faking high polygon look of model such as normal maps

In the next post I'm going to describe the current state of work, so stay tuned!


different angle setup for arcs

arcs + walls => simple bridge

simple bridge 2

Sunday, November 4, 2012

So what is this project about?

This blog should be a silent witness (unless you guys drop down a few lines, which would be really great) of my struggle with development of a plug-in into 3D content creation suite Blender.

FAID is a procedural content generation tool employing shape grammars and its core is  based on Peter Wonka's paper.

Three main features of FAID should be:

  • to facilitate automatic generation of high detail (maybe high polygon would be more honest:-)) 3D models of architecture objects like castles, houses, towers, walls, bridges, aqueducts, etc. (simply speaking - medieval fashioned stuff composed of walls and ogives)
  • to allow regeneration of whole parts of building such as resize all windows on single side of structure or switch from using stones to bricks or change the hight of a single floor and so on by simply selecting desired items in a hierarchy tree and changing relevant attributes. 
  • add some final touches achievable only by designers or artists such as breaking some windows  or painting some really juicy wall writing (like Romanes eunt domus)

How should FAID work?
  1. in blender simply create bounding volume object (like cube) to define basic dimensions of building and its place in scene
  2. fill basic attributes like a type of building or a side where an entrance should be
  3. based on data provided in previous steps, the tool will generate the basic string for shape grammar (along with shape attributes - size, place, etc) 
  4. perform derivation of string created in step 3 during which a model is created and its key elements are accessible from a tree like menu for further refinement
  5. edit grammar rules and go back to any of previous steps (FAID comes with set of rules but its main power is in writing new rules doing exactly what you want)

Sources:
  • Procedural Modeling of Buildings - Peter Wonka - a paper on which FAID is based on
  • Procedural World - really great blog (about Following one man's task of building a virtual world from the comfort of his pajamas). The aim of this project is to create a tool called voxel studio which will be capable of creating a whole and amazingly detailed world.
  • Masonry plug-in nice plug-in for blender helping with creation of complex stone structures from simple ones. 
    • Unlike this tool FAID's goal is to provide possibility to generate a complex structure and then refine its elements at will.

In next article I'm going to
  • explain what FAID will be capable of and what would be nice to have
  • explain why I think it's a good idea to write a blender plug-in
  • describe current state of work
So I hope this is the beginning of a long series of articles on which end there will be a pretty awesome medieval kingdom.

A few unpolished renders from current prototype.

Simple building


Simple tower  - different windows

Simple tower - detail