Ejemplo n.º 1
0
        // Public constructor to initialize those fields, etc
        public Sphere()
        {
            rotate = new AxisAngleRotation3D();
            xform = new RotateTransform3D(rotate);

            PropertyChanged(this, new DependencyPropertyChangedEventArgs());
        }
Ejemplo n.º 2
0
Archivo: Cell.cs Proyecto: babaq/Soul
        public Cell(INeuron neuron, ModelVisual3D mophology, Imaging imager)
        {
            this.neuron = neuron;
            this.mophology = mophology;
            this.imager = imager;
            neuron.Updated += OnUpdated;
            neuron.Hillock.Spike += OnSpike;
            IsPushing = true;

            var transforms = new Transform3DGroup();
            Rotate = new RotateTransform3D(new QuaternionRotation3D());
            Translate = new TranslateTransform3D(neuron.Position.X, neuron.Position.Y, neuron.Position.Z);
            Scale = new ScaleTransform3D();
            transforms.Children.Add(Rotate);
            transforms.Children.Add(Translate);
            transforms.Children.Add(Scale);
            Mophology.Transform = transforms;

            var binding = new Binding()
            {
                Source = neuron,
                Path = new PropertyPath("Position"),
                Mode = BindingMode.OneWay
            };
            BindingOperations.SetBinding(this, Cell.PositionProperty, binding);
        }
Ejemplo n.º 3
0
 public static RotateTransform3D GetRotateTransform3D(this XbimMatrix3D m)
 {
     RotateTransform3D r = new RotateTransform3D();
     XbimQuaternion xq = m.GetRotationQuaternion();
     r.Rotation = new QuaternionRotation3D(new Quaternion(xq.X, xq.Y, xq.Z, xq.W * (180.0 / Math.PI)));
     return r;
 }
Ejemplo n.º 4
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.rbOrthographic = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 2:
                this.rbPerspective = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 3:
                this.tbScaleX = ((System.Windows.Controls.TextBox)(target));
                return;

            case 4:
                this.tbScaleY = ((System.Windows.Controls.TextBox)(target));
                return;

            case 5:
                this.tbScaleZ = ((System.Windows.Controls.TextBox)(target));
                return;

            case 6:
                this.tbAngle = ((System.Windows.Controls.TextBox)(target));
                return;

            case 7:
                this.tbAxis = ((System.Windows.Controls.TextBox)(target));
                return;

            case 8:
                this.btnApply = ((System.Windows.Controls.Button)(target));

            #line 73 "..\..\CombineTransformation.xaml"
                this.btnApply.Click += new System.Windows.RoutedEventHandler(this.btnApply_Click);

            #line default
            #line hidden
                return;

            case 9:
                this.myViewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

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

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

            case 12:
                this.rotateTransform = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 5
0
        // Public constructor to initialize those fields, etc
        public Cylinder()
        {
            rotate = new AxisAngleRotation3D();
            xform = new RotateTransform3D(rotate);

            PropertyChanged(new DependencyPropertyChangedEventArgs());
        }
Ejemplo n.º 6
0
        public CellNet(INetwork network, ModelVisual3D mophology, Dictionary<Guid, ICell> cells, Dictionary<Guid, ICellNet> childcellnet)
        {
            this.network = network;
            this.mophology = mophology;
            this.cells = cells;
            this.childcellnet = childcellnet;
            IsPushing = true;

            var transforms = new Transform3DGroup();
            Rotate = new RotateTransform3D(new QuaternionRotation3D());
            Translate = new TranslateTransform3D(network.Position.X, network.Position.Y, network.Position.Z);
            Scale = new ScaleTransform3D();
            transforms.Children.Add(Rotate);
            transforms.Children.Add(Translate);
            transforms.Children.Add(Scale);
            Mophology.Transform = transforms;

            var binding = new Binding()
            {
                Source = network,
                Path = new PropertyPath("Position"),
                Mode = BindingMode.OneWay
            };
            BindingOperations.SetBinding(this, CellNet.PositionProperty, binding);
        }
Ejemplo n.º 7
0
 public Plant()
 {
     var x = new Vector3D(1, 0, 0);
     var r1 = new RotateTransform3D(new AxisAngleRotation3D(x, 80));
     var r2 = new RotateTransform3D(new AxisAngleRotation3D(x, -70));
     var r3 = new RotateTransform3D(new AxisAngleRotation3D(x, -10));
     var t1 = new TranslateTransform3D(0, 0, 0.5);
     var t2 = new TranslateTransform3D(0, 0, 0.7);
     var t3 = new TranslateTransform3D(0, 0, 1.0);
     var s1 = new ScaleTransform3D(0.5, 0.5, 0.5);
     var s2 = new ScaleTransform3D(0.3, 0.3, 0.3);
     var s3 = new ScaleTransform3D(0.8, 0.8, 0.8);
     var m1 = new Transform3DGroup();
     m1.Children.Add(r1);
     m1.Children.Add(s1);
     m1.Children.Add(t1);
     var m2 = new Transform3DGroup();
     m2.Children.Add(r2);
     m2.Children.Add(s2);
     m2.Children.Add(t2);
     var m3 = new Transform3DGroup();
     m3.Children.Add(r3);
     m3.Children.Add(s3);
     m3.Children.Add(t3);
     T1 = m1;
     T2 = m2;
     T3 = m3;
 }
Ejemplo n.º 8
0
        public static Media3D.Transform3D CreateAnimatedTransform1(Media3D.Transform3DGroup transformGroup, Media3D.Vector3D center, Media3D.Vector3D axis, double speed = 4)
        {
            var rotateAnimation = new Rotation3DAnimation
            {
                RepeatBehavior = RepeatBehavior.Forever,
                By             = new Media3D.AxisAngleRotation3D(axis, 90),
                Duration       = TimeSpan.FromSeconds(speed / 2),
                IsCumulative   = true,
            };

            var rotateTransform = new Media3D.RotateTransform3D();

            rotateTransform.BeginAnimation(Media3D.RotateTransform3D.RotationProperty, rotateAnimation);

            transformGroup.Children.Add(rotateTransform);

            var rotateAnimation1 = new Rotation3DAnimation
            {
                RepeatBehavior = RepeatBehavior.Forever,
                By             = new Media3D.AxisAngleRotation3D(axis, 240),
                Duration       = TimeSpan.FromSeconds(speed / 4),
                IsCumulative   = true,
            };

            var rotateTransform1 = new Media3D.RotateTransform3D();

            rotateTransform1.CenterX = center.X;
            rotateTransform1.CenterY = center.Y;
            rotateTransform1.CenterZ = center.Z;
            rotateTransform1.BeginAnimation(Media3D.RotateTransform3D.RotationProperty, rotateAnimation1);

            transformGroup.Children.Add(rotateTransform1);

            return(transformGroup);
        }
Ejemplo n.º 9
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
        }
Ejemplo n.º 10
0
 //Create a rotation transformation about the specified axis by the specified number of degrees anti-clockwise:
 public static RotateTransform3D makeAxisTransform(Vector3D axis, double angle)
 {
     RotateTransform3D myRotateTransform3D = new RotateTransform3D();
     AxisAngleRotation3D myAxisAngleRotation3d = new AxisAngleRotation3D();
     myAxisAngleRotation3d.Axis = axis;
     myAxisAngleRotation3d.Angle = angle; //rotate anticlockwise by the specified angle
     myRotateTransform3D.Rotation = myAxisAngleRotation3d;
     return myRotateTransform3D;
 }
Ejemplo n.º 11
0
 public Trackball(double rotationFactor = 4.0, double zoomFacfor = 1.0) {
     _rotationFactor = rotationFactor;
     _zoomFactor = zoomFacfor;
     _transform = new Transform3DGroup();
     _transform.Children.Add(_scale);
     _rotateTransform = new RotateTransform3D(_rotation);
     _transform.Children.Add(_rotateTransform);
     _transform.Children.Add(_translate);
 }
Ejemplo n.º 12
0
        private static void CenterYPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RotateTransform3D target = ((RotateTransform3D)d);

            target._cachedCenterYValue = (double)e.NewValue;


            target.PropertyChanged(CenterYProperty);
        }
