예제 #1
0
 /// <summary>
 /// Creates a material with the specifed brush as diffuse material. 
 /// This method will also add a white specular material.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="specularPower">The specular power.</param>
 /// <returns></returns>
 public static Material CreateMaterial(Brush brush, double specularPower)
 {
     var mg = new MaterialGroup();
     mg.Children.Add(new DiffuseMaterial(brush));
     if (specularPower > 0)
         mg.Children.Add(new SpecularMaterial(Brushes.White, specularPower));
     return mg;
 }
예제 #2
0
        public ThrustLine(Viewport3D viewport, SharedVisuals sharedVisuals, Vector3D forceDirection, Vector3D localOffset)
        {
            this.Viewport = viewport;
            _forceDirection = forceDirection;
            _forceStrength = forceDirection.Length;       // this way they don't have to set this if they don't want
            this.BodyOffset = new TranslateTransform3D(localOffset);       // just setting it to something so it's not null

            #region Create Visual

            // I'll create the visual, but won't add it until they fire the thruster

            // Material
            MaterialGroup materials = new MaterialGroup();
            materials.Children.Add(new DiffuseMaterial(Brushes.Coral));
            materials.Children.Add(new SpecularMaterial(Brushes.Gold, 100d));

            // Geometry Model
            // Create a skinny 3D rectangle along the x axis
            GeometryModel3D geometry = new GeometryModel3D();
            geometry.Material = materials;
            geometry.BackMaterial = materials;
            geometry.Geometry = sharedVisuals.ThrustLineMesh;


            // Figure out how much to rotate the cube to be along the opposite of the force line.  I do the opposite, because
            // thruster flames shoot in the opposite direction that they're pushing
            Vector3D flameLine = forceDirection;
            flameLine.Negate();

            Vector3D axis;
            double radians;
            Math3D.GetRotation(out axis, out radians, new Vector3D(1, 0, 0), flameLine);

            if (radians == 0d)
            {
                _initialRotate = null;
            }
            else
            {
                _initialRotate = new RotateTransform3D(new AxisAngleRotation3D(axis, Math1D.RadiansToDegrees(radians)));
            }

            //// Transform
            //Transform3DGroup transform = new Transform3DGroup();		// rotate needs to be added before translate
            //transform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(axis, Math3D.RadiansToDegrees(radians))));
            //transform.Children.Add(new TranslateTransform3D(from));




            // Model Visual
            _model = new ModelVisual3D();
            _model.Content = geometry;
            _model.Transform = new TranslateTransform3D();        // I won't do anything with this right now

            #endregion
        }
예제 #3
0
        public TrackballGrabber(FrameworkElement eventSource, Viewport3D viewport, double sphereRadius, Color hoverLightColor)
        {
            if (viewport.Camera == null || !(viewport.Camera is PerspectiveCamera))
            {
                throw new ArgumentException("This class requires a perspective camera to be tied to the viewport");
            }

            _eventSource = eventSource;
            _viewport = viewport;
            _camera = (PerspectiveCamera)viewport.Camera;

            this.SyncedLights = new List<Model3D>();

            this.HoverVisuals = new ObservableCollection<Visual3D>();
            this.HoverVisuals.CollectionChanged += HoverVisuals_CollectionChanged;

            _eventSource.MouseEnter += new System.Windows.Input.MouseEventHandler(EventSource_MouseEnter);
            _eventSource.MouseLeave += new System.Windows.Input.MouseEventHandler(EventSource_MouseLeave);
            _eventSource.MouseDown += new System.Windows.Input.MouseButtonEventHandler(EventSource_MouseDown);
            _eventSource.MouseUp += new System.Windows.Input.MouseButtonEventHandler(EventSource_MouseUp);
            _eventSource.MouseMove += new System.Windows.Input.MouseEventHandler(EventSource_MouseMove);

            #region Sphere

            // Material
            _sphereMaterials = new MaterialGroup();
            _sphereMaterials.Children.Add(new DiffuseMaterial(new SolidColorBrush(Color.FromArgb(25, 255, 255, 255))));

            // This gets added/removed on mouse enter/leave
            _sphereMaterialHover = new SpecularMaterial(new SolidColorBrush(Color.FromArgb(64, 128, 128, 128)), 33d);

            // Geometry Model
            GeometryModel3D geometry = new GeometryModel3D();
            geometry.Material = _sphereMaterials;
            geometry.BackMaterial = _sphereMaterials;
            geometry.Geometry = UtilityWPF.GetSphere_LatLon(20, sphereRadius);

            // Model Visual
            _sphereModel = new ModelVisual3D();
            _sphereModel.Content = geometry;

            // Add it
            _viewport.Children.Add(_sphereModel);

            #endregion
            #region Hover Light

            // Light
            PointLight hoverLight = new PointLight();
            hoverLight.Color = hoverLightColor;
            hoverLight.Range = sphereRadius * 10;

            _hoverLight = new ModelVisual3D();
            _hoverLight.Content = hoverLight;

            #endregion
        }
예제 #4
0
 //Create a default material of the specified colour:
 public static MaterialGroup getSurfaceMaterial(Color colour)
 {
     var materialGroup = new MaterialGroup();
     var emmMat = new EmissiveMaterial(new SolidColorBrush(colour));
     materialGroup.Children.Add(emmMat);
     materialGroup.Children.Add(new DiffuseMaterial(new SolidColorBrush(colour)));
     var specMat = new SpecularMaterial(new SolidColorBrush(Colors.White), 30);
     materialGroup.Children.Add(specMat);
     return materialGroup;
 }
        private void SetColor(Color color)
        {
            MaterialGroup unlitMaterial = new MaterialGroup();
            unlitMaterial.Children.Add(new DiffuseMaterial(new SolidColorBrush(Colors.Black)));
            unlitMaterial.Children.Add(new EmissiveMaterial(new SolidColorBrush(color)));
            unlitMaterial.Freeze();

            _model.Material = unlitMaterial;
            _model.BackMaterial = unlitMaterial;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 25 "..\..\Materials.xaml"
                ((System.Windows.Controls.StackPanel)(target)).AddHandler(System.Windows.Controls.Primitives.ButtonBase.ClickEvent, new System.Windows.RoutedEventHandler(this.chk_Click));

            #line default
            #line hidden
                return;

            case 2:
                this.chkBackground = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 3:
                this.chkDiffuse = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 4:
                this.chkSpecular = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 5:
                this.chkEmissive = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 6:
                this.rect = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 7:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 8:
                this.Scene = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 9:
                this.ring = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 10:
                this.Torus01OR9GR10 = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 11:
                this.materialsGroup = ((System.Windows.Media.Media3D.MaterialGroup)(target));
                return;
            }
            this._contentLoaded = true;
        }
예제 #7
0
        public Egg(Point3D position, World world, int materialID, ItemOptions itemOptions, ShipDNA dna)
        {
            // The radius should be 20% the size of the adult ship
            this.Radius = dna.PartsByLayer.SelectMany(o => o.Value).
                Max(o => o.Position.ToVector().Length + Math1D.Max(o.Scale.X, o.Scale.Y, o.Scale.Z))
                * .2d;

            Vector3D scale = new Vector3D(.75d, .75d, 1d);

            #region WPF Model

            // Material
            MaterialGroup materials = new MaterialGroup();
            materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(WorldColors.EggColor)));
            materials.Children.Add(WorldColors.EggSpecular);

            // Geometry Model
            GeometryModel3D geometry = new GeometryModel3D();
            geometry.Material = materials;
            geometry.BackMaterial = materials;
            geometry.Geometry = UtilityWPF.GetSphere_LatLon(5, this.Radius);
            geometry.Transform = new ScaleTransform3D(scale);

            this.Model = geometry;

            // Model Visual
            ModelVisual3D model = new ModelVisual3D();
            model.Content = geometry;

            #endregion

            #region Physics Body

            Transform3DGroup transform = new Transform3DGroup();
            transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));
            transform.Children.Add(new TranslateTransform3D(position.ToVector()));

            double volume = (4d / 3d) * Math.PI * scale.X * this.Radius * scale.Y * this.Radius * scale.Z * this.Radius;
            double mass = volume * itemOptions.Egg_Density;

            using (CollisionHull hull = CollisionHull.CreateSphere(world, 0, scale * this.Radius, null))
            {
                this.PhysicsBody = new Body(hull, transform.Value, mass, new Visual3D[] { model });
                this.PhysicsBody.MaterialGroupID = materialID;
                this.PhysicsBody.LinearDamping = .01f;
                this.PhysicsBody.AngularDamping = new Vector3D(.001f, .001f, .001f);
            }

            #endregion

            this.CreationTime = DateTime.UtcNow;
        }
예제 #8
0
 /// <summary>
 /// 获取纸张背面的半透明材质
 /// </summary>
 /// <returns></returns>
 public MaterialGroup GetBackShadow()
 {
     transparentBackMaterial = backMaterial.Clone();
     foreach (Material m in transparentBackMaterial.Children)
     {
         DiffuseMaterial dm = (DiffuseMaterial)m;
         if (dm != null)
         {
             dm.Color = dm.AmbientColor = Color.FromArgb(100, 255, 255, 255);
         }
     }
     return transparentBackMaterial;
 }
