Game Development Community

dev|Pro Game Development Curriculum

Spline Roads

by Duncan Gray · 10/27/2008 (12:49 am) · 32 comments

I thought I would post a blog and some pictures about what I'm busy with. A previous game I made used a road system of dif sections which were auto assembled into a random road grid. It worked fine and I was able to extract positional information to determine whether the vehicle had left the road, was going the wrong way etc.

But that road system was flat and using dif's was not suitable for bendy or curvy roads and I wanted to do something more natural looking. I first attempted to save the terrain as a heightmap and import it into a 3D tool where I could create a road system which followed the terrain as needed. I ran into problems with getting the terrain to import at the correct scale and decided there had to be a better way. I recalled D-racer had some great looking roads so I thought I would try and make my own version of spline roadway.

It turned out great. I only have to plot a few roadmarkers on the terrain and the software creates a perfect road which is divided into sections for scenegraph purposes and rendering efficiency. I also had to implement a collision system and solve the problem of gradually applying fog at the horizon. I can extract exact information about where each wheel is which is useful for dolling out violation points etc.

Still working on it but so far so good.
www.ultrabizz.com/biz/splineRoad.jpgwww.ultrabizz.com/biz/splineRoad2.jpgwww.ultrabizz.com/biz/splineRoad3.jpg
Page «Previous 1 2
#1
10/27/2008 (1:04 am)
Sweet! 8-)
#2
10/27/2008 (1:05 am)
Cool! Looks good.
#3
10/27/2008 (1:43 am)
Very nice looking.
#4
10/27/2008 (2:15 am)
Wow, that looks awesome.
#5
10/27/2008 (3:40 am)
This is very cool and sounds like its simple to use. I've built similiar road systems using loft objects that are based on splines in a modeling package. But you're saying this method generates the model based only on terrain markers you place on the terrain in Torque's Editor? This alone would eliminate the hassle of getting the road to exactly match the terrain, something that requires a lot of back-forth referencing the way I normally do it.

Is this code something you plan to release?
#6
10/27/2008 (7:00 am)
impressive!!!
#7
10/27/2008 (8:28 am)
this is dts?or dif?if is dif...So cool...
#8
10/27/2008 (9:12 am)
This looks great.
#9
10/27/2008 (10:03 am)
Looks great Duncan!
#10
10/27/2008 (11:48 am)
Very nice and quite impressive. I'm looking forward to more news on this.
#11
10/27/2008 (12:45 pm)
Very awesome stuff. Keep up the good work and hopefully we will see that is a content pack we can purchase and integrate into our games.
#12
10/27/2008 (1:17 pm)
Very very nice Duncan! Makes me want to do a racing game.
#13
10/27/2008 (2:24 pm)
So smooth...
#14
10/27/2008 (3:00 pm)
That is too cool!
#15
10/27/2008 (3:53 pm)
Duncan we want it! keep working on it and give us a content pack please! :-)

JoZ ;-)
#16
10/28/2008 (8:28 am)
Gorgeous!

This system is exactly the kind of thing they use in BigWorld (I think it was BW) to do rivers also...
#17
10/28/2008 (2:59 pm)
This is great. So you send the control points from the editor into C++ which draws your geometry right? I'd be interested to see how you handle intersections. Bunching is always a problem at sharp corners.
#18
10/28/2008 (3:48 pm)
Yeah a river would work well too. Just put on a water textures (or shader) animate the texture coordinates and you get a flow all along the spline. Add some spray particles, some floating debris etc and it should look good.

Also good for train lines and roller coaster tracks. For the latter I would "mount " the carriages to the spline with an offset then animate the velocity. That way it would follow the rails perfectly without the need for rocket science, cpu intensive physics.

So many ideas, so few people willing to pay good money for them.

@Andy, I'm actually at the point of adding intersections. My current approach is to use a TSstatic and start and stop the spline on either end of the intersection. I can put nodes in the TSStatic and use them to tell the spline where it should meet the junction so that the road polly's make a seamless join to the TSStatic.

I was considering marking a control point as a junction which would tell the engine to create a junction there but that would mean hard-coding the junction vertices and you would have the additional problem of expecting that control point to exist in two simGroups simultaniously. A separate TSStatic junction seems to be a better approach.

I get no bunching with the curves in the pictures above but the inner vertices are getting about 0.5 meters apart, so it can it can go just a little tighter before they start overlapping/bunching.
#19
10/28/2008 (6:21 pm)
I put a video up there showing how easy it is to work with.
#20
10/29/2008 (1:25 am)
We can go to where download or to obtain these features????
Page «Previous 1 2