Ejemplo n.º 13
0
        public ModelVisual3D Render()
        {
            _blocks = new GeometryModel3D[_dimension, _dimension, _dimension];

            Model3DGroup group = new Model3DGroup();

            double space = 0.03;
            double w = (1 - space * (_dimension - 1)) / _dimension;
            double slot = w + space;

            ScaleTransform3D scaling = new ScaleTransform3D(w, w, w);

            for (int i = 0; i < _dimension * _dimension * _dimension; i++)
            {
                int x = i % _dimension;
                int y = (int)(i / _dimension) % _dimension;
                int z = (int)(i / (_dimension * _dimension));

                GeometryModel3D c = CreateMiniCube();
                _blocks[x, y, z] = c;

                TranslateTransform3D pos = new TranslateTransform3D((slot * x), (slot * y), -(slot * z));

                Transform3DGroup tgroup = new Transform3DGroup();
                tgroup.Children.Add(scaling);
                tgroup.Children.Add(pos);

                c.Transform = tgroup;

                group.Children.Add(c);
            }

            Transform3DGroup cubeTransGroup = new Transform3DGroup();

            TranslateTransform3D cubePos = new TranslateTransform3D(-0.5, -0.5, 0.5);
            cubeTransGroup.Children.Add(cubePos);

            // Animation
            _spinTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0));

            //Vector3DAnimation myVectorAnimation = new Vector3DAnimation(new Vector3D(0, 0, -1), new Duration(TimeSpan.FromMilliseconds(5000)));
            //myVectorAnimation.RepeatBehavior = RepeatBehavior.Forever;
            //myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AxisProperty, myVectorAnimation);

            //myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, doubleAnim);

            cubeTransGroup.Children.Add(_spinTransform);

            // Animation end

            group.Transform = cubeTransGroup;

            ModelVisual3D model = new ModelVisual3D();
            model.Content = group;

            return model;
        }
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
 {
     switch (connectionId)
     {
     case 1:
         this.Rt3d = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
         return;
     }
     this._contentLoaded = true;
 }
Ejemplo n.º 15
0
 public void Move(double offsetX, double offsetY, double offsetZ, double angle)
 {
     Transform3DGroup transform = new Transform3DGroup();
     RotateTransform3D rotateTrans = new RotateTransform3D();
     rotateTrans.Rotation = new AxisAngleRotation3D(new Vector3D(0, 1, 0), angle);
     TranslateTransform3D translateTrans = new TranslateTransform3D(offsetX, offsetY, offsetZ);
     transform.Children.Add(rotateTrans);
     transform.Children.Add(translateTrans);
     this.Transform = transform;
 }
Ejemplo n.º 16
0
        public Cube(Viewport3D myViewport3D, float obesity)
        {

            this.up = ((PerspectiveCamera)myViewport3D.Camera).UpDirection;
            this.trans = new Transform3DGroup();
            this.scale = new ScaleTransform3D();
            this.translation = new TranslateTransform3D();
            this.rotation = new RotateTransform3D();
            this.axis = new AxisAngleRotation3D();

            this.obesity = obesity;   
            this.cube = new Model3DGroup();

            Point3D p0 = new Point3D(-1, -1, -1);
            Point3D p1 = new Point3D(1, -1, -1);
            Point3D p2 = new Point3D(1, -1, 1);
            Point3D p3 = new Point3D(-1, -1, 1);
            Point3D p4 = new Point3D(-1, 0, -1);
            Point3D p5 = new Point3D(1, 0, -1);
            Point3D p6 = new Point3D(1, 0, 1);
            Point3D p7 = new Point3D(-1, 0, 1);

            //front side triangles
            cube.Children.Add(CreateTriangleModel(p3, p2, p6));
            cube.Children.Add(CreateTriangleModel(p3, p6, p7));
            //right side triangles
            cube.Children.Add(CreateTriangleModel(p2, p1, p5));
            cube.Children.Add(CreateTriangleModel(p2, p5, p6));
            //back side triangles
            cube.Children.Add(CreateTriangleModel(p1, p0, p4));
            cube.Children.Add(CreateTriangleModel(p1, p4, p5));
            //left side triangles
            cube.Children.Add(CreateTriangleModel(p0, p3, p7));
            cube.Children.Add(CreateTriangleModel(p0, p7, p4));
            //top side triangles
            cube.Children.Add(CreateTriangleModel(p7, p6, p5));
            cube.Children.Add(CreateTriangleModel(p7, p5, p4));
            //bottom side triangles
            cube.Children.Add(CreateTriangleModel(p2, p3, p0));
            cube.Children.Add(CreateTriangleModel(p2, p0, p1));

            this.model = new ModelVisual3D();
            this.model.Content = cube;
            this.myDirectionalLight = new DirectionalLight();
            this.myDirectionalLight.Color = Colors.Green;
            this.myDirectionalLight.Direction = new Vector3D(-2, -3, 1);
            this.cube.Children.Add(myDirectionalLight);
            myViewport3D.Children.Add(model);

            trans.Children.Add(scale);
            trans.Children.Add(rotation);
            trans.Children.Add(translation);

            this.cube.Transform = trans;
        }
Ejemplo n.º 17
0
        public UserControl1()
        {
            InitializeComponent();

            ax3d = new AxisAngleRotation3D(new Vector3D(0, 2, 0), 1);
            RotateTransform3D myRotateTransform = new RotateTransform3D(ax3d);

            var ModelVisual3D = this.GetModel();
            MatrixTransform3D mTransform = new MatrixTransform3D();
            ModelVisual3D.Transform = myRotateTransform;

            //model
            ////
        }
Ejemplo n.º 18
0
        private static void AddBone(MeshGeometry3D mesh, Point3D startPoint, Point3D endPoint)
        {
            AxisAngleRotation3D rotate = new AxisAngleRotation3D();
            RotateTransform3D xform = new RotateTransform3D(rotate);

            Vector3D boneVec = endPoint - startPoint;

            // radius always points towards -Z (when possible)
            Vector3D radius;

            if (boneVec.X == 0 && boneVec.Y == 0)
            {
                // Special case.
                radius = new Vector3D(0, -1, 0);
            }
            else
            {
                // Find vector axis 90 degrees from bone where Z == 0
                rotate.Axis = Vector3D.CrossProduct(boneVec, new Vector3D(0, 0, 1));
                rotate.Angle = -90;

                // Rotate 90 degrees to find radius vector
                radius = boneVec * xform.Value;
                radius.Normalize();
            }

            // Rotate the radius around the bone vector
            rotate.Axis = boneVec;

            var positions = mesh.Positions;
            const int slices = 10;
            for (int slice = 0; slice < slices; ++slice)
            {
                // Rotate radius vector
                rotate.Angle = slice * 360.0 / slices;
                Vector3D vectRadius = radius * xform.Value;
                rotate.Angle = (slice + 1) * 360.0 / slices;
                Vector3D vectRadius1 = radius * xform.Value;

                // Bit of a hack to avoid having to set the normals or worry about consistent winding.
                positions.Add(startPoint);
                positions.Add(endPoint + delta * vectRadius);
                positions.Add(endPoint + delta * vectRadius1);

                positions.Add(startPoint);
                positions.Add(endPoint + delta * vectRadius1);
                positions.Add(endPoint + delta * vectRadius);
            }
        }
Ejemplo n.º 19
0
 private void VerticalTransform(bool upDown, double angleDeltaFactor)
 {
     Vector3D postion = new Vector3D(myPerspectiveCamera.Position.X, myPerspectiveCamera.Position.Y, myPerspectiveCamera.Position.Z);
     Vector3D rotateAxis = Vector3D.CrossProduct(postion, myPerspectiveCamera.UpDirection);
     RotateTransform3D rt3d = new RotateTransform3D();
     AxisAngleRotation3D rotate = new AxisAngleRotation3D(rotateAxis, angleDeltaFactor * (upDown ? -1 : 1));
     rt3d.Rotation = rotate;
     Matrix3D matrix = rt3d.Value;
     Point3D newPostition = matrix.Transform(myPerspectiveCamera.Position);
     myPerspectiveCamera.Position = newPostition;
     myPerspectiveCamera.LookDirection = new Vector3D(-newPostition.X, -newPostition.Y, -newPostition.Z);
     Vector3D newUpDirection = Vector3D.CrossProduct(myPerspectiveCamera.LookDirection, rotateAxis);
     newUpDirection.Normalize();
     myPerspectiveCamera.UpDirection = newUpDirection;
 }
Ejemplo n.º 20
0
        // Public constructor to initialize those fields, etc
        public Cylinder()
        {
            rotate = new AxisAngleRotation3D();
            xform = new RotateTransform3D(rotate);

            MeshGeometry3D mesh = (MeshGeometry3D)Geometry;
            mesh.Positions = new Point3DCollection((Slices + 1) * (Stacks + 5) - 2);
            mesh.Normals = new Vector3DCollection((Slices + 1) * (Stacks + 5) - 2);
            mesh.TriangleIndices = new Int32Collection(6 * Slices * (Stacks + 1));
            mesh.TextureCoordinates = new PointCollection((Slices + 1) * (Stacks + 5) - 2);

            // Initialize all collection based on default properties
            GeneratePositions();
            GenerateTriangleIndices();
            GenerateTextureCoordinates();
        }
