Table of Contents
This project is a 3D procedural house generator that interprets CGA-style shape grammar from a .shp file to build complex architectural structures in OpenGL.
Each rule in the grammar defines how shapes split, scale, translate, and combine to form walls, roofs, doors, and chimneys, allowing for dynamic and deterministic procedural modeling.
The system consists of:
- Grammar Parser: reads
.shpfiles defining procedural rules - Interpreter: expands symbols recursively to generate building geometry
- OpenGL Renderer: visualizes the final #D structure with transformations and materials
- C++ 17
- OpenGL (GLFW, GLAD)
- GLSL
- GLM for vector and matrix math
Follow these instructions to build and run the project locally.
You need the following installed:
- CMake (>= 3.15)
- C++ 17 compiler
- OpenGL drivers
- GLFW and GLAD
- GLM
- Clone the repository
git clone https://github.com/bhavyaven/BuildingGenerator.git- Navigate to the project directory
cd BuildingGenerator- Load a
.shpgrammar file from underassets/inmain.cpp
interpreter.loadGrammar("../../assets/config3-house.shp");- Navigate to ```out\build\BuildingGenerator.sln``
- Click "Start Without Debugging"
- Modify
.shpgrammar files to define new architectural rules - Adjust view with mouse and keyboard navigation
- Extend grammar to include doors, chimneys, and multi-floor logic
param width = 1.0
param height = 1.0
param depth = 1.0
# S: Start shape
shape S
split(z) { 0.5: B | 0.5: F }
# B: Back half
shape B
add_chimney(right)
# F: Front half, split into 3 blocks across x
shape F
split(x) { 0.33: I | 0.34: J | 0.33: K }
# I: Left cube
shape I
scale(z) 1.5
scale(y) 0.5
# J: Middle cube with door
shape J
scale(z) 1.5
scale(y) 0.5
add_door
# K: Right cube
shape K
scale(z) 1.5
scale(y) 0.5
- Add window modules
- Implement randomized grammar rule selection
- Add materials and textures for realism
- GUI to edit grammar interactively
Bhavya Venkataraghavan - bhavya.v04@gmail.com
LinkedIn: http://www.linkedin.com/in/bhavya-venkat
GitHub: https://github.com/bhavyaven
Project Link: https://github.com/bhavyaven/BuildingGenerator
