Skip Navigation Links  

Dieses Beispiel

zeigt, wie Heightmapping in Drawing3d realisiert ist. Verwendet wird die Klasse Terrain die von Mesh abstammt. Durch Aufruf von SetHighMap(HightMap) für ein Bitmap Hightmap wird ein Bitmap gesetzt, dessen Grauwerte als Höhenwerte interpretiert werden. Scaliert wird durch terrain.HightScale.

using System.Drawing;
using System.Windows.Forms;
using Drawing3d;
namespace HightMap
{
    public partial class Form1 : Form
    {
        MyDevice Device = new MyDevice();
        public Form1()
        {
            InitializeComponent();
            Device.WinControl = this;
        }
    }
    public class MyDevice:OpenGlDevice
    {
        public Terrain terrain = new Terrain();
        Bitmap HightMap = null;
        Texture Texture = new Texture();
        protected override void OnCreated()
        {
            terrain.Width = 20;
            terrain.Height =20;
            terrain.x = -10;
            terrain.y = -10;
            HightMap = Bitmap.FromFile("Metal_Grill_006_height.png") as Bitmap;
            terrain.HightScale = 200; // scales the height of the Bitmap by dividing.
            terrain.SetHighMap(HightMap); // sets the Height 
           
            Texture.LoadFromFile("Metal_Grill_006_ambientOcclusion.jpg");
            terrain.Texture = Texture;
            terrain.CompileEnable = false; // compile needs a lot of time.
            terrain.SnappEnable = false;   // calculating the snapinfos needs a lot of time.
            base.OnCreated();
        }
        public override void OnPaint()
        {
            terrain.Paint(this);
        
        }
    }
}
Copyright © Drawing3D inc