Ejemplo n.º 21
0
        private Tuple <Material, Media3D.Transform3D> LoadTeapot()
        {
            //var m = new VolumeTextureRawDataMaterial();
            //m.Texture = VolumeTextureRawDataMaterialCore.LoadRAWFile("teapot256x256x178.raw", 256, 256, 178);
            var m    = new VolumeTextureDiffuseMaterial();
            var data = VolumeTextureRawDataMaterialCore.LoadRAWFile("teapot256x256x178.raw", 256, 256, 178);

            m.Texture     = ProcessData(data.VolumeTextures, data.Width, data.Height, data.Depth, out var transferMap);
            m.Color       = new Color4(1, 1, 1, 0.4f);
            m.TransferMap = transferMap;
            m.Freeze();
            var transform = new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Vector3D(1, 0, 0), 180));

            transform.Freeze();
            return(new Tuple <Material, Media3D.Transform3D>(m, transform));
        }
Ejemplo n.º 22
0
        private static void RotationPropertyChanged(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;
            }


            RotateTransform3D target = ((RotateTransform3D)d);


            target._cachedRotationValue = (Rotation3D)e.NewValue;

            Rotation3D oldV = (Rotation3D)e.OldValue;
            Rotation3D newV = (Rotation3D)e.NewValue;

            System.Windows.Threading.Dispatcher dispatcher = target.Dispatcher;

            if (dispatcher != null)
            {
                DUCE.IResource targetResource = (DUCE.IResource)target;
                using (CompositionEngineLock.Acquire())
                {
                    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);
                        target.ReleaseResource(oldV, channel);
                        target.AddRefResource(newV, channel);
                    }
                }
            }

            target.PropertyChanged(RotationProperty);
        }
Ejemplo n.º 23
0
        private void RenderSomeModels()
        {
            myViewport.Name = "myViewport";
            //Set camera viewpoint and properties.
            myPCamera.FarPlaneDistance = 20;
            myPCamera.NearPlaneDistance = 1;
            myPCamera.FieldOfView = 45;
            myPCamera.Position = new Point3D(-5, 2, 3);
            myPCamera.LookDirection = new Vector3D(5, -2, -3);
            myPCamera.UpDirection = new Vector3D(0, 1, 0);

            //Add light sources to the scene.
            myDirLight.Color = Colors.White;
            myDirLight.Direction = new Vector3D(-3, -4, -5);

            teapotModel.Geometry = (MeshGeometry3D)Application.Current.Resources["myTeapot"];

            //Define DiffuseMaterial and apply to the mesh geometries.
            DiffuseMaterial teapotMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Blue));
            //Define a transformation
            RotateTransform3D myRotateTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 2, 0), 1));
            //Define an animation for the transformation
            DoubleAnimation myAnimation = new DoubleAnimation();
            myAnimation.From = 1;
            myAnimation.To = 361;
            myAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(5000));
            myAnimation.RepeatBehavior = RepeatBehavior.Forever;
            //Add animation to the transformation
            myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, myAnimation);

            //Add transformation to the model
            teapotModel.Transform = myRotateTransform;

            teapotModel.Material = teapotMaterial;

            //Add the model to the model group collection
            modelGroup.Children.Add(teapotModel);
            modelGroup.Children.Add(myDirLight);
            myViewport.Camera = myPCamera;

            myModelVisual3D.Content = modelGroup;
            myViewport.Children.Add(myModelVisual3D);

            //add the Viewport3D to the window
            mainWindow.Content = myViewport;
        }
Ejemplo n.º 24
0
        public WorkShop()
        {
            InitializeComponent();

            var network = new Network();
            var solver = new ODESolver();
            var recorder = new Recorder(Simulator, RecordType.None, "Soul");
            Simulator = new Simulator(0.01, 50, network, solver, recorder);
            IsReportProgress = true;
            CellNet = new CellNet(network);
            IsImaging = true;

            var transformGroup = new Transform3DGroup();
            TranslateTransform = new TranslateTransform3D();
            RotateTransform = new RotateTransform3D(new QuaternionRotation3D());
            ScaleTransform = new ScaleTransform3D();
            transformGroup.Children.Add(TranslateTransform);
            transformGroup.Children.Add(RotateTransform);
            transformGroup.Children.Add(ScaleTransform);
            ModelVisual.Transform = transformGroup;

            ActionType = ActionType.None;
            MouseLeftButtonDown += WorkShop_MouseLeftButtonDown;
            MouseLeftButtonUp += WorkShop_MouseLeftButtonUp;
            MouseRightButtonDown += WorkShop_MouseRightButtonDown;
            MouseRightButtonUp += WorkShop_MouseRightButtonUp;
            MouseMove += WorkShop_MouseMove;
            MouseWheel += WorkShop_MouseWheel;

            var n = new LI(-50, -48, 5, 2, -55);
            var net0 = Proliferation.Division(n, new Point3D(1, 10, 10), "InitPotential", new Randomizer(new RNG(), dimyend: 9, dimzend: 9, mean: -50.0, std: 5));
            net0.ReSet();
            //net0.ReShape(new Point3D(2, 10, 5));
            var net1 = Proliferation.Division(n, new Point3D(1, 10, 10), "InitPotential", new Randomizer(new RNG(), dimyend: 9, dimzend: 9, mean: -50.0, std: 10));
            net1.ReSet();
            Projection.From_To(net0, net1, new WeightSynapse(null, 1), ProjectionType.OneToOne, 1.0);
            Projection.From_To(net0, net0, new WeightSynapse(null, -0.4), ProjectionType.AllToAll, 0.3);
            Projection.From_To(net1, net0, new WeightSynapse(null, -0.1), ProjectionType.AllToAll, 0.5);
            Projection.From_To(net1, net1, new WeightSynapse(null, 0.1), ProjectionType.OneToOne, 0.8);
            var net = new Network();
            net.ChildNetworks.Add(net0.ID, net0);
            net.ChildNetworks.Add(net1.ID, net1);
            LoadNetwork(net);
            CellNet.ChildCellNet[net0.ID].Position = new Point3D(-15, 0, 15);
        }
Ejemplo n.º 25
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.MyAnimatedObject = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 2:
                this.myPerspectiveCamera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.myRotateTransform3D = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
        private void Filter_FilterUpdate(object sender, EventArgs e)
        {
            Quaternion corrected = new Quaternion();
            corrected.X = filter.Transform.Y;
            corrected.Y = filter.Transform.Z;
            corrected.Z = -filter.Transform.X;
            corrected.W = filter.Transform.W;

            var transform = new QuaternionRotation3D(corrected);
            Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
            {
                var rot = new RotateTransform3D();
                rot.Rotation = transform;
                Transform = new MatrixTransform3D(rot.Value);

                

                this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Transform"));
            }));
        }
Ejemplo n.º 27
0
        public ElementCloud()
        {
            this.Background = Brushes.Transparent;

            canvas = new Canvas()
            {
                VerticalAlignment = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch
            };
            this.Children.Add(canvas);
            rotateTransform = new RotateTransform3D();

            SizeChanged += OnPageSizeChanged;

            rotationType = RotationType.Mouse;
            rotateDirection = new Point(100, 0);
            slowDownCounter = 500;
            elementsCollection = new List<ElementCloudItem>();
            scaleRatio = 0.09;
            opacityRatio = 1.3;
        }
Ejemplo n.º 28
0
        private Media3D.Transform3D CreateAnimatedTransform1(Vector3D translate, Vector3D axis, double speed = 4)
        {
            var lightTrafo = new Media3D.Transform3DGroup();

            lightTrafo.Children.Add(new Media3D.TranslateTransform3D(translate));

            var rotateAnimation = new Rotation3DAnimation
            {
                RepeatBehavior = RepeatBehavior.Forever,
                By             = new Media3D.AxisAngleRotation3D(axis, 90),
                Duration       = TimeSpan.FromSeconds(speed / 4),
                IsCumulative   = true,
            };

            var rotateTransform = new Media3D.RotateTransform3D();

            rotateTransform.BeginAnimation(Media3D.RotateTransform3D.RotationProperty, rotateAnimation);
            lightTrafo.Children.Add(rotateTransform);

            return(lightTrafo);
        }
        protected void Update()
        {
            ClearModels();

            if (dataPoints != null)
            {
                double spaceToUseY = 5;
                double spaceToUseX = 5;
                double barWidth = spaceToUseX / dataPoints.Count;
                double largestValue = GetLargestValue();
                double unitHeight = spaceToUseY / largestValue;

                double bottom = -spaceToUseY;
                double left = -spaceToUseX;
                double height;
                int nIndex = 0;

                foreach (NameValuePair nvp in dataPoints)
                {
                    height = (nvp.Value * unitHeight);
                    Color col = columnColors[nIndex % columnColors.Count];

                    Model3D column = CreateColumn(left, bottom, height, barWidth, 0, barWidth, col);
                    ModelVisual3D model = new ModelVisual3D();
                    model.Content = column;
                    main.Children.Add(model);

                    AxisAngleRotation3D angleRot = new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0);
                    RotateTransform3D rot = new RotateTransform3D(angleRot, new Point3D(-spaceToUseX + (spaceToUseX / 2), 0, -(barWidth / 2)));

                    Binding rotBind = new Binding("Value");
                    rotBind.Source = rotateSlider;
                    BindingOperations.SetBinding(angleRot, AxisAngleRotation3D.AngleProperty, rotBind);
                    model.Transform = rot;

                    left += barWidth;
                    nIndex++;
                }
            }
        }
