How to import tracks in server?
I want to develop a game server for a 3D car racing game. To decrease the load of the server, I'm not going to do any physics in server, just broadcast the player's state instead. I also want to do some simple check in server. For example, i want to check whether the car's coordinate is on the track. Here comes the problem: how does the program know the track's area? how can i import the racing track? Any ideas?
Thanks!
How do you know whether the car is on the track on the client?
Do the same thing on the server.
Do the same thing on the server.
Quote:Original post by hplus0603
How do you know whether the car is on the track on the client?
Do the same thing on the server.
Thanks!
When the client sends its coordinate to the server, if the server knows the track's area, it can know whether the car is on the track. If the car isn't on the track on the client actually and the client sends a fake coordinate, it won't affect the game result, because the result is desided by the server. And other clients will see that the car is still on the track as long as the coordiante sent to the server is on the track.
Anyway, how can the server know the track's area?
Here's one suggestion:
In your track editor, mark the triangles that are "track" (as opposed to scenery). When you export your track geometry, also export a file that contains only the "Track" triangles, projected to a 2D flat plane. Load these triangles into a quadtree.
When you need to test "is coordinate X on the track", simply run the coordinate through the quadtree, and test the triangles that you find in the terminal nodes; if the point is inside a triangle, it's "on the track."
In your track editor, mark the triangles that are "track" (as opposed to scenery). When you export your track geometry, also export a file that contains only the "Track" triangles, projected to a 2D flat plane. Load these triangles into a quadtree.
When you need to test "is coordinate X on the track", simply run the coordinate through the quadtree, and test the triangles that you find in the terminal nodes; if the point is inside a triangle, it's "on the track."
Quote:Original post by hplus0603
Here's one suggestion:
In your track editor, mark the triangles that are "track" (as opposed to scenery). When you export your track geometry, also export a file that contains only the "Track" triangles, projected to a 2D flat plane. Load these triangles into a quadtree.
When you need to test "is coordinate X on the track", simply run the coordinate through the quadtree, and test the triangles that you find in the terminal nodes; if the point is inside a triangle, it's "on the track."
Thanks a lot!
I don't know about graphics very well. Can u explain more about how to load triangles from the file(is it a .mesh file?), or is there any article about that?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement