Skip to content

DonBeleren/split-grammar-2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

facade-grammar — Text-Driven 3D Building Facade Generator

Type a short description of a building. Get back a textured 3D facade rendered in real time.

Demo

This is a proof of concept. It was the first iteration of the idea — a 2D-grid facade with depth-layered textured materials. The work continued in Edifice, which generalizes the same DSL idea into full procedural 3D buildings: Flex/Bison-parsed scripts driving split, merge, group, and texture ops on a live OpenGL renderer. If you're looking at this and want the more complete version, go there.

What it does

Input is a small custom DSL built around a hierarchical split() operator that recursively subdivides a rectangle. A short program declares the overall facade dimensions, splits it into floors along the y-axis, splits each floor into bays along the x-axis, and assigns each cell a material (concrete, brick, glass, door, window). Each material maps to its own texture.

Example:

Depth = -200
R = rect(100,200)
-----------------------------------------
Sp = split("y",.1,.5){F1|F2|F3}
F1 = split("x",.1,.5){concrete|glass|concrete}
F2 = split("x",.1,.5){brick|window|brick}
F3 = split("x",.1,.5){glass|door|glass}

The parsed tree drives an interactive Qt + OpenGL viewport — left-mouse to rotate, right-mouse / scroll to zoom — that renders the facade as a 3D model. Materials are placed on slightly offset depth planes to avoid z-fighting between adjacent surfaces.

How it's built

  • Parser — hand-written recursive descent in WallMesh.cpp. Reads the DSL, extracts split structure and per-cell material names, builds the index buffers that drive rendering.
  • Mesh generationWallMesh.cpp. Generates a quad grid for the wall, then per-cell quads with cell-local UVs grouped by material into one VAO + EBO per texture slot.
  • RenderingGLWidget3D.cpp. Multi-pass draw: base wall, split background, outlines, per-material textured quads. Color/texture mode is selected per pass via a shader uniform.
  • App shellMainWindow.cpp, Qt 5. File menu loads a .txt program; the viewport rebuilds on load.

Roughly 1,660 lines of original C++ and GLSL across the parser, mesh generation, and rendering glue.

Build

  1. Install Qt 5.15.2 LTS via the Qt online installer. Pick the MSVC 2019 64-bit component (under Archive in the installer's filter).
  2. Install the Qt VS Tools extension in Visual Studio. Register your Qt install via Extensions → Qt VS Tools → Qt Versions.
  3. Open Facade2D/base_qt/base_qt.sln. Build Release | x64.
  4. Run. From the File menu, click Read Txt to load Facade.txt and render its facade.

Edit Facade.txt to change what gets rendered. An OpenGL 3.3-capable driver is required.

Limitations

This being a proof of concept, the renderer is fixed at a 3×3 grid (9 cells) and the split() fractions in the DSL are decorative — the parser hardcodes splits to 10% / 50% / 40%. Both restrictions are gone in Edifice, where the parser is Flex/Bison-driven and the geometry pipeline supports arbitrary subdivisions and full 3D buildings rather than a single facade plane.

About

Render textured 3D building facades from a short text description, using a hierarchical split-grammar DSL parsed and drawn live in Qt + OpenGL.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages