but whats in a heightmap? Bethesda's creation kit will export the height map into four .raw files. Each raw file is a quadrant. Q1 to Q4. They are fairly consistent in how they represent the data. The entire map your character can be on and more is defined in the raw files. As a fan of rain and wetness in Fallout, I have long fantasized of nonpiercing rain and floods. There is simply no other way to approach the problem of flooding, fluids and rain better than this.
I have one last thing to say. This is not a code snippet that is ready to adapt to rain. Just like I relied on the heightmap data to know where to place floods, you need a map of all objects. using the position of an object and its bounding box you can know which areas rain should not fall. In code we would have these nogo areas in a list so a user would have the same approach of drawing bits of vertexes outward from their player but with no worry it would penetrate objects. in fairness there are multiple ways we could buidl the object map. It be just like the height map but the pixels that are different don't mean how far up or down, but do not drop or in in the user's case draw particise in those positions.
Code: Select all
short ** ppHeightmap;
// 16bit value 0 to 65,535. Player minimum and maximum 65,535 * 2.
//(-131070 to 131070). height values are all capped at 16 bits. max Z = 65,535
int XYToZ(int nX, int nY, int &outQuad)
{
int nHeightValue = 0;
int nQuad = 1;
if (nX >= 0 && nY >= 0)
nQuad = 2;
else if (nX <= 0 && nY <0>= 0 && nY <= 0)
nQuad = 4;
if (outQuad != nQuad)
outQuad = nQuad;
// A complete height map is two by two .raw files
nPlayerX = nPlayerX / 2;
nPlayerY = nPlayerY / 2;
const int nResolution = 1024 - 1;
int nIndex = abs(nY) * nResolution + abs(nX);
short shVal = ppHeightmap[nQuad-1][nIndex];
return nHeightValue;
}
void falloutgame()
{
bool bInWasteland = true;
int nPlayerQuadrant = 0;
while (bInWasteland == true)
{
int nPlayerX = 0;
int nPlayerY = 0;
const int nAreaLengthX = 5;
const int nAreaLengthY = 5;
for (int xxx = 0; xxx < nAreaLengthX; ++xxx) {
for (int yyy = 0; yyy < nAreaLengthY; ++yyy) {
int nHeight = XYToZ(nPlayerX + xxx, nPlayerY + yyy, nPlayerQuadrant);
/*
* one could do a number of things at this time.
* one could translate amesh or particle up the Z using nHeight as a minimum.
* one could bake physics simulations (fluids) using the position data.
*/
}
}
}
}
I sure hope you enjoyed this post. I should also mention this means new vegas could have nice rain too.