//! zinc
library TerrainSampler {
constant real GridSize = 128; // Size of a terrain mesh quad.
location samplePoint = Location(0,0);
real x, y, z, minX, minY, maxX, maxY, sampleZ;
rect bounds = null;
function InitBounds() {
bounds = GetWorldBounds();
minX = GetRectMinX(bounds);
minY = GetRectMinY(bounds);
maxX = GetRectMaxX(bounds);
maxY = GetRectMaxY(bounds);
}
function SampleYAxis() {
y = minY;
while (y <= maxY) {
MoveLocation(samplePoint, x, y);
sampleZ = GetLocationZ(samplePoint);
if (sampleZ > z) z = sampleZ;
y += GridSize;
}
}
function SampleXAxis() {
if (bounds == null) InitBounds();
z = -10000000;
x = minX;
while (x <= maxX) {
ForForce(bj_FORCE_PLAYER[0], function SampleYAxis);
x += GridSize;
}
}
public function SampleTerrainMaxZ() -> real {
ForForce(bj_FORCE_PLAYER[0], function SampleXAxis);
return z;
}
}
//! endzinc