Ejemplo n.º 30
0
        public Model3DGroup Transform3D_OnMemberEntity_fromLCStoGCS(Model3DGroup modelgroup_original, CMember member)
        {
            double dAlphaX = 0;
            double dBetaY = 0;
            double dGammaZ = 0;
            double dBetaY_aux = 0;
            double dGammaZ_aux = 0;

            member.GetRotationAngles(out dAlphaX, out dBetaY, out dGammaZ, out dBetaY_aux, out dGammaZ_aux);

            RotateTransform3D RotateTrans3D_AUX_Y = new RotateTransform3D();
            RotateTransform3D RotateTrans3D_AUX_Z = new RotateTransform3D();

            RotateTrans3D_AUX_Y.Rotation = new AxisAngleRotation3D(new Vector3D(0, 1, 0), dBetaY_aux * 180 / Math.PI);
            RotateTrans3D_AUX_Y.CenterX = 0;
            RotateTrans3D_AUX_Y.CenterY = 0;
            RotateTrans3D_AUX_Y.CenterZ = 0;

            RotateTrans3D_AUX_Z.Rotation = new AxisAngleRotation3D(new Vector3D(0, 0, 1), dGammaZ_aux * 180 / Math.PI);
            RotateTrans3D_AUX_Z.CenterX = 0;
            RotateTrans3D_AUX_Z.CenterY = 0;
            RotateTrans3D_AUX_Z.CenterZ = 0;

            TranslateTransform3D Translate3D_AUX = new TranslateTransform3D(member.NodeStart.X, member.NodeStart.Y, member.NodeStart.Z);

            Transform3DGroup Trans3DGroup = new Transform3DGroup();
            Trans3DGroup.Children.Add(RotateTrans3D_AUX_Y);
            Trans3DGroup.Children.Add(RotateTrans3D_AUX_Z);
            Trans3DGroup.Children.Add(Translate3D_AUX);

            // Objekty na prute s x <> 0
            // Modelgroup musime pridat ako child do novej modelgroup inak sa "Transform" definovane z 0,0,0 do LCS pruta prepise "Transform" z LCS do GCS

            Model3DGroup modelgroup_out = new Model3DGroup();
            modelgroup_out.Children.Add(modelgroup_original);
            modelgroup_out.Transform = Trans3DGroup;

            // Return transformed model group
            return modelgroup_out;
        }
Ejemplo n.º 31
0
 //Create a rotation transformation about the specified axis by the specified number of degrees anti-clockwise:
 public static RotateTransform3D makeAxisTransform(Axis axis, double angle)
 {
     RotateTransform3D myRotateTransform3D = new RotateTransform3D();
     AxisAngleRotation3D myAxisAngleRotation3d = new AxisAngleRotation3D();
     switch (axis)
     {
         case Axis.X:
             myAxisAngleRotation3d.Axis = new Vector3D(1, 0, 0);
             break;
         case Axis.Y:
             myAxisAngleRotation3d.Axis = new Vector3D(0, 1, 0);
             break;
         case Axis.Z:
             myAxisAngleRotation3d.Axis = new Vector3D(0, 0, 1);
             break;
         default:
             throw new ArgumentException("Cannot rotate about unrecognised axis. ", "axis");
     }
     myAxisAngleRotation3d.Angle = angle; //rotate anticlockwise by the specified angle
     myRotateTransform3D.Rotation = myAxisAngleRotation3d;
     return myRotateTransform3D;
 }
Ejemplo n.º 32
0
        // Updates the matrices of the slaves using the rotation quaternion.
        private void UpdateServants(Quaternion q, double s)
        {
            var rotation = new RotateTransform3D(); //IB: changed this


            var quatRotation = new QuaternionRotation3D(q);
            rotation.Rotation = quatRotation;
            //rotation.Rotation = new Rotation3D(q);
            rotation.CenterX = _center.X;
            rotation.CenterY = _center.Y;

            var scale = new ScaleTransform3D(new Vector3D(s, s, s));
            var rotateAndScale = new Transform3DCollection {scale, rotation};

            //IB: moved out of the constructor above


            if (_servants != null)
            {
                foreach (var i in _servants)
                {
                    // Note that we don't copy constantly here, we copy the first time someone tries to
                    // trackball a frozen Models, but we replace it with a ChangeableReference
                    // and so subsequent interactions go through without a copy.
                    /* mijacobs: commenting out
					if (i.Models.Transform.IsFrozen)
					{
						Model3DGroup mutableCopy = i.Models.Copy();
						//mutableCopy.StatusOfNextUse = UseStatus.ChangeableReference; IB: no longer necessary I need to architect this out if time permits
						i.Models = mutableCopy;
					}*/

                    var myTransformGroup = new Transform3DGroup {Children = rotateAndScale}; //IB: added transformGroup

                    // mijacobs old: i.Models.Transform = myTransformGroup;
                    ((Model3DGroup) ((ModelVisual3D) i.Children[0]).Content).Transform = myTransformGroup;
                }
            }
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Create an arrow representing the magnitude and direction
        /// for a given bin.  This will create an arrow within a column.
        /// The Column will start at 0 and go down, using the bin times a scale
        /// factor to move down the column for each bin.  The magnitude will
        /// give the length and color of the arrow.  The angle will be used to rotate around
        /// the origin of 0,0, to give the direction.  The angle is based off North = 0 degrees.
        /// </summary>
        /// <param name="bin">Bin to create.</param>
        /// <param name="mag">Magnitude of the bin.</param>
        /// <param name="angleYNorth">Direction of the bin with reference to Y as North.</param>
        /// <returns>3D model of the arrow.</returns>
        private GeometryModel3D CreateBin(int bin, double mag, double angleYNorth)
        {
            // Location on the axis for each bin
            // Set the Camera UpDirection in XMAL to UpDirection="0, 1, 0" to make it use Y axis as Up.  Default is Z up.
            double xAxisLoc = 0;
            double yAxisLoc = 0;
            double zAxisLoc = 0;

            if (YAxis)
            {
                yAxisLoc = -bin * TRANSLATION_SCALE;
            }
            else
            {
                xAxisLoc = bin * TRANSLATION_SCALE;
            }

            // Create the shape of the object
            // This will be an arrow
            // Use the magnitude to get the length of the arrow
            // Create a column of bins with arrows
            var mb = new MeshBuilder(false, false);
            if (YAxis)
            {
                mb.AddArrow(new Point3D(xAxisLoc, yAxisLoc, zAxisLoc), new Point3D(mag * SCALE_ARROW, yAxisLoc, zAxisLoc), ARROW_HEAD_SIZE);
            }
            else
            {
                mb.AddArrow(new Point3D(xAxisLoc, yAxisLoc, zAxisLoc), new Point3D(xAxisLoc, mag * SCALE_ARROW, zAxisLoc), ARROW_HEAD_SIZE);
            }
            Geometry3D geometry = mb.ToMesh();

            // Set the color based off the magnitude
            // If the bin is selected, use the selected color
            Material material;
            if (bin != SelectedBin)
            {
                material = MaterialHelper.CreateMaterial(GenerateColor(mag));
            }
            else
            {
                material = MaterialHelper.CreateMaterial(SELECTED_BIN_COLOR);
            }
            material.Freeze();

            // Rotate the object
            var rotation = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(xAxisLoc, yAxisLoc, zAxisLoc), angleYNorth));
            rotation.Freeze();

            // Create the model with the rotation
            var tg = new Transform3DGroup();
            tg.Children.Add(rotation);
            var model = new GeometryModel3D(geometry, material) { Transform = tg };

            return model;
        }
