Jump to content

  • Log In with Google      Sign In   
  • Create Account

server side game object location tracking


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 snacktime   Members   -  Reputation: 292

Like
0Likes
Like

Posted 18 July 2013 - 12:49 AM

I'm working on an open source server side game engine and am tackling how to track game objects in 3d space.  

 

The basic idea I am working with is that the server will track moving objects and record their location.   I was thinking about dividing up the space into cubes of equal size, and doing enough math to figure out what cube an object is in whenever I record their current location.  With something like this 'objects near me' becomes an efficient query, as I just get the objects in your cube plus adjacent cubes.

 

But having spent most of my career working with server side code, 3d math isn't something I've ever really had to deal with, so I'm starting from scratch as to what the best algorithm would be, and what libraries would help me the most.  I'm using jruby,  so libraries in java or C would work, although I'd prefer java.

 

I was also toying with the idea of using a 2d grid and a 3d space made of cubes.  If I know the location of an object on the 2d grid, I'm thinking I can do some quick math to get objects that are within X number of 3d cubes away by just looking at the z axis of the objects.  So if I have a player in a known cube, and I want to get all other players in that cube and all ajdacent cubes, I could just compare the z axis of all the objects I got from the 2d grid calculation.   It wouldn't be an exact calculation, In order to get all players within range,  I'd end up with some players outside of the range I really want if I use a number large enough to get all players within range.

 

But maybe I'm overthinking this, and the math  isn't really that expensive to 'do it right'?

 

Chris



Sponsor:

#2 Waterlimon   Crossbones+   -  Reputation: 2573

Like
0Likes
Like

Posted 18 July 2013 - 02:34 AM

Yup, you want a spatial partitioning system to speed up spatial queries. Theyre more like "find potential collisions/nearbies" (is that a word?), you still want to do the actual check, at least on the edge cases.

A grid will work fine. A hashmap with 2D/3D coords as keys will work too if a grid takes too much space, since a hashmap is sparse.

Hierarchical solutions work too (quad/octree, whatever else there are) especially if you have a wide range of object sizes.

o3o





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS