TreadMill Approach To Tiling Terrain - PLEASE HELP 
      #222569 - Tue May 14 2002 12:02 AM   Edit     Reply     Quote    
 
 

I've tried to do my homework by searching the boards, playing with examples from tuts, etc., but it's just not coming together for me... Any help would be greatly appreciated ...

We're dynamically building our worlds (i.e. all entities) from information streamed to the client from the server. This all works fine for us, but currently we have a fixed size for our levels and a player can enter a different area of the world but we use level_load() to do this.

But, we'd like to have our huge world be one seamless world where as the player moves around, we dynamically load terrain tiles as needed. Our code already can support this for all other entities in our world ... it is just the terrain we can't figure out.

I've read posts saying a "treadmill" approach is "easy". In one posts, Doug from Conitec says "I built a 20 mile by 20 mile flight sim using this approach". 

Well, what am I missing... because even conceptually I'm not seeing how this would work. Doesn't every level need to be enclosed in some type of bounding box? If so, even if I could figure out how to dynamically create the "next" map tile and line it up with the existing map tile a player is on, won't I eventually run into the wall of the bounding box? Or is that why you call it "treadmill" and my player isn't supposed to move at all and I'm supposed to move the entire world move around him so he always satys in the center?

If anyone could walk me through in a bit more detail, how to dynamically add tiles of terrain I would be most grateful. Again, I've read several posts talking around this subject but I'm still not getting it.

Thanks in advance! 

Post Extras:            
**DONOTDELETE**  
 
 

 
 
 
 
  Re: TreadMill Approach To Tiling Terrain - PLEASE HELP 
      #222570 - Tue May 14 2002 03:02 AM   Edit     Reply     Quote    
 
 

Well, you got it right. It's called treadmill, because you're player stays at (0,0,height). You merely move the world around him. A somewhat different approach (depending on your needs) could be to move the player towards level boundaries (e.g. 40000, 40000) and then teleport him back to the other end of the level to make him walk on forever.. 

Post Extras:            
Doug  
Conitec  
  

 
Reged: Jul 23 2000  
Posts: 4408  
Loc: San Diego  
  Re: TreadMill Approach To Tiling Terrain - PLEASE HELP 
      #222571 - Tue May 14 2002 03:27 AM   Edit     Reply     Quote    
 
 

Love to go into this in detail, but this is a busy week and it has been awhile since I did my 20 square mile world. But I can give you some hints.

The basic idea I used was a 100 by 100 grid of tiles (worldArray[10000]). Each tile was a square map entity representing a piece of the world (I assume you can use terrain files for this as well, but I did this with the A4 engine). The tiles should match up along the edge so that the player can not see the connections. The tiles should also be a little wider then the player's view (more on this later). 

I wrote some code to calculate where the player (helicopter in my case) was in this array. I placed that tile in the center of the world. Then I found the surrounding 8 tiles and placed them around the center tile (giving me a 3x3 array). Each tile was wide enough so the player could see over it's edge.

When the player moved across the edge of the center tile into one of the surrounding tiles, I moved him back by the width of the tile and then calculated a new set of tiles.

That's it. There are a lot of ways to optimize this (shifting tiles instead of loading a whole new set). My final version also had a basic level-of-detail with dynamically scaled movement which allows the player to travel 50,000 feet into the air without seeing the edges of the world. But you should start with something simple and build on it. 

Post Extras:            
tesanders  
Senior Member  
  

 
Reged: Jan 22 2002  
Posts: 465  
Loc: USA  
  Re: TreadMill Approach To Tiling Terrain - PLEASE HELP 
      #222572 - Wed May 15 2002 12:49 AM   Edit     Reply     Quote    
 
 

This approach is pretty neat; I would assume that iterating over the entity list via ent_next() would work to move eveything over when the player reached a boundary.

Is it possible to shift particles over as well?

=thomas 

Post Extras:            
Doug  
Conitec  
  

 
Reged: Jul 23 2000  
Posts: 4408  
Loc: San Diego  
  Re: TreadMill Approach To Tiling Terrain - PLEASE HELP 
      #222573 - Wed May 15 2002 01:43 AM   Edit     Reply     Quote    
 
 

Good question, I'm not sure of an easy way to shift the particles over (it didn't come up in my example). You might want to have each of your particle update functions check a global offset value which is changed when the player moves between tiles. 

Post Extras:            
NateDog  
Member  
 

 
Reged: Apr 10 2002  
Posts: 101  
Loc: Fairfax, VA  
  Re: TreadMill Approach To Tiling Terrain - PLEASE HELP 
      #222574 - Wed May 15 2002 06:37 AM   Edit     Reply     Quote    
 
 

Been experimenting and I'm making some progress.

Using just a flat map tile that is a cube, I built the rudimentary auto-tiling system. I'm using the option of a 3x3 grid and as soon as I walk beyond the edge of the middle tile, I shift the entire world back to make the new tile the center tile.

BUT - Forgive my ignorance, I tried to use real terrain instead of just flattened cubes and I can't figure out how to "Build WMB" with a terrain .HMP or .MDL I created in MED using the standard heightmap/terrain map approach.

I keep getting the CRITICAL ERROR:

Can't read interim file XXXX.$$P

So, how do I create Map Entities for terrain that is created in MED using the heightmap/terrainmap approach?

Also, I briefly started down the path of trying to make my player always stay at (0,0,z) but abondoned it because it seems like with that approach I have to write my own code to handle collision detection... right? Because, I'm not moving the player at all, I'm moving all the entities. I really didn't want to go down that path ... at least not yet  

Post Extras:            
**DONOTDELETE**  
 
 

 
 
 
 
  Re: TreadMill Approach To Tiling Terrain - PLEASE HELP 
      #222575 - Wed May 15 2002 10:26 PM   Edit     Reply     Quote    
 
 

Add a small (invisible) cube to your terrain prefabs and you'll get rid of the error. 

Post Extras:            
NateDog  
Member  
 

 
Reged: Apr 10 2002  
Posts: 101  
Loc: Fairfax, VA  
  Re: TreadMill Approach To Tiling Terrain - PLEASE HELP 
      #222576 - Wed May 15 2002 11:20 PM   Edit     Reply     Quote    
 
 

Thanks George. With an invisible cube I got CRITICAL ERROR - no visible blocks in map.

So, I made the cube visible and then no errors but in my .wdl file when I call ent_create(MapTile##.wmb, MapVec##, MapTileCreate) only the cube is visible. The actual terrain is not visible?!?! 

Post Extras:            
**DONOTDELETE**  
 
 

 
 
 
 
  Re: TreadMill Approach To Tiling Terrain - PLEASE HELP 
      #222577 - Thu May 16 2002 12:54 AM   Edit     Reply     Quote    
 
 

Create the terrain.hmp itself instead of trying to build map entities with the terrain.hmp in them.
Only level blocks and lights are included as a part of map entities. 
ent_create(MapTile##.hmp,MapVec##,MapTileCreate); 
They can also be scaled by script
function MapTile(){
MY.SCALE_X = 10;
MY.SCALE_Y = 10;
MY.SCALE_Z = 10;
} 

Post Extras:            
NateDog  
Member  
 

 
Reged: Apr 10 2002  
Posts: 101  
Loc: Fairfax, VA  
  Re: TreadMill Approach To Tiling Terrain - PLEASE HELP 
      #222578 - Thu May 16 2002 12:58 AM   Edit     Reply     Quote    
 
 

THANK YOU!!!! Oh my lord I can't believe how many hours I've been stuck on this and I didn't try that!!! It works now. THANKS AGAIN!!! 
 
