O'Reilly logo

DarkBASIC Pro Game Programming, Second Edition by Joshua R. Smith, Jonathan S. Harbour

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Following the Contour

Possibly the most common thing you will want to do with a matrix is to have a 3D model move over the terrain and follow the contour of the landscape. You might have an animated character walking over the terrain, or a vehicle driving over it. DB provides a convenient command to calculate the height of the matrix at any given coordinate. You can then use that height value to render your mesh at that location.

The command of interest here is called GET GROUND HEIGHT. There are three simple parameters: the matrix number, the x position, and the z position (which will usually be the location of your mesh object).

height = GET GROUND HEIGHT(matrix #, x position, z position)

Let’s put this command to work by demonstrating how ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required