What is the best approach to find neighbours nodes?

EDIT: Ok :smiley: I found the BoundingVolume  :roll:


I am bustling with my first game attempt, let's say one of billions attempts to make a stars! game :smiley:

Let's say that if I used an algorithm on all stars data would be more efficient, also because I must replay the finder on a darkstar server, or better it's the darkstar server that might provide all stars connections. But for now I am exclusively interested for finding neighbour nodes via 3D API on the client.

Time ago, for another similar project I was using Java3D. So I got the bounding sphere volume of every star, then finding its collisions, and then repeating the routine for every star placed on a border range excluding all "catched" stars by others.

But with JMonkey APIs I am yet a newbie, so I don't know if it exists a more fast way for finding all neighbours at a fixed distance. In my current approach I am using indirectly the collision algorithm offered by the API, after creation of a sphere having it's center on the known node and a radius equal to the fixed distance, I calculate all collisions.

So, is there a more convenient way to accomplish this finding operation?   :?


Actually the Collsion-Method is not that bad. It is more or less that what I would have been done manually.

Which would mean: take every planet and check that planet's worldtranslation with the worldtranslation of every other planet:

   float distance = planet1.getWorldTranslation().distance(planet2.getWorldTranslation())

But actually if you working with BoundingCollision does more or less the same. You can cache the distance-results as you will calculate the same distances more than once, but as the distance-calculation is so trivial it is a question if a hashmap-cache wouldn't be slower than calculating the mutliple-checks again.

Hope that helps a bit.