Ejemplo n.º 34
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 8 "..\..\MainWindow.xaml"
                ((_3DCubeImages.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.ColorLight = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 3:
                this.imageBrush1 = ((System.Windows.Media.ImageBrush)(target));
                return;

            case 4:
                this.myRotate3D = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 5:
                this.rotate = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 6:
                this.rotateAnimation = ((System.Windows.Media.Animation.Rotation3DAnimation)(target));
                return;

            case 7:
                this.ColorAnimation1 = ((System.Windows.Media.Animation.ColorAnimation)(target));
                return;

            case 8:
                this.ColorAnimation2 = ((System.Windows.Media.Animation.ColorAnimation)(target));
                return;

            case 9:
                this.ColorAnimation3 = ((System.Windows.Media.Animation.ColorAnimation)(target));
                return;

            case 10:
                this.listFile1 = ((System.Windows.Controls.ListView)(target));

            #line 116 "..\..\MainWindow.xaml"
                this.listFile1.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.ListFile1_MouseUp);

            #line default
            #line hidden
                return;

            case 11:
                this.button2 = ((System.Windows.Controls.Button)(target));

            #line 123 "..\..\MainWindow.xaml"
                this.button2.Click += new System.Windows.RoutedEventHandler(this.Button2_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 35
0
        public MainViewModel()
        {
            EffectsManager  = new DefaultEffectsManager();
            RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn];


            // ----------------------------------------------
            // titles
            this.Title    = "SwapChain Top Surface Rendering Demo";
            this.SubTitle = "WPF & SharpDX";

            // ----------------------------------------------
            // camera setup
            this.Camera = new PerspectiveCamera {
                Position = new Point3D(100, 100, 100), LookDirection = new Vector3D(-100, -100, -100), UpDirection = new Vector3D(0, 1, 0)
            };

            // ----------------------------------------------
            // setup scene
            this.AmbientLightColor = Colors.DimGray;

            this.Light1Color = Colors.White;
            this.Light2Color = Colors.Red;
            this.Light3Color = Colors.LightYellow;
            this.Light4Color = Colors.LightBlue;

            this.Light2Attenuation = new Vector3D(0.1f, 0.05f, 0.010f);
            this.Light3Attenuation = new Vector3D(0.1f, 0.01f, 0.005f);
            this.Light4Attenuation = new Vector3D(0.1f, 0.02f, 0.0f);

            this.Light1Direction          = new Vector3D(0, -10, -10);
            this.Light1Transform          = new TranslateTransform3D(-Light1Direction);
            this.Light1DirectionTransform = CreateAnimatedTransform2(-Light1Direction, new Vector3D(0, 1, -1), 36);

            this.Light2Transform = CreateAnimatedTransform1(new Vector3D(-100, 50, 0), new Vector3D(0, 0, 1), 3);
            this.Light3Transform = CreateAnimatedTransform1(new Vector3D(0, 50, 100), new Vector3D(0, 1, 0), 5);

            this.Light4Direction          = new Vector3D(0, -100, 0);
            this.Light4Transform          = new TranslateTransform3D(-Light4Direction);
            this.Light4DirectionTransform = CreateAnimatedTransform2(-Light4Direction, new Vector3D(1, 0, 0), 48);

            // ----------------------------------------------
            // light model3d
            var sphere = new MeshBuilder();

            sphere.AddSphere(new Vector3(0, 0, 0), 4);
            Sphere = sphere.ToMeshGeometry3D();
            this.LightModelMaterial = new PhongMaterial
            {
                AmbientColor  = Colors.Gray.ToColor4(),
                DiffuseColor  = Colors.Gray.ToColor4(),
                EmissiveColor = Colors.Yellow.ToColor4(),
                SpecularColor = Colors.Black.ToColor4(),
            };
            Task.Run(() => { LoadFloor(); });
            Task.Run(() => { LoadLander(); });

            var transGroup = new Media3D.Transform3DGroup();

            transGroup.Children.Add(new Media3D.ScaleTransform3D(0.04, 0.04, 0.04));
            var rotateAnimation = new Rotation3DAnimation
            {
                RepeatBehavior = RepeatBehavior.Forever,
                By             = new Media3D.AxisAngleRotation3D(new Vector3D(0, 1, 0), 90),
                Duration       = TimeSpan.FromSeconds(4),
                IsCumulative   = true,
            };
            var rotateTransform = new Media3D.RotateTransform3D();

            transGroup.Children.Add(rotateTransform);
            rotateTransform.BeginAnimation(Media3D.RotateTransform3D.RotationProperty, rotateAnimation);
            transGroup.Children.Add(new Media3D.TranslateTransform3D(0, 60, 0));
            ModelTransform = transGroup;
        }
Ejemplo n.º 36
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 9 "..\..\MainWindow.xaml"
                ((View.MainWindow)(target)).KeyDown += new System.Windows.Input.KeyEventHandler(this.MainWindow_KeyDown);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((View.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.MainWindow_Closing);

            #line default
            #line hidden
                return;

            case 2:
                this.viewport = ((System.Windows.Controls.Viewport3D)(target));

            #line 15 "..\..\MainWindow.xaml"
                this.viewport.MouseMove += new System.Windows.Input.MouseEventHandler(this.Viewport_MouseMove);

            #line default
            #line hidden

            #line 15 "..\..\MainWindow.xaml"
                this.viewport.LostFocus += new System.Windows.RoutedEventHandler(this.viewport_LostFocus);

            #line default
            #line hidden
                return;

            case 3:
                this.cameraMain = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.lightAmbient = ((System.Windows.Media.Media3D.AmbientLight)(target));
                return;

            case 5:
                this.lightKey = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 6:
                this.lightSide = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 7:
                this.lightPoint = ((System.Windows.Media.Media3D.PointLight)(target));
                return;

            case 8:
                this.modelBackground = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 9:
                this.modelFloor = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

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

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

            case 12:
                this.translatorPointer = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;

            case 13:
                this.groupPlayers3D = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 14:
                this.groupFood3D = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 15:

            #line 152 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.DockPanel)(target)).Loaded += new System.Windows.RoutedEventHandler(this.MainWindow_Loaded);

            #line default
            #line hidden
                return;

            case 16:
                this.lblPlayerName = ((System.Windows.Controls.Label)(target));
                return;

            case 17:
                this.lblMass = ((System.Windows.Controls.Label)(target));
                return;

            case 18:
                this.lblFoodCount = ((System.Windows.Controls.Label)(target));
                return;

            case 19:
                this.lblPlayerCount = ((System.Windows.Controls.Label)(target));
                return;

            case 20:
                this.lblPlayerPosition = ((System.Windows.Controls.Label)(target));
                return;

            case 21:
                this.bttnDisconnect = ((System.Windows.Controls.Button)(target));

            #line 188 "..\..\MainWindow.xaml"
                this.bttnDisconnect.Click += new System.Windows.RoutedEventHandler(this.DisconnectButton_Clicked);

            #line default
            #line hidden
                return;

            case 22:
                this.txtbxMessages = ((System.Windows.Controls.TextBox)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 37
0
        public MainViewModel()
        {
            EffectsManager  = new DefaultEffectsManager();
            RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn];


            // ----------------------------------------------
            // titles
            this.Title    = "SwapChain Top Surface Rendering Demo";
            this.SubTitle = "WPF & SharpDX";

            // ----------------------------------------------
            // camera setup
            this.Camera = new PerspectiveCamera {
                Position = new Point3D(100, 100, 100), LookDirection = new Vector3D(-100, -100, -100), UpDirection = new Vector3D(0, 1, 0)
            };

            // ----------------------------------------------
            // setup scene
            this.AmbientLightColor = Colors.DimGray;

            this.Light1Color = Colors.White;
            this.Light2Color = Colors.Red;
            this.Light3Color = Colors.LightYellow;
            this.Light4Color = Colors.LightBlue;

            this.Light2Attenuation = new Vector3D(0.1f, 0.05f, 0.010f);
            this.Light3Attenuation = new Vector3D(0.1f, 0.01f, 0.005f);
            this.Light4Attenuation = new Vector3D(0.1f, 0.02f, 0.0f);

            this.Light1Direction          = new Vector3D(0, -10, -10);
            this.Light1Transform          = new TranslateTransform3D(-Light1Direction);
            this.Light1DirectionTransform = CreateAnimatedTransform2(-Light1Direction, new Vector3D(0, 1, -1), 36);

            this.Light2Transform = CreateAnimatedTransform1(new Vector3D(-100, 50, 0), new Vector3D(0, 0, 1), 3);
            this.Light3Transform = CreateAnimatedTransform1(new Vector3D(0, 50, 100), new Vector3D(0, 1, 0), 5);

            this.Light4Direction          = new Vector3D(0, -100, 0);
            this.Light4Transform          = new TranslateTransform3D(-Light4Direction);
            this.Light4DirectionTransform = CreateAnimatedTransform2(-Light4Direction, new Vector3D(1, 0, 0), 48);

            // ----------------------------------------------
            // light model3d
            var sphere = new MeshBuilder();

            sphere.AddSphere(new Vector3(0, 0, 0), 4);
            Sphere = sphere.ToMeshGeometry3D();
            this.LightModelMaterial = new PhongMaterial
            {
                AmbientColor  = Colors.Gray.ToColor4(),
                DiffuseColor  = Colors.Gray.ToColor4(),
                EmissiveColor = Colors.Yellow.ToColor4(),
                SpecularColor = Colors.Black.ToColor4(),
            };
            var models = Load3ds("wall12.obj").Select(x => x.Geometry as MeshGeometry3D).ToArray();

            Floor = models[0];
            Floor.OctreeParameter.EnableParallelBuild = true;
            this.FloorTransform = new Media3D.TranslateTransform3D(0, 0, 0);
            this.FloorMaterial  = new PhongMaterial
            {
                AmbientColor      = Colors.Gray.ToColor4(),
                DiffuseColor      = new Color4(0.75f, 0.75f, 0.75f, 1.0f),
                SpecularColor     = Colors.White.ToColor4(),
                SpecularShininess = 100f
            };

            var landerItems = Load3ds("Car.3ds").Select(x => x.Geometry as MeshGeometry3D).ToArray();

            Model = MeshGeometry3D.Merge(landerItems);
            Model.OctreeParameter.EnableParallelBuild = true;
            ModelMaterial = PhongMaterials.BlackRubber;
            var transGroup = new Media3D.Transform3DGroup();

            transGroup.Children.Add(new Media3D.ScaleTransform3D(0.04, 0.04, 0.04));
            var rotateAnimation = new Rotation3DAnimation
            {
                RepeatBehavior = RepeatBehavior.Forever,
                By             = new Media3D.AxisAngleRotation3D(new Vector3D(0, 1, 0), 90),
                Duration       = TimeSpan.FromSeconds(4),
                IsCumulative   = true,
            };
            var rotateTransform = new Media3D.RotateTransform3D();

            transGroup.Children.Add(rotateTransform);
            rotateTransform.BeginAnimation(Media3D.RotateTransform3D.RotationProperty, rotateAnimation);
            transGroup.Children.Add(new Media3D.TranslateTransform3D(0, 60, 0));
            ModelTransform    = transGroup;
            NumberOfTriangles = Floor.Indices.Count / 3 + Model.Indices.Count / 3;
            NumberOfVertices  = Floor.Positions.Count + Model.Positions.Count;
        }
Ejemplo n.º 38
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.grid = ((System.Windows.Controls.Grid)(target));
                return;

            case 2:
                this.ViewPort = ((System.Windows.Controls.Viewport3D)(target));

            #line 13 "..\..\MainWindow.xaml"
                this.ViewPort.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.ViewPort_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 14 "..\..\MainWindow.xaml"
                this.ViewPort.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.ViewPort_MouseLeftButtonUp);

            #line default
            #line hidden

            #line 14 "..\..\MainWindow.xaml"
                this.ViewPort.MouseMove += new System.Windows.Input.MouseEventHandler(this.ViewPort_MouseMove);

            #line default
            #line hidden

            #line 15 "..\..\MainWindow.xaml"
                this.ViewPort.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.ViewPort_MouseWheel);

            #line default
            #line hidden

            #line 15 "..\..\MainWindow.xaml"
                this.ViewPort.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.ViewPort_MouseDown);

            #line default
            #line hidden

            #line 15 "..\..\MainWindow.xaml"
                this.ViewPort.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.ViewPort_MouseUp);

            #line default
            #line hidden

            #line 15 "..\..\MainWindow.xaml"
                this.ViewPort.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.ViewPort_MouseRightButtonDown);

            #line default
            #line hidden
                return;

            case 3:
                this.CAMERA = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.translacija = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;

            case 5:
                this.myLight = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 6:
                this.dirLightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 7:
                this.model3dGroup = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 8:
                this.Rotate = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 9:
                this.myAngleRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 10:

            #line 80 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.CheckBox_Unchecked);

            #line default
            #line hidden

            #line 80 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Checked += new System.Windows.RoutedEventHandler(this.CheckBox_Checked);

            #line default
            #line hidden
                return;

            case 11:

            #line 81 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.CheckBox_Unchecked);

            #line default
            #line hidden

            #line 81 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Checked += new System.Windows.RoutedEventHandler(this.CheckBox_Checked);

            #line default
            #line hidden
                return;

            case 12:

            #line 82 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.CheckBox_Unchecked);

            #line default
            #line hidden

            #line 82 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Checked += new System.Windows.RoutedEventHandler(this.CheckBox_Checked);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 39
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.menu = ((System.Windows.Controls.Menu)(target));
                return;

            case 2:

            #line 12 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Checked += new System.Windows.RoutedEventHandler(this.MenuItem_Checked);

            #line default
            #line hidden

            #line 12 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.MenuItem_Unchecked);

            #line default
            #line hidden
                return;

            case 3:

            #line 13 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Checked += new System.Windows.RoutedEventHandler(this.MenuItem_Checked_1);

            #line default
            #line hidden

            #line 13 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.MenuItem_Unchecked_1);

            #line default
            #line hidden
                return;

            case 4:

            #line 14 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Checked += new System.Windows.RoutedEventHandler(this.MenuItem_Checked_2);

            #line default
            #line hidden

            #line 14 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.MenuItem_Unchecked_2);

            #line default
            #line hidden
                return;

            case 5:
                this.viewport1 = ((System.Windows.Controls.Viewport3D)(target));

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseRightButtonDown);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseRightButtonUp);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.MouseDown);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.viewport1_MouseWheel);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseLeftButtonUp);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseMove += new System.Windows.Input.MouseEventHandler(this.viewport1_MouseMove);

            #line default
            #line hidden
                return;

            case 6:
                this.map = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 7:
                this.Bottom = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 8:
                this.Front = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 9:
                this.translacija = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;

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

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

            case 12:
                this.myHorizontalRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 13:
                this.myVerticalRTransform = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

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

            case 15:
                this.myHorizontalRTransform2 = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 16:
                this.myHorizontalRotation2 = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 40