예제 #9
0
        public MaterialLibrary(Loader l)
        {
            MaterialGroup group = null;
            DiffuseMaterial diffuse = null;
            SpecularMaterial specular = null;

            foreach (Instruction i in l.Parse())
            {
                switch (i.Type)
                {
                    case "newmtl":
                        group = new MaterialGroup();

                        diffuse = new DiffuseMaterial();
                        group.Children.Add(diffuse);
                        specular = new SpecularMaterial();
                        group.Children.Add(specular);

                        Materials.Add(i.Arg, group);
                        break;
                    case "Ns":
                        specular.SpecularPower = i.Double();
                        break;
                    case "d":
                    case "Tr":
                        diffuse.Brush.Opacity = i.Float();
                        break;
                    case "Ka":
                        diffuse.AmbientColor = i.Color();
                        break;
                    case "Kd":
                        diffuse.Brush = new SolidColorBrush(i.Color());
                        break;
                    case "Ks":
                        specular.Brush = new SolidColorBrush(i.Color());
                        break;
                    // TODO: UV Maps
                    case "illum":
                    case "Ni": // Index of Refraction
                        // Unsupported, ignore
                        break;
                    default:
                        // Unrecognized symbol
                        break;
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Builds the 3D model for the cartoon view a the given residue.
        /// </summary>
        /// <param name="residue">A residue.</param>
        /// <param name="initialColor">The residue's current color.</param>
        internal Cartoon(Residue residue, Color initialColor)
        {
            this.residue = residue;

            this.materialGroup = new MaterialGroup();

            this.diffuseMaterial = new DiffuseMaterial(new SolidColorBrush(initialColor));
            this.materialGroup.Children.Add(diffuseMaterial);

            SpecularMaterial specularMaterial = new SpecularMaterial();
            specularMaterial.Brush = new SolidColorBrush(Color.FromArgb(192, 255, 255, 255));
            specularMaterial.SpecularPower = 50;
            this.materialGroup.Children.Add(specularMaterial);

            this.model = new Model3DGroup();

            this.residue.Ribbon.GetResidueSpline(this.residue, out this.ribbonPoints,
                out this.torsionVectors, out this.normalVectors);

            if (this.residue.IsHelix)
            {
                this.AddTube(Cartoon.helixWidth, Cartoon.helixHeight);

                if (this.residue.IsStructureStart)
                    this.AddTubeCap(Cartoon.helixWidth, Cartoon.helixHeight);

                if (this.residue.IsStructureEnd)
                    this.AddTubeCap(Cartoon.helixWidth, Cartoon.helixHeight);
            }
            else if (this.residue.IsSheet)
            {
                this.AddSheet();

                if (this.residue.IsStructureStart || this.residue.IsStructureEnd)
                    this.AddSheetCap();
            }
            else
            {
                this.AddTube(Cartoon.turnWidth, Cartoon.turnWidth);

                if (this.residue.IsStructureStart)
                    this.AddTubeCap(Cartoon.turnWidth, Cartoon.turnWidth);

                if (this.residue.IsStructureEnd)
                    this.AddTubeCap(Cartoon.turnWidth, Cartoon.turnWidth);
            }
        }
        public static Material ToMaterial(this IfcSurfaceStyleRendering r)
        {
            MaterialGroup grp = new MaterialGroup();
            if (r.DiffuseColour is IfcNormalisedRatioMeasure)
            {
                Brush brush = new SolidColorBrush(r.SurfaceColour.ToColor((IfcNormalisedRatioMeasure)r.DiffuseColour));
                brush.Opacity = r.Transparency.HasValue ? 1.0 - r.Transparency.Value : 1.0;
                grp.Children.Add(new DiffuseMaterial(brush));
            }
            else if (r.DiffuseColour is IfcColourRgb)
            {
                Brush brush = new SolidColorBrush(((IfcColourRgb)r.DiffuseColour).ToColor());
                brush.Opacity = r.Transparency.HasValue ? 1.0 - r.Transparency.Value : 1.0;
                grp.Children.Add(new DiffuseMaterial(brush));
            }
            else if (r.DiffuseColour == null)
            {
                Brush brush = new SolidColorBrush(r.SurfaceColour.ToColor());
                brush.Opacity = r.Transparency.HasValue ? 1.0 - r.Transparency.Value : 1.0;
                grp.Children.Add(new DiffuseMaterial(brush));
            }

            if (r.SpecularColour is IfcNormalisedRatioMeasure)
            {
                Brush brush = new SolidColorBrush(r.SurfaceColour.ToColor());
                brush.Opacity = r.Transparency.HasValue ? 1.0 - r.Transparency.Value : 1.0;
                grp.Children.Add(new SpecularMaterial(brush, (IfcNormalisedRatioMeasure)(r.SpecularColour)));
            }
            if (r.SpecularColour is IfcColourRgb)
            {
                Brush brush = new SolidColorBrush(((IfcColourRgb)r.SpecularColour).ToColor());
                brush.Opacity = r.Transparency.HasValue ? 1.0 - r.Transparency.Value : 1.0;
                grp.Children.Add(new SpecularMaterial(brush, 100.0));
            }

            if (grp.Children.Count == 1)
            {
                Material mat = grp.Children[0];
                return mat;
            }
            else
            {
                return grp;
            }
        }
예제 #12
0
        public static Model3DGroup GetCylinder(MaterialGroup materialGroup, Point3D midPoint, double radius, double depth)
        {
            var cylinder = new Model3DGroup();
            var nearCircle = new CircleAssitor();
            var farCircle = new CircleAssitor();

            var twoPi = Math.PI * 2;
            var firstPass = true;

            double x;
            double y;

            var increment = 0.1d;
            for (double i = 0; i < twoPi + increment; i = i + increment)
            {
                x = (radius * Math.Cos(i));
                y = (-radius * Math.Sin(i));

                farCircle.CurrentTriangle.P0 = midPoint;
                farCircle.CurrentTriangle.P1 = farCircle.LastPoint;
                farCircle.CurrentTriangle.P2 = new Point3D(x + midPoint.X, y + midPoint.Y, midPoint.Z);

                nearCircle.CurrentTriangle = farCircle.CurrentTriangle.Clone(depth, true);

                if (!firstPass)
                {
                    cylinder.Children.Add(FYDP_3Dobject_Util.CreateTriangleModel(materialGroup, farCircle.CurrentTriangle));
                    cylinder.Children.Add(FYDP_3Dobject_Util.CreateTriangleModel(materialGroup, nearCircle.CurrentTriangle));

                    cylinder.Children.Add(FYDP_3Dobject_Util.CreateTriangleModel(materialGroup, farCircle.CurrentTriangle.P2, farCircle.CurrentTriangle.P1, nearCircle.CurrentTriangle.P2));
                    cylinder.Children.Add(FYDP_3Dobject_Util.CreateTriangleModel(materialGroup, nearCircle.CurrentTriangle.P2, nearCircle.CurrentTriangle.P1, farCircle.CurrentTriangle.P2));
                }
                else
                {
                    farCircle.FirstPoint = farCircle.CurrentTriangle.P1;
                    nearCircle.FirstPoint = nearCircle.CurrentTriangle.P1;
                    firstPass = false;
                }
                farCircle.LastPoint = farCircle.CurrentTriangle.P2;
                nearCircle.LastPoint = nearCircle.CurrentTriangle.P2;
            }
            return cylinder;
        }
예제 #13
0
 public static Material GetImageMaterial(ImageSource imageSource, Brush specularBrush = null, double specularPower = 10)
 {
     var material = new MaterialGroup();
     var diffuse = new DiffuseMaterial
     {
         Brush = new ImageBrush
         {
             ImageSource = imageSource,
             TileMode = TileMode.Tile
         }
     };
     material.Children.Add(diffuse);
     if (!ReferenceEquals(null, specularBrush))
     {
         var specular = new SpecularMaterial
         {
             Brush = specularBrush,
             SpecularPower = specularPower
         };
         material.Children.Add(specular);
     }
     return material;
 }
예제 #14
0
 /// <summary>
 /// Creates a material with the specified diffuse, emissive and specular brushes.
 /// </summary>
 /// <param name="diffuse">The diffuse.</param>
 /// <param name="emissive">The emissive.</param>
 /// <param name="specular">The specular.</param>
 /// <param name="opacity">The opacity.</param>
 /// <param name="specularPower">The specular power.</param>
 /// <returns></returns>
 public static Material CreateMaterial(Brush diffuse, Brush emissive, Brush specular, double opacity, double specularPower)
 {
     var mg = new MaterialGroup();
     if (diffuse != null)
     {
         diffuse = diffuse.Clone();
         diffuse.Opacity = opacity;
         mg.Children.Add(new DiffuseMaterial(diffuse));
     }
     if (emissive != null)
     {
         emissive = emissive.Clone();
         emissive.Opacity = opacity;
         mg.Children.Add(new EmissiveMaterial(emissive));
     }
     if (specular != null)
     {
         specular = specular.Clone();
         specular.Opacity = opacity;
         mg.Children.Add(new SpecularMaterial(specular, specularPower));
     }
     return mg;
 }
예제 #15
0
        // Constructor
        // -----------
        public WireBase()
        {
            LineCollection = new Point3DCollection();

            // Create MeshGeometry3D.
            MeshGeometry3D mesh = new MeshGeometry3D();

            // Create MaterialGroup.
            MaterialGroup matgrp = new MaterialGroup();
            matgrp.Children.Add(new DiffuseMaterial(Brushes.Black));
            matgrp.Children.Add(new EmissiveMaterial(new SolidColorBrush(Color)));

            // Create GeometryModel3D.
            GeometryModel3D model = new GeometryModel3D(mesh, matgrp);

            // Remove this later
            model.BackMaterial = new DiffuseMaterial(Brushes.Red);

            // Set the Content property to the GeometryModel3D.
            Content = model;

            // Add to collection.
            listWireBases.Add(new WireBaseAndUltimateParent(this));
        }
예제 #16
0
            public Material GetMaterial(string texturePath)
            {
                var mg = new MaterialGroup();
                if (DiffuseMap == null)
                {
                    var diffuseBrush = new SolidColorBrush(Diffuse) { Opacity = Dissolved };
                    mg.Children.Add(new DiffuseMaterial(diffuseBrush));
                }
                else
                {
                    var path = Path.Combine(texturePath, DiffuseMap);
                    if (File.Exists(path))
                    {

                        var img = new BitmapImage(new Uri(path, UriKind.Relative));
                        var textureBrush = new ImageBrush(img) { Opacity = Dissolved };
                        mg.Children.Add(new DiffuseMaterial(textureBrush));
                    }
                }

                mg.Children.Add(new SpecularMaterial(new SolidColorBrush(Specular), SpecularCoefficient));

                return mg;
            }
예제 #17
0
        private Model3DGroup CreateGeometry(bool isFinal)
        {
            int domeSegments = isFinal ? 2 : 10;
            int cylinderSegments = isFinal ? 6 : 35;

            Model3DGroup retVal = new Model3DGroup();

            GeometryModel3D geometry;
            MaterialGroup material;
            DiffuseMaterial diffuse;
            SpecularMaterial specular;

            #region Insides

            if (!isFinal)
            {
                ScaleTransform3D scaleTransform = new ScaleTransform3D(HEIGHT, HEIGHT, HEIGHT);

                //TODO: This caps them to a sphere.  It doesn't look too bad, but could be better
                Model3D[] insideModels = BrainDesign.CreateInsideVisuals(.4, this.MaterialBrushes, base.SelectionEmissives, scaleTransform);

                retVal.Children.AddRange(insideModels);
            }

            #endregion
            #region Outer Shell

            geometry = new GeometryModel3D();
            material = new MaterialGroup();
            Color shellColor = WorldColors.Brain;
            if (!isFinal)
            {
                shellColor = UtilityWPF.AlphaBlend(shellColor, Colors.Transparent, .75d);
            }
            diffuse = new DiffuseMaterial(new SolidColorBrush(shellColor));
            this.MaterialBrushes.Add(new MaterialColorProps(diffuse, shellColor));
            material.Children.Add(diffuse);

            specular = WorldColors.BrainSpecular;
            this.MaterialBrushes.Add(new MaterialColorProps(specular));
            material.Children.Add(specular);

            if (!isFinal)
            {
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                base.SelectionEmissives.Add(selectionEmissive);
            }

            geometry.Material = material;
            geometry.BackMaterial = material;

            List<TubeRingBase> rings = new List<TubeRingBase>();

            rings.Add(new TubeRingRegularPolygon(0, false, RADIUSPERCENTOFSCALE_NARROW, RADIUSPERCENTOFSCALE_NARROW, true));
            rings.Add(new TubeRingRegularPolygon(HEIGHT, false, RADIUSPERCENTOFSCALE_WIDE, RADIUSPERCENTOFSCALE_WIDE, true));

            geometry.Geometry = UtilityWPF.GetMultiRingedTube(cylinderSegments, rings, true, true);

            retVal.Children.Add(geometry);

            #endregion

            retVal.Transform = GetTransformForGeometry(isFinal);

            return retVal;
        }
예제 #18
0
        //------------------------------------------------------
        //
        //  Public Properties
        //
        //------------------------------------------------------

        private static void ChildrenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // The first change to the default value of a mutable collection property (e.g. GeometryGroup.Children)
            // will promote the property value from a default value to a local value. This is technically a sub-property
            // change because the collection was changed and not a new collection set (GeometryGroup.Children.
            // Add versus GeometryGroup.Children = myNewChildrenCollection). However, we never marshalled
            // the default value to the compositor. If the property changes from a default value, the new local value
            // needs to be marshalled to the compositor. We detect this scenario with the second condition
            // e.OldValueSource != e.NewValueSource. Specifically in this scenario the OldValueSource will be
            // Default and the NewValueSource will be Local.
            if (e.IsASubPropertyChange &&
                (e.OldValueSource == e.NewValueSource))
            {
                return;
            }


            MaterialGroup target = ((MaterialGroup)d);


            // If this is both non-null and mutable, we need to unhook the Changed event.
            MaterialCollection oldCollection = null;
            MaterialCollection newCollection = null;

            if ((e.OldValueSource != BaseValueSourceInternal.Default) || e.IsOldValueModified)
            {
                oldCollection = (MaterialCollection)e.OldValue;
                if ((oldCollection != null) && !oldCollection.IsFrozen)
                {
                    oldCollection.ItemRemoved  -= target.ChildrenItemRemoved;
                    oldCollection.ItemInserted -= target.ChildrenItemInserted;
                }
            }

            // If this is both non-null and mutable, we need to hook the Changed event.
            if ((e.NewValueSource != BaseValueSourceInternal.Default) || e.IsNewValueModified)
            {
                newCollection = (MaterialCollection)e.NewValue;
                if ((newCollection != null) && !newCollection.IsFrozen)
                {
                    newCollection.ItemInserted += target.ChildrenItemInserted;
                    newCollection.ItemRemoved  += target.ChildrenItemRemoved;
                }
            }
            if (oldCollection != newCollection && target.Dispatcher != null)
            {
                using (CompositionEngineLock.Acquire())
                {
                    DUCE.IResource targetResource = (DUCE.IResource)target;
                    int            channelCount   = targetResource.GetChannelCount();

                    for (int channelIndex = 0; channelIndex < channelCount; channelIndex++)
                    {
                        DUCE.Channel channel = targetResource.GetChannel(channelIndex);
                        Debug.Assert(!channel.IsOutOfBandChannel);
                        Debug.Assert(!targetResource.GetHandle(channel).IsNull);
                        // resource shouldn't be null because
                        // 1) If the field is one of our collections, we don't allow null elements
                        // 2) Codegen already made sure the collection contains DUCE.IResources
                        // ... so we'll Assert it

                        if (newCollection != null)
                        {
                            int count = newCollection.Count;
                            for (int i = 0; i < count; i++)
                            {
                                DUCE.IResource resource = newCollection.Internal_GetItem(i) as DUCE.IResource;
                                Debug.Assert(resource != null);
                                resource.AddRefOnChannel(channel);
                            }
                        }

                        if (oldCollection != null)
                        {
                            int count = oldCollection.Count;
                            for (int i = 0; i < count; i++)
                            {
                                DUCE.IResource resource = oldCollection.Internal_GetItem(i) as DUCE.IResource;
                                Debug.Assert(resource != null);
                                resource.ReleaseOnChannel(channel);
                            }
                        }
                    }
                }
            }
            target.PropertyChanged(ChildrenProperty);
        }
예제 #19
0
        /// <summary>
        /// Set the properties, then call create
        /// NOTE:  This adds itself to the viewport and world.  In the future, that should be handled by the caller
        /// </summary>
        protected void CreateBot(Viewport3D viewport, SharedVisuals sharedVisuals, World world, Point3D worldPosition)
        {
            _viewport = viewport;
            _sharedVisuals = sharedVisuals;
            _world = world;

            // Thruster
            _origThrustDirection = new Vector3D(0, _thrustForce, 0);
            _thruster = new ThrustLine(_viewport, sharedVisuals, _origThrustDirection, new Vector3D(0, 0, 0));
            _thruster.LineMaxLength = this.ThrustLineStandardLength * _thrustLineMultiplier;

            MaterialGroup material = null;
            GeometryModel3D geometry = null;
            ModelVisual3D model = null;

            _visuals = new List<ModelVisual3D>();

            #region Interior Extra Visuals

            // These are visuals that will stay oriented to the ship, but don't count in collision calculations

            #region Core

            // Neutral
            _coreMaterialNeutral = new MaterialGroup();
            _coreMaterialNeutralColor = new DiffuseMaterial(new SolidColorBrush(_coreColor));
            _coreMaterialNeutral.Children.Add(_coreMaterialNeutralColor);
            _coreMaterialNeutral.Children.Add(new SpecularMaterial(Brushes.DimGray, 75d));

            // Attack
            _coreMaterialAttack = new MaterialGroup();
            _coreMaterialAttack.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.AlphaBlend(Colors.Red, UtilityWPF.AlphaBlend(Colors.Black, Colors.DimGray, .5), .15d))));
            _coreMaterialAttack.Children.Add(new SpecularMaterial(new SolidColorBrush(Color.FromArgb(255, 255, 128, 128)), 100d));

            _lightAttack = new PointLight();
            _lightAttack.Color = Color.FromArgb(255, 96, 0, 0);
            _lightAttack.Position = new Point3D(0, 0, 0);
            _lightAttack.Range = _radius * 3;

            // Geometry Model
            _coreGeometry = new GeometryModel3D();
            _coreGeometry.Material = _coreMaterialNeutral;
            _coreGeometry.BackMaterial = _coreMaterialNeutral;
            _coreGeometry.Geometry = UtilityWPF.GetSphere_LatLon(5, _radius * .4, _radius * .4, _radius * .4);
            _coreGeometry.Transform = new TranslateTransform3D(0, 0, 0);

            // Model Visual
            _core = new ModelVisual3D();
            _core.Content = _coreGeometry;

            //NOTE: model.Transform is set to the physics body's transform every frame

            _visuals.Add(_core);

            // Add to the viewport
            _viewport.Children.Add(_core);

            #endregion

            #endregion

            #region Glass Shell

            // Material
            //NOTE:  There seems to be an issue with drawing objects inside a semitransparent object - I think they have to be added in a certain order or something
            Brush skinBrush = new SolidColorBrush(Color.FromArgb(25, 255, 255, 255));  // making the skin semitransparent, so you can see the components inside

            material = new MaterialGroup();
            material.Children.Add(new DiffuseMaterial(skinBrush));
            material.Children.Add(new SpecularMaterial(Brushes.White, 75d));     // more reflective (and white light)

            MaterialGroup backMaterial = new MaterialGroup();
            backMaterial.Children.Add(new DiffuseMaterial(skinBrush));
            backMaterial.Children.Add(new SpecularMaterial(new SolidColorBrush(Color.FromArgb(255, 20, 20, 20)), 10d));       // dark light, and not very reflective

            // Geometry Model
            geometry = new GeometryModel3D();
            geometry.Material = material;
            geometry.BackMaterial = backMaterial;
            geometry.Geometry = UtilityWPF.GetSphere_LatLon(5, _radius, _radius, _radius);

            // Transform
            Transform3DGroup transform = new Transform3DGroup();		// rotate needs to be added before translate
            transform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 0)));
            transform.Children.Add(new TranslateTransform3D(worldPosition.ToVector()));

            // Model Visual
            model = new ModelVisual3D();
            model.Content = geometry;
            model.Transform = transform;

            _visuals.Add(model);

            // Add to the viewport
            _viewport.Children.Add(model);

            #endregion
            #region Physics Body

            // Make a physics body that represents this shape
            _physicsBody = new ConvexBody3D(world, model);

            //NOTE:  Not setting material _physicsBody.MaterialGroupID, so it takes the default material

            _physicsBody.NewtonBody.UserData = this;

            _physicsBody.Mass = Convert.ToSingle(this.Mass);

            _physicsBody.LinearDamping = .01f;
            _physicsBody.AngularDamping = new Vector3D(10f, 10f, 10f);   // fairly heavy damping (the bot doesn't try to cancel its spin, so I'll let Newt do it for me)

            _physicsBody.ApplyForce += new BodyForceEventHandler(Body_ApplyForce);

            #endregion

            #region Exterior Extra Visuals

            // There is a bug in WPF where visuals added after a semitransparent one won't show inside.  So if you want to add exterior
            // bits that aren't visible inside, this would be the place

            #endregion

            _thruster.IsFiring = true;

            // Show the proper core
            this.IsAttacking = _isAttacking;
        }
