Larger Maps Solution
by Nelson A. K. Gonsalves · in Torque Game Engine · 03/01/2002 (6:50 pm) · 8 replies
Before starting I will say I know this isnt the best solution... but I know it was the easiest to implement ;P
Take a look at this picture:
what you see are 2 terrain files intersecting, raising the map to 2x its size(without repeating the same terrain over and over)
What I want to know is if anyone is interested in it... if so I can post a tutorial, if not I will just use it myself and keep it secret, hehe
Take a look at this picture:
what you see are 2 terrain files intersecting, raising the map to 2x its size(without repeating the same terrain over and over)What I want to know is if anyone is interested in it... if so I can post a tutorial, if not I will just use it myself and keep it secret, hehe
About the author
#2
03/01/2002 (7:13 pm)
Sounds interesting. I bet a lot of people would be interested in a tutorial! (I would)
#3
03/01/2002 (8:17 pm)
well dont laff if this sounds dumb but why cant you just scale everything down and leave the mapsize alone?
#4
This Is an interesting Idea, very simple and something to think about when/if you ever need more space.
03/01/2002 (8:22 pm)
You can scale everything down, the problem with that though is your terrain textures won't be as smooth, distance calculations would be off, etc. I think I remember reading about a project that was using a smaller scale to get more room.This Is an interesting Idea, very simple and something to think about when/if you ever need more space.
#5
03/01/2002 (10:23 pm)
How much is the performance affected?
#6
03/01/2002 (11:27 pm)
hmmm - I tried that - and I wasn't able to move the position of the terrains... I just got them overlapping in place. Plus if I tried using two terrains of different size, the high spots of the smaller one dominated the low spots of the larger one... I'll have to try it again. By all means, post your method !
#7
I was going to do some terrain positioning code, but I seem to be breaking things lately :\
03/01/2002 (11:58 pm)
This would be really good for making islands. Stop the terrains from repeating, then put a few large terrain blocks in different positions along with a large waterblock...I was going to do some terrain positioning code, but I seem to be breaking things lately :\
#8
There is also a problem with textures getting misplaced, where they are placed on a terrain they dont belong to... It only happens on some parts of the terrain and depending on the terrains position it doesnt even happen! and sometimes it happen all over the place, I guess it has something to do with the texture coordinates of the blocks... but havent found anything...
The Performance didnt seem to get any hits... as I think the engine only rendered the terrain within its viewing range.
Here is a quick list of things Ive changed... after doing this I really thing if this was improved it could be the way to add larger maps to the engine. Let me know what you think and yours findings... Together we can get this to work out pretty well...
Engine\Terrain\TerrCollision.cc changes
1) Add the following lines to void TerrainBlock::buildConvex right after GridSquare *gs = findSquare(0, Point2I(xi, yi));
if(x != xi || y != yi)
break;
Engine\Terrain\TerrRender.cc changes
1) Add the following lines to TerrainRender::emitTerrChunkright after // return
if(mBlockPos.x || mBlockPos.y)
return;
Engine\Terrain\TerrData.h changes
1) Add the following lines right after public: (around line 251)
S32 X;
S32 Y;
S32 Z;
Engine\Terrain\TerrData.cc changes
1) Add the following lines to TerrainBlock::TerrainBlock() right after squareSize = 8;
X = 0;
Y = 0;
Z = 0;
2) Change
setPosition(Point3F(-squareSize * (BlockSize >> 1), -squareSize * (BlockSize >> 1), 0));
to
setPosition(Point3F(X,Y,Z));
3) Add the following lines to void TerrainBlock::initPersistFields right after Parent::initPersistFields();
addField("X", TypeS32, Offset(X, TerrainBlock));
addField("Y", TypeS32, Offset(Y, TerrainBlock));
addField("Z", TypeS32, Offset(Z, TerrainBlock));
4) Add the following lines to U32 TerrainBlock::packUpdate right after stream->write(squareSize);
stream->write(X);
stream->write(Y);
stream->write(Z);
5) Add the following lines to U32 TerrainBlock::unpackUpdate right after stream->read(&squareSize);
stream->read(&X);
stream->read(&Y);
stream->read(&Z);
Mission script file changes
1) Add the following lines to the first TerrainBlock(should be the only one till now)
X="-1024";
Y="-1024";
Z="0";
2) Now add more TerrainBlocks and play with their X, Y and Z values
03/02/2002 (4:37 am)
Ok... after some more testing I found some weird things happening... there is of course the water problem, but I didnt mess with it yet...There is also a problem with textures getting misplaced, where they are placed on a terrain they dont belong to... It only happens on some parts of the terrain and depending on the terrains position it doesnt even happen! and sometimes it happen all over the place, I guess it has something to do with the texture coordinates of the blocks... but havent found anything...
The Performance didnt seem to get any hits... as I think the engine only rendered the terrain within its viewing range.
Here is a quick list of things Ive changed... after doing this I really thing if this was improved it could be the way to add larger maps to the engine. Let me know what you think and yours findings... Together we can get this to work out pretty well...
Engine\Terrain\TerrCollision.cc changes
1) Add the following lines to void TerrainBlock::buildConvex right after GridSquare *gs = findSquare(0, Point2I(xi, yi));
if(x != xi || y != yi)
break;
Engine\Terrain\TerrRender.cc changes
1) Add the following lines to TerrainRender::emitTerrChunkright after // return
if(mBlockPos.x || mBlockPos.y)
return;
Engine\Terrain\TerrData.h changes
1) Add the following lines right after public: (around line 251)
S32 X;
S32 Y;
S32 Z;
Engine\Terrain\TerrData.cc changes
1) Add the following lines to TerrainBlock::TerrainBlock() right after squareSize = 8;
X = 0;
Y = 0;
Z = 0;
2) Change
setPosition(Point3F(-squareSize * (BlockSize >> 1), -squareSize * (BlockSize >> 1), 0));
to
setPosition(Point3F(X,Y,Z));
3) Add the following lines to void TerrainBlock::initPersistFields right after Parent::initPersistFields();
addField("X", TypeS32, Offset(X, TerrainBlock));
addField("Y", TypeS32, Offset(Y, TerrainBlock));
addField("Z", TypeS32, Offset(Z, TerrainBlock));
4) Add the following lines to U32 TerrainBlock::packUpdate right after stream->write(squareSize);
stream->write(X);
stream->write(Y);
stream->write(Z);
5) Add the following lines to U32 TerrainBlock::unpackUpdate right after stream->read(&squareSize);
stream->read(&X);
stream->read(&Y);
stream->read(&Z);
Mission script file changes
1) Add the following lines to the first TerrainBlock(should be the only one till now)
X="-1024";
Y="-1024";
Z="0";
2) Now add more TerrainBlocks and play with their X, Y and Z values
Torque Owner Matt Webster
Just make two terrain datablocks and position them accordingly :) The problem of course, is the fact that you have 2x the terrain to render!