Best way to add roads/objects to a terrain engine?

Posts: 509
Joined: 2002.05
Post: #1
Well I am at the point where I need to add roads to my terrain engine, and my current solution is not working as smooth as I want it too.

The current one basically goes like this. You make a road mesh in Meshworks, and then I load it to my game, and then stick it to the terrain .05 above it. There are several problems with this.

One is I have to go into photoshop and write down the X,Y cords of each place that needs a vertex. For example if I have a hill with a slope of 1 and then a flat area I need 3 sets of vertex, one at each end and one where the slope changes. This is a pain in the ass when you have lots of different slopes like I want. Also when I need a curve I have to write down the XY coords and then use them in meshworks by hand.

Another is that making curves and texturing is slow, I have to assign each vertex a UV location of its own and then making cures looks good, but is time consuming to make the correct detail.

Most things (like the physics system and LOD terrain) were added with no major problems and are working now, but this is my main problem. Who here has added road to a height map before, or can tell me the best way to do this.
Quote this message in a reply
Post: #2
I believe creating specific terrain textures with roads painted on them and then associating polygons with those textures is probably the easiest way.
Quote this message in a reply
Posts: 916
Joined: 2002.10
Post: #3
nabobnick Wrote:I believe creating specific terrain textures with roads painted on them and then associating polygons with those textures is probably the easiest way.
Quote this message in a reply
Posts: 353
Joined: 2002.04
Post: #4
Maybe multi-texturing is your answer?
Quote this message in a reply
Posts: 1,142
Joined: 2002.04
Post: #5
Doesn't hit on roads, but some cool papers for when you need to take a rest from coding..


Carlos A. Camacho,
Quote this message in a reply
Posts: 338
Joined: 2004.07
Post: #6
monteboyd Wrote:Maybe multi-texturing is your answer?

I'm thinking the same thing...

Maybe have one large square texture for rough, and a thin strip of cement texture for road. You can combine that thin strip with some sort of path. I'd suggest hermite splines- it's basically a list of points and directions, and your road will travel through these points going in the direction you specify. Google it for more info if you're interested. If you want to add variable road width, maybe have that be a parameter for control points along with position and direction, and do linear interpolation between them.

From there I'd have an orthographic view (glOrtho,) all rough, with the road path "painted" on it. You can render it to a new texture (NeHe lesson 36) and then just slap the texture over your terrain.

The only downside would be the stretching of the road texture over steep slopes.

I've never coded anything like it before so I don't know 100% if it will work, but it seems feasible.

Some useful links about all this stuff:
Rendering to a texture
Hermite curves

Hope that helps!

Justin Ficarrotta
"It is better to be The Man than to work for The Man." - Alexander Seropian
Quote this message in a reply
Posts: 509
Joined: 2002.05
Post: #7
Well after spending two hours reading last night (Cmd-Option-Control-8 is great for white text Smile) I learned a great deal.

1. Most tutorials tell you how to create these great scenes with LOD and very few triangles, but tell you nothing about texturing. My engine has a great LOD engine that can reduce about 16K triangles into 2K and still look almost exactly the same, but I have 1 texture that is tiled over the entire thing right now.

2. Multitexturing is how its really done. I have never done this before, so I am going to write a demo after I post this to figure it out, but it is exactly what I want probably. I just need to find if it is going to slow me down too much, considering most triangles will have 2+ textures on it. I need to read up on this more before I implement it though

3. Photoshop 7 can't do crap with 16 bit greyscales, but CS on my PC can, so now I can actually use 16 bit height maps instead of 8 and it makes me wonder how I waited so long to make the switch (all because of PS 7s lack of gradient for 16 bit.)

4. Roads can be done in a much easier way, I forgot the screenshot, but basically you make a big line of floating point values in between the tiles, and then that represents the center, and attack more triangles perpendicular to the points to make the road have width.

Well I am done typing, I just need to go experiment and do more reading right now before I say too much more.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Decals on terrain, objects etc. IBethune 3 4,232 May 11, 2007 07:44 AM
Last Post: TomorrowPlusX
  Roads in a 3D Heightmap Jake 11 9,317 Nov 15, 2004 04:51 PM
Last Post: Jake
  Dot3 terrain engine Jake 4 6,446 Nov 3, 2004 06:36 PM
Last Post: Jake
  Water gfx in a terrain engine Mars_999 3 4,285 Sep 4, 2003 04:32 PM
Last Post: David