private Model3D CreateGeometry(bool isFinal) { Model3DGroup retVal = new Model3DGroup(); #region box MaterialGroup material = new MaterialGroup(); Color ringColor = WorldColors.DirectionControllerRing_Color; DiffuseMaterial diffuse = new DiffuseMaterial(new SolidColorBrush(ringColor)); MaterialBrushes.Add(new MaterialColorProps(diffuse, ringColor)); material.Children.Add(diffuse); SpecularMaterial specular = WorldColors.DirectionControllerRing_Specular; MaterialBrushes.Add(new MaterialColorProps(specular)); material.Children.Add(specular); if (!isFinal) { EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent); material.Children.Add(selectionEmissive); SelectionEmissives.Add(selectionEmissive); } GeometryModel3D geometry = new GeometryModel3D { Material = material, BackMaterial = material, Geometry = ConverterMatterToFuelDesign.GetMesh(.36d * SCALE, .04d * SCALE, 3), }; retVal.Children.Add(geometry); #endregion #region brain ScaleTransform3D scaleTransform = new ScaleTransform3D(SCALE, SCALE, SCALE); if (!isFinal) { retVal.Children.AddRange(BrainDesign.CreateInsideVisuals(SCALE * .6, MaterialBrushes, SelectionEmissives, scaleTransform)); } retVal.Children.Add(BrainDesign.CreateShellVisual(isFinal, MaterialBrushes, SelectionEmissives, scaleTransform)); #endregion retVal.Transform = GetTransformForGeometry(isFinal); return(retVal); }
private readonly double _volume; // this is used to calculate energy draw #endregion #region Constructor public Brain(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer energyTanks) : base(options, dna, itemOptions.Brain_Damage.HitpointMin, itemOptions.Brain_Damage.HitpointSlope, itemOptions.Brain_Damage.Damage) { _itemOptions = itemOptions; _energyTanks = energyTanks; Design = new BrainDesign(options, true); Design.SetDNA(dna); // Build the neurons (not doing the links yet - or maybe do the internal links?) _brainChemicals = CreateBrainChemicals(dna, itemOptions); _neurons = CreateNeurons(dna, itemOptions, _brainChemicals.Select(o => o.Position).ToArray()); //_design.NeuronLocations = _neurons.Select(o => o.Position).ToArray(); GetMass(out _mass, out _volume, out double radius, out _scaleActual, dna, itemOptions); Radius = radius; }
internal static Model3D CreateGeometry(List <MaterialColorProps> materialBrushes, List <EmissiveMaterial> selectionEmissives, Transform3D transform, Tuple <Vector3D, double>[][] ringRotations, bool isFinal) { Model3DGroup retVal = new Model3DGroup(); #region rings MaterialGroup material = new MaterialGroup(); Color ringColor = WorldColors.DirectionControllerRing_Color; DiffuseMaterial diffuse = new DiffuseMaterial(new SolidColorBrush(ringColor)); materialBrushes.Add(new MaterialColorProps(diffuse, ringColor)); material.Children.Add(diffuse); SpecularMaterial specular = WorldColors.DirectionControllerRing_Specular; materialBrushes.Add(new MaterialColorProps(specular)); material.Children.Add(specular); if (!isFinal) { EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent); material.Children.Add(selectionEmissive); selectionEmissives.Add(selectionEmissive); } foreach (var torusAngle in ringRotations) { GeometryModel3D geometry = new GeometryModel3D { Material = material, BackMaterial = material }; Transform3DGroup transformGroup = new Transform3DGroup(); foreach (var individualAngle in torusAngle) { transformGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(individualAngle.Item1, individualAngle.Item2))); } const double THICKNESS = SIZEPERCENTOFSCALE * .04; // it's actually half thickness const double RINGRADIUS = (SIZEPERCENTOFSCALE * BRAINSIZE) - THICKNESS; if (isFinal) { geometry.Geometry = UtilityWPF.GetTorus(10, 4, THICKNESS, RINGRADIUS); // must be 10 sided to match the icosidodecahedron (not same as the ichthyosaur) } else { geometry.Geometry = UtilityWPF.GetTorus(60, 12, THICKNESS, RINGRADIUS); } geometry.Transform = transformGroup; retVal.Children.Add(geometry); } #endregion #region brain double brainScale = SIZEPERCENTOFSCALE * BRAINSIZE; ScaleTransform3D scaleTransform = new ScaleTransform3D(); scaleTransform.ScaleX = brainScale; scaleTransform.ScaleY = brainScale; scaleTransform.ScaleZ = brainScale; if (!isFinal) { retVal.Children.AddRange(BrainDesign.CreateInsideVisuals(brainScale * .9, materialBrushes, selectionEmissives, scaleTransform)); } retVal.Children.Add(BrainDesign.CreateShellVisual(isFinal, materialBrushes, selectionEmissives, scaleTransform)); #endregion retVal.Transform = transform; return(retVal); }