private void GetMineralBlipSprtCacheProps() { // Get the min/max values double minDollars = double.MaxValue; double maxDollars = double.MinValue; SortedList <MineralType, double> dollars = new SortedList <MineralType, double>(); foreach (MineralType mineralType in Enum.GetValues(typeof(MineralType))) { if (mineralType == MineralType.Custom) { continue; } decimal suggestedDollars = Mineral.GetSuggestedValue(mineralType); double suggestedDollarsScaled = Math.Sqrt(Convert.ToDouble(suggestedDollars)); // taking the square root, because the values are exponential, and I want the color scale more linear dollars.Add(mineralType, suggestedDollarsScaled); if (suggestedDollarsScaled < minDollars) { minDollars = suggestedDollarsScaled; } if (suggestedDollarsScaled > maxDollars) { maxDollars = suggestedDollarsScaled; } } // Store color based on those values _mineralColors = new SortedList <MineralType, MineralBlipProps>(); Color maxColor = Colors.Chartreuse; foreach (MineralType mineralType in Enum.GetValues(typeof(MineralType))) { MineralBlipProps props = new MineralBlipProps(); if (mineralType == MineralType.Custom) { props.DiffuseColor = Colors.HotPink; // not sure what to do here. maybe I'll know more if I ever use custom minerals :) props.SpecularColor = props.DiffuseColor; props.Size = 4; } else { double dollar = dollars[mineralType]; double colorPercent = UtilityCore.GetScaledValue_Capped(.33d, 1d, minDollars, maxDollars, dollar); props.DiffuseColor = UtilityWPF.AlphaBlend(maxColor, Colors.Transparent, colorPercent); props.SpecularColor = props.DiffuseColor; props.Size = UtilityCore.GetScaledValue_Capped(2d, 5d, minDollars, maxDollars, dollar); } _mineralColors.Add(mineralType, props); } }
private Visual3D GetMineralBlip(Mineral mineral) { //if (mineral.Radius < 2) // limit by value instead of size //{ // // No need to flood the map with tiny minerals // return null; //} // Using the mineral's color makes the map look very busy. Instead, set an intensity of a solid color based on its relative value // in relation to the other minerals if (_mineralColors == null) { GetMineralBlipSprtCacheProps(); } MineralBlipProps blipProps = _mineralColors[mineral.MineralType]; double size = blipProps.Size * mineral.VolumeInCubicMeters; // blipProps.Size is for a volume of 1, so adjust by volume // Material MaterialGroup materials = new MaterialGroup(); materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(blipProps.DiffuseColor))); materials.Children.Add(new SpecularMaterial(new SolidColorBrush(blipProps.SpecularColor), 100d)); // Geometry Model GeometryModel3D geometry = new GeometryModel3D(); geometry.Material = materials; geometry.BackMaterial = materials; geometry.Geometry = _blipGeometry_Circle.Value; geometry.Transform = new ScaleTransform3D(size, size, size * .25d); // Model Visual ModelVisual3D retVal = new ModelVisual3D(); retVal.Content = geometry; // Exit Function return(retVal); }
private ModelVisual3D GetMineralBlip(Mineral mineral) { //if (mineral.Radius < 2) // limit by value instead of size //{ // // No need to flood the map with tiny minerals // return null; //} // Using the mineral's color makes the map look very busy. Instead I will set an intensity of a solid color based on its relative value // in relation to the other minerals if (_mineralColors == null) { GetMineralBlipSprtCacheProps(); } MineralBlipProps blipProps = _mineralColors[mineral.MineralType]; // Material MaterialGroup materials = new MaterialGroup(); materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(blipProps.DiffuseColor))); materials.Children.Add(new SpecularMaterial(new SolidColorBrush(blipProps.SpecularColor), 100d)); // Geometry Model GeometryModel3D geometry = new GeometryModel3D(); geometry.Material = materials; geometry.BackMaterial = materials; geometry.Geometry = GetBlipGeometry(); geometry.Transform = new ScaleTransform3D(blipProps.Size, blipProps.Size, blipProps.Size * .25d); // Model Visual ModelVisual3D retVal = new ModelVisual3D(); retVal.Content = geometry; retVal.Transform = new TranslateTransform3D(mineral.PositionWorld.ToVector()); // Exit Function return(retVal); }
private void GetMineralBlipSprtCacheProps() { // Get the min/max values double minDollars = double.MaxValue; double maxDollars = double.MinValue; SortedList<MineralType, double> dollars = new SortedList<MineralType, double>(); foreach (MineralType mineralType in Enum.GetValues(typeof(MineralType))) { if (mineralType == MineralType.Custom) { continue; } decimal suggestedDollars = Mineral.GetSuggestedValue(mineralType); double suggestedDollarsScaled = Math.Sqrt(Convert.ToDouble(suggestedDollars)); // taking the square root, because the values are exponential, and I want the color scale more linear dollars.Add(mineralType, suggestedDollarsScaled); if (suggestedDollarsScaled < minDollars) { minDollars = suggestedDollarsScaled; } if (suggestedDollarsScaled > maxDollars) { maxDollars = suggestedDollarsScaled; } } // Store color based on those values _mineralColors = new SortedList<MineralType, MineralBlipProps>(); Color maxColor = Colors.Chartreuse; foreach (MineralType mineralType in Enum.GetValues(typeof(MineralType))) { MineralBlipProps props = new MineralBlipProps(); if (mineralType == MineralType.Custom) { props.DiffuseColor = Colors.HotPink; // not sure what to do here. maybe I'll know more if I ever use custom minerals :) props.SpecularColor = props.DiffuseColor; props.Size = 4; } else { double dollar = dollars[mineralType]; double colorPercent = UtilityCore.GetScaledValue_Capped(.33d, 1d, minDollars, maxDollars, dollar); props.DiffuseColor = UtilityWPF.AlphaBlend(maxColor, Colors.Transparent, colorPercent); props.SpecularColor = props.DiffuseColor; props.Size = UtilityCore.GetScaledValue_Capped(2d, 5d, minDollars, maxDollars, dollar); } _mineralColors.Add(mineralType, props); } }