private void InitBlendMaps( Axiom.Components.Terrain.Terrain terrain )
{
TerrainLayerBlendMap blendMap0 = terrain.GetLayerBlendMap( 1 );
TerrainLayerBlendMap blendMap1 = terrain.GetLayerBlendMap( 2 );
Real minHeight0 = 70;
Real fadeDist0 = 40;
Real minHeight1 = 70;
Real fadeDist1 = 15;
float[] pBlend1 = blendMap1.BlendPointer;
int blendIdx = 0;
for ( ushort y = 0; y < terrain.LayerBlendMapSize; y++ )
{
for ( ushort x = 0; x < terrain.LayerBlendMapSize; x++ )
{
float tx = 0;
float ty = 0;
blendMap0.ConvertImageToTerrainSpace( x, y, ref tx, ref ty );
Real height = terrain.GetHeightAtTerrainPosition( tx, ty );
Real val = ( height - minHeight0 ) / fadeDist0;
val = Utility.Clamp( val, 0, 1 );
val = ( height - minHeight1 ) / fadeDist1;
val = Utility.Clamp( val, 0, 1 );
pBlend1[ blendIdx++ ] = val;
}
}
blendMap0.Dirty();
blendMap1.Dirty();
blendMap0.Update();
blendMap1.Update();
}