Hi im trying to make a very very basic 3d racing game.
Basically, ive spent hours trying to work out how to detect whether my rocket (the car) has left the side of the track or not. I cant work out how to properly use bounding boxes/bounding spheres in 3D and i dont understand how that would even work with a track with bends etc.
Here is my source code for you to download and try and understand what I mean. Any help is really appreciated.
EDIT - http://www.sendspace.com/file/6pcunk
http://www.megaupload.com/ d=G6CLZF70
Or if someone could just explain how to go about working out whether the car has left the track or not What fuctions you should use or whatever.

3D racer problem (collisions)
gg1
for some start. In easy way.
Vikas Rao
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1274413&SiteID=1
In my post is simple method for checks...
if ((aPosition + vector) == outOfBounds)
{
velocity = 0;
}
My first suggestion was to use maps for bounds. You can do this in array int[,] or read from file. @riemers you can learn reading maps from bmp. So, Bmp in pixels(or your array) could look like this(you are choosing resolution):
XXXXXXXXXXXXXXXXXX
X XXXXXXXXXXXXXX
X XXXXXXXXXXXXXX
X X
X X
XXXXXXXXXXXXXXXXXX
In standard directions up, left, right, down it's easy, with vectors it's a li'l tricky.
Your movement vs "onMapMovement". You want to keep higher resolution in game while keeping lower on map.
The easiest way would be to use floats(something like 0.05), and cast them to integers before collision checks on map.
Treat this as li'l tutorial created from my short experience. Not great, but tested and good for any hard-tiled game.
If that's not sufficient, I would even write some test code. :)
Edits: Pic and few words about arrays.
Pockey
However im not sure exactly how to do this to be honest. As I said, im rather new to this.
How do I go about creating this map Do I just draw my a white track with a black background in paint and save as a bmp. Do i still use the model of the track aswell And then how exactly will this fit into my code.
It would be really really great if you could write the code that would work specifically for my game and show me what each bit does. I know thats a lot to ask but if anyone could to that then I would be so greatful.
Tejas34
Even if you could just tell me what would be the best way to code some way of telling whether the rocket car has left the track
Danny Thorpe MSFT
sendspace.com or fileho.com.
Marco Wiedemeyer
So all I want is...
- how to tell if my rocket car has gone off of the side of the track.
- how to tell if my rocket car has gone off of the end of the track.
And im not really that great at programming so the more in depth anyone can explain how to do things the better. And the simpler the better!
Thanks for the help so far.
Olavo
Any help would be greatly appreciated!!
dmadrian
Hmm even by looking on example...i can't figure out...is this real 3d(something like plain) or just 2d maps can be used
If just 2d(even with some high) I guess easiest way is to create maps...with colors for height. But it could be expensive for game(projects rule of triangle). Other way would be bezier curves for walls. It's very nice method for racers because racing game walls are usually rounded. If your game is full 3d or you just doing this game for learning, you'll want to go into something harder...
You can create another simpler model(not for rendering) of your track Just walls, floor...and other collision objects. And check with them.
If you too lazy...or afraid of hard to find bugs. You can do per face collision. Cut your track on crossed parts(and sides) and do checks on them.
EDIT: Oh, you should be able to do all that with BB or BS .contains(vector3) or intersects(plane). And many other nice overloads.
Mario M.
rschaeling
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Creating_the_3D_city.php
int_Floorplan = new int[,]
{
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,1,1,0,0,0,1,1,0,0,1,0,1},
{1,0,0,1,1,0,0,0,1,0,0,0,1,0,1},
{1,0,0,0,1,1,0,1,1,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,1,1,0,0,0,1,0,0,0,0,0,0,1},
{1,0,1,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,1,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,1,0,0,0,1,0,0,0,0,1},
{1,0,1,0,0,0,0,0,0,1,0,0,0,0,1},
{1,0,1,1,0,0,0,0,1,1,0,0,0,1,1},
{1,0,0,0,0,0,0,0,1,1,0,0,0,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
};
and cast your position on this.
I can't help more...I would need to write code for you, to go more deep and after reconsider - I am too damn lazy to do work 4free, sorry.
Read about vectors on wiki... read documentation, experiment a li'l. That's the way it goes. Goodluck.