Aim of the project
Build an opportunely approximated tridimensional model of the residence surroundings.
You can download the runnable project archive or the source code archive.
This page is just a mirror of http://plm.dia.uniroma3.it/~256479/
Result Preview
Index
Introduction
The project models the surroundings of my residence address. A quick look to the area can be found via google maps here.
The entire project is a complex hierarchical structure, that is the results of a tradeoff between the number of details and the computational resources needed to display it.
The exported model of the project is a 64 Mb hpc file.
It generates more than 470.000 batches, and may require a long time to load ( it takes between four and five minutes to be loaded on a iMac with ATI Radeon HD 4850 graphic chipset, Intel Core i5 2.66 GHz CPU with 8GB RAM and about 15 minutes on a MacBook Air with built-in GMA X3100 graphic chipset without dedicated memory, 2GB RAM, 1.8 Ghz Intel Core 2 Duo CPU ).
To view the project, run the world.py program from the runnable archive, or the world_generation.py program if it’s the first time you load it from the source archive.
Models Preview
Colors and Textures
In order to build reasonable realistic models, a set of custom colors has been defined.
The use of textures instead has been quite limited, because of the lack of support for "repeated" textures.
As a matter of fact, all of the texture used in this project are "stretched" over the complexes they are applied to.
Definitions of custom colors are provided by the colors.py module.
Models Details
Streets Modeling
The streets have been generated with the same technique used during the 4th homework: a poly-line for each road has been detected, then for each control point a fixed distance has been considered on the perpendicular of the line connecting the middle of the previous and following segment, in order to compute the borders points.
From the such obtained border lines, a 2-d representation of the roads has been defined.
In order to build the sidewalks complex, two different 2-d roads representations has been computed, with different road width. The second representation has different road width in order to actually include in its area the sidewalks white borders more than just the roads.
The sidewalks complex has then been obtained with a structure composed by:
-
The difference between a full structure ( whole_model_x, whole_model_y, sidewalks_z) and the extrusion of the second representation ( this difference is actually the grey portion of the sidewalks )
-
The difference between the extrusions of the second representation and the extrusions of the first representation ( to obtain the white portion of the sidewalks )
Both the representations have been composed with other 2-d solidified polygons in order to match some parking areas or other roads with irregular shapes.
In addition, in order to display some grass areas, to the first structure that represents the grey portion of sidewalks has been applied another difference with the solidified corresponding polygons, and then composed with the extrusion of such polygons with a grass texture applied. Anyway, the visual effect of such technique did not reach the desired result so it has not been widely used in the project.
The result of such composed complex is showed in the following picture:
And here is a closer detail to show the z-extrusion of the sidewalks:
The code to generate this model is provided by the module graticcio.py
Flat buildings
Most of the flat buildings in the area of interest share the same structure.
The module terrazzo.py provides the terraces models for both "BRICK" and "GREEN" styles flat buildings, with parametrical colors and textures.
Terraces are supplied with railings, randomly drawn sun curtains, and very stylized plant-plots. To decrease loading time, all of the elements are pre-generated once inside the module, so that external modules don’t have to recall their functions many times. When there are many versions of the same element ( e.g. terraces with different drawn-state sun curtains or plant-plots ), the modules instance a list with all of the available versions, which is provided to the external module that is then able to randomly choose among them.
The palazzo.py module is in charge to actually build the flat buildings, assembling terraces, ground entrance, flat roof and a simple grey base with some parking spots.
Functions defined in this module allow the generation of multi-floor and multi-staircase flat buildings depending on the provided parameters. Each staircase give access to four flats in the same floor. Any flat has a terrace oriented depending on its order and flats at the border of buildings has another smaller terrace on that side.
Anyway, to short loading time, two kind of flat buildings are pre-generated inside the module for each building style.
-
A single staircase / eight floor complex ( shown in the previous picture )
-
A two staircase / six floor complex (shown in the following picture)
The following pictures shows the two-staircase complexes and an example of their entrances.
The "Lego House"
The casa_lego.py module provide the model for this strange building.
The model has been fairly simplified and the windows has been modeled with a simple texture applied over a cuboid object to keep the complexity of the module small. The blue/yellow towers and terraces instead have been modeled with a 3d structure.
Since this is a very uncommon building, a picture from google street view is here reported to be compared with a screenshoot from the module.
The ACI building
The "Automobil Club Italia" building is provided by the palazzo_aci.py module.
The building is composed by a base with a pair of entrance door, many windows on all of its sides, and its particular structure on the roof that may be a cooling / wind turbine vane system.
Here is a wind turbine vanes detail. They are obtained with the extrusion of a profile composed by polylines and bezier curves.
The Churc
The church building is divided into two annex, both overtopped by a the first-floor structure with its typical circular windows and dark glasses.
The roof is decorated with walls made of squared elements with cylindrical holes.
On the right of the building, there is a particular crucifix actually composed by 12 dark metal cylinders.
The church building and its entrance streets are surrounded by trees and round flowerbeds.
This model is provided by the chiesa.py module.
Sporting Fields
Next to the church, some sporting fields and bleaches have been modeled.
Both the soccer and basketball field are basically the composition of a texture applied on a large cuboid complex and the goals or baskets for each side, depending on the field type.
Here is a detailed picture of the basket and the soccer goal.
About the basket, the orange structure is actually a TORUS composed with a cuboid.
The net is obtained with the 1-d skeleton of a composition of cylinders, embedded in the 3-d space.
Sporting fields models are provided by the campi.py module.
Other Common Urban Elements
Cars
The cars have been modeled as a composition of the chassis, the wheels, the glasses complex and other elements such as lights, an antenna and a license plate.
The cars models are provided by the macchina.py module.
In order to provide different coloured cars, this module instance a list containing a single car model for each color defined, to be accessed by external modules. Right now, available cars are blue, bordeaux or purple.
Parking Spots
Since cars are often represented as stationary in parking spots, the macchina.py module also provide code to model parking spots.
Currently, two different kind of parking spots have been defined:
-
In-line parking sposts.
-
Two-angled-rows parking spots.
Both these kind are showed in pictures below.
In order to build parking spots with a certain percentage of stationary cars, the functions that actually generate the models accept a set of parameters, that more that defining the number of spots define also the chance to get empty spots.
Trees and plants
The trees are provided by the albero.py module. In the beginning, the intention was to define a detailed tree model but the partial result reached ( in the picture below, on the left ) was too clomplex in terms of number of batches and still not enough pleasant at sight so i decided to build a stylized tree model ( in the picture below, on the right ) to include in the project model.
This stylized tree model is basically composed by a free trunk and a composition of scaled spheres as head, both with opportune textures applied.
Here is how the stylized tree model looks like when placed over the streets of the project model.
In addition, a plant model has been designed to be included in the project in the entrance of the buildings.
This is a typical element in the represented area and has been obtained composing a white squared plot with a sort of trunk modeled with a rotational surface and big palm-like leafs obtained with the mapping of a profiled surface.
Here is a picture of the such obtained model. The code providing this model in in the varie.py module.
Bus Stops
Bus stops has been modeled with a texture applied over a cuboid complex, then composed with two cylindrical structure opportunely coloured and with the top element obtained witht the extrusion of its profile made of a poliline and a bezier curve.
Each bus stop comes always togheter with a green garbage pail.
Code for this model is also provided by the varie.py module.
Rubbish Containers
Rubbish container have been modeled by composing their main body obtained with the extrusion of their profile made of polylines and bezier curves, and their coloured covers.
Code for this model is also provided by the varie.py module.
Billboards
Billboards are very simple models obtained by composing cuboid structures coloured with custom colors or with applied textures. In order to keep the project complexity low, just few billboards have been placed on its sidewalks and roads.
Code for this model is also provided by the varie.py module.
Grass Roundabout
Grass roundabouts are basically provided by the "aiuola" function of the varie.py module, that accept an "n" parameter that basically defines the number of fences elements in the returned roundabout. Since the fence element length is 1.5, the returned model has so a radius of (1.5*n)/(2*PI), and is composed by the fence, a grass textured cylinder, and a stylized tree model in the center.
Surface Modeling
At the beginning, one of the task scheduled for the project was to actually reproduce even the surface of the residence surroundings. With this purpose, I wrote two python modules to retrieve data via web services from Google Maps and GeoNames.org. These works returning a list of elevation values with given sampling intervals for an area which is given by its central Latitude and Longitude coordinates and the area size values.
The returned list is ordered such as if the area results divided in an MxN grid spaced with the sampling value ( M rows, N columns ), the first N+1 values of the list are the elevation values for the point on the first orizontal line of the grid where vertical lines intersect it, the second N+1 group refers to points on the second orizontal line and so on.
Unfortunately, the area of interest is rich of artificial bumps and sub-areas raised or leveled up to make the buildings contruction easier, and not the data retrieved from Google Maps nor from GeoNames.org resulted in a suitable surface for the purpose of the project. Anyway, the modules to retrieve data from those web services are included for further use.
Composition
To assemble the final model, a "grid" function has been used in order to find the correct coordinates to place models.
The grid function is provided by the grid.py module, and accept parameters for both sample intervals and intervals for hightlighted samples, more than just the height, the width and the grid colors.
The project model is assembled in the world_generation.py module, where a "place" function is used to deploy the models on the streets.
One last picture