I've been scratching my head over this one for
weeks now.
I want to be able to specify "roads" or "paths" in
my 3D engine with a series of 2D lines. That would give me the flexibility
to have roads any any angle, any direction, and any number/combination of
intersections.
There's two ways I see of doing it.
First, I would start
with a quad that would represent the section of road, and it would be "dropped"
down onto the terrain. Of course, the quad would need to be broken up into
as many polys neccessary to follow the shape of the terrain, and then these
polys would be rendered as part of an ordered group on top of the terrain,
and/or as a decal texture.
Second method that I'm sure would be the obvious
response, would be to rotate the U/V for the road texture to whatever
angle is needed, and do another texture pass on my polys. The problem I
see with this is I don't want an entire terrain "block" (a simple 4x4
mesh) handled with two texture stages for performance reasons, and second,
roads/paths would be created separately from the terrain heightmap, and I won't
know when I'm creating the terrain mesh if there's a road there or not.
Also, if there's an intersection of 2 or more roads, each would require an
additional texture stage.
Seems to me that an extra 30-40 polygons in a
"modelled" road would be insignificant, performance-wise, compared to getting
into multiple texture passes (and I do want to add a detail texture pass later,
so we'd be up to 3 passes). Early tests I've done with multitexturing
hasn't resulted in very good performance on decent 3D hardware (1.8GHz CPU,
GeForce2 and better).
FYI, the terrain is created completely on-the-fly
as height data is delivered from the server. No pre-created geometry, or
this would be a little easier.
Seems like there has to be a simpler solution for
this sort of thing, not much different than applying pre-calc'd lightmaps
or shadowmaps or decals like bullet holes in walls (ala Q3, Half-Life,
etc). The obvious low-end solution is a series of say 16 (or more)
textures representing various combinations of the road textures AND the terrain
textures, and using those instead of the normal terrain texture. But that
limits how freely the roads can be designed, and would duplicate the number of
terrain textures I'm loading already (which is more than I should be as it
is).
The first method makes the most sense to me, but
breaking an initial quad up into all the needed polygons is a bit beyond me, at
least without spending months developing spme really ugly code for
it.
If anyone has even the slightest suggestion I'm all
ears.
Scott
Virtopia 2 3D Project
|