Game Development Community

Stop Terrain Repetition

by AIDan · in Torque Game Engine · 11/21/2001 (12:56 am) · 30 replies

Hi

I want a terrain for each island in our maps. Is there any way to stop terrain repetition??
I have added more terrains, all works fine (lighting, loading) but only the first terrain is shown.
Is there also a way to reduce the amount of squares in a terrain, because the islands would be smaller than 2048
Page «Previous 1 2
#1
12/03/2001 (7:17 am)
From what I have seen and read, changing how the terrain repitition works is going to require some pretty hefty engine modification. Useful information huh?

Justin Mette
21-6 Productions
#2
12/03/2001 (8:37 am)
Two words: Texture Synthesis

By using a source tile and a control image a unique texture can be generated. Gamedev has a link to a white paper about it. It's an interesting read regardless of if you can actually implement it. Probably really useful for you MMOG's people.
#3
12/03/2001 (9:05 am)
There would be two solutions to remove wrapping, one is to change the higher level block loops to only loop through a single block. This sounds pretty easy, but I haven't looked at the code yet.

The other is to replace the wrapped values with some default. There are a few places where there terrain height and other info is returned based on an x,y position. The x,y values are simply masked x &= 0xff, etc. to optain the wrapped values. You could change that code to simply return default values (such as a 0 height) if the coordinates are outside the center block.
#5
04/01/2002 (4:01 pm)
So does this mean that is really hard to make a working island map? cause it is pretty critical to my project that you can make an medium sized island.... and one more thing.. I've seen some cool Tribes 2 island maps... should they be fully importable to torque engine? and is it possible to use all tools that are ment to work with tribes 2 missions and maps?
#6
04/01/2002 (4:49 pm)
you could do it like this tho:

1) make a large map with no hills or watever.
2) add the water, make it go throughout the map.
3) make your terrain in worldcraft.
4) add the woldcraft terrain as an object, almost like a base.
5) add the base on top.

=D
#7
04/01/2002 (6:36 pm)
I knwo this is probably just stating the obvious but I made an island map in the following way.

- Make a large map
- Add in your ocean
- Raise the land for the island so it is above the water
- Add fog.

People standing on the shore of the island will not be able to see far enough to be able to see the terrain repetition.

You can make a fairly large island in this way with no engine alterations.
#8
04/01/2002 (6:47 pm)
yup, it works, but if you have boats & aircraft, people will keep encountering the copies of your island, and you give away some terrain smoothness by giving up area to the in-between spaces.
#9
04/01/2002 (8:19 pm)
Very True :)
Just depends on the application I guess.
#10
04/01/2002 (8:24 pm)
I thought someone came up with a solution to stop terrain repetition? He posted a screenshot and everything.
#11
04/01/2002 (8:52 pm)
yeah, that was me. As it turns out, I ws able to stop only the terrain rendering from repeating, but not the collision detection or shadow lighting ...
#12
04/01/2002 (11:51 pm)
I've got this all working. It has a "tile terrain" checkbox in the editor, so you can turn the repetition on and off. It doesn't render the terain, you can't collide with it, the TerrainBlock::RayCast function doesn't hit the phantom tiles, and you can set the position of the tile (for islands).

There are a few problems though. The editor looks for one specific terrain block named "Terrain." So in order to use the terraformer on a specific island, you have to rename that island to "Terrain." Same thing goes with painting textures etc.

I was going to add a new attachTerrain command like the one in the terrain editor, but I haven't had time. If someone is willing to do that then I'll upload my terrain files for all to download. I didn't document the changes as I made them, so it would be easier to just replace your existing terrain files with mine (or you can manually merge them).


There's a problem with the textures sometimes too. If you have a terrain overlapping another terrain then their textures will swap and look all screwy. I made two green islands (both were non-tiling), and a sandy, flat (tiled) terrain block for the ocean floor. Their textures would switch around though. The lush islands would have squares of sand that move around (like the old editor's paint code). It only happens when two or more terrain blocks are in view.



Well what do you think? Sorry I didn't post earlier, I was kind of holding back. I wanted to see if anyone else tried this.
#13
04/02/2002 (7:22 am)
Can we take a look Chris?
#14
04/02/2002 (4:58 pm)
www.planettribes.com/aoe/misc/members/dark/crap/tileterrain.zip

There you go! The specific changes can probably be found by searching for mTileTerrain, and mPosition.

I think that's it, if anyone has any problems let me know.
#15
04/03/2002 (7:32 am)
Thanks! :) Let me add a suggestion: this works real nice but it essentially hardcodes turning off terrain tiling. What about adding a flag that would allow turning off terrain tiling for a particular mission only?

Another thought--I had tried Ken's version and in some cases it might be nice to have the collision on in the no-longer-tiled areas; instead of falling off the main terrain, walking around on the invisible areas might be a useful (optional) feature. Perhaps another mission file flag for the terrCollision.cc code?

Also, in the mission file, values for X and Y should be based on squareSize so, if squareSize=4 for example these should be X=-512, Y=-512, right? Unless we are offsetting this particular terrain in the world? And, there is already a "position" parameter in the terrain dataBlock; can this be used instead of X,Y,Z?

Very nice work guys!
#16
04/03/2002 (9:56 am)
or you could do what i did in my space map falling off the map, just create a new waterblock for lava
//-------in your mis file
new WaterBlock(Lava) {
position = "-648 -712 115.755";
rotation = "1 0 0 0";
scale = "1664 1216 1";
liquidType = "Lava";
density = "1";
viscosity = "15";
waveMagnitude = "0";
surfaceTexture = "~/data/water/lava";
surfaceOpacity = "0.2";
envMapTexture = "~/data/skies/day_0007";
envMapIntensity = "0.2";
removeWetEdges = "1";
params0 = "0.32 -0.67 0.066 0.5";
params1 = "0.63 -2.41 0.33 0.21";
extent = "10 10 10";
params2 = "0.39 0.39 0.2 0.133";
params3 = "1.21 -0.61 0.13 -0.33";
};

