Dynamic Pages

Zola

31-07-2006 22:20:39

Hello sirs of PLSM2,

I'm wondering if PLSM2 will work for my project. I hope it's modular enough to simply load pages in as they're required. Populating in a new page seems like a basic atomic operation -- but as far as I can tell, PLSM2 is mostly geared towards "loading a supertile once, and splitting it up into pieces." But I don't really want that at all: I'd like to populate in a set of pages at a time as they're required.

Say you were doing something like a 3d map-browser. Imagine like google maps, where you view terrain, and can scroll in whatever directions you like. I want to download the pages from an http server connected to a database, as each page is required. I cannot ask the clients to "stream a gig of data", and then load a gigabyte of map data into PLSM2 in one insanely large chunk. I'm not sure if PLSM2 can even handle that. So I need to unload things as I go.

The pseudocode is like this:

if (viewport is scrolled && new page(s) are in view) {
for (each page in new pages in view) {
download new page for position x,y from server;
cache new page locally;
populate new page into PLSM2 at position x,y;
}
for (each page in pages which have gone far out of range) {
free memory for page;
}
}


Of course, I'd modify this a little bit to load in the nearby page within a given threshhold of distance before you ever scroll to them, so that they're ready before you even scroll there.

What I want to do seems like a fairly straightforward and basic requirement for a "paging landscape" SceneManager.
Loading one huge tile *once* does not apply to me, and it seems like a biased usage-model geared towards games or a game world with fixed dimensions.
I don't want that.
Is PLSM2 general enough to do what I need?
And if so, what would be the best way to go about implementing this with PLSM2?

- Zola

Zola

01-08-2006 07:16:48

Hello,
Is there anybody in there,
Just nod if you can hear me,
Is there anyone at home?

Evak

01-08-2006 08:10:12

I know what you mean, I'd kind of like you have a terrain that works like a 2D tileset in an old school RTS.

have a collection of terrain features and unique areas, a collection of tile sets and filler tiles that are used in 80% of the terrain as filler.

Use a simple ASCII grid with 0-9 and a - z numbers referencing a tile.

Something like that anyway. Not likely to happen any time soon though, I just don't think PLSM is designed with that kind of use in mind.

Zola

01-08-2006 08:34:32

I'd really just like a definitive reply from the devs on what PLSM2 really can or can't do. After all, it's a "Paging Landscape" SceneManager, isn't it? What I'm asking for seems like the very definition of what such a SceneManager should do. No?

Jerky

01-08-2006 09:14:45

Well, to answer your question, you *can* do that, but only after you integrate your own code (networking, etc) into it. I will let Tuan be more specific, but PLSM cannot do this "out of the box." You will need to do some of your own integration, but I am sure it can be done.

Also, since Tuan works on PLSM pretty much alone, give him some time to respond. It may take a while. He was out of town, I am sure he has some catching up to do. Just get used to being patient for answers in here.

Falagard

01-08-2006 15:33:33


What I want to do seems like a fairly straightforward and basic requirement for a "paging landscape" SceneManager.


I think it'd be an interesting feature to have, but definitely not a basic requirement. 99% of the *games* (what the PLM2 is targetted towards) that will use the Paging Landscape Scene Manager will have the entire landscape precached on their machine and the scene manager's job is just to load and display the pages as the player moves around. It doesn't load the huge tile once, it pages in as the player moves around, however it is indeed a pre cached fixed dimension system by default.

I think Tuan will have an answer for you like "it can be done if you do this" though.

Also, you really need to calm down, posting multiple times in a 3 hour period is ridiculous.

tuan kuranes

01-08-2006 15:47:26

@Zola : Indeed that's about what PLSM2 can do.

1. Just note that PLSM2 terminology is different, which can cause glitches:

Here, A page is a big chunk of Height data (sufficent to have a meaning in term of filesystem, or network IO time), whereas a tile is more a GPU bounded pieces of a page (GPU likes buffers with less than 65535 vertices).
But both pagesize and tilesize are customizable.

2. What you need to provide a new class subclassed from "PagingLandScapeData2D" that handle the load of data from network into an Height Array. That's a good start. If network cannot provide data fast enough, you'll can call afterwards Scenemanager::setOption("PageUpdate", &Vector2(PageX, PageZ)) that will force a reload of the page with new data.

@Jerky : He was out of town, I am sure he has some catching up to do. Just get used to being patient for answers in here.
Indeed, a lot of work did pile up very fast...

That said, I do like getting some help in forums, thanks to all !

Zola

01-08-2006 17:56:18

