Game Development Reference
In-Depth Information
}
}
}
Fluid::~Fluid()
{
delete [] tangent;
delete [] normal;
delete [] buffer[1];
delete [] buffer[0];
}
void Fluid::Evaluate( void )
{
// Apply Equation (15.25).
for ( long j = 1; j < height - 1; j++)
{
const Vector3D *crnt = buffer[renderBuffer] + j * width;
Vector3D *prev = buffer[1 - renderBuffer] + j * width;
for ( long i = 1; i < width - 1; i++)
{
prev[i].z = k1 * crnt[i].z + k2 * prev[i].z +
k3 * (crnt[i + 1].z + crnt[i - 1].z +
crnt[i + width].z + crnt[i - width].z);
}
}
// Swap buffers.
renderBuffer = 1 - renderBuffer;
// Calculate normals and tangents.
for ( long j = 1; j < height - 1; j++)
{
const Vector3D *next = buffer[renderBuffer] + j * width;
Vector3D *nrml = normal + j * width;
Vector3D *tang = tangent + j * width;
for ( long i = 1; i < width - 1; i++)
{
Search Nedrilad ::




Custom Search