public void ExportHeightsToBitmap(System.Drawing.Bitmap bitmap, float MaxHeight, float MinHeight) { float mult = 5.0f / 3.0f; float range = (MaxHeight - MinHeight); for (int i = 0; i < this._vertices.Length; i++) { int x = int.MaxValue, y = int.MaxValue, z = int.MaxValue; float zf = float.MaxValue; Tools.Vector <float> position = this._vertices[i].Position; try { x = int.Parse(Math.Round(position[0] / mult).ToString()); y = int.Parse(Math.Round(position[1] / mult).ToString()); zf = 255.0f * (position[2] - MinHeight) / range; z = !float.IsNaN(zf) ? int.Parse(Math.Round(zf).ToString()) : 124; System.Drawing.Color col = System.Drawing.Color.FromArgb(z, z, z); bitmap.SetPixel(x, y, col); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show("Crapped Out:\n" + ex.Message + "\n" + ex.StackTrace); System.Windows.Forms.MessageBox.Show(string.Format("Position: {0} x={1} y={2} z={3} zf={4}", position, x, y, z, zf)); throw ex; } } }
public void Load(System.IO.BinaryReader reader) { this._position = new SFX.YATT.Tools.Vector <float>(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); this._normal = new SFX.YATT.Tools.Vector <float>(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); byte b = reader.ReadByte(), g = reader.ReadByte(), r = reader.ReadByte(), a = reader.ReadByte(); this._rgba = System.Drawing.Color.FromArgb(a, r, g, b); this._data[0] = reader.ReadSingle(); this._data[1] = reader.ReadSingle(); this._data[2] = reader.ReadSingle(); this._data[3] = reader.ReadSingle(); }
public void ExportColoursToBitmap(System.Drawing.Bitmap bitmap) { double mult = Constants.VertexSpacing; for (int i = 0; i < this._vertices.Length; i++) { int x = int.MaxValue, y = int.MaxValue; Tools.Vector <float> position = this._vertices[i].Position; try { x = int.Parse(Math.Round(position[0] / mult).ToString()); y = int.Parse(Math.Round(position[1] / mult).ToString()); System.Drawing.Color col = this._vertices[i].Color; bitmap.SetPixel(x, y, col); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show("Crapped Out Ixporting Colours:\n" + ex.Message + "\n" + ex.StackTrace); throw ex; } } }
public void Load( System.IO.BinaryReader reader ) { this._position = new SFX.YATT.Tools.Vector<float>( reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() ); this._normal = new SFX.YATT.Tools.Vector<float>( reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() ); byte b = reader.ReadByte(), g = reader.ReadByte(), r = reader.ReadByte(), a = reader.ReadByte(); this._rgba = System.Drawing.Color.FromArgb( a, r, g, b ); this._data[0] = reader.ReadSingle(); this._data[1] = reader.ReadSingle(); this._data[2] = reader.ReadSingle(); this._data[3] = reader.ReadSingle(); }