예제 #20
0
        //TODO: Rewrite this.  Make it look like a cave, or sea shell - something organic with an opening
        private Model3DGroup CreateGeometry(bool isFinal)
        {
            ScaleTransform3D scaleTransform = new ScaleTransform3D(SCALE, SCALE, SCALE);

            Model3DGroup retVal = new Model3DGroup();

            GeometryModel3D geometry;
            MaterialGroup material;
            DiffuseMaterial diffuse;
            SpecularMaterial specular;

            Transform3DGroup transformGroup = new Transform3DGroup();
            transformGroup.Children.Add(scaleTransform);

            #region Outer Shell

            geometry = new GeometryModel3D();
            material = new MaterialGroup();

            diffuse = new DiffuseMaterial(new SolidColorBrush(WorldColors.SwarmBay));
            this.MaterialBrushes.Add(new MaterialColorProps(diffuse, WorldColors.SwarmBay));
            material.Children.Add(diffuse);

            specular = WorldColors.SwarmBaySpecular;
            this.MaterialBrushes.Add(new MaterialColorProps(specular));
            material.Children.Add(specular);

            if (!isFinal)
            {
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                base.SelectionEmissives.Add(selectionEmissive);
            }

            geometry.Material = material;
            geometry.BackMaterial = material;

            transformGroup = new Transform3DGroup();
            transformGroup.Children.Add(scaleTransform);
            transformGroup.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));

            geometry.Geometry = UtilityWPF.GetSphere_Ico(.5, 0, false);
            geometry.Transform = transformGroup;

            retVal.Children.Add(geometry);

            #endregion
            #region Line

            BillboardLine3D line = new BillboardLine3D();
            line.Color = WorldColors.SwarmBay;
            line.Thickness = .05 * SCALE;
            line.IsReflectiveColor = false;
            line.FromPoint = new Point3D(0, 0, 0);
            line.ToPoint = new Point3D(0, 0, .55 * SCALE);

            retVal.Children.Add(line.Model);

            #endregion

            // Transform
            retVal.Transform = GetTransformForGeometry(isFinal);

            // Exit Function
            return retVal;
        }
