Hi guys,
I'm fiddling with yet another xi4n plugin (a fully automatic TV director) - but I want it to work properly on tracks without nodes (i.e. BL1X).
One problem I want to solve is how to predict when something interesting is about to happen. For that I kinda need nodes to make what I want do-able in a practical sense - calculating the distance and closing speed between close players on the track, and doing it for all racers is just ridiculous (if you're not seeing why I suggest you run the numbers of calculating the distance between every racer on a 32 slot server, assuming it's full).
So I've come up with 2 solutions thus far for creating pseudo-nodes;
1. A basic grid system that basically rounds the racers x,y,z coords to the nearest "chunk" (at the moment about 20x20 in-game units/meters) and then I query all racers in that chunk. The problem is that it's really dumb and doesn't take into account the shape of the track, or cross overs (I could make it cleverer, by making it a 3D chunk to solve). It's pretty quick, however, but the real issue is that a chunk might only have a very small amount of track in it, because it doesn't take into account the shape of the track. I've put together a quick prototype and it sort of works, but because of the shape issue it's not good enough in my opinion. Increasing the size of the chunk makes things more usable, but still suffers from the same problem.
2. A 3 dimensional KD tree, built when the track is loaded, from the relevant track or layout PTH file - i.e. I take every Nth x,y,z coord from the PTH file and use that as the center point for my node). Using this I can actually get the players nearest a particular node with minimal calculations (thats the point of a KD tree). By grouping the racers every update I can make a pretty good assumption that the racers in the same pseudo node are actually racing each other. The problem is I don't fancy writing a 3D KD tree implementation this afternoon unless I absolutely have to, plus it requires a PTH file. More over, if you're on a remote insim connection, you don't get the PTH file thats loaded, so it would need to be a manual process selecting it - this seems a little sucky. The major benefit is that you really do get a pseudo node, like you would normally, and it's reasonably quick to determine which node a player is closest to. Generating the KD tree might be a little slow, but I think it'll be acceptable since it can probably be pre-calculated, or calculated on track load.
So I ask you, if you've thought about this even a little have you considered any options that I might've dismissed?
Bear in mind I've not got a compsci degree, so I'm acutely aware that I'm lacking in some of my structures knowledge and I'm kinda expecting that I've missed something.
Or have I just got hung up trying to create pseudo nodes and I'm missing something really obvious?
I'm fiddling with yet another xi4n plugin (a fully automatic TV director) - but I want it to work properly on tracks without nodes (i.e. BL1X).
One problem I want to solve is how to predict when something interesting is about to happen. For that I kinda need nodes to make what I want do-able in a practical sense - calculating the distance and closing speed between close players on the track, and doing it for all racers is just ridiculous (if you're not seeing why I suggest you run the numbers of calculating the distance between every racer on a 32 slot server, assuming it's full).
So I've come up with 2 solutions thus far for creating pseudo-nodes;
1. A basic grid system that basically rounds the racers x,y,z coords to the nearest "chunk" (at the moment about 20x20 in-game units/meters) and then I query all racers in that chunk. The problem is that it's really dumb and doesn't take into account the shape of the track, or cross overs (I could make it cleverer, by making it a 3D chunk to solve). It's pretty quick, however, but the real issue is that a chunk might only have a very small amount of track in it, because it doesn't take into account the shape of the track. I've put together a quick prototype and it sort of works, but because of the shape issue it's not good enough in my opinion. Increasing the size of the chunk makes things more usable, but still suffers from the same problem.
2. A 3 dimensional KD tree, built when the track is loaded, from the relevant track or layout PTH file - i.e. I take every Nth x,y,z coord from the PTH file and use that as the center point for my node). Using this I can actually get the players nearest a particular node with minimal calculations (thats the point of a KD tree). By grouping the racers every update I can make a pretty good assumption that the racers in the same pseudo node are actually racing each other. The problem is I don't fancy writing a 3D KD tree implementation this afternoon unless I absolutely have to, plus it requires a PTH file. More over, if you're on a remote insim connection, you don't get the PTH file thats loaded, so it would need to be a manual process selecting it - this seems a little sucky. The major benefit is that you really do get a pseudo node, like you would normally, and it's reasonably quick to determine which node a player is closest to. Generating the KD tree might be a little slow, but I think it'll be acceptable since it can probably be pre-calculated, or calculated on track load.
So I ask you, if you've thought about this even a little have you considered any options that I might've dismissed?
Bear in mind I've not got a compsci degree, so I'm acutely aware that I'm lacking in some of my structures knowledge and I'm kinda expecting that I've missed something.
Or have I just got hung up trying to create pseudo nodes and I'm missing something really obvious?