This project aim to be a run-time street builder done inside World Wind. This application works drawing texturized shapes accordingly to the position given by the user. The program modifies the terrain taken the elevation from these shapes in order to have a street every time over the terrain. User can: add and remove pieces of shap, add and remove shape, select shapes already present, move points of the street, modify the blend. All these stuff are explained inside this paper.
1. Stefano Tranquillini
Street Builder
Raffaele De Amicis, Giuseppe Conti Principi di Computer Grafica – UNITN 08‐09
2.
3. Summary
Abstract ....................................................................................................................................................................6
Street Builder ............................................................................................................................................................6
Library used ..........................................................................................................................................................6
Interface ...................................................................................................................................................................6
Load and Save .......................................................................................................................................................7
Add .......................................................................................................................................................................7
Edit ........................................................................................................................................................................7
Pick........................................................................................................................................................................7
Move .....................................................................................................................................................................7
Delete ...................................................................................................................................................................8
Setting ...................................................................................................................................................................8
The Project’s file .......................................................................................................................................................8
Street ....................................................................................................................................................................8
Shape ....................................................................................................................................................................8
Street ................................................................................................................................................................8
Guard rail ..........................................................................................................................................................9
The classes ............................................................................................................................................................. 10
How Project Works ................................................................................................................................................ 10
Construction of a street ..................................................................................................................................... 10
Modification of points ....................................................................................................................................... 15
Modification of the terrain ................................................................................................................................ 16
Rectangular Tessellator ................................................................................................................................. 16
ModifiedTerrain ............................................................................................................................................. 20
TerrainBoundary ............................................................................................................................................ 21
Some Results and image ....................................................................................................................................... 22
.
Modification of terrain ...................................................................................................................................... 22
Line construction ............................................................................................................................................... 23
Blend .................................................................................................................................................................. 23
Tile density ........................................................................................................................................................ 25
.
Conclusion ............................................................................................................................................................. 26
Possible extension ............................................................................................................................................. 26
6. Abstract
This project aim to be a run‐time street builder done inside World
Wind. This application works drawing texturized shapes accordingly
to the positions given by the user. The program modifies the terrain
taken the elevation from these shapes in order to have a street every
time over the terrain. User can: add and remove pieces of a shape,
add and remove shape, select shapes already present, move points of
the street, modify the blend. All these stuff are explained inside this
paper.
Street Builder
Library used
Inside this project I’d use:
• World Wind source by NASA. Use the modify package (jar)!
• JTS: java topological suite.
• JOGL: a binding of OpenGL in java.
• SimpleFramework to store and load XML.
Interface
7.
Load Save Add Edit Pick Move Delete Setting Information
• Load: permits to load shape or shapes from file.
• Save: store shape or shapes into a file.
• Add: Adding a shape (street).
• Edit: adding or removing pieces of the shape.
• Pick: select a shape.
• Move: permits to move the points of the street, and the Bezier control point.
• Delete: remove the current shape.
• Setting: change the setting of the system.
Load and Save
The user can select or specify the file to store or load.
Add
This interface appears when a user tries to add a shape. The user
can select the type of the street and the type of the guardrail.
As we can see, each street has a different texture and dimension.
Same thing for the guardrails.
All these information are store into a XML file.
Edit
The user can works on the current shape. If no shape is selected the add dialog is displayed and the user can
specify the new shape to add. The edit functionality permits to:
• Add a piece: simply click on the terrain with the left mouse button
• Remove a piece: Clicking by the right mouse button
Pick
This function permits to select a shape. When is activates and the mouse rollover a shape the shape become
green. If the user click on the shape, the shape become the current shape and the user can work on it.
Move
Clicking on this button, the system shown points on the current shape, points for: start and end pieces, 3 points
for the Bezier.
If inside setting, snap is enabling, the points of the street can be moved only on the middle line of the pieces.
8. NB: Bezier point can be:
• Move: Simply click and drag the point
• Rotate: Press and hold the “A” button and drag the point.
• Resize: Press and hold the “S” button and drag the point.
These last three functionalities are given to let at the user a way to have a better result.
Delete
Remove an entire shape. When a shape has to be removed a prompt is shown and the street becomes green.
Setting
This is the setting’s dialog, the user can specified:
• The numbers of points that will be add at the current tile density.
• If shown or not the current shape
• If shown or not the interior boundary (grid)
• If the points have to be snapped: the points is moved on the line of the quad,
otherwise the movement is freehand.
• If has to be shown the construction line. (see the results section )
• The path of the skirt Texture
• The path from where load the shape configuration.
When click on save these information are stored into a file.
The Project’s file
Al lots of stuff are stored in files: shapes’ setting and the streets done by the user.
Street
In order to store the street the system serialize a class that aim to transport the information of the street.
Shape
There are two type of shape: street and guardrail. To add new shape need to construct a new file that follows
the structure above.
Street
<shapeConfig> Contains:
<path>shapecity.png</path> The texture path
<delta_width>6.0</delta_width>
<name>City Street </name>
The dimension
<description> </description> The name and a description.
</shapeConfig>
9. Guard rail
<guardrailConfig> Contains:
<texGuard>shapeguardrail1.png</texGuard> The texture path
<dimGuard>1.0</dimGuard>
<name>GuardRail 1</name>
The dimension (elevation)
</guardrailConfig> The name and a description.
10. The classes
This section contains a brief explanation of the classes. To have a better explanation looks on the JavaDoc or
inside the code.
• Gui: Contains the gui parts (the prompts shown on add and setting)
• Information: Contains a static class (TempAdd). This class is used to
share information into the project
• Main: Contains the main class. This class manages the menu and the
interaction.
• Setting: This package contains the setting parts of the system.
• Shape: Contains the classes that are used to build and render the
shape. Shape is the parent class that contains a list of shapeQuad.
Each ShapQuad is a piece of the street.
• Terrain: This package contains the classes used to modify the
terrain. ModifiedTerrain is the parent class that contains a list of
TerrainBoundary. The RectangularTessellator is a modified version
of the RectangularTessleator done by world wind.
Dragable classes are used to allow the movement of the points.
• UTIL: This package contains the util part of the system
o Listener: The manager of the listener: mouse and keyboard
o Geom: My class that is used to compute line, intersection
and other things.
o Other: Class that allows a simply way to load stuff
How Project Works
In this section there’s the explanation about how the project works.
Construction of a street
The construction of a street is done in two different ways. The first time is a simple construction of a rectangle
around a line (see image 1, 2 and 3). When a new piece is added the previous quad is cut and the new quad is
added. Between these two quads a number of quads are added as connectors that are used to construct a
blend.
14. The result.
NB: the vertexes are named in this way. The Boundary indexes
are 2 and 3 near the start position and 0, 1 near the end. This
is done by JTS that give us the boundary in this way.
This figure is useful to understand how the algorithm for the
newPieces works and how the vertexes are attached.
These entire steps are done using a Meters coordinates, WW works in lat Lon (angle) and so, inside the render,
there’s a converting of the coordinate in latlon done using a class PositionUtil:
private Position fromUTMtoPosition(Position p, Coordinate e)
Inside the converting step there’s the calculation of the guard rail points done taken the boundary of the street
and computing points that has an elevation plus the elevation of guard rail.
In render step, each quad render a skirt from the boundary of the street to the center of the earth.
15. The guardrail and the skirt.
The skirt is shown better in the following image.
Modification of points
The project permits to modify the point of the street. Clicking on button, on the shape appears some points,
these points’ permits to move the pieces of the shape or the Bezier points.
When a point is moved, the system recalculates all the connectors and the new vertices. These steps are done
in the render.
17. The creation of the ModifiedTerrain
if (Setting.showInterior == this.makeTileSkirts) {
this.makeTileSkirts = !Setting.showInterior;
WorldWind.getMemoryCache(CACHE_ID).clear();
dc.getModel().setShowWireframeInterior(Setting.showInterior);
}
This part is done to shown the interior Wireframe without the skirt. If there’s a change remove all the cache
and recomputed all the tiles
MemoryCache cache = WorldWind.getMemoryCache(CACHE_ID);
CacheKey cacheKey = this.createCacheKey(dc, tile, resolution);
18.
Read the cache of WW
if (!TempAdd.toRemove) {
tile.ri = (RenderInfo) cache.getObject(cacheKey);
if (tile.ri != null) {
return;
}
} else {
ModifiedTerrains.clear();
cache.clear();
cacheKey = null;
}
If there’s a modification (a pieces is added or removed: the ELSE branch) remove my cache and all the cache.
Otherwise (the IF branch) load the information already present.
int totShape = TempAdd.shapes.size();
ModifiedTerrain mf = new ModifiedTerrain();
if (ModifiedTerrains.containsKey(tile.getTileKey())) {
mf = ModifiedTerrains.get(tile.getTileKey());
} else {
//construtct all.
mf = new ModifiedTerrain();
for (int i = 0; i < totShape; i++) {
Shape Shape_now = TempAdd.shapes.get(i);
if (tile.sector.intersects(Shape_now.sector())) {
int tot_pice = Shape_now.pieces.size();
for (int j = 0; j < tot_pice; j++) {
TerrainBoundary sq = Shape_now.pieces.get(j).terrainBoundary;
if (tile.sector.intersects(sq.sector())) {
mf.addTerrainBoundary(sq);
}
Vector<ShapeQuad> connectors =
(Vector<ShapeQuad>)Shape_now.connectors.get(j + "-" + (j + 1));
if (connectors != null) {
int tot_partial = connectors.size();
for (int k = 0; k < tot_partial; k++) {
TerrainBoundary tb =
connectors.get(k).terrainBoundary;
if (tile.sector.intersects(tb.sector())) {
mf.addTerrainBoundary(tb);
}
}
}
}
mf.isModified = true;
}
}
}
This part is the construction of the Modified terrain for the current tile. First check if inside my HashMap
already present the modified terrain, if true: load it. Otherwise recreate all the Modified terrain.
22. Some Results and image
Modification of terrain
The bridge: the terrain is below the line
A cutting of the terrain: the terrain is above the line In these 2 image we can see the difference of delta
23. Line construction
The system allows to shown only the construction
line of a street. You can show using the setting gui.
Blend
Some blend shown by construction line and rendered shape. In 3rd and 4th figure there’s a modification of the
rotation and distance of Bezier points.