Game Development Community

Invisible Terrain Feature

by Toby W. Allen · in Torque Game Engine · 04/18/2005 (10:23 am) · 15 replies

Heya there,
I was curious to know if it would be possible to make the terrain invisible -
I would like to achieve this so that I can still have a terrain and control it and have collision with the terrain, but visually make it invisible.

For some reason, when I apply an invisible png texture, it doesn't like it.

Any ideas?

Toby.

#1
04/18/2005 (10:24 am)
I've never thought about doing this, but can you select a NULL texture to paint with?
#2
04/18/2005 (10:25 am)
Actually I think it may be as simple as changing a flag in the mission file, lemme take a look around and see what I can figure for ya.

@David, it will render a grey white if you do that.
#3
04/18/2005 (10:31 am)
See if this works...
Create a new terrain in your mission editor don't apply ANY textures to it.
Save it as myterrain
next open the mission editor in notepad or whatever and edit the terrainblock to this.
new TerrainBlock(Terrain) {
      rotation = "1 0 0 0";
      scale = "1 1 1";
      detailTexture = "~/data/terrains/details/transparent";
      terrainFile = "./myterrain.ter";
      squareSize = "8";
      bumpScale = "0";
      bumpOffset = "0";
      zeroBumpScale = "0";
         position = "-1024 -1024 0";
         locked = "true";
   };

Finally create a 512x512 transparent.png and copy it to data/terrains/details

That SHOULD work.
#4
04/18/2005 (10:56 am)
I keep getting this message when I try to create a Terrain:

Loading compiled script editor/newObject.cs.
editor/newObject.cs (0): Register object failed for object invisble of class TerrainBlock.

Rather odd - I looked into the script and it says this:
ObjectBuilderGui.newObject = new TerrainBlock(invisble) {
   terrainFile = "0";
   squareSize = "8";
};
Invisible is what I named it as.. but rather odd...

Toby.
#5
04/18/2005 (10:59 am)
Cartoon outlining resource that (part way down) had an unusual bug which allowed the terrain to not be rendered. I hadn't read that for quite a while. Just noticed it again when Toby W. Allen posted his plan.

EDIT: Holy hell, I just read the name of the poster and realized it was the same as the .plan I harvested that from.
#6
04/18/2005 (11:02 am)
I did it accidnetly when I was trying to do cartoon rendering... If you go into terrain/terrRender.cc in TerrainRender::renderXFCache()... Find this:
U32 vertexCount = mXFIndexBuffer[count + 1];      

glDrawElements(mode, vertexCount, GL_UNSIGNED_SHORT, mXFIndexBuffer + count + 2);

and change it to this:

bool terrIsVis=Con::getBoolVariable("$Pref::terrainIsVisible",true);

 U32 vertexCount = mXFIndexBuffer[count + 1];      

if (terrIsVis)
{
glDrawElements(mode, vertexCount, GL_UNSIGNED_SHORT, mXFIndexBuffer + count + 2);
}

add this to prefs.cs file:

$pref::terrainIsVisible = true;

now you can call $pref::terrainIsVisible = false from a script or hte console to make it invisible.
#7
04/18/2005 (11:03 am)
I created that bug (not something to be proud of I guess)
#8
04/18/2005 (11:05 am)
Hey, if it helps him with the intent of making his terrain invisible, it's moved from bugdom to feature.
#9
04/18/2005 (11:07 am)
That makes me feel better I guess.... One mans garbage is another mans invisible terrain!
#10
04/18/2005 (11:08 am)
Chris,
Thanks for this - Essentially the need for this feature came from your bug, as you made a level of ours look really cool :D

However, if we implement your code, then we can't have cel-shading, which is why I was curious as to whether I could do this with a texture, which seems pretty normal, so I'm not sure why I'm hitting a bug when I try with a transparent texture on the terrain, wonder it this might be caused by the renderer for ther terrain not showing what to show when its transparent.

Toby.
#11
04/18/2005 (11:09 am)
You can do both... its not a problem

Just put the doOutline() if-else loop inside of the terrIsVis check... they both work then

EDIT: Just dont make every level invisible, or it kinda defeats the point.
#12
04/18/2005 (11:14 am)
Maybe I should post that as a resource tonight? What you guys think? How to make your terrain invisible... .

EDIT: Nevermind, Im too lazy to test it... You guys can post it if you feel ambitous
#13
04/18/2005 (11:35 am)
@Toby - Did it work properly?
#14
05/04/2005 (11:37 am)
We're currently implementing it as a dynamic field option and then I'll post a little more.

Toby.
#15
06/24/2005 (3:53 pm)
That would be cool actually....

Im thinking you could call it a "magnetic field" in a futuristic game and you walk over terrain.

Or you could use it in a puzzle where you wanted to do an unusual maze with no clues how to get to the target.

Im flashing back to "Indiana Jones and the Last Crusade" where he takes the leap of faith.

Nice idea. Proof that asking what might seem like a strange question can turn into a nice addition to the toolbox.