Skip to main content

Criterium: Roads

Roads are tricky.  They have to match the terrain; they have to bank, curve, swerve and whatnot.  I have three ideas for roads, and no idea is trivial to implement.  All my ideas output a road mesh with a rectangular cross section, so there will be no gaps between the road and the underlying terrain.  The road will actually be a rectangular "tube" with only the top of the tube showing above the terrain.

First up is procedural generation of roads.  For this scheme, I would first generate the terrain heightmap.  Then, the roads could be generated by following contours, making random changes in direction, or making random jumps to different contours.  In the end, the procedural algorithm would output a list of waypoints for the road, and a mesh could be generated from the waypoints.

Second is direct creation of the road mesh.  I would have to make a modeling tool for the road, and extrude road segments from the end of the road.  Perhaps Bezier curves and control points could be used to manipulate curves in the road (both vertical and horizontal).

My last idea is a combination of the last two.  I could paint the road waypoints on top of a 2D texture, and then have an algorithm calculate the appropriate height of the road at each point.  The algorithm would need the heightmap as an input to calculate the road height.

That's all for now, more ideas soon.

Comments

Popular posts from this blog

Sparse Voxel Octrees

Terrain implementation for games is a subject with a lot of depth. At the surface, it's very easy to get rudimentary terrain working via a noise function and fixed triangle grid. As you add more features, though, the complexity builds quickly. Overhangs, caves Multiple materials Destructive terrain Collision detection Persistence Dynamic loading Regions, biomes Very large scale Smooth features Sharp features Dynamic level of detail Extremely long view distances In isolation, each of these features can make terrain difficult to implement. Taken together, it takes a lot of care and attention to make it all work. Minecraft is probably the canonical example for terrain generation in the last generation of games. In fact, I'd say Minecraft's terrain is the killer feature that makes the game so great. Minecraft does an excellent job at 1-8, but for a recent planetary renderer project I was working on, I really wanted 9-12 too. In a series of articles, I'm planning to break do...

Lua-Style Coroutines in C++

Lua's implementation of coroutines is one of my all-time favorite features of the language. This (short) paper explains the whole reasoning behind the Lua's coroutine implementation and also a little about the history of coroutines. Sadly, coroutines are not supported out-of-the box by many modern languages, C++ included. Which brings me to the subject of this post: Lua-style coroutines in C++! For those who don't know (or were too lazy to read the paper!), Lua's coroutines support three basic operations: Create: Create a new coroutine object Resume: Run a coroutine until it yields or returns Yield: Suspend execution and return to the caller To implement these three operations, I'll use a great header file: ucontext.h. #include <vector> #include <ucontext.h> class Coroutine { public: typedef void (*Function)(void); Coroutine(Function function); void resume(); static void yield(); private: ucontext_t context_; std...

Password Generator for Chrome

This week, I finally got fed up with typing in/managing passwords on a billion different sites. Since things like OpenID haven't really taken off, I decided to take matters into my own hands...and write a password generator extension for Google Chrome. There are actually a ton of such apps on the Chrome web store, but I'm paranoid about security, so I wrote my own and open-sourced it. By virtue of being open source, perhaps people will trust my version a bit more. Anyway, the extension is available here , and the source code is hosted at github . May all your online transactions be secure! UPDATE: Fixed github link.