Beispiel #1
0
// Constructor for the landscape class.
BoidsLand::BoidsLand( )
{
	// Initialise the COM interface pointers.
	landFrame = NULL;

	solidStyle = DEFAULT_LANDSCAPE_SOLID_STYLE;
	solidColour = LSC_GREEN;


	wireframeOn = true;  // Initialize the flags.
	solidOn = false;

	exists = false;  // This will be set by the build function.

	// Call the member function to produce the landscape altitudes.
	calcHeights( );
}
Beispiel #2
0
static void makeNormalMap(sU16* dst, const sU16* src, sInt w, sInt h, sF32 hScale)
{
  sInt  x, y;
  sF32  nx, ny, nz;

  for (y = 0; y < h; y++)
  {
    for (x = 0; x < w; x++)
    {
      dst[3] = calcHeights(src, x, y, w, h, 1, 1, nx, ny) * 32767.0f;
      nx = -nx * hScale;
      ny = -ny * hScale;
      nz = 16383.0f / sqrt(nx * nx + ny * ny + 1.0f);
      dst[0] = nz + 16384;
      dst[1] = ny * nz + 16384;
      dst[2] = nx * nz + 16384;
      dst += 4;
    }
  }
}
Beispiel #3
0
// Destroy, recalculate and redraw the landscape.
void BoidsLand::recalculate( )
{
	// Deconstruct the landscape.
	if ( landFrame )
	{
		deconstruct( );
	}

	// Call the member function to produce the landscape altitudes.
	calcHeights( );

	// If the lanscape is not present, bring it back as a wireframe -
	// - to show the recalculation.
	if ( solidOn == false && wireframeOn == false )
	{
		wireframeOn = true;
	}

	// Re-build the landscape.
	build( window, d3drm, scene, solidStyle );
}