Async asset loading question?

Lets say I have a floor tile which is basically a quad geometry five steps away from my character. The character can be a geometry inside a node. I want to load into my scene said tile from a tile.j3o file when my character is three steps away from where the floor tile is supposed to be.

What is an efficient way to know when the character is three steps away from this floor tile? Remember that the floor tile geometry hasn’t been loaded or attached to the rootNode or any other kind of node. The floor tile is basically sitting on the hard drive inside the tile.j3o file.

Have some thing sitting above it all that manages loading tiles based on where the player is.

Not sure if it is the most efficient way, but it does require a distance check.

In most paging systems, some form of sectors are defined that represents the area of tile or chunk. As the focal point moves, distance checks are performed against the adjacent sectors focal point (adjacent sectors are any that could potentially have crossed into the distance you are checking against).

If a tile moves into this radius:

  • create a future that handles loading the asset, or creating the new tile mesh, or, etc, etc
  • add this to a queue of spatials to be loaded (once the future is complete)
  • pop the oldest one and add it to your scene (one per frame if there are more than this in the queue)

If a tile moves outside of this range:

  • Add it to the removal queue.
  • pop the oldest one and remove it from the scene (one per frame if there are more than this in the queue)

This is the general idea for paging anyways.

NOTE: Managing the futures is a different story and require another queue system.

@t0neg0d said: Not sure if it is the *most* efficient way, but it does require a distance check.

In most paging systems, some form of sectors are defined that represents the area of tile or chunk. As the focal point moves, distance checks are performed against the adjacent sectors focal point (adjacent sectors are any that could potentially have crossed into the distance you are checking against).

If a tile moves into this radius:

  • create a future that handles loading the asset, or creating the new tile mesh, or, etc, etc
  • add this to a queue of spatials to be loaded
  • pop the oldest one and add it to your scene (one per frame if there are more than this in the queue)

If a tile moves outside of this range:

  • Add it to the removal queue.
  • pop the oldest one and remove it from the scene (one per frame if there are more than this in the queue)

This is the general idea for paging anyways.

…and the tricky part is making sure that removed tiles yet to be built are also removed from the building/loading queue. That’s the part that takes a very straight forward idea and adds a bunch of simplicity tradeoffs.

Depending on the size of the tiles and how fast the player can move this may not be an issue… but the “what state is this tile in?” thing can be tricky.

@t0neg0d You understand what I’m talking about.

The thing is I won’t be able to perform a distance check. Remember that the tile is sitting on the tile.j3o file. Which means it hasn’t been loaded into a Node or Geometry.

How do I perform a distance check on things that have not being loaded without me having manually to create a table with specific resource mapping.

I just find that it would be tedious if I had to give my geometries fancy names like bench_sector2C.j3o in order to know when to load it.

I know that performing a distance check could theoretically solve the problem, but again, the resources have not been loaded yet.

Will I at the end have to manually create a table in a .txt file to check adjacent geometries to be loaded?

@pspeed said: ..and the tricky part is making sure that removed tiles yet to be built are also removed from the building/loading queue. That's the part that takes a very straight forward idea and adds a bunch of simplicity tradeoffs.

Depending on the size of the tiles and how fast the player can move this may not be an issue… but the “what state is this tile in?” thing can be tricky.

True… but, it’s the general idea anyways =)

Funny, I went back and edited the post while you were posting this with a note about just this. It really is the bitch of the whole process.

@Pixelapp said: @t0neg0d You understand what I'm talking about.

The thing is I won’t be able to perform a distance check. Remember that the tile is sitting on the tile.j3o file. Which means it hasn’t been loaded into a Node or Geometry.

How do I perform a distance check on things that have not being loaded without me having manually to create a table with specific resource mapping.

I just find that it would be tedious if I had to give my geometries fancy names like bench_sector2C.j3o in order to know when to load it.

I know that performing a distance check could theoretically solve the problem, but again, the resources have not been loaded yet.

Will I at the end have to manually create a table in a .txt file to check adjacent geometries to be loaded?

Your sectors are defined outside of the actualy mesh… they are Vector3f’s… places in 3d space… So your distance check is:

vec.distance(otherVec);

EDIT: Break your world into definable, managable chunks… say, 5x5 wu areas, 30x30, wu areas, etc.

@t0neg0d said: True... but, it's the *general idea* anyways =)

Yeah, I wasn’t criticizing at all. It always seems like such a simple thing at the start.

Every time I try to genericize Mythruna’s paging into something simple that I might publish, I’m still left with what is essentially a tile array that mirrors the eventual child nodes. To me it feels like the problem is more generic than that but the alternative of an extra placeholder node and/or some controls that later get removed starts to feel even more cumbersome.

