public ILColorProvider(ILColorProvider hlsrgb) { this.red = hlsrgb.Red; this.blue = hlsrgb.Blue; this.green = hlsrgb.Green; this.luminance = hlsrgb.Luminance; this.hue = hlsrgb.Hue; this.saturation = hlsrgb.Saturation; }
protected void CreateVertices(object sender, EventArgs e) { VertexBuffer buffer = (VertexBuffer)sender; VERTEX_FORMAT[] vertices = (VERTEX_FORMAT[])buffer.Lock(0, 0); float val = 0.0f; float minZ = m_globalClipping.ZMin; float maxZ = m_globalClipping.ZMax; float a = MAXHUEVALUE / (maxZ - minZ); float b = -minZ * a; int i = 0; ILColorProvider colHelp = new ILColorProvider(0.0f, 0.5f, 1.0f); for (int r = 0; r < m_rows; r++) { for (int c = 0; c < m_cols; c++) { val = m_sourceArray.GetValue(c, r); vertices[i].X = c; vertices[i].Y = r; vertices[i].Z = val; vertices[i++].Color = colHelp.H2RGB(MAXHUEVALUE - val * a - b); } } #region create normals // Vector3 normal; i = 0; for (int r = 0; r < m_rows; r++) { for (int c = 0; c < m_cols; c++, i++) { normal = new Vector3(); if (c > 0 && c < m_cols) { normal.Add(vertices[i - 1].Position); } if (c < m_cols - 1) { normal.Add(vertices[i + 1].Position); } if (r > 0 && r < m_rows) { normal.Add(vertices[i - m_cols].Position); } if (r < m_rows - 1) { normal.Add(vertices[i + m_cols].Position); } normal.Normalize(); vertices[i].Normal = normal; } } #endregion buffer.Unlock(); m_vertexReady = true; }