예제 #21
0
        private Model3DGroup CreateGeometry(bool isFinal)
        {
            const double INSIDEPOINTRADIUS = .45d;

            ScaleTransform3D scaleTransform = new ScaleTransform3D(SCALE, SCALE, SCALE);

            Model3DGroup retVal = new Model3DGroup();

            GeometryModel3D geometry;
            MaterialGroup material;
            DiffuseMaterial diffuse;
            SpecularMaterial specular;

            Transform3DGroup transformGroup = new Transform3DGroup();
            transformGroup.Children.Add(scaleTransform);

            #region Insides

            if (!isFinal)
            {
                Model3D[] insideModels = CreateInsideVisuals(INSIDEPOINTRADIUS, this.MaterialBrushes, base.SelectionEmissives, scaleTransform);
                retVal.Children.AddRange(insideModels);
            }

            #endregion

            #region Lights

            // Neat effect, but it makes my fan spin up, and won't slow back down.  Need to add an animation property to the options
            // class (and listen for when it toggles)

            //if (!isFinal)
            //{
            //    int numLights = 1 + this.Options.Random.Next(3);

            //    for (int cntr = 0; cntr < numLights; cntr++)
            //    {
            //        PointLight light = new PointLight();
            //        light.Color = Colors.Black;
            //        light.Range = SCALE * INSIDEPOINTRADIUS * 2d;
            //        light.LinearAttenuation = 1d;

            //        transformGroup = new Transform3DGroup();
            //        transformGroup.Children.Add(new TranslateTransform3D(Math3D.GetRandomVectorSpherical(this.Options.Random, INSIDEPOINTRADIUS)));
            //        transformGroup.Children.Add(scaleTransform);
            //        light.Transform = transformGroup;

            //        retVal.Children.Add(light);

            //        ColorAnimation animation = new ColorAnimation();
            //        animation.From = UtilityWPF.ColorFromHex("CC1266");
            //        animation.To = Colors.Black;
            //        animation.Duration = new Duration(TimeSpan.FromSeconds(1d + (this.Options.Random.NextDouble() * 5d)));
            //        animation.AutoReverse = true;
            //        animation.RepeatBehavior = RepeatBehavior.Forever;
            //        animation.AccelerationRatio = .5d;
            //        animation.DecelerationRatio = .5d;

            //        light.BeginAnimation(PointLight.ColorProperty, animation);
            //    }
            //}

            #endregion

            #region Outer Shell

            geometry = new GeometryModel3D();
            material = new MaterialGroup();
            Color shellColor = WorldColors.Brain;
            if (!isFinal)
            {
                shellColor = UtilityWPF.AlphaBlend(shellColor, Colors.Transparent, .75d);
            }
            diffuse = new DiffuseMaterial(new SolidColorBrush(shellColor));
            this.MaterialBrushes.Add(new MaterialColorProps(diffuse, shellColor));
            material.Children.Add(diffuse);

            specular = WorldColors.BrainSpecular;
            this.MaterialBrushes.Add(new MaterialColorProps(specular));
            material.Children.Add(specular);

            if (!isFinal)
            {
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                base.SelectionEmissives.Add(selectionEmissive);
            }

            geometry.Material = material;
            geometry.BackMaterial = material;

            transformGroup = new Transform3DGroup();
            transformGroup.Children.Add(scaleTransform);
            transformGroup.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));		// this is just so it's not obvious that the brains are shared visuals

            geometry.Geometry = SharedVisuals.BrainMesh;		// SharedVisuals keeps track of which thread made the request
            geometry.Transform = transformGroup;

            retVal.Children.Add(geometry);

            #endregion

            // Transform
            retVal.Transform = GetTransformForGeometry(isFinal);

            // Exit Function
            return retVal;
        }