0
        private void RotateCamera(Point currentPosition)
        {
            Vector3D camZ = _camera.LookDirection;
            camZ.Normalize();
            Vector3D camX = -Vector3D.CrossProduct(camZ, _camera.UpDirection);
            camX.Normalize();
            Vector3D camY = Vector3D.CrossProduct(camZ, camX);
            camY.Normalize();

            double dX = currentPosition.X - _previousPosition2D.X;
            double dY = currentPosition.Y - _previousPosition2D.Y;

            dX *= _rotateScale;
            dY *= -_rotateScale;

            AxisAngleRotation3D aarY = new AxisAngleRotation3D(camY, dX);
            AxisAngleRotation3D aarX = new AxisAngleRotation3D(camX, dY);

            RotateTransform3D rotY = new RotateTransform3D(aarY);
            RotateTransform3D rotX = new RotateTransform3D(aarX);

            camZ = camZ * rotY.Value * rotX.Value;
            camZ.Normalize();
            camY = camY * rotX.Value * rotY.Value;
            camY.Normalize();

            _camera.LookDirection = camZ;
            _camera.UpDirection = camY;
        }
Ejemplo n.º 41
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 29 "..\..\Container3DView.xaml"
                ((HeuristicLab.Problems.BinPacking.Views.Container3DView)(target)).MouseMove += new System.Windows.Input.MouseEventHandler(this.Container3DView_MouseMove);

            #line default
            #line hidden

            #line 29 "..\..\Container3DView.xaml"
                ((HeuristicLab.Problems.BinPacking.Views.Container3DView)(target)).MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.Container3DView_MouseDown);

            #line default
            #line hidden

            #line 29 "..\..\Container3DView.xaml"
                ((HeuristicLab.Problems.BinPacking.Views.Container3DView)(target)).MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Container3DView_MouseUp);

            #line default
            #line hidden

            #line 30 "..\..\Container3DView.xaml"
                ((HeuristicLab.Problems.BinPacking.Views.Container3DView)(target)).MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.Container3DView_OnMouseWheel);

            #line default
            #line hidden

            #line 31 "..\..\Container3DView.xaml"
                ((HeuristicLab.Problems.BinPacking.Views.Container3DView)(target)).MouseEnter += new System.Windows.Input.MouseEventHandler(this.Container3DView_OnMouseEnter);

            #line default
            #line hidden
                return;

            case 2:
                this.viewport3D1 = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 3:
                this.camMain = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.dirLightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 5:
                this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 6:
                this.scale = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 7:
                this.rotateX = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 8:
                this.rotateY = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 9:
                this.scaleZoom = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 42
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.viewport1 = ((System.Windows.Controls.Viewport3D)(target));

            #line 10 "..\..\MainWindow.xaml"
                this.viewport1.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 11 "..\..\MainWindow.xaml"
                this.viewport1.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseLeftButtonUp);

            #line default
            #line hidden

            #line 11 "..\..\MainWindow.xaml"
                this.viewport1.MouseMove += new System.Windows.Input.MouseEventHandler(this.viewport1_MouseMove);

            #line default
            #line hidden

            #line 12 "..\..\MainWindow.xaml"
                this.viewport1.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.viewport1_MouseWheel);

            #line default
            #line hidden

            #line 12 "..\..\MainWindow.xaml"
                this.viewport1.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.Viewport1_MouseDown);

            #line default
            #line hidden

            #line 12 "..\..\MainWindow.xaml"
                this.viewport1.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Viewport1_MouseUp);

            #line default
            #line hidden
                return;

            case 2:
                this.modelGroup = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 3:
                this.rotateTransform = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 4:
                this.rotate = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 5:
                this.rotateTransformX = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 6:
                this.rotateX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 7:
                this.translacija = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;

            case 8:
                this.skaliranje = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 43
