Jump to content
  • Advertisement
Sign in to follow this  
sion5

OpenGL Implementing a Car Racing Track

This topic is 3477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, sorry for the bombardment of info but here is what i'm trying to do. FYI I use C++ and OpenGL. I want to create a racing track, can be a simple oval, complexity isnt an issue. I'm implementing a NN to drive the car so the car will have 2 "feelers" of set length, and the feelers will report an intersection with the edge or wall of the track (so that the NN can do its thing and sort itself out). [img=http://img369.imageshack.us/img369/4827/carfeelersyw2.jpg] So the design contraints are whether its 2D or 3D there must be a way of reporting how much of the green feelers have left the track (or intersected a wall on a 3D track). My question is: How can I put a track in the game (easiest way)? with that method of implementation how will I establish how much of the feeler has left the track?

Share this post


Link to post
Share on other sites
Advertisement
you could use a simple line - plane intersection test, if you have constructed walls as 3d geomtery around the track, i.e. a triangle mesh indicating a wall is there then you can use this data to test for an intersection, simply loop through all triangles, test for the intersection and find the point of intersection of the triangle that intersected, most algorithms for finding an intersection give you the intersection point as a value between 0.0 and 1.0, if you want to finds the point of intersection you would do: p = p0 + ((p1 - p0) * a) where a is the ratio between 0 and 1, p0 and p1 are the two points of the line segment, or in this case the feelers. this can be easily transfered to 2d by replacing the mesh with line segments and testing for a 2d line - line intersection.

Share this post


Link to post
Share on other sites
I am quite comfortable with loading in 3D models so may make something similar in max/maya and load it in. I have come accross line plane intersections before but was a little unsure as to whether this was the right scenario to use it.

The 2D version seems a little more complex as how will the intersection testing work on curves (a bend)? a quick google brings up some ugly looking math :-s

Share this post


Link to post
Share on other sites
Quote:
Original post by sion5
I am quite comfortable with loading in 3D models so may make something similar in max/maya and load it in. I have come accross line plane intersections before but was a little unsure as to whether this was the right scenario to use it.

The 2D version seems a little more complex as how will the intersection testing work on curves (a bend)? a quick google brings up some ugly looking math :-s


if you are using some other structure like a bezier curve then you can just break it up into line segments, but for a full curve-line intersection it requires complex maths and will probaly be less efficient in the end.

you can still get realistic results by just using x-amount of line segments per curve, this is the exact same thing you would be doing with a 3d mesh exept you would be using triangles instead of lines.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!