예제 #22
0
        internal static Model3D[] CreateInsideVisuals(double radius, List<MaterialColorProps> materialBrushes, List<EmissiveMaterial> selectionEmissives, ScaleTransform3D scaleTransform)
        {
            List<Point3D[]> insidePoints = new List<Point3D[]>();
            for (int cntr = 0; cntr < 3; cntr++)
            {
                GetLineBranch(insidePoints, Math3D.GetRandomVector_Spherical(radius).ToPoint(), radius, radius * .8d, .33d, 4);
            }

            Random rand = StaticRandom.GetRandomForThread();

            List<Model3D> retVal = new List<Model3D>();

            foreach (Point3D[] lineSegment in insidePoints)
            {
                GeometryModel3D geometry = new GeometryModel3D();
                MaterialGroup material = new MaterialGroup();

                Color color = WorldColors.BrainInsideStrand;		// storing this, because it's random
                DiffuseMaterial diffuse = new DiffuseMaterial(new SolidColorBrush(color));
                materialBrushes.Add(new MaterialColorProps(diffuse, color));
                material.Children.Add(diffuse);

                SpecularMaterial specular = WorldColors.BrainInsideStrandSpecular;
                materialBrushes.Add(new MaterialColorProps(specular));
                material.Children.Add(specular);

                //if (!isFinal)
                //{
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                selectionEmissives.Add(selectionEmissive);
                //}

                geometry.Material = material;
                geometry.BackMaterial = material;

                Vector3D line = lineSegment[1] - lineSegment[0];
                double lineLength = line.Length;
                double halfLength = lineLength * .5d;
                double widestWidth = lineLength * .033d;

                List<TubeRingBase> rings = new List<TubeRingBase>();
                rings.Add(new TubeRingPoint(0, false));
                rings.Add(new TubeRingRegularPolygon(halfLength, false, widestWidth, widestWidth, false));
                rings.Add(new TubeRingPoint(halfLength, false));

                Quaternion zRot = new Quaternion(new Vector3D(0, 0, 1), 360d * rand.NextDouble()).ToUnit();
                Quaternion rotation = Math3D.GetRotation(new Vector3D(0, 0, 1), line).ToUnit();

                Transform3DGroup transformGroup = new Transform3DGroup();
                transformGroup.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Quaternion.Multiply(rotation, zRot))));
                transformGroup.Children.Add(new TranslateTransform3D(lineSegment[0].ToVector()));
                transformGroup.Children.Add(scaleTransform);

                geometry.Geometry = UtilityWPF.GetMultiRingedTube(3, rings, true, false, transformGroup);

                retVal.Add(geometry);
            }

            return retVal.ToArray();
        }
예제 #23
0
        /// <summary>
		/// The initialize method is used by the emitter to initialize the particle.
		/// It is called within the emitter's createParticle method and need not
		/// be called by the user.
        /// </summary>
        /// <param name="emitter">The Emitter that created the particle.</param>
        /// <param name="particle">The particle to be initialized.</param>
        public override void Initialize(Emitter emitter, Particle particle)
        {
            BitmapImage image = GetImage();
            ImageBrush brush = new ImageBrush(image);

            if (IsSingle)
            {
                MaterialWrap materialWrap = new MaterialWrap()
                {
                    MaterialType = MaterialType,
                    Brush = brush,
                    Color = Colors.White,
                };
                Material material = materialWrap.Create();

                GeometryModel3D model = new GeometryModel3D()
                {
                    Geometry = Particle.CreateDefaultMesh(1.0, 1.0, image.Width, image.Height),
                    Material = material,
                };

                particle.Brush = brush;
                particle.Material = material;
                particle.Model = model;
            }
            else
            {
                // front
                MaterialWrap materialWrap1 = new MaterialWrap()
                {
                    MaterialType = MaterialType,
                    Brush = brush,
                    Color = Colors.White,
                };

                // back
                MaterialWrap materialWrap2 = new MaterialWrap()
                {
                    MaterialType = MaterialType,
                    Brush = brush,
                    Color = Color.FromArgb(0xC0, 0xFF, 0xFF, 0xFF),
                };

                Material material1 = materialWrap1.Create();
                Material material2 = materialWrap2.Create();

                MaterialGroup matGroup = new MaterialGroup();
                matGroup.Children.Add(material2);
                matGroup.Children.Add(material1);

                GeometryModel3D model = new GeometryModel3D()
                {
                    Geometry = Particle.CreateDefaultMesh(1.0, 1.0, image.Width, image.Height),
                    Material = matGroup,
                };

                particle.Brush = brush;
                particle.Material = material1;
                particle.Model = model;
            }
        }
예제 #24
0
        // Creates new material
        void CreateMaterial()
        {
            // Creates materials
            material = new MaterialGroup();
            diffuseMaterial = new DiffuseMaterial(new SolidColorBrush(diffuse.Value)){AmbientColor = ambient.Value};
            if (bumpImage == null) bumpImage = new BitmapImage(new Uri("pack://application:,,,/NuGenBioChem;component/Images/Noise.png"));
            bumpMaterial = new DiffuseMaterial(new ImageBrush(bumpImage) { TileMode = TileMode.Tile, Opacity = bumpLevel.Value }) { Color = diffuse.Value, AmbientColor = ambient.Value };
            if(reflectionImage==null) reflectionImage = new BitmapImage(new Uri("pack://application:,,,/NuGenBioChem;component/Images/Clouds.png"));
            enviromentMaterial = new DiffuseMaterial(new ImageBrush(reflectionImage) { TileMode = TileMode.Tile, Opacity = reflectionLevel.Value }) { Color = diffuse.Value, AmbientColor = ambient.Value };
            emissiveMaterial = new EmissiveMaterial(new SolidColorBrush(emissive.Value){Opacity = emissiveLevel.Value});
            specularMaterial = new SpecularMaterial(new SolidColorBrush(specular.Value){Opacity = glossiness.Value},specularPower.Value);

            // Fill group
            if (diffuse.Value.A > 5) // Only if diffuse is not transparent
            {
                if ((bumpLevel.Value < 1) && (reflectionLevel.Value < 1)) material.Children.Add(diffuseMaterial);
                if ((bumpLevel.Value > 0) && (reflectionLevel.Value < 1)) material.Children.Add(bumpMaterial);
                if (reflectionLevel.Value > 0) material.Children.Add(enviromentMaterial);
                if ((emissiveLevel.Value > 0) && (emissive.Value != Colors.Black))
                    material.Children.Add(emissiveMaterial);
                if ((glossiness.Value > 0) && (specular.Value != Colors.Black)) material.Children.Add(specularMaterial);
            }
            RaisePropertyChanged("VisualMaterial");
        }
