The Procedural Building Generator

By Nic Morales & Ali Moghadam

cs384g final project, spring 2010


  The Procedural Building Generator implements the majority of the system
designed in Müller et all. We support the definition of Split Grammar rules
(see section RULES), and some parameterization outside of the grammar system.
There are some things discussed in the paper that we have not implemented,
either because they were obsoleted by other grammar constructs or because
they were simplification constructs that we did not have time to implement
(our system is full featured; however getting similar results to the ones
in the paper takes much longer).


	Input files must be of the form



	The axiom is the starting point of the Split Grammar System. In our
implementation, a series of lots are arranged in a grid. The user parameterizes
the size of the grid and certain properties of the grammar in the axiom
	The axiom definition must be the following:

	width:			<grid width (int)>
	depth:			<grid depth (int)>
	height:			<maximum building height (double)>


	All rules in the grammar must be of the form
		id: pred: cond -> successor: prob
Note that cond is not implemented, so it can be ommitted, as follows:
		id: pred -> successor: prob

	The predecessor is the name of a shape type; the user can define any
non-terminal shape type; however, these will not be drawn. The shape name must
be lowercase with no numbers or symbols. There exist some reserved shape types:
lot, facade, facadebox, window, door.
	The successor defines how to interpret the Shape. It can be one of the
	+ Subdivide: takes an object symbol and splits it along an axis into
		different shapes.
		- Format: Subdiv( "AXIS", v1, v2, ... ) { sym1 | sym2 | ... }
			where AXIS is one of X, Y, or Z.
		- Note: The number of symbols and values (vi) must be the same. This is
			the only successor where Scope.s* can be used for a value (see
	+ Scope: Takes an object symbol and applies a transformation to yield
		a resulting symbol.
		- Format: T( vx, vy, vz ) OR S( vx, vy, vz ) OR R( vx, vy, vz ) or
			[ or ] and must include a symbol sym.
			T, S, and R denote translation, scale, and rotation, respectively,
			and [ ] denote a push and pop operation, respectively.
		- Note: The expressions may be in any arbitrary order, and are read
			from left to right.
	+ Repeat: Takes a symbol and replaces it with the specified symbol n
		times along the specified axis.
		- Format: Repeat( "AXIS", n ) { symb }
			where AXIS is one of X, Y, or Z.
		- Note: n must be an integer
	In the rule file, +++ indicates the end of file.


	Values (the v's above) can be either a double value (with a decimal and
digits before and after the decimal) or a simple expression. The expressions
allow */+- operators, with no order of operations and evaluated left to right.
In the subdivide rule, values can be relative, denoted by <double>r. There
are four functions that can be a value:,,, and
rand( min#max ). Note that Scope.s* is only available in subdive rules. These
take the value of the specified dimension of the scope for the current shape.
rand( min#max ) yields a random value between doubles min and max.


	Our renderer draws up to a 50x50 grid without artifacts. Included features
are per-pixel lighting and shadows. The camera is controlled as follows:
W      - Forward
A      - Left
S      - Down
D      - RIGHT
C      - DOWN
Q      - QUIT


	We used the following libraries: OpenGL, SDL, GLEW, Boost::xpressive,
and some reused code we had written; mainly the Enif/ math functions and some of
the rendering code (including shaders).
	Some run-time libraries may not be included. GLEW, for example is not,
so we wrote a wrapper script that should export the ./lib folder to the
library path. If any other libraries cannot ben found, place them in the
lib folder. (the xpressive library)


Here is a copy of our source.  Included is a run script which will load the
glew library (also included) so that you man run the program.

How to run:
optional parameters are:
 anything (enables what we call 'trippy mode') =)

ex: sh grammar2.txt trip

Here is a pdf of the presentation
that we did for class.