PLSM2, roads, decals, etc...

elver

17-10-2005 14:47:16

I have a question regarding PLSM2.

Let's say I wanted to have a square batch of land that is built using a heightmap. There's some basic grass there, some sand and through the area goes an S-shaped road.

How do I texture that S-shaped road?

If it was just a dirt road, it'd be quite easy, actually. I'd just use some basic splatting and that'd be it.

However, what if I wanted to put tarmac with those middle-of-the-road stripes on it?

Or what about later adding tire marks where the vehicles go through the grass?

Is that possible with PLSM2? How?

Is it done with decals?

Can anyone point me in the right direction?

The result I'm looking for regarding the road is something like this:

tuan kuranes

17-10-2005 15:23:09

Unless you have a very detailed landscape resolution, in which case splatting would still do it (think of yellow lines as separated splat from road), decals is the way.


Further mapEditor tool release is planning a map to mesh exporter, so you can have hand on the terrain mesh in a 3D tool and will make your decals offline. (see mapeditor thread.)

Perhaps you can do that now by using heightmaps and same scale value in you 3d editor if it supports it. And inside 3d edtior make your road.


It's would be possible with plsm2 at run-time using decals.
Here's how we can have access to an Array of terrain heights today


Real *myArray = new Real (1000);
setOption ("BrushArray", myArray);
setOption ("BrushArrayHeight", 10);
setOption ("BrushArrayWidth", 100);

// it's the center of the square given above
setOption ("fillBrushArray", &Vector3(x,y,z));


Now I can easily add a fillMeshArray that would return Vector3 instead of just height. But it would up to you to build the mesh...
Or I can create the mesh and return an Entity...

Thing is that you'll have to make rectangular section of roads, like in Road Construction Set, as all mesh would be rectangular.

What do you think ?

Falagard

17-10-2005 15:42:16

I'm going to be facing that problem. Take a look at the "rods and rigs" in the showcase section for a solution. In that case he's used separate meshes that piece together - probably a straight piece, turn left, etc. etc. I'd suggest doing something similar to that except to make it look better you have the texture of the road mesh transition to dirt on the sides... then splat down dirt texture on the terrain to match it... and then put in some extra grass on rocks and stuff along the side of the road to mask the transition between the road and the terrain.

That's what I'm planning anyhow :-)

If I had lots of time I'd create a system that would let you lay down road along a spline and it would take a road mesh and tile it and bend it to match the spline. That would be the best way to do it actually, because with the above "pieces" approach you have nasty problems with seams. You're okay if you're only working on a flat road though, because you can get the meshes to come together nicely in that case.

Wanna work on spline roads for me? :-D

Technically, I'm not sure how it's done, but it does work. A game called Trainz found at www.auran.com does it very well.

http://www.math.uiowa.edu/ftp/comp_math ... rt-145.pdf
http://www.cs.uiowa.edu/~kearney/pubs/C ... tPoint.pdf

I wish I could find some code out there that already did it though.

Oh yeah, the other way to do it would be to export your terrain as a mesh and open it in a modelling program, create your road in there (most advanced ones like 3ds max have the ability to do spline stuff like we're trying to do) and then break it up into pieces and re-export it. Come to think of it, my first version will probably do exactly this. I'm adding the feature to the map editor to split out a terrain page as a mesh (ASE in my case since it's an easy format).

Clay

Falagard

17-10-2005 18:09:22

After a bit of time to think about this, I'm definitely going to be exporting the terrain to a mesh and loading it in my modelling program to do the road externally.

I'll then build in functionality in the map editor to automatically break up a really large mesh into smaller pieces when loading a mesh. I can probably leverage this code from the DotSceneOctree project which I believe breaks meshes up into pieces. This will allow really cool stuff such as whole road systems, city blocks, etc. to be modelled completely outside of the map editor and imported into the scene in one fell swoop, at which point they'll be converted into separate .mesh files and loaded into the scene as MeshGameObjects for my object framework.

In my case, I need to do modern day roads, which includes paved roads, intersections, sidewalks in urban areas, etc. and it would be too complex to try to create systems to do these automatically in the editor, so I'll use the advanced tools in existing 3d modelling programs to do them, and give then add functionality in the map editor to help break these up automatically.

3ds max has a "conform" modifier in which the help documentation has a tutorial specifically for making a road follow terrain. It also already has the ability to extrude meshes along a path, etc. so it's perfect. Then for complex things like intersections would can create an intersection mesh and stitch the vertices together with the other pieces of road.

Clay