/// <summary> /// Get the sidewalk material, or if one has not been generated, generate one based off DefaultSidewalkMaterial /// </summary> /// <param name="provider"></param> /// <param name="random"></param> /// <param name="defaultMaterial"></param> /// <returns></returns> public static string RoadSidewalkMaterial(this INamedDataCollection provider, Func <double> random, string defaultMaterial = null) { Contract.Requires(provider != null); Contract.Requires(random != null); return(provider.DefaultMaterial(random, RoadSidewalkMaterialName, defaultMaterial ?? provider.GetValue(DefaultSidewalkMaterialName))); }
/// <summary> /// Create the base block for this facade (which embossing stamps will be applied to) /// </summary> /// <param name="bounds"></param> /// <param name="geometry"></param> /// <param name="hierarchicalParameters"></param> /// <returns></returns> protected virtual ICsgShape CreateFacade(Prism bounds, ISubdivisionGeometry geometry, INamedDataCollection hierarchicalParameters) { Contract.Requires(geometry != null); Contract.Requires(hierarchicalParameters != null); return(geometry.CreatePrism(hierarchicalParameters.DefaultMaterial(Random), bounds.Footprint, bounds.Height)); }
public static string ExternalWallMaterial(this INamedDataCollection provider, Func <double> random, params string[] possibilities) { Contract.Requires(provider != null); Contract.Requires(random != null); Contract.Requires(possibilities != null); //Select a random value from the possibilities, if no possibilities are supplied use the default material var generated = possibilities.Length == 0 ? provider.DefaultMaterial(random) : possibilities[random.RandomInteger(0, possibilities.Length - 1)]; return(provider.DetermineHierarchicalValue(ExternalWallDefaultMaterialName, oldValue => { //If no possibilities were provided, everything is valid! if (possibilities.Length == 0) { return oldValue; } //Use the old value if it is one of the allowed possibilities if (((IList <string>)possibilities).Contains(oldValue)) { return oldValue; } //Otherwise generate a new value (from the range of allowed possibilities) return generated; }, () => generated)); }
public override void Subdivide(Prism bounds, ISubdivisionGeometry geometry, INamedDataCollection hierarchicalParameters) { var height = (float)Math.Min(bounds.Height, Math.Sqrt(Math.Abs(bounds.Footprint.Area())) * (Random() + 0.5)); var material = hierarchicalParameters.DefaultMaterial(Random); var prism = geometry.CreatePrism(material, bounds.Footprint, height).Transform(Matrix4x4.CreateTranslation(0, height / 2f - bounds.Height / 2f + GroundHeight, 0)); geometry.Union(prism); }