Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to implement a paged terrain ?

Author
Message
Juggernaut
14
Years of Service
User Offline
Joined: 12th Mar 2012
Location:
Posted: 22nd Jul 2012 00:13
Hello,

How do I implement a paged terrain - means the whole terrain is split into seperete .x files and I want to load them when the camera
moves near one end / edge of the initial terrain.

Thanks,
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 22nd Jul 2012 14:15
It is possible but without multi-threading (which DBP does do) you would get a pause when you cross over boundaries and the new terrain sections are being loaded in.



You would need to load up at least 9 segments and the camera would be in the centre segment. Once the camera crosses a boundary then your program will change the centre reference segment, discard the unused segments and re-load the other segments.

ie, if the camera moves into segment 2, segments 6, 7 and 8 will be discarded, the new centre will be 2 and segments 1, 2, and 3 will be loaded in.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Juggernaut
14
Years of Service
User Offline
Joined: 12th Mar 2012
Location:
Posted: 22nd Jul 2012 22:37
@WLGfx: Where do I hold the objects (chunks of terrain) in a multidimensional array ?
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 22nd Jul 2012 23:51
I have been thinking about this lately.

I think it's still possible without loading any extra meshes(or objects).

You would reuse the same meshes over and over but gradually change the height of the mesh vertices to represent the mesh you are travelling toward. You would work it so the mesh is exactly as it should be by the time you can see it.

You could fetch your height data using a networking plugin, you could also gradually alter images in the same way for your textures.

This technique would mean there are no limits to the size of your world(apart from server storage space).

Juggernaut
14
Years of Service
User Offline
Joined: 12th Mar 2012
Location:
Posted: 23rd Jul 2012 00:28
Quote: "This technique would mean there are no limits to the size of your world(apart from server storage space)."


Yes that is what I want to achieve. But how to implement that in code is the real question.
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 23rd Jul 2012 00:41


Started out like a DBP snippet but turned into pseudo code as the actual code to achieve this would probably take half an hour to write. You probably want to use a two-dimensional array to store the segment data as well and as Matty H suggested you can re-use the same 9 segments by using the vertexdata functions to change them to correspond to geometry data for the segments that you have stored somewhere permanently (ie. you don't have to load a set of new meshes whenever you're changing the current segment).


"Why do programmers get Halloween and Christmas mixed up?"
Juggernaut
14
Years of Service
User Offline
Joined: 12th Mar 2012
Location:
Posted: 23rd Jul 2012 00:45
Thanks Rudolpho .... I will look into your snippet.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 23rd Jul 2012 03:11
The Bike game I wrote in DBP (and c++) used a single matrix terrain where the camera (and player) would cross boundaries onto another segment on the terrain, DBP would then scroll the terrain and the camera would be re-positioned. 3D Motor-Chase

Basically the movements would check against a range (ie 0-127) and then re-position the camera using DBP's MOD (modulus) command.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Login to post a reply

Server time is: 2026-07-07 18:21:11
Your offset time is: 2026-07-07 18:21:11