public static void ColorReceptiveField(Mesh d3dMesh, AnimatTools.Framework.Vec3d vFieldPoint, AnimatTools.DataObjects.Gain gnGain) { CustomVertex.PositionNormalColored vVertex; GraphicsStream buffer = d3dMesh.LockVertexBuffer(LockFlags.None); float fltBaseVal = (float) gnGain.CalculateGain(0); float fltDist, fltGain=0; for(int i=0; i<d3dMesh.NumberVertices; i++) { buffer.Position = i * d3dMesh.NumberBytesPerVertex; vVertex = (CustomVertex.PositionNormalColored)buffer.Read(typeof(CustomVertex.PositionNormalColored)); //dwc changes fltDist = (float) Distance(vFieldPoint, vVertex.X, vVertex.Y, vVertex.Z) * Util.Environment.DistanceUnitValue; fltGain = (float) gnGain.CalculateGain(fltDist); fltGain = 255 - (255*(fltGain/fltBaseVal)); if(fltGain < 0) fltGain = 0; if(fltGain>255) fltGain = 255; vVertex.Color = Color.FromArgb(255, (int) fltGain, (int) fltGain).ToArgb(); buffer.Position = i * d3dMesh.NumberBytesPerVertex; buffer.Write(new CustomVertex.PositionNormalColored(vVertex.X, vVertex.Y, vVertex.Z, vVertex.Nx, vVertex.Ny, vVertex.Nz, vVertex.Color)); } d3dMesh.UnlockVertexBuffer(); }