Quick Fix to make Melv's Water Render with TerrainManager
by Brett Fattori · in Torque Game Engine · 04/12/2003 (4:08 pm) · 3 replies
I was wondering why Melv's fluid rendering code (with the nice shoreline texturing and depthmapping) didn't work with the TerrainManager.. Well, a quick look into his code in waterblock.cc led me to the answer. The waterblock knew NOTHING about the TerrainManager and was instead dealing with TerrainBlock's directly. So, without further ado:
In waterBlock.cc, just after the last include, add:
- Brett
In waterBlock.cc, just after the last include, add:
#include "terrain/terrManager.h"Then in the same source, inside the function WaterBlock::SnagTerrain, change it to read:
void WaterBlock::SnagTerrain( SceneObject* sceneObj, void * key )
{
WaterBlock* pWater = (WaterBlock*)key;
TerrainManager * terrain = dynamic_cast<TerrainManager*>(sceneObj);
pWater->mpTerrain = terrain->GetBlock(0);
}Recompile and you should see the nice shoreline textures and depth masking working again. I've only tested this on a 1x1 terrain with TerrainManager, so if anyone has problems (and finds the fix) for multiple terrains, let us all know!- Brett
#2
04/12/2003 (6:04 pm)
There are lots of places where ANY terrain block will do. This might be one of them, I'll have to take a look.
#3
I moved the terrain position code up to sceneobject from gamebase (I *should* have put it there the first time) and modied the water blocks to not use snagterrain but instead get the terrain straight from TM. This means for each terrain block you want to have water in you need to have a water block. I'm not sure if i'm exactly happy with this solution I'm thinking it might be better to just rework the fluid code so that it's TM aware. Melv if you're reading this care to comment?
04/15/2003 (5:48 am)
Looks like the fluid code needs a major overhaul to get it to work right with TM if you want Melv's enhancements. The whole point of SnagTerrain is to grab the heightmap for the TerrainBlock so things like depth can be determined. The fix mentioned at the start of this thread works for a "1x1" block of terrain just fine, but anything other than that will be wrong for every other block, you'll have shallow texturing where it's deep and what not.I moved the terrain position code up to sceneobject from gamebase (I *should* have put it there the first time) and modied the water blocks to not use snagterrain but instead get the terrain straight from TM. This means for each terrain block you want to have water in you need to have a water block. I'm not sure if i'm exactly happy with this solution I'm thinking it might be better to just rework the fluid code so that it's TM aware. Melv if you're reading this care to comment?
Associate Ron Yacketta
-Ron