Monday, 7 September 2009

Road Signs

To make things look more like a real road system, I have begun to implement a road sign system. It's still in it's infancy, but it currently uses road nodes to generate a list of all the roads meeting at that node and create a texture for the sign showing the road names. Te texture is created in a similar way to the sprite font, however this time it copies pixels from a font bitmap into the target bitmap in memory, then binds this to a texture name and so on.


Some work needs doing to remove duplicates and put arrows on the sign so that it makes more sense, but it's a start. I could probably do with some higher resolution fonts as well, since the signs can be quite large on the screen, but that should be easy enough.

The main issue, however, will be positioning the signs in useful places. Roads often have nodes even if they only join two sections of the same road. Obviously there is no need to put a sign down that confirms you are still on the same road. On the other hand, when a junction is met, where should the sign be placed? This can be calculated by taking the direction the road is coming away from the node in, and placing the sign on the left-hand side of the road. Finding a vector perpendicular to the road is easy in two dimensions, and only slightly harder in three (take the cross product of the direction of the road and the global 'up' vector, that is (0, 1, 0)).

Thursday, 3 September 2009

Road Markings

After much thinking and fiddling with code, the first semblance of road markings have appeared. To get this working, I have used the road link data which has a list of coordinates for each road showing the lay of said road. By lining up quads along this string of coordinates, pretty convincing road markings can easily be created.

Unfortunately, the markings are in sections of straight lines, which can be seen in this screenshot. The next step is to interpolate between the points on said line to make a curve, and align the markings tangentially along this curve.