then in your players double the damage

function Armor::onEnterLiquid(%this, %obj, %coverage, %type)
{
switch(%type)
{
case 0: //Water
case 1: //Ocean Water
case 2: //River Water
case 3: //Stagnant Water
case 4: //Lava
%obj.setDamageDt(%this, $DamageLava, "Lava");
%obj.setDamageDt(%this, $DamageLava, "Lava");
case 5: //Hot Lava
%obj.setDamageDt(%this, $DamageHotLava, "Lava");
case 6: //Crusty Lava
%obj.setDamageDt(%this, $DamageCrustyLava, "Lava");
case 7: //Quick Sand
}
}

instant death
the just make the lave jpg the same color as the background it is in
( you have two other lava's there to use for lave)
#17
04/03/2002 (11:26 am)
LOL, good idea :)
#18
04/08/2002 (5:17 pm)
Here is an addition to build on Chris and Ken's start on terrain tiling; this allows two flags to be added to the terrain dataBlock in the mission file--repeatTiles and collisionOnTiles to turn repeats on and off and, if off, to turn the collision on or off.

I haven't tested with multiple terrains yet--let me know how it works.

-------------------------------------------------------
In terrData.h (TerrainBlock class)

after:
private:
   S32 squareSize;

  public:
add:
//terrain tiling/collision
	S32 X;
	S32 Y;
	S32 Z;
	bool repeatTiles;       
	bool collisionOnTiles;
----------------------------------------------------
In terrData.cc

after:
TerrainBlock::TerrainBlock()
{
   squareSize = 8;
add:
//terrain tiling/collision
	repeatTiles = true;       //on by default
	collisionOnTiles = true;  //on by default
	X = 0;
	Y = 0;
	Z = 0;
after:
bool TerrainBlock::onAdd()
{
   if(!Parent::onAdd())
      return false;
add:
//terrain tiling/collision
	if(repeatTiles)  //normal mode
	{
		setPosition(Point3F(-squareSize * (BlockSize >> 1), -squareSize * (BlockSize >> 1), 0));
	}
	else
	{
		setPosition(Point3F(X,Y,Z));
	}
after:
void TerrainBlock::initPersistFields()
{
   Parent::initPersistFields();
add:
//terrain tiling/collision
	addField("X", TypeS32, Offset(X, TerrainBlock));
	addField("Y", TypeS32, Offset(Y, TerrainBlock));
	addField("Z", TypeS32, Offset(Z, TerrainBlock));
	addField("repeatTiles", TypeBool, Offset(repeatTiles, TerrainBlock));
	addField("collisionOnTiles", TypeBool, Offset(collisionOnTiles, TerrainBlock));
after:
U32 TerrainBlock::packUpdate(NetConnection *, U32 mask, BitStream *stream)
{
   if(stream->writeFlag(mask & InitMask))
   {
      stream->write(mCRC);
      stream->writeString(mTerrFileName);
      stream->writeString(mDetailTextureName);
      stream->write(squareSize);
add:
//terrain tiling/collision
      stream->write(repeatTiles);
      stream->write(collisionOnTiles);
      stream->write(X);
      stream->write(Y);
      stream->write(Z);
after:
void TerrainBlock::unpackUpdate(NetConnection *, BitStream *stream)
{
   if(stream->readFlag())  // init
   {
      stream->read(&mCRC);
      mTerrFileName = stream->readSTString();
      mDetailTextureName = stream->readSTString();
      stream->read(&squareSize);
add:
//terrain tiling/collision
      stream->read(&repeatTiles);
      stream->read(&collisionOnTiles);
      stream->read(&X);
      stream->read(&Y);
      stream->read(&Z);
---------------------------------------------------
in terrCollision.cc

after:
GridSquare *gs = findSquare(0, Point2I(xi, yi));
add:
//terrain tiling/collision
	if(repeatTiles == false && collisionOnTiles == false)
	{
		if(x != xi || y != yi)
			break;
	}
----------------------------------------------------
in terrRender.cc

after:
void TerrainRender::emitTerrChunk(SquareStackNode *n, F32 squareDistance, U32 lightMask, bool farClip, bool drawDetails)
{
   //if(n->pos.x || n->pos.y)
	//   return;
add:
[b]//terrain tiling/collision
	if(mCurrentBlock->repeatTiles == false)
	{
		if(mBlockPos.x || mBlockPos.y)
			return;
	}[/b]
-----------------------------------------------------
In your mission file add the last five lines:
new TerrainBlock(Terrain1) {
      rotation = "1 0 0 0";
      scale = "1 1 1";
      detailTexture = "~/data/terrains/details/detail1";
      terrainFile = "./test_terrain.ter";
      squareSize = "4";
         locked = "true";
         position = "0 0 0"; 
     //add these [b]
      repeatTiles = "false";           
      collisionOnTiles = "true";  
      X = "-512";					
      Y = "-512";
      Z = "0"; [/b]
   };
#19
05/14/2004 (6:15 am)
Cool Des. Does it stop the terrain from being generated or just occlude it from rendering? I will test it out tonight and see if it does the trick. Thanks Desmond.
#20
11/01/2004 (12:25 pm)
Does this include Chris Evan's code also? cause the link he posted is dead ;(
Page «Previous 1 2