Guys,
It seems the point of this thread got sidetracked or missed.
Please, let's not get sidetracked.
I've updated the original post to clarify it.
I never for one moment thought that PLSM2 should handle the *network loading*.
I didn't expect that, want that, or even request that.
I didn't want an explanation of how to implement network loading, either.
That was only an example I gave. Notice how I said "Say you were doing something like"
That's stuff for each individual project to be concerned about.
It's not a general use of the library.
Let's not focus on the network loading.
I'm not clueless, and obviously I understand that I'd need to write that part myself.

Tuan -- what I'm trying to find out is is how to load in new pages dynamically. There will be no problem populating the heightmap for a page from data on the remote server -- that's not what I'm asking, that's the easy part. I just want to know if I can *only* populate that height data into an individual page as its required, and then join it onto the edge of the world at a given location, so that PLSM2 can put it into view as it's required. I do not want to download the data for every single page, all at once. I want to download and add it onto the edge of the world, as required.

tuan kuranes

01-08-2006 18:24:31

I just want to know if I can *only* populate that height data into an individual page as its required, and then join it onto the edge of the world at a given location, so that PLSM2 can put it into view as it's required. I do not want to download the data for every single page, all at once. I want to download and add it onto the edge of the world, as required.

PLSM2 does paging so it calls PagingLandScapeData2D::load only if page is needed (using a camera distance to page trigger), so it's up to you to feed it when it's called.
A page is preloaded a bit of time being in viewable distance to user.

So As said above, when PLSM2 needs data all you have to do is to provide your own PagingLandScapeData2D that feed PLSM2 with Height Array when called. In case of network, or threaded heightmap generation, if Data not available when asked, you can load it using Scenemanager::setOption("PageUpdate", &Vector2(PageX, PageZ)).

I do not want to download the data for every single page, all at once.
only in distance page are needed.
I want to download and add it onto the edge of the world, as required
you download and feed it to PLSM2, and PLSM2 adds it to the world.

Falagard

01-08-2006 18:35:07

Zola, you're the one that's going off on a tangent. I'm pretty sure no one said that you thought that PLM2 included code to load terrain from a network, just that you'll have to implement that part yourself using the methods described by Tuan. Also, no one has (yet) said that you're a newbie, but I'll say it now: you're acting like one. People here are giving you viable solutions to your problem, you just need to turn your thinking around.

Instead of feeding pages to the PLM2, it's the other way around. You position the camera somewhere, and the PLM2 loads up pages. It's during the page load code that you can feed the heightmap data from any source you want. You'd do this by subclassing the PagingLandScapeData2D class with your own derived class.

As has been clearly stated by Tuan, this doesn't mean you need to download all the pages before the user even runs PLM2.

Here's another simple example of something that can be done with the flexibility of this type of system: Generate terrain on the fly using a noise generator. It doesn't matter where you're getting your heightmap page data from if you subclass PagingLandScapeData2D, you can pull it out of your ass if you want.

This architecture does indeed solve your problem but you need to stop thinking about feeding arbitrary pages to the PLM, and instead understand the PLM uses the camera position to determine an x,z page based on page size, and then instantiates and loads a page for that position, at which point you can get that data from anywhere.

Zola

01-08-2006 19:07:41

Tuan:

Perfect! That's just what I wanted. I'll try it, figure it out, and report back on how it worked. :)

Some people were saying that "infinite" terrain isn't possible. How is this not infinite? If I can load/unload pages, isn't that effectively "infinite"?

Falagard:

So does this mean that I have to pre-decide on a global dimension / fixed map size, and then feed the data into that fixed dimension at runtime? But cannot exceed those original bounds?

tuan kuranes

01-08-2006 19:25:36

Previous infinite post were mostly related to repeating terrain from what I recall. But still Infinite can pose problem in term of float precision, use double in Ogre and plsm2 and that should help a lot. Keep in mind that GPU still run in float and that can lead to some problem. It's non probable, but if you reach the problem, we'll think about that.

You can decide at start on a very high global dimension / fixed map size you'll never reach or / and you can update dynamically to fit your needs.

praetor

02-08-2006 15:43:59

Related to infinite terrain:

@Tuan: What if I architect the game around PLSM2, and detect what page I'm operating in. I set up a local coordinate system within each page and only deal in that. That should solve the precision problem. But, will solve ALL the problems, or do you see issues occuring within PLSM itself?

tuan kuranes

02-08-2006 15:52:46

plsm2 world geometry will be subject to same sort of bug. That should be part of the scene manager, and ends in converting all scene data into a local coord system just prior to rendering (a game programming gems 4 has an article exaclty on that)

praetor

02-08-2006 15:56:06

Ok, so it is possible, with just a little (maybe not so simple) pre-processing step before rendering.