0
        private DoubleAnimation Rotate(int face, double angle, double animationTime = 200)
        {
            Vector3D axis = RotationAxis[face];
            DoubleAnimation result = null;

            // we must update the array that contains the position of each cubelet
            var rotatedCubelets = new Model3DGroup[Size, Size, Size];
            for (int i = 0; i < Size; i++)
                for (int j = 0; j < Size; j++)
                    for (int k = 0; k < Size; k++)
                        rotatedCubelets[i, j, k] = cubelets[i, j, k];

            // positive angle is turning clockwise
            // turning face 0: (fix,*,*)

            //  2,0 2,1 2,2      2,2 1,2 0,2
            //  1,0 1,1 1,2  =>  2,1 1,1 0,1 
            //  0,0 0,1 0,2      2,0 1,0 0,0

            // if angle is negative we need to rotate 
            // the cubelets the other way

            int n = Size - 1;

            // this method only supports rotating the outer sides of the cube

            for (int a = 0; a < Size; a++)
            {
                for (int b = 0; b < Size; b++)
                {
                    int at = b;
                    int bt = n - a;
                    if (angle < 0)
                    {
                        at = n - b;
                        bt = a;
                    }

                    Model3DGroup group = null;
                    switch (face)
                    {
                        case 0:
                            group = rotatedCubelets[0, at, bt] = cubelets[0, a, b];
                            break;
                        case 1:
                            group = rotatedCubelets[n, bt, at] = cubelets[n, b, a];
                            break;
                        case 2:
                            group = rotatedCubelets[bt, 0, at] = cubelets[b, 0, a];
                            break;
                        case 3:
                            group = rotatedCubelets[at, n, bt] = cubelets[a, n, b];
                            break;
                        case 4:
                            group = rotatedCubelets[at, bt, 0] = cubelets[a, b, 0];
                            break;
                        case 5:
                            group = rotatedCubelets[bt, at, n] = cubelets[b, a, n];
                            break;
                        default:
                            continue;
                    }

                    var rot = new AxisAngleRotation3D { Axis = axis };
                    var anim = new DoubleAnimation(angle, new Duration(TimeSpan.FromMilliseconds(animationTime)))
                                   {
                                       AccelerationRatio = 0.3,
                                       DecelerationRatio = 0.5
                                   };

                    rot.BeginAnimation(AxisAngleRotation3D.AngleProperty, anim);
                    if (result == null)
                        result = anim;

                    var rott = new RotateTransform3D(rot);
                    var gt = new Transform3DGroup();
                    gt.Children.Add(group.Transform);
                    gt.Children.Add(rott);
                    group.Transform = gt;
                }
            }
            cubelets = rotatedCubelets;

            // can subscribe to the Completed event on this
            return result;
        }
