17.11.2018, 16:57
Quote:
Yes.
You can use sscanf to parse the files easily. Either load them everytime you start the server into an array, or output the data as array to put it into your mode directly (the first will make it easier to edit, but considering the track won't change you will probably never need to do that anyway). Then you can just create an object and move it from node to node. May be a bit hard to find a good object for it, but the movement etc is really easy to do. You also need to calculate the object's rotation for each node. So if the object moves for example from Node 40 to 41 you can use atan2 and acos to get the angle between the coords of those nodes. I can give you an example for that if you wish. One thing however is that trains (the vehicles) move on the track by two axes per wagon. So each end of the train wagon follows the track just like a real train. An object just has one axis to rotate around, which is most likely the center. So the rotation while moving might look a bit wrong compared to actual trains. This is fixable but a bit tricky since you need to rearrange the nodes to make the rotation happen only on the actual turn, not while approaching the turn. The easiest fix would be doubling the amount of nodes, so that there is one node in between two turns and one exactly where the rail bends. But I'd do that later, and only if the current result is not satisfying enough. |
It's quite tricky even to get a good object for it. I'm going to test here with some object and see if I can show off with a "train"