The tricky part is always tying what is being built to what is being removed and that seems to require some intermediate object where otherwise none would be required. One thing is that the tile array + intermediate node approach makes LOD generation much simpler. At least then there is a thread-shared state that is easy to tweak and requeue as needed.

@t0neg0d

So would this be an efficient code:

private Node tileNode
private Vector3f tilePosition = new Vector3f();

…SimpleInit()
{
tileNode = assetManager.loadAsset(tile.j3o);

tilePosition = tileNode.getWorldBound().getCenter();

//Discard Node. I don’t want the Node to use my precious memory.
}

If your tiles are regular sized then you can predict where they will be without loading them.

If they are not regular sized then paging is a very difficult problem.

1 Like
@pspeed said: Yeah, I wasn't criticizing at all. It always seems like such a simple thing at the start.

Every time I try to genericize Mythruna’s paging into something simple that I might publish, I’m still left with what is essentially a tile array that mirrors the eventual child nodes. To me it feels like the problem is more generic than that but the alternative of an extra placeholder node and/or some controls that later get removed starts to feel even more cumbersome.

The tricky part is always tying what is being built to what is being removed and that seems to require some intermediate object where otherwise none would be required. One thing is that the tile array + intermediate node approach makes LOD generation much simpler. At least then there is a thread-shared state that is easy to tweak and requeue as needed.

JME has… ugh… I’m not going to remember the class now… it’s used in the endless terrain stuff for caching tiles by how recently they were used. He could leverage this and it might make it a bit easier… as any tile he loads but gets removed before the future is complete can be pushed directly into this so the problem doesn’t compound when someone runs back and forth between some add/remove threshold.

@pspeed

How can the pseudocode what I just explained become a very difficult problem.

Also, I’m trying to avoid the use of technical words like paging to keep things simple and not get lost on geek speak.

@pspeed said: If your tiles are regular sized then you can predict where they will be without loading them.

If they are not regular sized then paging is a very difficult problem.

@Pixelapp
Yep… @pspeed is actually where I got most of this info from.

If he says it… you should listen =)

@Pixelapp said: @pspeed

How can the pseudocode what I just explained become a very difficult problem.

Also, I’m trying to avoid the use of technical words like paging to keep things simple and not get lost on geek speak.

Because if you have to load all of your data before you know whether or not you need it then you might as well just leave it loaded.

Also, if your tiles are not regular sized then you start to run into issues of “impact”. While it might be ok to load a 32 meter square tile when it’s only 100 meters away you probably don’t want to do that for a 1000 meter square tile because the pop will be explosively jarring to the player.

@t0neg0d @pspeed Guyz, so you know. My problem is not about tiles. I’m thinking about how to make a Grand Theft Auto system type of world without loading screen. I want to know when to load far away buildings and when not to without a loading screen.

I just want you to think about floor tiles to keep things simple and to the point. So please keep referring to floor tiles.

@Pixelapp said: @t0neg0d @pspeed Guyz, so you know. My problem is not about tiles. I'm thinking about how to make a Grand Theft Auto system type of world without loading screen. I want to know when to load far away buildings and when not to without a loading screen.

I just want you to think about floor tiles to keep things simple and to the point. So please keep referring to floor tiles.

These two things are contradictory. GTA almost certainly uses something like a quad tree with multiple levels of data paged in based on distance. The concept of “simple tiles” is no longer relevant but they are certainly of a predictably regular size.

The fact that we are not supposed to use the word “paging” to describe… paging is going to be problematic. “Ok, describe mesh creation to me but don’t use technical words like mesh or triangles…”

@t0neg0d @pspeed

Then to conclude. The solution to this problem is my pseudo code. Which to map a city would take about 300kb of ram memory by using Vector3fs. And I should make sure my tiles are same-sized or at least the sectors are same-sized.

Would this be correct?

I guess I didn’t understand your pseudo code at all.

@t0neg0d @pspeed

Could you explain to me how Grand Theft Auto loads its world with no load screens? Please use the tiles metaphor if you may.

@Pixelapp said: @pspeed

How can the pseudocode what I just explained become a very difficult problem.

Also, I’m trying to avoid the use of technical words like paging to keep things simple and not get lost on geek speak.

Ah… geek speak… I have to Google most of what people say here until it sinks in ;)>

Think of the regions/tiles like the squares on a chess board.

Put a pawn on one of the squares and then look at how you would logically check the adjacent squares.

You would check in a rectangular pattern.

X X X
X O X
X X X

is the O (your player) in distance of X1? X2? etc, etc If your threshold is two tiles size… it would look like this:

X X X X X
X N N N X
X N O N X
X N N N X
X X X X X

O is your player…
N = no one cares cause these tiles are already loaded
X = might need to be loaded or unloaded.