예제 #25
0
        private static Model3D GetModel(double radius, Color? color = null)
        {
            Model3DGroup retVal = new Model3DGroup();

            // Blue
            MaterialGroup materials = new MaterialGroup();
            //TODO: Look at color
            materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("4D56A4"))));
            materials.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("C04AF8FF")), 4));
            materials.Children.Add(new EmissiveMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("104D4960"))));

            GeometryModel3D geometry = new GeometryModel3D();
            geometry.Material = materials;
            geometry.BackMaterial = materials;
            geometry.Geometry = UtilityWPF.GetSphere_Ico(radius * .75, 1, true);

            retVal.Children.Add(geometry);

            // White
            materials = new MaterialGroup();
            materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("C0FFF9DA"))));
            materials.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("A07972A6")), 30));
            materials.Children.Add(new EmissiveMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("209C91B3"))));

            geometry = new GeometryModel3D();
            geometry.Material = materials;
            geometry.BackMaterial = materials;

            var ball = UtilityWPF.GetDodecahedron(radius);
            geometry.Geometry = UtilityWPF.GetMeshFromTriangles_IndependentFaces(ball.AllTriangles);

            retVal.Children.Add(geometry);

            return retVal;
        }
        private void btnBodyPropeller3_Click(object sender, RoutedEventArgs e)
        {
            //TODO:  This is just a tweaked copy of 2 (I was feeling lazy).  They should really be merged

            RemoveCurrentBody();

            _world.Pause();

            // Materials
            MaterialGroup materialsFluidBlade = new MaterialGroup();		// These blades are what the fluid model knows about, but newton will know about a more complex object
            materialsFluidBlade.Children.Add(new DiffuseMaterial(new SolidColorBrush(_colors.HullFace)));
            materialsFluidBlade.Children.Add(_colors.HullFaceSpecular);

            MaterialGroup materialsPhysics = new MaterialGroup();		// this is the material for the composite physics object
            materialsPhysics.Children.Add(new DiffuseMaterial(new SolidColorBrush(_colors.GhostBodyFace)));
            materialsPhysics.Children.Add(_colors.GhostBodySpecular);

            // Geometries
            MeshGeometry3D meshFluidBlade = new MeshGeometry3D();

            MeshGeometry3D meshPhysicsBlade1 = null;
            MeshGeometry3D meshPhysicsBlade2 = null;
            MeshGeometry3D meshPhysicsBlade3 = null;
            MeshGeometry3D meshPhysicsCone = null;

            // Centered blade positions (these are defined once, then copies will be transformed and commited)
            Point3D[] bladePositionsFluid = new Point3D[4];
            bladePositionsFluid[0] = new Point3D(-1d, .25d, 0d);
            bladePositionsFluid[1] = new Point3D(-1d, -.25d, 0d);
            bladePositionsFluid[2] = new Point3D(1d, -.25d, 0d);
            bladePositionsFluid[3] = new Point3D(1d, .25d, 0d);

            Point3D[] bladePositionsPhysics = new Point3D[2];
            bladePositionsPhysics[0] = new Point3D(-1d, -.25d, -.05d);
            bladePositionsPhysics[1] = new Point3D(1d, .25d, .05d);

            // This tranform is throw away.  It's just used to transform points
            Transform3DGroup transform = new Transform3DGroup();
            transform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 90d + 5d)));		// rotar tilt (the flow defaults to -x, so face them into the wind)
            transform.Children.Add(new TranslateTransform3D(new Vector3D(1d + .33d, 0, 0)));		// pull away from the center a bit
            transform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 90)));		// I don't want it along X, I want it along Y

            // Fluid blade 1
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[0]));
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[1]));
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[2]));
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[3]));

            meshFluidBlade.TriangleIndices.Add(0);
            meshFluidBlade.TriangleIndices.Add(1);
            meshFluidBlade.TriangleIndices.Add(2);
            meshFluidBlade.TriangleIndices.Add(2);
            meshFluidBlade.TriangleIndices.Add(3);
            meshFluidBlade.TriangleIndices.Add(0);

            // Physics blade 1
            meshPhysicsBlade1 = UtilityWPF.GetCube_IndependentFaces(bladePositionsPhysics[0], bladePositionsPhysics[1]);
            CollisionHull collisionPhysicsBlade1 = CollisionHull.CreateBox(_world, 0, bladePositionsPhysics[1] - bladePositionsPhysics[0], transform.Value);
            Transform3D transformPhysicsBlade1 = transform.Clone();

            transform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 120d)));		// rotate the whole thing 120 degrees

            // Fluid blade 2
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[0]));
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[1]));
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[2]));
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[3]));

            meshFluidBlade.TriangleIndices.Add(0 + 4);
            meshFluidBlade.TriangleIndices.Add(1 + 4);
            meshFluidBlade.TriangleIndices.Add(2 + 4);
            meshFluidBlade.TriangleIndices.Add(2 + 4);
            meshFluidBlade.TriangleIndices.Add(3 + 4);
            meshFluidBlade.TriangleIndices.Add(0 + 4);

            // Physics blade 2
            meshPhysicsBlade2 = UtilityWPF.GetCube_IndependentFaces(bladePositionsPhysics[0], bladePositionsPhysics[1]);
            CollisionHull collisionPhysicsBlade2 = CollisionHull.CreateBox(_world, 0, bladePositionsPhysics[1] - bladePositionsPhysics[0], transform.Value);
            Transform3D transformPhysicsBlade2 = transform.Clone();

            transform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 120d)));		// rotate the whole thing 120 degrees

            // Fluid blade 3
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[0]));
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[1]));
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[2]));
            meshFluidBlade.Positions.Add(transform.Transform(bladePositionsFluid[3]));

            meshFluidBlade.TriangleIndices.Add(0 + 8);
            meshFluidBlade.TriangleIndices.Add(1 + 8);
            meshFluidBlade.TriangleIndices.Add(2 + 8);
            meshFluidBlade.TriangleIndices.Add(2 + 8);
            meshFluidBlade.TriangleIndices.Add(3 + 8);
            meshFluidBlade.TriangleIndices.Add(0 + 8);

            // Physics blade 3
            meshPhysicsBlade3 = UtilityWPF.GetCube_IndependentFaces(bladePositionsPhysics[0], bladePositionsPhysics[1]);
            CollisionHull collisionPhysicsBlade3 = CollisionHull.CreateBox(_world, 0, bladePositionsPhysics[1] - bladePositionsPhysics[0], transform.Value);
            Transform3D transformPhysicsBlade3 = transform.Clone();

            //TODO:  Make an overload on some of the geometry builders that take a tranform
            //meshPhysicsCone = UtilityWPF.GetCone_AlongX();

            // Geometry Models
            GeometryModel3D geometryFluidBlade = new GeometryModel3D();
            geometryFluidBlade.Material = materialsFluidBlade;
            geometryFluidBlade.BackMaterial = materialsFluidBlade;
            geometryFluidBlade.Geometry = meshFluidBlade;

            GeometryModel3D geometryPhysicsBlade1 = new GeometryModel3D();
            geometryPhysicsBlade1.Material = materialsPhysics;
            geometryPhysicsBlade1.BackMaterial = materialsPhysics;
            geometryPhysicsBlade1.Geometry = meshPhysicsBlade1;
            geometryPhysicsBlade1.Transform = transformPhysicsBlade1;

            GeometryModel3D geometryPhysicsBlade2 = new GeometryModel3D();
            geometryPhysicsBlade2.Material = materialsPhysics;
            geometryPhysicsBlade2.BackMaterial = materialsPhysics;
            geometryPhysicsBlade2.Geometry = meshPhysicsBlade2;
            geometryPhysicsBlade2.Transform = transformPhysicsBlade2;

            GeometryModel3D geometryPhysicsBlade3 = new GeometryModel3D();
            geometryPhysicsBlade3.Material = materialsPhysics;
            geometryPhysicsBlade3.BackMaterial = materialsPhysics;
            geometryPhysicsBlade3.Geometry = meshPhysicsBlade3;
            geometryPhysicsBlade3.Transform = transformPhysicsBlade3;

            // Model Visual
            ModelVisual3D modelFluidBlade = new ModelVisual3D();
            modelFluidBlade.Content = geometryFluidBlade;
            modelFluidBlade.Transform = _modelOrientationTrackball.Transform;

            ModelVisual3D modelPysicsBlade1 = new ModelVisual3D();
            modelPysicsBlade1.Content = geometryPhysicsBlade1;
            modelPysicsBlade1.Transform = _modelOrientationTrackball.Transform;

            ModelVisual3D modelPysicsBlade2 = new ModelVisual3D();
            modelPysicsBlade2.Content = geometryPhysicsBlade2;
            modelPysicsBlade2.Transform = _modelOrientationTrackball.Transform;

            ModelVisual3D modelPysicsBlade3 = new ModelVisual3D();
            modelPysicsBlade3.Content = geometryPhysicsBlade3;
            modelPysicsBlade3.Transform = _modelOrientationTrackball.Transform;

            CollisionHull collisionHull = CollisionHull.CreateCompoundCollision(_world, 0, new CollisionHull[] { collisionPhysicsBlade1, collisionPhysicsBlade2, collisionPhysicsBlade3 });

            // Body
            _body = new Body(collisionHull, _modelOrientationTrackball.Transform.Value, 1, null);
            collisionHull.Dispose();
            collisionPhysicsBlade1.Dispose();
            collisionPhysicsBlade2.Dispose();
            collisionPhysicsBlade3.Dispose();

            // Hull
            _fluidHull = new FluidHull();
            _fluidHull.Triangles = FluidHull.FluidTriangle.GetTrianglesFromMesh(meshFluidBlade);
            _fluidHull.IsClosedConvexInUniformField = false;
            _fluidHull.Transform = _modelOrientationTrackball.Transform;
            _fluidHull.Field = _field;
            _fluidHull.Body = _body;

            // Wireframe
            ScreenSpaceLines3D modelWireframe = GetModelWireframe(_fluidHull);
            modelWireframe.Transform = _modelOrientationTrackball.Transform;
            _viewport.Children.Add(modelWireframe);

            // Rope
            Point3D bodyAttachPoint = _modelOrientationTrackball.Transform.Transform(new Point3D(.25, 0, 0));
            Point3D anchorPoint = _modelOrientationTrackball.Transform.Transform(new Point3D(3, 0, 0));
            //Point3D bodyAttachPoint = _modelOrientationTrackball.Transform.Transform(new Point3D(0, 0, 0));
            //Point3D anchorPoint = _modelOrientationTrackball.Transform.Transform(new Point3D(.33, 0, 0));
            AddRope(bodyAttachPoint, anchorPoint, Math1D.DegreesToRadians(1d));

            // Add to the viewport
            _viewport.Children.Add(modelFluidBlade);
            _viewport.Children.Add(modelPysicsBlade1);
            _viewport.Children.Add(modelPysicsBlade2);
            _viewport.Children.Add(modelPysicsBlade3);

            // Finish setting up the body
            _body.Visuals = new Visual3D[] { modelPysicsBlade1, modelPysicsBlade2, modelPysicsBlade3, modelWireframe, modelFluidBlade };
            _body.ApplyForceAndTorque += new EventHandler<BodyApplyForceAndTorqueArgs>(Body_ApplyForceAndTorque);
            _body.BodyMoved += new EventHandler(Body_BodyMoved);

            _world.UnPause();
        }
        private void btnBodyPlate_Click(object sender, RoutedEventArgs e)
        {
            RemoveCurrentBody();

            _world.Pause();

            #region Main Body

            #region WPF Model

            // Material
            MaterialGroup materials = new MaterialGroup();
            materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(_colors.HullFace)));
            materials.Children.Add(_colors.HullFaceSpecular);

            // Geometry Mesh
            MeshGeometry3D mesh = UtilityWPF.GetCube_IndependentFaces(new Point3D(-1, -1, -.1), new Point3D(1, 1, .1));
            CollisionHull collisionHull = CollisionHull.CreateBox(_world, 0, new Vector3D(2, 2, .2), null);

            // Geometry Model
            GeometryModel3D geometry = new GeometryModel3D();
            geometry.Material = materials;
            geometry.BackMaterial = materials;
            geometry.Geometry = mesh;

            // Transform
            //transform = new Transform3DGroup();		// rotate needs to be added before translate
            //rotation = _defaultDirectionFacing.GetAngleAroundAxis(directionFacing);
            //transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(rotation)));
            //transform.Children.Add(new TranslateTransform3D(position.ToVector()));

            // Model Visual
            ModelVisual3D model = new ModelVisual3D();
            model.Content = geometry;
            //model.Transform = _modelOrientationTrackball.Transform;		// start this in that orientation, but let physics take over from there (_modelOrientationTrackball update won't touch this body)

            #endregion

            // Body
            _body = new Body(collisionHull, _modelOrientationTrackball.Transform.Value, 1, null);
            collisionHull.Dispose();

            // Hull
            _fluidHull = new FluidHull();
            _fluidHull.Triangles = FluidHull.FluidTriangle.GetTrianglesFromMesh(mesh);
            _fluidHull.IsClosedConvexInUniformField = chkClosedHulls.IsChecked.Value;
            _fluidHull.Field = _field;
            _fluidHull.Body = _body;

            // Wireframe
            ScreenSpaceLines3D modelWireframe = GetModelWireframe(_fluidHull);
            modelWireframe.Transform = _modelOrientationTrackball.Transform;
            _viewport.Children.Add(modelWireframe);

            #endregion

            // Rope1
            Point3D bodyAttachPoint = _modelOrientationTrackball.Transform.Transform(new Point3D(1, -1, 0));
            Point3D anchorPoint = _modelOrientationTrackball.Transform.Transform(new Point3D(2, -3, 0));
            AddRope(bodyAttachPoint, anchorPoint, null);

            if (StaticRandom.Next(2) == 0)
            {
                // Rope2
                bodyAttachPoint = _modelOrientationTrackball.Transform.Transform(new Point3D(1, 1, 0));
                anchorPoint = _modelOrientationTrackball.Transform.Transform(new Point3D(2, 3, 0));
                AddRope(bodyAttachPoint, anchorPoint, null);
            }

            // Add to the viewport
            _viewport.Children.Add(model);		// this must be last, or it won't appear transparent to models added after it

            // Finish setting up the body
            _body.Visuals = new Visual3D[] { model, modelWireframe };
            _body.ApplyForceAndTorque += new EventHandler<BodyApplyForceAndTorqueArgs>(Body_ApplyForceAndTorque);
            _body.BodyMoved += new EventHandler(Body_BodyMoved);

            _world.UnPause();
        }
