Game Development Community

Definition of squareSize?

by Michael Rogers · in Torque Game Engine · 08/02/2005 (9:20 am) · 5 replies

Can someone provide me with a definition of squareSize, or point to where this is described?

Thanks in advance,

Michael Rogers

#1
08/02/2005 (10:18 am)
There are essentially three major things that effect the size of the terrain,
squareSize, blockSize, and blockShift.

Before I go further I'm going to define a few words so that we can speak
the same language. These words are not necessarily representative of
anything in C++ or in-game. They are just a means for us to communicate
better.

Firstly, a TerrainBlock is the entire non-repeating terrain. Terrain is essentially
infinite, but it is tiled and only the part you design in the map editor is unique.
This unique part is exactly 2048x2048 in world size.

A Block is similar to the TerrainBlock. It represents what would be
the entire non-repreating terrain. It is kind of hard to conceptualize but the
difference here is the Block is representative of the heightfield whereas
the TerrainBlock is representative of the geometry. A Block is the
size of blockSize, which is 256x256. Because the Block is representative
of the heightfield it should come to no surprise that this is exactly how big
the heightfields are in Torque.

A TerrainBlock is made up of many Squares. These Squares coincidentally
happen to be the same size as one non-tiled texture mapped to the terrain.
If you were to take a texture, and mark the outside edges, and apply that
single texture to the terrain you would be able to see this. A TerrainBlock is
made up of exactly 32x32 Squares. A Square is exactly squareSize in size,
which is 8x8.

A Square is made of many smaller blocks, 8x8 to be exact. However, there
is not a direct correlation between the squareSize of the Square and the
number of sub-blocks of the Square. This number is controlled by blockShift,
which is 8. BlockShift controls the sampling of the heightfield.

So, given this information we can see that a TerrainBlock is exactly
squareSize(8) * blockSize(Square(32) * blockShift(8)) or 2048x2048 in size.

Most of this information you can find by dissecting terrData.h and the various
terrain code.
#2
08/02/2005 (10:30 am)
Great description, thanks for that :)
#3
08/03/2005 (9:58 am)
Robert,

Thanks for your reply. It's helping, but I'm still confused about the units. You say that a TerrainBlock is 2048x2048, but that a Block (which is also "non-repeating terrain" and therefore presumably must cover the same area), is 256x256. Is there a picture available that shows TerrainBlocks, Blocks, and Squares? That'd help me a lot.

Just to clarify, the heightfield is, in some sense, being stretched over an entire TerrainBlock (or maybe Block); and the texture is being stretched over a much smaller area, a Square. Have I at least got that correct?

Michael
#4
08/03/2005 (11:40 am)
A Block and a TerrainBlock are the same thing, essentially. I've just seperated the two because for me, it makes more sense to say that a Block represents a heightfield of 256x256 and the TerrainBlock represents the world geometry of the terrain which is 2048x2048

If you want to see how the world terrain geometry and the heightfield relate to each other go into your favorite photoshop-like program, and make a 256x256 greyscale image. And then import that image via the Torque Terrain Editor.

I guess you could say that given the TerrainBlock is made up of 32x32 squares with each square containing a 8x8 sub-blocks that each sub-block would be a single pixel within that 256x256 image.

When I have the time I'll see if I can't make some pictures of this.
#5
08/03/2005 (12:14 pm)
I have some info about this including pictures on my homepage.

Click here to go there

/roland