protected void SetColorFromIndices(SurfaceShading surfaceShading, byte opacity) { int[] cmap = colourMap.ToIntArray(); if (surfaceShading == SurfaceShading.Smooth) { int index = 0; int indexOff = colourMapIndices.Length; foreach (UInt16 magnitude in colourMapIndices) { vertices[index].Color = (opacity << 24) | cmap[magnitude]; vertices[index + indexOff].Color = (opacity << 24) | cmap[magnitude]; index++; } } else { int currentVertInd = 0; UInt16 magnitude; int index = 0; int colour1, colour2, colour3, colour4; for (int v = 0; v < lengthV - 1; v++) { for (int u = 0; u < lengthU - 1; u++) { bool interpolateColourInFacets = true; if (interpolateColourInFacets) { magnitude = colourMapIndices[index]; colour1 = (opacity << 24) | cmap[magnitude]; magnitude = colourMapIndices[index + 1]; colour2 = (opacity << 24) | cmap[magnitude]; magnitude = colourMapIndices[index + lengthU + 1]; colour3 = (opacity << 24) | cmap[magnitude]; magnitude = colourMapIndices[index + lengthU]; colour4 = (opacity << 24) | cmap[magnitude]; vertices[currentVertInd + 0].Color = colour1; vertices[currentVertInd + 1].Color = colour2; vertices[currentVertInd + 2].Color = colour3; vertices[currentVertInd + 3].Color = colour3; vertices[currentVertInd + 4].Color = colour4; vertices[currentVertInd + 5].Color = colour1; currentVertInd += 6; } else { } index++; } index++; } } }
protected void SetColorFromIndices() { lock (updateLocker) { SurfaceShading surfaceShading = SurfaceShading.Smooth; byte opacity = 255; Dispatcher.Invoke(new Action(delegate() { surfaceShading = SurfaceShading; opacity = (byte)(255 - (byte)GetValue(TransparencyProperty)); })); SetColorFromIndices(surfaceShading, opacity); } }