예제 #28
0
        private void Display()
        {
            viewport.Children.Remove(modViz);

            var CVPoints = new Point3DCollection();
            foreach (var chV in convexHullVertices)
            {
                CVPoints.Add(chV.Center);
                viewport.Children.Add(chV.AsHullVertex());
            }

            var faceTris = new Int32Collection();
            foreach (var f in faces)
            {
                // The vertices are stored in clockwise order.
                faceTris.Add(convexHullVertices.IndexOf(f.Vertices[0]));
                faceTris.Add(convexHullVertices.IndexOf(f.Vertices[1]));
                faceTris.Add(convexHullVertices.IndexOf(f.Vertices[2]));
            }
            var mg3d = new MeshGeometry3D
            {
                Positions = CVPoints,
                TriangleIndices = faceTris
            };

            var material = new MaterialGroup
            {
                Children = new MaterialCollection
                {
                    new DiffuseMaterial(Brushes.Red),
                    new SpecularMaterial(Brushes.Beige, 2.0)
                }
            };

            var geoMod = new GeometryModel3D
            {
                Geometry = mg3d,
                Material = material
            };

            modViz = new ModelVisual3D { Content = geoMod };
            viewport.Children.Add(modViz);
        }
예제 #29
0
		///<summary>Objects are added in this step as all gray.  Colors are set in a separate step.</summary>
		public void AddObjectGroup(D3ObjectGroup group) {
			_model3Dgroup=new Model3DGroup();		
			DirectionalLight light=new DirectionalLight(Colors.WhiteSmoke,new Vector3D(-3,-3,-3));
			_model3Dgroup.Children.Add(light);
			DirectionalLight light2=new DirectionalLight(Colors.LightGray,new Vector3D(2.8,-3,-3));
			_model3Dgroup.Children.Add(light2);
			//AmbientLight ambientLight=new AmbientLight(Colors.DarkGray);
			//_model3Dgroup.Children.Add(ambientLight);
			objectNames=new List<string>();
			objectNames.Add("light1");
			objectNames.Add("light2");//to maintain 1:1
			for(int i=0;i<group.D3Objects.Count;i++) {
				MeshGeometry3D meshGeometry3D=new MeshGeometry3D();
				Point3DCollection points=group.D3Objects[i].GenerateVertices();
				meshGeometry3D.Positions=points;
				PointCollection textures=group.D3Objects[i].GenerateTextures();
				meshGeometry3D.TextureCoordinates=textures;
				Vector3DCollection vectors=group.D3Objects[i].GenerateNormals();
				meshGeometry3D.Normals=vectors;
				Int32Collection indices=group.D3Objects[i].GenerateIndices();
				meshGeometry3D.TriangleIndices=indices;
				GeometryModel3D geometryModel3D=new GeometryModel3D();
				geometryModel3D.Geometry=meshGeometry3D;
				//materials
				MaterialGroup materialGroup=new MaterialGroup();
				DiffuseMaterial diffuseMaterial=new DiffuseMaterial();
				if(group.D3Objects[i].TextureMap!=null) {
					ImageBrush imageBrush=new ImageBrush(D3Helper.ConvertImage(group.D3Objects[i].TextureMap));
					imageBrush.ViewportUnits=BrushMappingMode.Absolute;
					ScaleTransform scaleTransform=new ScaleTransform(1,-1);//scale y -1 to flip vertically
					TranslateTransform translateTransform=new TranslateTransform(0,1);//shift up one after flipping
					TransformGroup transformGroup=new TransformGroup();
					transformGroup.Children.Add(scaleTransform);
					transformGroup.Children.Add(translateTransform);
					imageBrush.Transform=transformGroup;
					diffuseMaterial.Brush=imageBrush;
				}
				else if(group.TextureMap!=null && group.D3Objects[i].VertexNormals[0].Texture!=null) {//a group texture is specified and this object uses texture mapping
					ImageBrush imageBrush=new ImageBrush(D3Helper.ConvertImage(group.TextureMap));
					imageBrush.ViewportUnits=BrushMappingMode.Absolute;
					ScaleTransform scaleTransform=new ScaleTransform(1,-1);//scale y -1 to flip vertically
					TranslateTransform translateTransform=new TranslateTransform(0,1);//shift up one after flipping
					TransformGroup transformGroup=new TransformGroup();
					transformGroup.Children.Add(scaleTransform);
					transformGroup.Children.Add(translateTransform);
					imageBrush.Transform=transformGroup;
					diffuseMaterial.Brush=imageBrush;
				}
				else {
					diffuseMaterial.Brush=new SolidColorBrush(Colors.Gray);
					//diffuseMaterial.Color=Colors.Gray;//this didn't work.  Needs brush.
				}
				materialGroup.Children.Add(diffuseMaterial);
				//specular material at 1
				SpecularMaterial specularMaterial=new SpecularMaterial();
				specularMaterial.Brush=new SolidColorBrush(Colors.White);
				specularMaterial.SpecularPower=150;//smaller numbers give more reflection.  150 is minimal specular.
				materialGroup.Children.Add(specularMaterial);
				geometryModel3D.Material=materialGroup;
				_model3Dgroup.Children.Add(geometryModel3D);
				objectNames.Add(group.D3Objects[i].Name);
			}
			ModelVisual3D modelVisual3D=new ModelVisual3D();
			modelVisual3D.Content=_model3Dgroup;
			myViewport.Children.Add(modelVisual3D);
		}