Ejemplo n.º 44
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 5 "..\..\MainWindow.xaml"
                ((Processes_Manage.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:

            #line 9 "..\..\MainWindow.xaml"
                ((System.Windows.Media.Animation.Storyboard)(target)).Completed += new System.EventHandler(this.zoomInStoryboardCompleted);

            #line default
            #line hidden
                return;

            case 3:

            #line 33 "..\..\MainWindow.xaml"
                ((System.Windows.Media.Animation.Storyboard)(target)).Completed += new System.EventHandler(this.zoomOutStoryboardCompleted);

            #line default
            #line hidden
                return;

            case 4:
                this.newTask_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 67 "..\..\MainWindow.xaml"
                this.newTask_MenuItem.Click += new System.Windows.RoutedEventHandler(this.newTask_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 5:
                this.quit_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 69 "..\..\MainWindow.xaml"
                this.quit_MenuItem.Click += new System.Windows.RoutedEventHandler(this.quit_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 6:
                this.topmost_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 73 "..\..\MainWindow.xaml"
                this.topmost_MenuItem.Click += new System.Windows.RoutedEventHandler(this.topmost_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 7:
                this.set_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 77 "..\..\MainWindow.xaml"
                this.set_MenuItem.Click += new System.Windows.RoutedEventHandler(this.set_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 8:
                this.about_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 80 "..\..\MainWindow.xaml"
                this.about_MenuItem.Click += new System.Windows.RoutedEventHandler(this.about_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 9:
                this.FirstPageRadioButton = ((System.Windows.Controls.RadioButton)(target));

            #line 88 "..\..\MainWindow.xaml"
                this.FirstPageRadioButton.Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 10:

            #line 89 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 11:

            #line 90 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 12:

            #line 91 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 13:

            #line 92 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 14:
                this.myViewport3D = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 15:
                this.myPlane = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 16:
                this.myGeometry = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 17:
                this.myHorizontalRotation = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 18:
                this.MyHorizontalAxisAngleRotation3D = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 19:
                this.MyScaleTransform3D = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 20:
                this.scrollViewerBorder = ((System.Windows.Controls.Border)(target));
                return;

            case 21:
                this.myScrollViewer = ((System.Windows.Controls.ScrollViewer)(target));
                return;

            case 22:
                this.mainFrame = ((System.Windows.Controls.Frame)(target));

            #line 182 "..\..\MainWindow.xaml"
                this.mainFrame.ContentRendered += new System.EventHandler(this.frameContentRendered);

            #line default
            #line hidden
                return;

            case 23:
                this.processesNums_Now = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 24:
                this.cpu_Rate = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 25:
                this.memory_Rate = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 26:
                this.gpu_temperature = ((System.Windows.Controls.TextBlock)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 45
0
        private void AddBranch(MeshBuilder mesh, Point3D p0, Vector3D direction, int p)
        {
            double angle = GetAngleBetween(direction, UpVector);
            bool isStem = angle < 10;


            double h = isStem ? 2.5 : 2;
            double r = (Level+1-p)*0.1;

            mesh.AddCone(p0, direction, r, r * 0.8, h, false, false, 12);
            var p1 = p0 + direction*h;

            if (p == Level)
                return;

            if (isStem)
            {
                var rightVector=direction.FindAnyPerpendicular();
                var t0 = new RotateTransform3D(new AxisAngleRotation3D(rightVector, GetRandom(3)));
                AddBranch(mesh, p1, t0.Transform(direction), p + 1);
                
                var t1 = new RotateTransform3D(new AxisAngleRotation3D(rightVector, 95 + GetRandom(5)));
                var d1 = t1.Transform(direction);
                int nBranches = 5+GetRandom(2);
                for (int i = 0; i < nBranches; i++)
                {
                    double a = 360.0 * i / nBranches + GetRandom(25);
                    var t2 = new RotateTransform3D(new AxisAngleRotation3D(UpVector, a));
                    AddBranch(mesh, p1, t2.Transform(d1), p + 1);
                }
            } else
            {
                var rightVector=Vector3D.CrossProduct(direction, UpVector);
                var t1 = new RotateTransform3D(new AxisAngleRotation3D(rightVector, -5 + GetRandom(5)));
                var t2 = new RotateTransform3D(new AxisAngleRotation3D(UpVector, 45+GetRandom(10)));
                var t3 = new RotateTransform3D(new AxisAngleRotation3D(UpVector, -45 + GetRandom(10)));
                var d1 = t1.Transform(direction);
                AddBranch(mesh, p1, d1, p + 1);
                AddBranch(mesh, p1, t2.Transform(d1), p + 1);
                AddBranch(mesh, p1, t3.Transform(d1), p + 1);                
            }
        }
        // DisplayModel -----> Performs Rotations and translations and sends models to VirtualRobotWindow
        public void DisplayModel()
        {
            this.dispatcher.Invoke((Action)(() =>
            {
                // Convert bevel angles to x-y rotations
                double rxTheta = (rub - rlb) / 2;
                double ryTheta = (rub + rlb) / 2;
                double lxTheta = -(lub - llb) / 2;
                double lyTheta = (lub + llb) / 2;

                // Define rotations and translations

                // right shoulder rotations
                rightShoulderRotY.Angle = ryTheta;
                rsyTransform.Rotation = rightShoulderRotY;
                rightShoulderRotX.Angle = rxTheta;
                rsxTransform.Rotation = rightShoulderRotX;
                // right elbow rotations
                rightElbow.Angle = rel;
                relTransform.Rotation = rightElbow;
                // right tip rotations
                rightTip.Angle = cTwist;
                rTipTransform.Rotation = rightTip;
                //left shoulder rotations
                leftShoulderRotY.Angle = -lyTheta;
                lsyTransform.Rotation = leftShoulderRotY;
                leftShoulderRotX.Angle = -lxTheta;
                lsxTransform.Rotation = leftShoulderRotX;
                // left elbow rotations
                leftElbow.Angle = -lel;
                lelTransform.Rotation = leftElbow;
                // grasper rotations
                graspOrient1.Angle = jTwist;
                graspTransform.Rotation = graspOrient1;

                jawAngle1.Angle = jOpen;
                jaw1Transform.Rotation = jawAngle1;
                jawAngle2.Angle = -jOpen;
                jaw2Transform.Rotation = jawAngle2;

                //// whole model rotations
                RotateTransform3D modelXTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), -90));
                RotateTransform3D modelYTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 180));

                // Cautery Tip Roatations
                rightTipVisual.Transform = rTipTransform;
                rightTipVisual2.Transform = rTipTransform;
                rightTipVisual3.Transform = rTipTransform;
                // Right elbow rotation
                rightForeVisual.Transform = relTransform;
                rightForeVisual2.Transform = relTransform;
                rightForeVisual3.Transform = relTransform;
                // Right shoulder rotations
                Transform3DGroup rightArmTransform = new Transform3DGroup();
                rightArmTransform.Children.Add(rsxTransform);
                rightArmTransform.Children.Add(rsyTransform);
                rightVisual.Transform = rightArmTransform;
                rightVisual2.Transform = rightArmTransform;
                rightVisual3.Transform = rightArmTransform;
                // Left grasper open/close
                jawOneVisual.Transform = jaw1Transform;
                jawTwoVisual.Transform = jaw2Transform;
                jawOneVisual2.Transform = jaw1Transform;
                jawTwoVisual2.Transform = jaw2Transform;
                jawOneVisual3.Transform = jaw1Transform;
                jawTwoVisual3.Transform = jaw2Transform;
                // Left grasper rotations
                grasperVisual.Transform = graspTransform;
                grasperVisual2.Transform = graspTransform;
                grasperVisual3.Transform = graspTransform;
                // Left elbow rotaions
                leftForeVisual.Transform = lelTransform;
                leftForeVisual2.Transform = lelTransform;
                leftForeVisual3.Transform = lelTransform;
                // Left shoulder rotations
                Transform3DGroup leftArmTransform = new Transform3DGroup();
                leftArmTransform.Children.Add(lsxTransform);
                leftArmTransform.Children.Add(lsyTransform);
                leftVisual.Transform = leftArmTransform;
                leftVisual2.Transform = leftArmTransform;
                leftVisual3.Transform = leftArmTransform;
                // Whole model transform
                Transform3DGroup modelTransform = new Transform3DGroup();
                modelTransform.Children.Add(modelXTransform);
                modelTransform.Children.Add(modelYTransform);
                wholeModel.Transform = modelTransform;
                wholeModel2.Transform = modelTransform;
                wholeModel3.Transform = modelTransform;

                // Add content to HelixViewport3D in VirtualRobotWindow.xaml
                newWindow.FullModel = wholeModel;
                newWindow.DModel = wholeModel2;
                newWindow.SModel = wholeModel3;

            }));
        }
Ejemplo n.º 47
0
        public override UtilityNewt.IObjectMassBreakdown GetMassBreakdown(double cellSize)
        {
            if (_massBreakdown != null && _massBreakdown.Item2 == this.Scale && _massBreakdown.Item3 == cellSize)
            {
                // This has already been built for this size
                return _massBreakdown.Item1;
            }

            // Convert this.Scale into a size that the mass breakdown will use (mass breakdown wants height along X, and scale is for radius, but the mass breakdown wants diameter
            // Reducing Z a bit, because the energy tank has a rounded cap
            Vector3D size = new Vector3D(this.Scale.Z * .92d, this.Scale.X * RADIUSPERCENTOFSCALE * 2d, this.Scale.Y * RADIUSPERCENTOFSCALE * 2d);

            // Cylinder
            UtilityNewt.ObjectMassBreakdown cylinder = UtilityNewt.GetMassBreakdown(UtilityNewt.ObjectBreakdownType.Cylinder, UtilityNewt.MassDistribution.Uniform, size, cellSize);

            Transform3D transform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 90));		// the physics hull is along x, but dna is along z

            // Rotated
            UtilityNewt.ObjectMassBreakdownSet combined = new UtilityNewt.ObjectMassBreakdownSet(
                new UtilityNewt.ObjectMassBreakdown[] { cylinder },
                new Transform3D[] { transform });

            // Store this
            _massBreakdown = new Tuple<UtilityNewt.IObjectMassBreakdown, Vector3D, double>(combined, this.Scale, cellSize);

            // Exit Function
            return _massBreakdown.Item1;
        }
Ejemplo n.º 48
0
        public MainViewModel()
        {
            //RenderTechniquesManager = new DefaultRenderTechniquesManager();
            //RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn];
            EffectsManager  = new DefaultEffectsManager();
            RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn];
            // ----------------------------------------------
            // titles
            this.Title    = "Lighting Demo";
            this.SubTitle = "WPF & SharpDX";

            // ----------------------------------------------
            // camera setup
            this.Camera = new PerspectiveCamera {
                Position = new Point3D(100, 100, 100), LookDirection = new Vector3D(-100, -100, -100), UpDirection = new Vector3D(0, 1, 0)
            };
            // ----------------------------------------------
            // setup scene
            this.AmbientLightColor = Colors.DimGray;
            this.Light1Color       = Colors.LightGray;


            this.Light1Direction = new Vector3D(-100, -100, -100);
            SetupCameraBindings(Camera);
            // ----------------------------------------------
            // ----------------------------------------------
            // scene model3d
            this.ModelMaterial = PhongMaterials.Silver;

            // ----------------------------------------------
            // floor model3d
            var b2 = new MeshBuilder(true, true, true);

            b2.AddBox(new Vector3(0.0f, 0, 0.0f), 150, 1, 150, BoxFaces.All);
            b2.AddBox(new Vector3(0, 25, 70), 150, 50, 20);
            b2.AddBox(new Vector3(0, 25, -70), 150, 50, 20);
            this.Floor                    = b2.ToMeshGeometry3D();
            this.FloorMaterial            = PhongMaterials.Bisque;
            this.FloorMaterial.DiffuseMap = LoadFileToMemory(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute).ToString());
            this.FloorMaterial.NormalMap  = LoadFileToMemory(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute).ToString());

            var caritems = Load3ds("leone.3DBuilder.obj").Select(x => x.Geometry as MeshGeometry3D).ToArray();
            var scale    = new Vector3(1f);

            foreach (var item in caritems)
            {
                for (int i = 0; i < item.Positions.Count; ++i)
                {
                    item.Positions[i] = item.Positions[i] * scale;
                }
            }
            Model = MeshGeometry3D.Merge(caritems);

            ModelTransform = new Media3D.RotateTransform3D()
            {
                Rotation = new Media3D.AxisAngleRotation3D(new Vector3D(1, 0, 0), -90)
            };

            Instances = new Matrix[6];
            for (int i = 0; i < Instances.Length; ++i)
            {
                Instances[i] = Matrix.Translation(new Vector3(15 * i - 30, 15 * (i % 2) - 30, 0));
            }

            OutlineInstances = new Matrix[6];
            for (int i = 0; i < Instances.Length; ++i)
            {
                OutlineInstances[i] = Matrix.Translation(new Vector3(15 * i - 30, 15 * (i % 2), 0));
            }

            var blendDesc = new BlendStateDescription();

            blendDesc.RenderTarget[0] = new RenderTargetBlendDescription
            {
                IsBlendEnabled        = true,
                BlendOperation        = BlendOperation.Add,
                AlphaBlendOperation   = BlendOperation.Add,
                SourceBlend           = BlendOption.One,
                DestinationBlend      = BlendOption.One,
                SourceAlphaBlend      = BlendOption.Zero,
                DestinationAlphaBlend = BlendOption.One,
                RenderTargetWriteMask = ColorWriteMaskFlags.All
            };
            BlendDescription        = blendDesc;
            DepthStencilDescription = new DepthStencilStateDescription()
            {
                IsDepthEnabled  = true,
                DepthComparison = Comparison.LessEqual,
                DepthWriteMask  = DepthWriteMask.Zero
            };
        }