How do I put a hole in the new terrain
by Nigel Budden · in Torque Game Engine Advanced · 07/27/2005 (8:02 pm) · 11 replies
G'day Guys,
Back again :)
I've been moving over to the Atlas terrain, which ROCKS! however I do have a question,
How do I punch holes into the terrain so that I can put my underground sections back in? ( I realise there isn't a way to do this via the editor, is there a way to do it via code?
Other than that issue, I've been thoroughly enjoying MS-2, Keep up the great work guys.
Back again :)
I've been moving over to the Atlas terrain, which ROCKS! however I do have a question,
How do I punch holes into the terrain so that I can put my underground sections back in? ( I realise there isn't a way to do this via the editor, is there a way to do it via code?
Other than that issue, I've been thoroughly enjoying MS-2, Keep up the great work guys.
About the author
#2
09/01/2005 (8:35 pm)
Can this be used to make caves? AKA dungeons?
#3
02/25/2007 (10:39 am)
Is this feature available now? I want to make some undergroud areas but cant figure out how to break through the terrain.
#4
02/25/2007 (12:17 pm)
It is not available yet.
#5
02/26/2007 (6:50 am)
Quote:You can remove triangles from the mesh via code - not very fun. The next update I do to Atlas will put that feature, along with many others, back in.Wow, I just realized that comment was from 2005. How did this topic get bumped?
#6
03/17/2007 (9:42 pm)
I have a better question, how is this not done if it was supposed to be worked on "next?"
#7
03/19/2007 (8:42 am)
Obviously he ran into a lot of trouble getting it working. Since I don't know how to get it working I'm going to say I'm in no position to criticize Ben about it.
#8
I believe that a realtime Atlas terraform editor, or realtime Atlas hole editor, or runtime Atlas terrain deformation, IMHO is a tremendous amount of work for very little added functionality. It simply does not make sense. Legacy terrain and Atlas terrain are just too different to expect to be able to edit them in the same way.
Below is a composite screen shot of a full-size (8192 meter x 8192 meter) Atlas2 terrain for Boulder Colorado showing the terrain both textured (right side) and in wireframe (left side). The texture is 16384x16384 and the heightfield is 513x513.

Legacy terrain is a regular grid. If you could process this heightfield as legacy terrain then the terrain grid would contain 524,288 triangles ((height-1)*2)*(width-1). I think that's right.
And remember that those chunks are paged in and out as they are needed.
All 6 levels in the Atlas file contain a total of 2,239,880 triangles
Terraforming
Now imagine trying to terraform some of the flat areas on this terrain. Image if your edit crosses a chunk boundary. To terraform a small area (which may or may not contain any vertices), you would need to either tessellate the area back to the original heightfield resolution or grab the same area from the original heightfield. Then after the edit you would want to decimate the area again. If you didn't decimate the area again then after just a few edits, your terrain size could be twice or three times it's original size. Then the 6 new decimated areas (one for each level) would need to be merged into the existing Atlas file.
If you get a headache just thinking about how to code this then join the club.
The only sane way to do this would be to edit the original heightfield in the editor. Then when exiting the editor, reprocess the whole heightfield into an Atlas terrain file, delete the current Atlas terrain and load the newly processed Atlas terrain.
But why go to all that trouble when it would probably be easier to write a stand-alone heightfield editor or find a heightfield editor, because you'll need to reprocess the whole terrain anyway.
Atlas terrain hole cutting
Because legacy terrain is a regular grid you can play lots of tricks. And hole cutting is a nice trick. But if you read the information above, then the idea of cutting holes in an Atlas terrain sounds just as frightening as trying to terraform Atlas terrain. I guess you could have a special code in the heightfield to mark the position of a hole. Then while processing the terrain you could generate an interior skirt around the hole just like the exterior one around the outside edge of the terrain. This means that again most of the work is done while processing the terrain from a heightfield. And once again, I'd rather have root canal work every day than try and code that.
I have to say that I don't have a need myself to edit the terrain realtime or create any caves.....
.... But ......
Has anyone tried having one Legacy tile surrounded by a number of Atlas1 or Atlas2 tiles?
You would have one terrain tile that you could edit while having vast terrain surround it.
Here is a shot of all three types of terrain - stronghold.ter (Legacy), arcticBlended.atlas (Atlas2), and smallTexture.chu/.tqt (Atlas1). (I'm still having problems with the Atlas1 texture.)

And here I'm editing stronghold.ter with arcticBlended.atlas in the background.
03/23/2007 (6:30 pm)
The following is just my opinion, you have the right to disagree in whole or in part.I believe that a realtime Atlas terraform editor, or realtime Atlas hole editor, or runtime Atlas terrain deformation, IMHO is a tremendous amount of work for very little added functionality. It simply does not make sense. Legacy terrain and Atlas terrain are just too different to expect to be able to edit them in the same way.
Below is a composite screen shot of a full-size (8192 meter x 8192 meter) Atlas2 terrain for Boulder Colorado showing the terrain both textured (right side) and in wireframe (left side). The texture is 16384x16384 and the heightfield is 513x513.

Legacy terrain is a regular grid. If you could process this heightfield as legacy terrain then the terrain grid would contain 524,288 triangles ((height-1)*2)*(width-1). I think that's right.
Level Triangles 0 524,288I processed this terrain at a tree depth of 6 and an error metric of 0.24 meters (just over 9 inches), so I don't expect a lot savings in triangle size. Still, the difference in the number of triangles in the lowest level compared to the highest level is enormous.
Level Triangles Chunks Triangles/chunk 0 482,889 1024 471.5 5 52,270 1 52,270
And remember that those chunks are paged in and out as they are needed.
All 6 levels in the Atlas file contain a total of 2,239,880 triangles
Terraforming
Now imagine trying to terraform some of the flat areas on this terrain. Image if your edit crosses a chunk boundary. To terraform a small area (which may or may not contain any vertices), you would need to either tessellate the area back to the original heightfield resolution or grab the same area from the original heightfield. Then after the edit you would want to decimate the area again. If you didn't decimate the area again then after just a few edits, your terrain size could be twice or three times it's original size. Then the 6 new decimated areas (one for each level) would need to be merged into the existing Atlas file.
If you get a headache just thinking about how to code this then join the club.
The only sane way to do this would be to edit the original heightfield in the editor. Then when exiting the editor, reprocess the whole heightfield into an Atlas terrain file, delete the current Atlas terrain and load the newly processed Atlas terrain.
But why go to all that trouble when it would probably be easier to write a stand-alone heightfield editor or find a heightfield editor, because you'll need to reprocess the whole terrain anyway.
Atlas terrain hole cutting
Because legacy terrain is a regular grid you can play lots of tricks. And hole cutting is a nice trick. But if you read the information above, then the idea of cutting holes in an Atlas terrain sounds just as frightening as trying to terraform Atlas terrain. I guess you could have a special code in the heightfield to mark the position of a hole. Then while processing the terrain you could generate an interior skirt around the hole just like the exterior one around the outside edge of the terrain. This means that again most of the work is done while processing the terrain from a heightfield. And once again, I'd rather have root canal work every day than try and code that.
I have to say that I don't have a need myself to edit the terrain realtime or create any caves.....
.... But ......
Has anyone tried having one Legacy tile surrounded by a number of Atlas1 or Atlas2 tiles?
You would have one terrain tile that you could edit while having vast terrain surround it.
Here is a shot of all three types of terrain - stronghold.ter (Legacy), arcticBlended.atlas (Atlas2), and smallTexture.chu/.tqt (Atlas1). (I'm still having problems with the Atlas1 texture.)

And here I'm editing stronghold.ter with arcticBlended.atlas in the background.
#9
03/23/2007 (11:36 pm)
What about over lapping them?? And by the way, did you have to do much to get that to work?!NM, i did it:) just added it in, i think this will solve a lot of peoples problems in some respects,:)
#10
as something to try.
As for getting the legacy terrain to work, it took me a while to figure out how to get the stronghold materials added to R1.
Just adding stronghold to my mission file, the terrain appears all black. I don't really understand materials and shaders that well so I had to use the Starter.fps mod as a guide because it uses legacy terrain (stronghold.ter).
Looking through the Starter.fps mod I saw the changes I needed to make:
I am still having problems getting the Atlas1 material and shaders to work right.
03/26/2007 (7:40 am)
I really was not thinking about overlapping the terrain, but it would be interesting to hear how that worked for you. I have no idea if this will solve anyone's problem. I'm just putting this out there as something to try.
As for getting the legacy terrain to work, it took me a while to figure out how to get the stronghold materials added to R1.
Just adding stronghold to my mission file, the terrain appears all black. I don't really understand materials and shaders that well so I had to use the Starter.fps mod as a guide because it uses legacy terrain (stronghold.ter).
Looking through the Starter.fps mod I saw the changes I needed to make:
myModDirectory/main.cs in the onStart function:
Just after the line
exec("./server/init.cs");
I needed to add
exec("./data/init.cs");I copied starter.fps/data/init.cs To myModDirectory/data/ The starter.fps/data/init.cs has one line: exec( "./terrains/highplains/propertyMap.cs");
So then I just needed to make sure that my myModDirectory/data/terrains/highplains directory was exactly the same as the one in the Starter.fps
I am still having problems getting the Atlas1 material and shaders to work right.
#11
08/04/2007 (1:20 am)
A possible workaround instead of trying to punch holes in the Atlas terrain might be to make a map object which sort of "builds up" the surrounding area around where you need to get through the terrain and have a teleport object (without any effects) that takes the player to another map object below the atlas terrain in such a way that the player doesn't realize they've been teleported. The area where the teleport object is above and below would have to appear identical, and it might be possible to use the player trajectory info to determine how to place the player on the other side, in case they strafe through it they would remain facing the same wall on the other side. It is by no means cutting a hole through the terrain, but you might be able to pull off the same illusion with a LOT less work and yield similar results.
Associate Ben Garney