Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
npm-debug.log
.DS_Store
49 changes: 10 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,16 @@
# [Project 4: Shape Grammar](https://github.com/CIS700-Procedural-Graphics/Project4-Shape-Grammar)

# Project 4: Shape Grammar

For this assignment you'll be building directly off of Project 3. To make things easier to keep track of, please fork and clone this repository [https://github.com/CIS700-Procedural-Graphics/Project4-Shape-Grammar](https://github.com/CIS700-Procedural-Graphics/Project4-Shape-Grammar) and copy your Project 3 code to start.
Created a procedural city using Shape grammars. Road map of city is first generated using a uniform radial approach creating circular main roads. Minor roads are also added to connect main roads.

**Goal:** to model an urban environment using a shape grammar.
The size and color of the buildings are dependent on the distance from the center of city. Buildings get smaller as you get closer to the center and the color palette used for the roofs of the buildings changes between every main road.

**Note:** We’re well aware that a nice-looking procedural city is a lot of work for a single week. Focus on designing a nice building grammar. The city layout strategies outlined in class (the extended l-systems) are complex and not expected. We will be satisfied with something reasonably simple, just not a uniform grid!
Grammar Rules for Building (ordered by priority):

## Symbol Node (5 points)
Modify your symbol node class to include attributes necessary for rendering, such as
- Associated geometry instance
- Position
- Scale
- Anything else you may need
1. Scale Rule - Scale shape along X, Y or Z axis
2. Rotate Rule - Rotate shape along X, Y or Z axis
3. Translate Rule - Translate shape along X, Y or Z axis
4. Roof Rule - Add roof to shape
5. Subdivide Rule - Subdivides shape along X, Y or Z axis
6. Windows Rule - Add window to shape

## Grammar design (55 points)
- Design at least five shape grammar rules for producing procedural buildings. Your buildings should vary in geometry and decorative features (beyond just differently-scaled cubes!). At least some of your rules should create child geometry that is in some way dependent on its parent’s state. (20 points)
- Eg. A building may be subdivided along the x, y, or z axis into two smaller buildings
- Some of your rules must be designed to use some property about its location. (10 points)
- Your grammar should have some element of variation so your buildings are non-deterministic. Eg. your buildings sometimes subdivide along the x axis, and sometimes the y. (10 points)
- Write a renderer that will interpret the results of your shape grammar parser and adds the appropriate geometry to your scene for each symbol in your set. (10 points)

## Create a city (30 points)
- Add a ground plane or some other base terrain to your scene (0 points, come on now)
- Using any strategy you’d like, procedurally generate features that demarcate your city into different areas in an interesting and plausible way (Just a uniform grid is neither interesting nor plausible). (20 points)
- Suggestions: roads, rivers, lakes, parks, high-population density
- Note, these features don’t have to be directly visible, like high-population density, but they should somehow be visible in the appearance or arrangement of your buildings. Eg. High population density is more likely to generate taller buildings
- Generate buildings throughout your city, using information about your city’s features. Color your buildings with a method that uses some aspect of its state. Eg. Color buildings by height, by population density, by number of rules used to generate it. (5 points)
- Document your grammar rules and general approach in the readme. (5 points)
- ???
- Profit.

## Make it interesting (10)
Experiment! Make your city a work of art.


## Warnings:
You can very easily blow up three.js with this assignment. With a very simple grammar, our medium quality machine was able to handle 100 buildings with 6 generations each, but be careful if you’re doing this all CPU-side.

## Suggestions for the overachievers:
Go for a very high level of decorative detail!
Place buildings with a strategy such that buildings have doors and windows that are always accessible.
Generate buildings with coherent interiors
If dividing your city into lots, generate odd-shaped lots and create building meshes that match their shape ie. rather than working with cubes, extrude upwards from the building footprints you find to generate a starting mesh to subdivide rather than starting with platonic geometry.
38 changes: 38 additions & 0 deletions deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var colors = require('colors');
var path = require('path');
var git = require('simple-git')(__dirname);
var deploy = require('gh-pages-deploy');
var packageJSON = require('require-module')('./package.json');

var success = 1;
git.fetch('origin', 'master', function(err) {
if (err) throw err;
git.status(function(err, status) {
if (err) throw err;
if (!status.isClean()) {
success = 0;
console.error('Error: You have uncommitted changes! Please commit them first'.red);
}

if (status.current !== 'master') {
success = 0;
console.warn('Warning: Please deploy from the master branch!'.yellow)
}

git.diffSummary(['origin/master'], function(err, diff) {
if (err) throw err;

if (diff.files.length || diff.insertions || diff.deletions) {
success = 0;
console.error('Error: Current branch is different from origin/master! Please push all changes first'.red)
}

if (success) {
var cfg = packageJSON['gh-pages-deploy'] || {};
var buildCmd = deploy.getFullCmd(cfg);
deploy.displayCmds(deploy.getFullCmd(cfg));
deploy.execBuild(buildCmd, cfg);
}
})
})
})
Binary file added images/.DS_Store
Binary file not shown.
Binary file added images/sunset.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>HW4: Shape Grammars</title>
<style>
html, body {
margin: 0;
overflow: hidden;
}
canvas {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<script src="bundle.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"scripts": {
"start": "webpack-dev-server --hot --inline",
"build": "webpack",
"deploy": "node deploy.js"
},
"gh-pages-deploy": {
"prep": [
"build"
],
"noprompt": true
},
"dependencies": {
"dat-gui": "^0.5.0",
"gl-matrix": "^2.3.2",
"stats-js": "^1.0.0-alpha1",
"three": "^0.82.1",
"three-orbit-controls": "^82.1.0",
"three-obj-loader": "^1.0.2",
"jquery": "^2.2.4",
"three.meshline": "^1.0.3"
},
"devDependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.8",
"babel-preset-es2015": "^6.18.0",
"colors": "^1.1.2",
"gh-pages-deploy": "^0.4.2",
"simple-git": "^1.65.0",
"webpack": "^1.13.3",
"webpack-dev-server": "^1.16.2",
"webpack-glsl-loader": "^1.0.1"
}
}
Binary file added shapes/.DS_Store
Binary file not shown.
59 changes: 59 additions & 0 deletions shapes/base1.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This file uses centimeters as units for non-parametric coordinates.