예제 #30
0
        /// <summary>
        /// Replaces any instances of the sentinal brush with the internal brush
        /// </summary>
        /// <param name="material">The material to look through</param>
        private void SwapInCyclicBrush(Material material)
        {
            int numMaterialsSwapped        = 0;
            Stack <Material> materialStack = new Stack <Material>();

            materialStack.Push(material);

            Brush internalBrush = (CacheMode as BitmapCache != null) ? (Brush)InternalBitmapCacheBrush : (Brush)InternalVisualBrush;

            while (materialStack.Count > 0)
            {
                Material currMaterial = materialStack.Pop();

                if (currMaterial is DiffuseMaterial)
                {
                    DiffuseMaterial diffMaterial = (DiffuseMaterial)currMaterial;
                    if ((Boolean)diffMaterial.GetValue(Viewport2DVisual3D.IsVisualHostMaterialProperty))
                    {
                        diffMaterial.Brush = internalBrush;
                        numMaterialsSwapped++;
                    }
                }
                else if (currMaterial is EmissiveMaterial)
                {
                    EmissiveMaterial emmMaterial = (EmissiveMaterial)currMaterial;
                    if ((Boolean)emmMaterial.GetValue(Viewport2DVisual3D.IsVisualHostMaterialProperty))
                    {
                        emmMaterial.Brush = internalBrush;
                        numMaterialsSwapped++;
                    }
                }
                else if (currMaterial is SpecularMaterial)
                {
                    SpecularMaterial specMaterial = (SpecularMaterial)currMaterial;
                    if ((Boolean)specMaterial.GetValue(Viewport2DVisual3D.IsVisualHostMaterialProperty))
                    {
                        specMaterial.Brush = internalBrush;
                        numMaterialsSwapped++;
                    }
                }
                else if (currMaterial is MaterialGroup)
                {
                    MaterialGroup matGroup = (MaterialGroup)currMaterial;

                    // the IsVisualHostMaterialProperty should not be set on a MaterialGroup - verify that
                    if ((Boolean)matGroup.GetValue(Viewport2DVisual3D.IsVisualHostMaterialProperty))
                    {
                        throw new ArgumentException(SR.Get(SRID.Viewport2DVisual3D_MaterialGroupIsInteractiveMaterial), "material");
                    }

                    // iterate over the children and put them on the stack of materials to modify
                    MaterialCollection children = matGroup.Children;

                    if (children != null)
                    {
                        for (int i = 0, count = children.Count; i < count; i++)
                        {
                            Material m = children[i];
                            materialStack.Push(m);
                        }
                    }
                }
                else
                {
                    Invariant.Assert(true, "Unexpected Material type encountered.  V2DV3D handles DiffuseMaterial, EmissiveMaterial, SpecularMaterial, and MaterialGroup.");
                }
            }

            // throw if there is more than 1 interactive material
            if (numMaterialsSwapped > 1)
            {
                throw new ArgumentException(SR.Get(SRID.Viewport2DVisual3D_MultipleInteractiveMaterials), "material");
            }
        }
예제 #31
0
        private GeometryModel3D CreateGeometry(bool isFinal)
        {
            MaterialGroup material = new MaterialGroup();
            DiffuseMaterial diffuse = new DiffuseMaterial(new SolidColorBrush(WorldColors.EnergyTank));
            this.MaterialBrushes.Add(new MaterialColorProps(diffuse, WorldColors.EnergyTank));
            material.Children.Add(diffuse);
            SpecularMaterial specular = WorldColors.EnergyTankSpecular;
            this.MaterialBrushes.Add(new MaterialColorProps(specular));
            material.Children.Add(specular);
            EmissiveMaterial emissive = WorldColors.EnergyTankEmissive;
            this.MaterialBrushes.Add(new MaterialColorProps(emissive));
            material.Children.Add(emissive);

            if (!isFinal)
            {
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                base.SelectionEmissives.Add(selectionEmissive);
            }

            GeometryModel3D retVal = new GeometryModel3D();
            retVal.Material = material;
            retVal.BackMaterial = material;

            int domeSegments = isFinal ? 2 : 10;
            int cylinderSegments = isFinal ? 6 : 35;

            List<TubeRingBase> rings = new List<TubeRingBase>();
            rings.Add(new TubeRingDome(0, false, domeSegments));
            rings.Add(new TubeRingRegularPolygon(.4, false, 1, 1, false));
            rings.Add(new TubeRingRegularPolygon(2.5, false, 1, 1, false));
            rings.Add(new TubeRingDome(.4, false, domeSegments));

            // Scale this so the height is 1
            double scale = 1d / rings.Sum(o => o.DistFromPrevRing);

            Transform3DGroup transformInitial = new Transform3DGroup();
            transformInitial.Children.Add(new ScaleTransform3D(scale, scale, scale));
            retVal.Geometry = UtilityWPF.GetMultiRingedTube(cylinderSegments, rings, true, true, transformInitial);

            // Transform
            retVal.Transform = GetTransformForGeometry(isFinal);

            // Exit Function
            return retVal;
        }
        private void btnStaticSphere3_Click(object sender, RoutedEventArgs e)
        {
            RemoveCurrentBody();

            #region WPF Model

            // Material
            MaterialGroup materials = new MaterialGroup();
            materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(_colors.HullFace)));
            materials.Children.Add(_colors.HullFaceSpecular);

            // Geometry Mesh
            MeshGeometry3D mesh = UtilityWPF.GetSphere_LatLon(4, 1d);

            // Geometry Model
            GeometryModel3D geometry = new GeometryModel3D();
            geometry.Material = materials;
            geometry.BackMaterial = materials;
            geometry.Geometry = mesh;

            // Transform
            //transform = new Transform3DGroup();		// rotate needs to be added before translate
            //rotation = _defaultDirectionFacing.GetAngleAroundAxis(directionFacing);
            //transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(rotation)));
            //transform.Children.Add(new TranslateTransform3D(position.ToVector()));

            // Model Visual
            _model = new ModelVisual3D();
            _model.Content = geometry;
            _model.Transform = _modelOrientationTrackball.Transform;

            #endregion

            // Hull
            _fluidHull = new FluidHull();
            _fluidHull.Triangles = FluidHull.FluidTriangle.GetTrianglesFromMesh(mesh);
            _fluidHull.IsClosedConvexInUniformField = chkClosedHulls.IsChecked.Value;
            _fluidHull.Field = _field;

            // Wireframe
            _modelWireframe = GetModelWireframe(_fluidHull);
            _modelWireframe.Transform = _modelOrientationTrackball.Transform;
            _viewport.Children.Add(_modelWireframe);

            // Add to the viewport
            _viewport.Children.Add(_model);
        }
예제 #33
0
 /// <summary>
 /// Changes the material when the color changed.
 /// </summary>
 private void ColorChanged()
 {
     var mg = new MaterialGroup();
     mg.Children.Add(new DiffuseMaterial(Brushes.Black));
     mg.Children.Add(new EmissiveMaterial(new SolidColorBrush(this.Color)));
     mg.Freeze();
     this.Model.Material = mg;
 }
예제 #34
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.ligthsComboBox = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 2:
                this.drl = ((System.Windows.Controls.ComboBoxItem)(target));

            #line 47 "..\..\..\Views\MainWindow.xaml"
                this.drl.Selected += new System.Windows.RoutedEventHandler(this.LightSelected);

            #line default
            #line hidden
                return;

            case 3:
                this.aml = ((System.Windows.Controls.ComboBoxItem)(target));

            #line 48 "..\..\..\Views\MainWindow.xaml"
                this.aml.Selected += new System.Windows.RoutedEventHandler(this.LightSelected);

            #line default
            #line hidden
                return;

            case 4:
                this.ptl = ((System.Windows.Controls.ComboBoxItem)(target));

            #line 49 "..\..\..\Views\MainWindow.xaml"
                this.ptl.Selected += new System.Windows.RoutedEventHandler(this.LightSelected);

            #line default
            #line hidden
                return;

            case 5:
                this.spl = ((System.Windows.Controls.ComboBoxItem)(target));

            #line 50 "..\..\..\Views\MainWindow.xaml"
                this.spl.Selected += new System.Windows.RoutedEventHandler(this.LightSelected);

            #line default
            #line hidden
                return;

            case 6:

            #line 52 "..\..\..\Views\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.MenuItem_Click);

            #line default
            #line hidden
                return;

            case 7:
                this.mainViewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 8:
                this.perspectiveCameraEditor = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 9:
                this.LightGroup = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 10:
                this.MaterialGroup = ((System.Windows.Media.Media3D.MaterialGroup)(target));
                return;

            case 11:
                this.DiffuseMaterial = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 12:
                this.transformGroup = ((System.Windows.Media.Media3D.Transform3DGroup)(target));
                return;

            case 13:
                this.figureRotateTransformationX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 14:
                this.figureRotateTransformationY = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 15:
                this.figureRotateTransformationZ = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 16:
                this.gridSliderX = ((System.Windows.Controls.Slider)(target));
                return;

            case 17:
                this.gridSliderY = ((System.Windows.Controls.Slider)(target));
                return;

            case 18:
                this.gridSliderZ = ((System.Windows.Controls.Slider)(target));
                return;

            case 19:
                this.objectSliderX = ((System.Windows.Controls.Slider)(target));

            #line 129 "..\..\..\Views\MainWindow.xaml"
                this.objectSliderX.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.ObjectSliderValueChanged);

            #line default
            #line hidden
                return;

            case 20:
                this.objectSliderY = ((System.Windows.Controls.Slider)(target));

            #line 130 "..\..\..\Views\MainWindow.xaml"
                this.objectSliderY.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.ObjectSliderValueChanged);

            #line default
            #line hidden
                return;

            case 21:
                this.objectSliderZ = ((System.Windows.Controls.Slider)(target));

            #line 131 "..\..\..\Views\MainWindow.xaml"
                this.objectSliderZ.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.ObjectSliderValueChanged);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }