Universe Entity Storing and Retrieving

Started by
2 comments, last by PixelPrime11 12 years, 6 months ago
Hello,

I'm thinking of making an space exploration game and I'm wondering what would be the most effective way of storing and retrieving information about entities existing in the universe. Say, for instance, the player is moving in a direction in space - how would I load the incoming planets and stars from a storage without having to go through all existing entities and check their relative position to the player?
- Methodic
Advertisement

Hello,

I'm thinking of making an space exploration game and I'm wondering what would be the most effective way of storing and retrieving information about entities existing in the universe. Say, for instance, the player is moving in a direction in space - how would I load the incoming planets and stars from a storage without having to go through all existing entities and check their relative position to the player?


Hi There,

I read somewhere else regarding a similar topic to this, that the answer could like in quadtrees or a similar data structure - where you can recursively page back through local nodes in order to retrieve 'nearby' objects without having to traverse too far.

A similarly intelligent data structure would be your answer, though.

[quote name='Methodic' timestamp='1318860394' post='4873456']
Hello,

I'm thinking of making an space exploration game and I'm wondering what would be the most effective way of storing and retrieving information about entities existing in the universe. Say, for instance, the player is moving in a direction in space - how would I load the incoming planets and stars from a storage without having to go through all existing entities and check their relative position to the player?


Hi There,

I read somewhere else regarding a similar topic to this, that the answer could like in quadtrees or a similar data structure - where you can recursively page back through local nodes in order to retrieve 'nearby' objects without having to traverse too far.

A similarly intelligent data structure would be your answer, though.
[/quote]


It really does sound like the way to go. So basically the screen would "frame" a bunch of nodes in the quadtree, and load all of the "framed" nodes respective nodes till it reaches a leaf containing an entity? I should probably do a lot of reading up on quadtrees first before asking too many questions, but the question is now how I would tell which nodes that are relevant to go through depending on the position of the player. I believe there are lots of information on this to read, but any more input on this is still appreciated of course. :)

Thanks PixelPrime11 for the reponse!
- Methodic

[quote name='Methodic' timestamp='1318860394' post='4873456']
Hello,

I'm thinking of making an space exploration game and I'm wondering what would be the most effective way of storing and retrieving information about entities existing in the universe. Say, for instance, the player is moving in a direction in space - how would I load the incoming planets and stars from a storage without having to go through all existing entities and check their relative position to the player?


Hi There,

I read somewhere else regarding a similar topic to this, that the answer could like in quadtrees or a similar data structure - where you can recursively page back through local nodes in order to retrieve 'nearby' objects without having to traverse too far.

A similarly intelligent data structure would be your answer, though.
[/quote]

It really does sound like the way to go. So basically the player position (possibly the center of the screen) would tell which node the player is currently at, and then it would page back from there loading entities till it reaches a node that covers the entire screen? I should probably do a lot of reading up on quadtrees first before asking to many questions as I believe there there are lots of information on this to read, but any more input on this is still appreciated of course. :)

Thanks PixelPrime11 for the response!
- Methodic

It really does sound like the way to go. So basically the player position (possibly the center of the screen) would tell which node the player is currently at, and then it would page back from there loading entities till it reaches a node that covers the entire screen? I should probably do a lot of reading up on quadtrees first before asking to many questions as I believe there there are lots of information on this to read, but any more input on this is still appreciated of course. :)

Thanks PixelPrime11 for the response!


No worries at all.

I just had a thought - if you're making a 3D game then a quadtree might not be the ultimate solution since that deals mainly with 2D data structures. The last time I checked we lived in more than 2-dimensions!

Octrees are the 3D equivalent, although it's possible to still represent a galaxy in a Quadtree - providing, of course, you don't have one element sharing the same Y position in space as another. Of course, that's impractical, so looking at Octress for full space partitioning would be the way forward, I think.

Your reasoning is sound, however. You'd locate your player's position in relation to the relevant tree node and work outwards until you've encompassed your entire 'active' region. Superimposing your intended new position into the quadtree should give you the overlapping nodes and give you the new data structures to peek inside. Quad or Octree, it's pretty much the same theory either way, just more dimensions to think about.

I don't have a tremendous amount of experience working with anything other than quadtrees, though, so you might need some advice from someone else much more versed in these matters :)

This topic is closed to new replies.

Advertisement