Game Development Community

Waterblock questions

by Ron Nelson · in Torque Game Engine Advanced · 10/16/2009 (2:05 am) · 3 replies

I am doing some conversion work and I am just trying to find out how the scale and gridSize relate to the world in terms of units such as meters. I have already looked on TDN and did not find the answer I needed.

Thanks in advance.

#1
10/16/2009 (3:45 pm)
" The water is square in shape because it is set up as a brute-force grid mesh. It will draw all of the vertices in the grid regardless of what your view distance may be set to.

One of the most important performance parameters for the WaterBlock is gridSize. The gridSize controls how much spacing there is between vertices in the grid - and therefore how many vertices there are in the grid. It should be set as high as possible as suits the needs of the environment. The reason for this is that when the water draws, it will always draw the entire grid. So if you have a 2 kilometer by 2 kilometer size WaterBlock, it will process all of the vertices in the grid, even if you have a viewing distance of a few hundred meters. If your gridSize is set large enough in this case, it's not a big deal. A size of 100 for instance, would process 400 vertices for a 2000x2000 size grid. If your gridSize was 10, however, it would process 40000 vertices which is much slower and wouldn't look a whole lot better.

There are two reasons for having lower gridSize values. The first is fogging. Fog is calculated per-vertex, so if the fog distance less than or near to the gridSize, there will likely be artifacts in the fog because the grid is not fine enough. If the fog distance is very near, and the WaterBlock is large, it might be best to change the shader such that the fog calculations are done per-pixel instead of per-vertex. Then the WaterBlock could be expanded into one large quad.

The second reason for small gridSizes would be smaller WaterBlocks. A WaterBlock can only be as small as one grid element and the size of that element is the gridSize parameter. Ie. if you want a 10x10 size WaterBlock, you must have at most a gridSize of 10. "

Taken from the documentation. Explains it pretty well. I had several problems myself dealing with water blocks and found some issues couldn't be resolved (at least by myself and no one answered online). But for the most part after several hours of experimenting I managed to figure it out. Keep trying and check out example files like stronghold. You'll get it.
#2
10/16/2009 (6:42 pm)
Great information but I what really need to know is how to convert the scale and grid size into meters.
#3
10/17/2009 (11:07 am)
OK then I have an important question, is the object box size of each item in Torque based upon meters/World units?