private static void GetModel_Rod_Klinth(Model3DGroup geometries, WeaponHandleDNA dna, WeaponHandleDNA finalDNA, WeaponMaterialCache materials) { GeometryModel3D geometry = new GeometryModel3D(); var color = WeaponMaterialCache.GetKlinth(dna.MaterialsForCustomizable); finalDNA.MaterialsForCustomizable = color.Item3; geometry.Material = color.Item1; geometry.BackMaterial = color.Item1; //NOTE: The dimensions shouldn't be randomized. This should look like a manufactured, almost mass produced product. // Also, being a crystal, it needs to appear solid List <TubeRingBase> rings = new List <TubeRingBase>(); rings.Add(new TubeRingPoint(0, false)); rings.Add(new TubeRingRegularPolygon(.2, false, .75, .75, false)); rings.Add(new TubeRingRegularPolygon(.3, false, 1, 1, false)); rings.Add(new TubeRingRegularPolygon(.5, false, .9, .9, false)); rings.Add(new TubeRingRegularPolygon(1, false, .8, .8, false)); rings.Add(new TubeRingRegularPolygon(15, false, .8, .8, false)); rings.Add(new TubeRingRegularPolygon(1, false, .9, .9, false)); rings.Add(new TubeRingRegularPolygon(.5, false, 1, 1, false)); rings.Add(new TubeRingRegularPolygon(.3, false, .75, .75, false)); rings.Add(new TubeRingPoint(.2, false)); rings = TubeRingBase.FitNewSize(rings, dna.Radius, dna.Radius, dna.Length); geometry.Geometry = UtilityWPF.GetMultiRingedTube(5, rings, false, true, new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 90))); // the tube builds along z, but this class wants along x geometries.Children.Add(geometry); }
//TODO: random chance of randomly placing metal fittings on the handle private static void GetModel_Rod_Wood(Model3DGroup geometries, WeaponHandleDNA dna, WeaponHandleDNA finalDNA, WeaponMaterialCache materials) { const double PERCENT = 1; Random rand = StaticRandom.GetRandomForThread(); var from = dna.KeyValues; var to = finalDNA.KeyValues; GeometryModel3D geometry = new GeometryModel3D(); #region material switch (dna.HandleMaterial) { case WeaponHandleMaterial.Soft_Wood: geometry.Material = materials.Handle_SoftWood; break; case WeaponHandleMaterial.Hard_Wood: geometry.Material = materials.Handle_HardWood; break; default: throw new ApplicationException("Unexpected WeaponHandleMaterial: " + dna.HandleMaterial.ToString()); } geometry.BackMaterial = geometry.Material; #endregion #region tube double maxX1 = WeaponDNA.GetKeyValue("maxX1", from, to, rand.NextDouble(.45, .7)); double maxX2 = WeaponDNA.GetKeyValue("maxX2", from, to, rand.NextDouble(.45, .7)); double maxY1 = WeaponDNA.GetKeyValue("maxY1", from, to, rand.NextDouble(.85, 1.05)); double maxY2 = WeaponDNA.GetKeyValue("maxY2", from, to, rand.NextDouble(.85, 1.05)); List <TubeRingBase> rings = new List <TubeRingBase>(); rings.Add(new TubeRingRegularPolygon(0, false, maxX1 * .45, maxY1 * .75, true)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("ring1", from, to, rand.NextPercent(.5, PERCENT)), false, maxX1 * .5, maxY1 * 1, false)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("ring2", from, to, rand.NextPercent(2, PERCENT)), false, maxX1 * .4, maxY1 * .8, false)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("ring3", from, to, rand.NextPercent(5, PERCENT)), false, Math1D.Avg(maxX1, maxX2) * .35, Math1D.Avg(maxY1, maxY2) * .75, false)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("ring4", from, to, rand.NextPercent(5, PERCENT)), false, maxX2 * .4, maxY2 * .8, false)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("ring5", from, to, rand.NextPercent(2, PERCENT)), false, maxX2 * .5, maxY2 * 1, false)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("ring6", from, to, rand.NextPercent(.5, PERCENT)), false, maxX2 * .45, maxY2 * .75, true)); rings = TubeRingBase.FitNewSize(rings, dna.Radius * Math.Max(maxX1, maxX2), dna.Radius * Math.Max(maxY1, maxY2), dna.Length); // multiplying x by maxX, because the rings were defined with x maxing at maxX, and y maxing at 1 geometry.Geometry = UtilityWPF.GetMultiRingedTube(10, rings, true, true, new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 90))); // the tube builds along z, but this class wants along x #endregion geometries.Children.Add(geometry); }
private static void GetModel_Rod_Moon(Model3DGroup geometries, WeaponHandleDNA dna, WeaponHandleDNA finalDNA, WeaponMaterialCache materials) { const double PERCENT = 1; Random rand = StaticRandom.GetRandomForThread(); var from = dna.KeyValues; var to = finalDNA.KeyValues; #region shaft GeometryModel3D shaft = new GeometryModel3D(); shaft.Material = materials.Handle_Moon; shaft.BackMaterial = shaft.Material; double maxRad1 = WeaponDNA.GetKeyValue("maxRad1", from, to, rand.NextDouble(.7, 1.02)); double maxRad2 = WeaponDNA.GetKeyValue("maxRad2", from, to, rand.NextDouble(.7, 1.02)); double maxRad12 = Math.Max(maxRad1, maxRad2); // this is used in several places List <TubeRingBase> rings = new List <TubeRingBase>(); rings.Add(new TubeRingRegularPolygon(0, false, maxRad1 * .4, maxRad1 * .4, true)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("tube1", from, to, rand.NextPercent(.25, PERCENT)), false, maxRad1 * .8, maxRad1 * .8, false)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("tube2", from, to, rand.NextPercent(.3, PERCENT)), false, maxRad1 * .85, maxRad1 * .85, false)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("tube3", from, to, rand.NextPercent(.75, PERCENT)), false, maxRad1 * .6, maxRad1 * .6, false)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("tube4", from, to, rand.NextPercent(20, PERCENT)), false, maxRad2 * .8, maxRad2 * .8, false)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("tube5", from, to, rand.NextPercent(1, PERCENT)), false, maxRad2 * .9, maxRad2 * .9, false)); rings.Add(new TubeRingRegularPolygon(WeaponDNA.GetKeyValue("tube6", from, to, rand.NextPercent(1, PERCENT)), false, maxRad2 * 1, maxRad2 * 1, false)); rings.Add(new TubeRingDome(WeaponDNA.GetKeyValue("tube7", from, to, rand.NextPercent(2.5, PERCENT)), false, 4)); rings = TubeRingBase.FitNewSize(rings, maxRad12 * dna.Radius, maxRad12 * dna.Radius, dna.Length); shaft.Geometry = UtilityWPF.GetMultiRingedTube(10, rings, true, true, new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), -90))); // the tube builds along z, but this class wants along x #endregion // Number of gems int numIfNew = 0; if (rand.NextDouble() > .66d) // only 33% will get gems { // Of the handles with gems, only 5% will get 2 numIfNew = rand.NextDouble() > .95 ? 2 : 1; } int numGems = Convert.ToInt32(WeaponDNA.GetKeyValue("numGems", from, to, numIfNew)); if (numGems == 0) { geometries.Children.Add(shaft); return; } #region gems List <double> percents = new List <double>(); for (int cntr = 0; cntr < numGems; cntr++) { string keyPrefix = "gem" + cntr.ToString(); // Get a placement for this gem double percentIfNew = 0; do { percentIfNew = rand.NextDouble(.15, .85); if (percents.Count == 0) { break; } } while (percents.Any(o => Math.Abs(percentIfNew - o) < .15)); double percent = WeaponDNA.GetKeyValue(keyPrefix + "Percent", from, to, percentIfNew); percents.Add(percent); // Gem GeometryModel3D gem = new GeometryModel3D(); gem.Material = materials.Handle_MoonGem; gem.BackMaterial = gem.Material; double width = WeaponDNA.GetKeyValue(keyPrefix + "Width", from, to, rand.NextDouble(maxRad12 * 1d, maxRad12 * 1.4d)); gem.Geometry = UtilityWPF.GetSphere_LatLon(5, dna.Radius * width); Point3D position = new Point3D((dna.Length * percent) - (dna.Length / 2d), 0, 0); gem.Transform = new TranslateTransform3D(position.ToVector()); // Light PointLight pointLight = new PointLight(materials.Handle_MoonGemLight, position); UtilityWPF.SetAttenuation(pointLight, dna.Radius * 120d, .1d); geometries.Children.Add(pointLight); geometries.Children.Add(gem); } // Adding this after so that you don't see the shaft through the gems geometries.Children.Add(shaft); #endregion }