mtllib base1.mtl
g default
v -0.500000 0.000000 0.500000
v 0.500000 0.000000 0.500000
v -0.500000 0.750000 0.500000
v 0.500000 0.750000 0.500000
v -0.500000 0.750000 -0.500000
v 0.500000 0.750000 -0.500000
v -0.500000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
vt 0.375000 0.000000
vt 0.375000 0.250000
vt 0.625000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.625000 1.000000
vt 0.875000 0.000000
vt 0.875000 0.250000
vt 0.125000 0.000000
vt 0.125000 0.250000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
s off
g roof24
usemtl roof2:initialShadingGroup
f 4/4/1 3/2/2 1/1/3 2/3/4
f 7/7/5 5/5/6 6/6/7 8/8/8
f 2/10/9 1/9/10 7/7/11 8/8/12
f 2/3/13 8/11/14 6/12/15 4/4/16
f 7/13/17 1/1/18 3/2/19 5/14/20
f 3/2/21 4/4/22 6/6/23 5/14/24
59 changes: 59 additions & 0 deletions shapes/base2.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This file uses centimeters as units for non-parametric coordinates.

mtllib base2.mtl
g default
v -0.500000 0.000000 0.500000
v 0.500000 0.000000 0.500000
v -0.500000 0.666667 0.500000
v 0.500000 0.666667 0.500000
v -0.500000 0.666667 -0.500000
v 0.500000 0.666667 -0.500000
v -0.500000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.625000 1.000000
vt 0.875000 0.000000
vt 0.875000 0.250000
vt 0.125000 0.000000
vt 0.125000 0.250000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
s off
g roof25
usemtl initialShadingGroup
f 4/4/1 3/3/2 1/1/3 2/2/4
f 8/8/5 7/7/6 5/5/7 6/6/8
f 2/10/9 1/9/10 7/7/11 8/8/12
f 2/2/13 8/11/14 6/12/15 4/4/16
f 7/13/17 1/1/18 3/3/19 5/14/20
f 4/4/21 6/6/22 5/14/23 3/3/24
59 changes: 59 additions & 0 deletions shapes/base3.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This file uses centimeters as units for non-parametric coordinates.

mtllib base3.mtl
g default
v -0.500000 0.000000 0.500000
v 0.500000 0.000000 0.500000
v -0.500000 0.750000 0.500000
v 0.500000 0.750000 0.500000
v -0.500000 0.750000 -0.500000
v 0.500000 0.750000 -0.500000
v -0.500000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.625000 1.000000
vt 0.875000 0.000000
vt 0.875000 0.250000
vt 0.125000 0.000000
vt 0.125000 0.250000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
s off
g roof28
usemtl initialShadingGroup
f 1/1/1 2/2/2 4/4/3 3/3/4
f 5/5/5 6/6/6 8/8/7 7/7/8
f 7/7/9 8/8/10 2/10/11 1/9/12
f 2/2/13 8/11/14 6/12/15 4/4/16
f 7/13/17 1/1/18 3/3/19 5/14/20
f 4/4/21 6/6/22 5/14/23 3/3/24
42 changes: 42 additions & 0 deletions shapes/roof1.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This file uses centimeters as units for non-parametric coordinates.

mtllib roof1.mtl
g default
v -0.500000 0.750000 0.500000
v 0.000000 1.000000 0.500000
v 0.500000 0.750000 0.500000
v -0.500000 0.750000 -0.500000
v 0.000000 1.000000 -0.500000
v 0.500000 0.750000 -0.500000
vt 0.500000 0.250000
vt 0.375000 0.250000
vt 0.625000 0.250000
vt 0.500000 0.500000
vt 0.375000 0.500000
vt 0.625000 0.500000
vn -0.567354 0.823474 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn -0.567354 0.823474 0.000000
vn 0.000000 1.000000 0.000000
vn 0.567354 0.823474 0.000000
vn 0.567354 0.823474 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
s off
g roof23
usemtl roof2:initialShadingGroup
f 1/2/1 2/1/2 5/4/3 4/5/4
f 2/1/5 3/3/6 6/6/7 5/4/8
f 6/6/9 4/5/10 5/4/11
f 2/1/12 1/2/13 3/3/14
f 1/2/15 4/5/16 6/6/17 3/3/18
Loading