Ejemplo n.º 1
0
        private void m_btnOK_Click(object sender, EventArgs e)
        {
            string error = ValidateData();
            if (string.IsNullOrWhiteSpace(error))
            {
                // create mask map.
                ImageData maskImg = new ImageData();
                maskImg.InitNew(MaskWidth, MaskHeight, ImageDataFORMAT.R8_UNORM);
                if (m_importedMask != null)
                {
                    for (int y = 0; y < maskImg.Height; y++)
                    {
                        for (int x = 0; x < maskImg.Width; x++)
                        {
                            byte src = m_importedMask.GetPixelByte(x, y);
                            maskImg.SetPixel(x, y, src);
                        }
                    }

                    m_importedMask.Dispose();
                    m_importedMask = null;
                }
                maskImg.Save(new Uri(m_maskTxt.Text));
                maskImg.Dispose();
            }
            else
            {
                error = "Error: " + Environment.NewLine + error;
                MessageBox.Show(this, error, "Create Terrain", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            
            DialogResult = System.Windows.Forms.DialogResult.OK;

        }
Ejemplo n.º 2
0
        private void OKbtnClick(object sender, EventArgs e)
        {
            string error = ValidateData();
            if (string.IsNullOrEmpty(error))
            {
                ImageData hmImg = new ImageData();
                hmImg.InitNew(HmapCols, HmapRows, ImageDataFORMAT.R32_FLOAT);
                if (m_importedHeightMap != null)
                {
                    float scalehm = ScaleImportedHeightmap;
                    if (m_importedHeightMap != null)
                    {
                        // apply imported heightmap.
                        for (int y = 0; y < hmImg.Height; y++)
                        {
                            for (int x = 0; x < hmImg.Width; x++)
                            {
                                float val = m_importedHeightMap.GetPixelFloat(x, y) * scalehm;
                                hmImg.SetPixel(x, y, val);
                            }
                        }
                    }
                }
                hmImg.Save(new Uri(HeightMapPath));
                hmImg.Dispose();

            }
            else
            {
                error = "Error: " + Environment.NewLine + error;
                MessageBox.Show(this, error, "Create Terrain", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;
        }