Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Creating curved roads 2, thinking inside the circle (theory and application)

Author
Message
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 4th May 2007 08:24 Edited at: 4th May 2007 08:49
This post will probably be long. I want to make a motorcycle simulation, not like a racing a game, but something like riding through the mountains here in California. I've been studying pictures and video I have taken while riding my motorcycle, and realized to simulate this that square matrixs, advanced terrains, or any other terrain system that I have seen will not work. One of the biggest drawbacks I have seen with any terrain system is, the bigger it gets, the slower the frame rates get. This seems to be because if you have a terrain size that is large, DX draws all the polygons regardless if they are on the screen or not, since they are one object. In fact, this is the case with any object, according to my tests. So, even the method for making a sky sphere, inverting the normals on a big sphere, may not be the best method. Modeling a track and or terrain and loading it will give great results, but, I suspect you will still have a frame rate hit because it is still one large object. I verified this with my first attempt at curved roads. The longer the road got, as one object, the slower my frame rate got. So, I started thinking, what is the MAIN thing I want to acheive? I want to create realistic roads. So then, I started thinking about what kind of properties roads have. They have width, they have a turn radius, they have grade (hills), they have shoulders. Everytime I ride my motorcycle, I'm constantly thinking, how can I simulate all this in 3D? Then it hit me. What if I could make the road, and draw the terrain around the road? After looking at my pictures and videos, I realized that you don't see too much terrain besides the actual road and the shoulder and the trees and hills alongside the road. So why do you need all that extra terrain you are never going to see? So, I modified my original curved road function, added the ability to make uphill turns and downhill turns, and I think I'm heading in the right direction. I learned you can use plains and paste images on them to point at you as you move along this road. So trees, rock outcroppings, roadsigns, etc, are no problem, and no big deal, and look 3D when you do them. I learned also that the code I created could also be used for long distance billboards, for mountain scenary. So, instead of creating a sphere and texturing the inside of it, you could place a strip around the road, and texture it. You save all the polys that you never see below you. Here is the function I came up with.

By repeating calls to this function, you can make radiating bands of curved segments. If you want a complete circle, make it 360 degrees. If you want a corkscrew, make it greater than 360 degrees and adjust the ysv#( y step value)
Here is a code snippet of it in use, where it creates a a 720 degree hi resolution corkscrew uphill turn, and the camera code to follow it.

This is a good test for the polys drawn issue. Make some other turns in different locations and different sizes. As individual objects, if the camera isn't pointing at them, they won't be drawn, and it won't affect your frame rate. I guess what I think is, for large terrains, maybe it's best to break them up into smaller chunks. I have alot of ideas to expand this concept, like create a type to keep track of all the vertex positions for each object. This would be handy for placing trees an rocks and such. Other applications could be train tracks, roller coasters, anything on a track, really.
sorry so long, but, I need some input on if anything like this has been done, I've searched but haven't found anything yet. I guess in it's most basic form I've created a different primitive.
Let me know what you think.

Attachments

Login to view attachments
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 4th May 2007 08:45
ok, I had some error on the second code snippet, because it takes media. I commented it, if you want to use mine, you have to download it, or you can point to your own image.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th May 2007 09:57
There's always ATD roads, if you imagine taking the heightmap from whatever terrain system your using, and creating blocks that sit on top of the terrain. By utilising vertice alpha, you can create sharp round transparency. The demo I made uses a simple mask image, and makes a circuit around a terrain, looks kinda like tarmac.

Really though, if this is a straightforward racing game, the traditional methods would give better results, it depends on if your planning on going off-road so to speak. I mean, a modelled road would look better than my roads due to the fact that I can't add edges, or fancy texturing. When modelling a road you'd have a long segmented length of road mesh, which can be twisted and bent to form a track. It comes with it's own problems (like collision detection), but modelling a race track is a lot more straightforward than most would think.

If you wanna see I'll attach my AT road demo later tonight.

Green Gandalf is working on a terrain shader that supports roads I believe, there's already one that gives a colour mask system, like you might have grass, sand, and tarmac, then using a colour mask, you can set the levels of each texture in the red, green, and blue colour components.


Good guy, Good guy, Wan...
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 4th May 2007 10:21
Maybe I need to put together a demo, with trees, rocks, and lots of road segments. I haven't seen the ATD roads yet, but I'd like to. I think what I'm getting at here is, don't make the terrain, then put the road, but, put the road and make the terrain around it. This is how this system I'm working on works. Look at this picture, and ask yourself how would you simulate this, and then maybe it will make more sense.

Attachments

Login to view attachments
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 4th May 2007 10:27
also, there is NO terrain system here. Roads I create are more like primitives, like cubes or spheres. Each turn could be placed on top of a terrain or matrix. Your system creates a terrain first, then makes roads. I propose make roads first, then create terrain AROUND the road. This function will make banked turns, uphil or downhill turns, heck, you can even make round matrixes. It can make roads with walls on both sides, a wall on one side and a drop off on the other. It can be used to make a billboard for far off scenery. Play with it, I think it will surprise you.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 5th May 2007 01:22
Why cant you just 2 or 3 small AT's that generate on-need... Thats what all of the pro ATV Off-Road games use. Just switch the AT heightmaps and reposition the AT's as they're needed. Roads can be achieved with AT, its fast, and gives you access to all of the at commands.

z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 5th May 2007 01:58
I don't know if this could work, but dividing the terrain up into a grid and drawing the cells of the grid within a radius of the player? That could speed it up.

~ z_man ~
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 5th May 2007 08:54
@Visigoth
I think this is called something like Octree, or something like that. It breaks up areas of a terrain/objects, etc, then uses the closest area for collision checking, details, shaders, etc.


Cheers,

-db


What? You mean I cant sleep here???
z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 5th May 2007 10:31
That is basicly what I was saying, if you divide the terrain up you can ultimately have a very fast game.

~ z_man ~
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 5th May 2007 15:23
Visigoth:

You never heard of resizing images? Lol!

The one you posted is a 1.6MB 3264x2448 pixel file (22.8MB uncompressed). 800x600 would have been a bit easier on those without broadband...

So to anyone wanting to view it, if you have a dial-up connection, it might take a while!

TDK_Man

Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 6th May 2007 07:12 Edited at: 6th May 2007 07:23
I'm really really sorry about that big picture. I have an 8mp camera, and I forget to resize sometimes. I apologize for that, please don't be mad at me. I resized the image to 800x600. I'm glad some folks took a look at my concept. If you look at this picture, you might see what my goal is. Large terrains are not necessary, since you don't really see too far off. So, in my opinion, making the actual road the main point and drawing the terrain around it makes sense. Here's where my tests are so far. Just a blue screen, with no objects, I get about 800 fps with my rig. (AMD64 3000 with an ATI 9650 128 mb and 1 gb main memory). If I put an object, big or small, as long as the polys are onscreen, fps drops to 400 - 500 fps. Polys on screen reported with the statistic(1) command shows polys onscreen if any part of the object is on screen. So, if I have an object that has 1000 polys, and only 1/5 of the object is on screen, the statistic(1) command says I have 1000 polys. Once I move past the object, then it reports 0. If I have a large terrain object, and say it has 1000 polys, as long as I'm over any part of it, it still reports 1000 polys, and in the case of matrixs, it STILL reports 1000 polys even if I move past it.(haven't tried advanced terrains yet) If the terrains were matrixs, it wouldn't really help breaking them up. If you look at my picture, you'll see there are only two turns there. And you don't see too much past the turns, in any direction, due to the boulders and trees. So why bother with a large terrain? I could simulate trees with plains and point them at the camera as it passed them. Same thing with boulders. I've done it already in tests, and it looks good. Lighting even works, well, ambient does. I also tested this idea by making the road one continual object. The longer it got, the slower the FPS got. So, looking at the picture, here's my idea how to simulate this. Use my function to create the road and the shoulders, and even the "cliff" on the right side. Use a rock type texture to texture the cliff, use plains pointing at the camera to simulate trees on the left side, and use my function again on the right side to billboard the big mountain. I still need to work out an algorithim for percents for UV values to have a "stretch mode" for images, but it shouldn't be to hard to do. Each turn is it's own object. Movement code is handled using the intersect object() command. Since you can keep track of which way you are going, you only have to check if you are above one object or the next (or previous, if you turn around) to hand off the movement code from one object to the next. I'm working on a demo to show this idea off. I really think it will work for what I am trying to achieve. This may not be the best way to do a race track or city scape, but, it might be a good, different way to do mountains and forest. And I just want to add, DBPro is great. I tried to do this in VB with DX, but I got lost and frustrated. I could probably do it now from what I have learned so far, but why bother. Thanks Lee and everyone else who built this great program. Thanks everyone.

Attachments

Login to view attachments
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 6th May 2007 08:31
I hate to reply to my own post, but I just had another thought. What if you did model an entire track, but, broke the model up into sections. The original vertex data would be the same, so, if you were using .x files to load these sections, they should still place in 3D in the correct location. And since each section was an individual object, it would not render unless it was onscreen. Since matrixs render regardless if onscreen or not, according to my tests, this should help the frame rate problem. Maybe the key is not using the the built in follow commands,(get terrain height, get matrix height) but using interstect object() over individual objects to move the player. Just a thought, and I think I'll test it.
The Smoking Pen
17
Years of Service
User Offline
Joined: 21st Sep 2006
Location:
Posted: 6th May 2007 12:17
Splitting the track model into sections is how the circuits were modelled in the commercial game Grand Prix 4.

Login to post a reply

Server time is: 2024-04-24 01:42:40
Your offset time is: 2024-04-24 01:42:40