private void Grid_MouseMove(object sender, MouseEventArgs e) {
			if(mDown) {
				Point pos = Mouse.GetPosition(viewport);
				Point actualPos = new Point(pos.X - viewport.ActualWidth / 2, viewport.ActualHeight / 2 - pos.Y);
				double dx = actualPos.X - mLastPos.X, dy = actualPos.Y - mLastPos.Y;

				double mouseAngle = 0;
				if(dx != 0 && dy != 0) {
					mouseAngle = Math.Asin(Math.Abs(dy) / Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2)));
					if(dx < 0 && dy > 0) mouseAngle += Math.PI / 2;
					else if(dx < 0 && dy < 0) mouseAngle += Math.PI;
					else if(dx > 0 && dy < 0) mouseAngle += Math.PI * 1.5;
				}
				else if(dx == 0 && dy != 0) mouseAngle = Math.Sign(dy) > 0 ? Math.PI / 2 : Math.PI * 1.5;
				else if(dx != 0 && dy == 0) mouseAngle = Math.Sign(dx) > 0 ? 0 : Math.PI;

				double axisAngle = mouseAngle + Math.PI / 2;

				Vector3D axis = new Vector3D(Math.Cos(axisAngle) * 4, Math.Sin(axisAngle) * 4, 0);

				double rotation = 0.01 * Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2));

				Transform3DGroup group = mGeometry.Transform as Transform3DGroup;
				QuaternionRotation3D r = new QuaternionRotation3D(new Quaternion(axis, rotation * 180 / Math.PI));
				group.Children.Add(new RotateTransform3D(r));

				mLastPos = actualPos;
			}
		}
Beispiel #2
0
        //------------------------------------------------------
        //
        //  Public Properties
        //
        //------------------------------------------------------

        private static void QuaternionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            QuaternionRotation3D target = ((QuaternionRotation3D)d);

            target._cachedQuaternionValue = (Quaternion)e.NewValue;


            target.PropertyChanged(QuaternionProperty);
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.view1 = ((HelixToolkit.Wpf.HelixViewport3D)(target));
                return;

            case 2:
                this.modelVisual3D = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 3:
                this.qRotation = ((System.Windows.Media.Media3D.QuaternionRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
 private TimeSpan _updateInterval = new TimeSpan(0, 0, 0, 0, 50); //500 ms
 private void TestCalibration_Loaded(object sender, RoutedEventArgs e)
 {
     _ts = Telemetry.Subscribe(KFlyCommandType.GetEstimationAttitude, (GetEstimationAttitude cmd) =>
     {
         view1.Dispatcher.BeginInvoke(new Action(()=>
             {
                 QuaternionRotation3D rot = new QuaternionRotation3D(
                     new System.Windows.Media.Media3D.Quaternion(
                         -cmd.Data.X, -cmd.Data.Y, -cmd.Data.Z, cmd.Data.W));
                 KFlyRotation.Rotation = rot;
             }));
     });
     _timer = new DispatcherTimer();
     _timer.Tick += new EventHandler(DispatcherTimer_Tick);
     _timer.Interval = _updateInterval;
     _timer.Start();
     Load3DModel();
 }
        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"));
            }));
        }
Beispiel #6
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;
                }
            }
        }
Beispiel #7
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.view1 = ((HelixToolkit.Wpf.HelixViewport3D)(target));

            #line 10 "..\..\View3D.xaml"
                this.view1.SizeChanged += new System.Windows.SizeChangedEventHandler(this.view1_SizeChanged);

            #line default
            #line hidden
                return;

            case 2:
                this.modelVisual3D = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 3:
                this.qRotation = ((System.Windows.Media.Media3D.QuaternionRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
        public PortalVisual(object item, double radius)
        {
            if (item is Shop)
            {
                this.PortalType = PortalVisualType.Shop;
            }
            else
            {
                throw new ApplicationException("Unknown item's type: " + item.GetType().ToString());
            }

            this.Item = item;

            #region WPF Model

            this.Model = GetModel(out this.BackdropPanelColors, this.PortalType, radius);

            _rotateTransform = new QuaternionRotation3D();
            _translateTransform = new TranslateTransform3D();

            Transform3DGroup transform = new Transform3DGroup();
            transform.Children.Add(new RotateTransform3D(_rotateTransform));
            transform.Children.Add(_translateTransform);

            ModelVisual3D visual = new ModelVisual3D();
            visual.Transform = transform;
            visual.Content = this.Model;

            this.Visuals3D = new Visual3D[] { visual };

            #endregion

            this.Token = TokenGenerator.NextToken();
            this.Radius = radius;
            this.CreationTime = DateTime.UtcNow;
        }
Beispiel #9
0
 public FixedWorker(AxisAngleRotation3D transform, double delta)
 {
     _isQuat = false;
     _transformAxis = transform;
     _transformQuat = null;
     _delta = delta;
 }
Beispiel #10
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        static Rotation3D()
        {
            // Create our singleton frozen instance
            s_identity = new QuaternionRotation3D();
            s_identity.Freeze();
        }
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        static Rotation3D()
        {
            // Create our singleton frozen instance
            s_identity = new QuaternionRotation3D();
            s_identity.Freeze();
        }
Beispiel #12
0
 /// <summary>
 /// This limits destination orientation axiis to a cone
 /// </summary>
 public static AnimateRotation Create_LimitedOrientation(QuaternionRotation3D transform, Vector3D centerAxis, double maxConeAngle, double angleDelta, int numFullRotations = 0)
 {
     return new AnimateRotation()
     {
         _worker = new ConeQuatWorker(transform, centerAxis, maxConeAngle, angleDelta, numFullRotations)
     };
 }
Beispiel #13
0
 /// <summary>
 /// This will rotate to a random rotation.  Once at that destination, choose a new random rotation to
 /// go to, and rotate to that.  Always at a constant speed
 /// </summary>
 /// <remarks>
 /// There are no limits on what axis can be used.  The rotation will always be at the fixed speed
 /// </remarks>
 /// <param name="angleDelta">degrees per elapsed</param>
 /// <param name="numFullRotations">
 /// If 0, this will rotate directly to destination, then choose a new destination.
 /// If 1, this will rotate to the destination, then a full 360, then choose another destination, 2 does 2 rotations, etc
 /// </param>
 public static AnimateRotation Create_AnyOrientation(QuaternionRotation3D transform, double angleDelta, int numFullRotations = 0)
 {
     return new AnimateRotation()
     {
         _worker = new AnyQuatWorker(transform, angleDelta, numFullRotations)
     };
 }
Beispiel #14
0
 public AnyQuatConeWorker(QuaternionRotation3D transform, double maxTransitionConeAngle, double anglePerSecond, double angleBetweenTransitions)
 {
     _transform = transform;
     _maxTransitionConeAngle = maxTransitionConeAngle;
     _angleBetweenTransitionsAdjusted = anglePerSecond / NEWANGLE;
     _destinationPercent = angleBetweenTransitions / NEWANGLE;
     _currentPercent = _destinationPercent + 1;      // set it greater so the first time tick is called, a new destination will be chosen
 }
        private void RemoveVisual()
        {
            if (_visual != null)
            {
                _viewport.Children.Remove(_visual);
            }

            _visual = null;
            _rotateTransform = null;
        }
        private void UpdateRotation()
        {
            Quaternion rotation = this.ModelAttitude * gesture.Rotation;
            QuaternionRotation3D quaternionRotation = new QuaternionRotation3D(rotation);
            RotateTransform3D myRotateTransform = new RotateTransform3D(quaternionRotation);
            model.Transform = myRotateTransform;
            xAxis.Transform = myRotateTransform;
            yAxis.Transform = myRotateTransform;

            PerspectiveCamera camera = (PerspectiveCamera)MainViewPort.Camera;
            Vector3D position = (Vector3D)camera.Position;
            Vector3D lookDirection = this.lookAt - camera.Position;
            double length = lookDirection.Length;
            length += (gesture.Zoom * this.modelRadius / 10); // 10 clicks to travel size of model
            if (length <= 0.1)
            {
                length = 0.1;
            }
            lookDirection.Normalize();
            lookDirection *= length;
            gesture.Zoom = 0;

            camera.Position = this.lookAt - lookDirection;
        }
        void Update()
        {
            PerspectiveCamera camera = (PerspectiveCamera)MainViewPort.Camera;
            Vector3D position = (Vector3D)CameraPosition;
            camera.Position = (Point3D)position;

            if (this.model != null)
            {
                this.modelBounds = this.model.Content.Bounds;
                double radius = Math.Max(modelBounds.Size.X, Math.Max(modelBounds.Size.Y, modelBounds.Size.Z));
                this.modelRadius = radius;
                Point3D center = new Point3D(modelBounds.X + (modelBounds.SizeX / 2), modelBounds.Y + (modelBounds.SizeY / 2), modelBounds.Z + (modelBounds.SizeZ / 2));
                this.lookAt = center;

                if (camera.Position.X == 0 && camera.Position.Y == 0 && camera.Position.Z == 0)
                {
                    position.X = this.modelBounds.X + this.modelBounds.SizeX;
                    position.Y = this.modelBounds.Y + (this.modelBounds.SizeY / 2);
                    position.Z = this.modelBounds.Z + this.modelBounds.SizeZ;
                    position.Normalize();
                    position *= (radius * 3);
                    camera.Position = (Point3D)position;
                }

                camera.LookDirection = this.lookAt - camera.Position;

                camera.FarPlaneDistance = radius * 10;

                Quaternion rotation = this.ModelAttitude * gesture.Rotation;
                QuaternionRotation3D quaternionRotation = new QuaternionRotation3D(rotation);
                RotateTransform3D myRotateTransform = new RotateTransform3D(quaternionRotation);
                model.Transform = myRotateTransform;
                xAxis.Transform = myRotateTransform;
                yAxis.Transform = myRotateTransform;
            }
        }
Beispiel #18
0
        public static Tuple<Point3D, Point3D> GetAABB(IEnumerable<PartBase> parts)
        {
            QuaternionRotation3D quatRot = new QuaternionRotation3D(Quaternion.Identity);
            RotateTransform3D transform = new RotateTransform3D(quatRot);

            bool sawPart = false;

            double minX = double.MaxValue;
            double minY = double.MaxValue;
            double minZ = double.MaxValue;
            double maxX = double.MinValue;
            double maxY = double.MinValue;
            double maxZ = double.MinValue;

            foreach (PartBase part in parts)
            {
                sawPart = true;

                quatRot.Quaternion = part.Orientation;

                GetAABB_Test(ref minX, ref maxX, transform, part.Position, part.ScaleActual, Axis.X);
                GetAABB_Test(ref minY, ref maxY, transform, part.Position, part.ScaleActual, Axis.Y);
                GetAABB_Test(ref minZ, ref maxZ, transform, part.Position, part.ScaleActual, Axis.Z);
            }

            if (sawPart)
            {
                return Tuple.Create(new Point3D(minX, minY, minZ), new Point3D(maxX, maxY, maxZ));
            }
            else
            {
                return Tuple.Create(new Point3D(0, 0, 0), new Point3D(0, 0, 0));
            }
        }
Beispiel #19
0
 public AnyQuatWorker(QuaternionRotation3D transform, double angleDelta, int numFullRotations, double? maxTransitionAngle = null)
 {
     _transform = transform;
     _angleDelta = angleDelta;
     _numFullRotations = numFullRotations;
     _maxTransitionAngle = maxTransitionAngle;
 }
Beispiel #20
0
 public ConeQuatWorker(QuaternionRotation3D transform, Vector3D centerAxis, double maxConeAngle, double angleDelta, int numFullRotations)
 {
     _transform = transform;
     _centerAxis = centerAxis;
     _maxConeAngle = maxConeAngle;
     _angleDelta = angleDelta;
     _numFullRotations = numFullRotations;
 }
        private void CreateVisual(double sizePercent)
        {
            const double ZOOMFULL = 2.7d;

            if (_item == null)
            {
                return;
            }

            Model3D model = UtilityCore.Clone(_item.Model);
            _rotateTransform = new QuaternionRotation3D(Quaternion.Identity);
            model.Transform = new RotateTransform3D(_rotateTransform);

            _visual = new ModelVisual3D() { Content = model };

            _camera.Position = (_camera.Position.ToVector().ToUnit() * (_item.Radius * ZOOMFULL / sizePercent)).ToPoint();
            _viewport.Children.Add(_visual);
        }
Beispiel #22
0
        /// <summary>
        /// This simply rotates the same direction and same speed forever
        /// </summary>
        public static AnimateRotation Create_Constant(QuaternionRotation3D transform, double angleDelta)
        {
            if (transform.Quaternion.IsIdentity)
            {
                throw new ArgumentException("The transform passed in is an identity quaternion, so the axis is unpredictable");
            }

            return new AnimateRotation()
            {
                _worker = new FixedWorker(transform, angleDelta)
            };
        }
        private void UpdateQuaternionRotation3D(object sender, EventArgs e)
        {
            //Clear prior values
            //find a cleaner way to do this--loop?
            RotationAxisXText.Clear();
            RotationAxisYText.Clear();
            RotationAxisZText.Clear();
            RotationAngleText.Clear();

            M11Text.Clear();
            M21Text.Clear();
            M31Text.Clear();
            OffsetXText.Clear();
            M12Text.Clear();
            M22Text.Clear();
            M32Text.Clear();
            OffsetYText.Clear();
            M13Text.Clear();
            M23Text.Clear();
            M33Text.Clear();
            OffsetZText.Clear();
            M14Text.Clear();
            M24Text.Clear();
            M34Text.Clear();
            M44Text.Clear();

            //Read new settings
            try
            {
                Double WValue = System.Convert.ToDouble(QuaternionWText.Text);
                Double XValue = System.Convert.ToDouble(QuaternionXText.Text);
                Double YValue = System.Convert.ToDouble(QuaternionYText.Text);
                Double ZValue = System.Convert.ToDouble(QuaternionZText.Text);

                endQuaternion = new Quaternion(XValue, YValue, ZValue, WValue);
            }
            catch
            {
                MessageBox.Show("Set non-null values for the quaternion.");
            }

            myQuaternionRotation3D = new QuaternionRotation3D(endQuaternion);
            myRotateTransform3D.Rotation = myQuaternionRotation3D;

            //update matrix display
            qrotationMatrix3D = myRotateTransform3D.Value;

            M11Text.Text = qrotationMatrix3D.M11.ToString();
            M21Text.Text = qrotationMatrix3D.M21.ToString();
            M31Text.Text = qrotationMatrix3D.M31.ToString();
            OffsetXText.Text = qrotationMatrix3D.OffsetX.ToString();
            M12Text.Text = qrotationMatrix3D.M12.ToString();
            M22Text.Text = qrotationMatrix3D.M22.ToString();
            M32Text.Text = qrotationMatrix3D.M32.ToString();
            OffsetYText.Text = qrotationMatrix3D.OffsetY.ToString();
            M13Text.Text = qrotationMatrix3D.M13.ToString();
            M23Text.Text = qrotationMatrix3D.M23.ToString();
            M33Text.Text = qrotationMatrix3D.M33.ToString();
            OffsetZText.Text = qrotationMatrix3D.OffsetZ.ToString();
            M14Text.Text = qrotationMatrix3D.M14.ToString();
            M24Text.Text = qrotationMatrix3D.M24.ToString();
            M34Text.Text = qrotationMatrix3D.M34.ToString();
            M44Text.Text = qrotationMatrix3D.M44.ToString();

            //apply transform
            myprocTransformGroup.Children.Clear();
            myprocTransformGroup.Children.Add(myRotateTransform3D);
            topModelVisual3D.Transform = myprocTransformGroup;

            //convert to axis/angle and display results
            RotationAxisXText.Text = endQuaternion.Axis.X.ToString();
            RotationAxisYText.Text = endQuaternion.Axis.X.ToString();
            RotationAxisZText.Text = endQuaternion.Axis.X.ToString();
            RotationAngleText.Text = endQuaternion.Angle.ToString();
        }
Beispiel #24
0
 /// <summary>
 /// This will go from any angle to any angle, but at the time of choosing a new destination, it won't
 /// exceed a cone defined by maxTransitionAngle
 /// </summary>
 /// <remarks>
 /// Without this constraint, the changes in direction are pretty jarring.  This is an attempt to smooth that out
 /// </remarks>
 public static AnimateRotation Create_AnyOrientation_LimitChange(QuaternionRotation3D transform, double maxTransitionConeAngle, double anglePerSecond, double angleBetweenTransitions)
 {
     return new AnimateRotation()
     {
         _worker = new AnyQuatConeWorker(transform, maxTransitionConeAngle, anglePerSecond, angleBetweenTransitions)
     };
 }
Beispiel #25
0
        private void RenderPart()
        {
            ModelVisual3D visual = new ModelVisual3D();
            visual.Content = this.Part.Model;
            _rotateTransform = new QuaternionRotation3D(Math3D.GetRandomRotation());
            visual.Transform = new RotateTransform3D(_rotateTransform);

            // Pull the camera back far enough to see the part
            double? maxDist = UtilityWPF.GetPointsFromMesh(this.Part.Model).
                Select(o => o.ToVector().LengthSquared).
                OrderByDescending(o => o).
                FirstOrDefault();

            double cameraDist = 2.1;
            if (maxDist != null)
            {
                maxDist = Math.Sqrt(maxDist.Value);

                cameraDist = maxDist.Value * 3;
            }

            _viewport.Children.Add(visual);

            _camera.Position = (_camera.Position.ToVector().ToUnit() * cameraDist).ToPoint();
        }
Beispiel #26
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

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

            #line default
            #line hidden
                return;

            case 2:
                this.buttonexit = ((System.Windows.Controls.Button)(target));

            #line 21 "..\..\MainWindow.xaml"
                this.buttonexit.Click += new System.Windows.RoutedEventHandler(this.Buttonexit_Click);

            #line default
            #line hidden
                return;

            case 3:
                this.buttonMinimize = ((System.Windows.Controls.Button)(target));

            #line 22 "..\..\MainWindow.xaml"
                this.buttonMinimize.Click += new System.Windows.RoutedEventHandler(this.ButtonMinimize_Click);

            #line default
            #line hidden
                return;

            case 4:
                this.comboBox = ((System.Windows.Controls.ComboBox)(target));

            #line 26 "..\..\MainWindow.xaml"
                this.comboBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.OnSelectionChanged);

            #line default
            #line hidden
                return;

            case 5:
                this.comboPicture = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 6:
                this.startButton = ((System.Windows.Controls.Button)(target));

            #line 43 "..\..\MainWindow.xaml"
                this.startButton.Click += new System.Windows.RoutedEventHandler(this.OnStartButtonClick);

            #line default
            #line hidden
                return;

            case 7:
                this.stopButton = ((System.Windows.Controls.Button)(target));

            #line 44 "..\..\MainWindow.xaml"
                this.stopButton.Click += new System.Windows.RoutedEventHandler(this.OnStopButtonClick);

            #line default
            #line hidden
                return;

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

            #line 45 "..\..\MainWindow.xaml"
                this.imageButton.Click += new System.Windows.RoutedEventHandler(this.OnImageButtonClick);

            #line default
            #line hidden
                return;

            case 9:
                this.webCameraControl = ((WebEye.Controls.Wpf.WebCameraControl)(target));
                return;

            case 10:
                this.MyMap = ((Microsoft.Maps.MapControl.WPF.Map)(target));
                return;

            case 11:
                this.DefaultPin = ((Microsoft.Maps.MapControl.WPF.Pushpin)(target));
                return;

            case 12:
                this.MyPushPin = ((Microsoft.Maps.MapControl.WPF.Pushpin)(target));
                return;

            case 13:
                this.defaultlocbtn = ((System.Windows.Controls.Button)(target));

            #line 56 "..\..\MainWindow.xaml"
                this.defaultlocbtn.Click += new System.Windows.RoutedEventHandler(this.defaultlocbtn_Click);

            #line default
            #line hidden
                return;

            case 14:
                this.GridGrafik = ((System.Windows.Controls.Grid)(target));
                return;

            case 15:
                this.grafikLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 16:
                this.TinggiPlot = ((Microsoft.Research.DynamicDataDisplay.ChartPlotter)(target));
                return;

            case 17:
                this.AccPlot = ((Microsoft.Research.DynamicDataDisplay.ChartPlotter)(target));
                return;

            case 18:
                this.GyroPlot = ((Microsoft.Research.DynamicDataDisplay.ChartPlotter)(target));
                return;

            case 19:
                this.yprButton = ((System.Windows.Controls.Button)(target));

            #line 98 "..\..\MainWindow.xaml"
                this.yprButton.Click += new System.Windows.RoutedEventHandler(this.yprButton_Click);

            #line default
            #line hidden
                return;

            case 20:
                this.elevasiButton = ((System.Windows.Controls.Button)(target));

            #line 99 "..\..\MainWindow.xaml"
                this.elevasiButton.Click += new System.Windows.RoutedEventHandler(this.elevasiButton_Click);

            #line default
            #line hidden
                return;

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

            #line 100 "..\..\MainWindow.xaml"
                this.ketinggianButton.Click += new System.Windows.RoutedEventHandler(this.ketinggianButton_Click);

            #line default
            #line hidden
                return;

            case 22:
                this.GridTerminal = ((System.Windows.Controls.Grid)(target));
                return;

            case 23:
                this.terminalText = ((System.Windows.Controls.TextBox)(target));

            #line 106 "..\..\MainWindow.xaml"
                this.terminalText.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.terminalText_PreviewKeyDown);

            #line default
            #line hidden
                return;

            case 24:
                this.visualButton = ((System.Windows.Controls.Button)(target));

            #line 117 "..\..\MainWindow.xaml"
                this.visualButton.Click += new System.Windows.RoutedEventHandler(this.visualButton_Click);

            #line default
            #line hidden
                return;

            case 25:
                this.logButton = ((System.Windows.Controls.Button)(target));

            #line 118 "..\..\MainWindow.xaml"
                this.logButton.Click += new System.Windows.RoutedEventHandler(this.logButton_Click);

            #line default
            #line hidden
                return;

            case 26:
                this.tabVisual = ((System.Windows.Controls.Grid)(target));
                return;

            case 27:
                this.gridKoneksi = ((System.Windows.Controls.Grid)(target));
                return;

            case 28:
                this.portCombo = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 29:
                this.baudCombo = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 30:
                this.databitCombo = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 31:
                this.stopbitCombo = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 32:
                this.parityCombo = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 33:
                this.handshakeCombo = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 34:
                this.delayCombo = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 35:
                this.portLauncher = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 36:
                this.konekButton = ((System.Windows.Controls.Button)(target));

            #line 155 "..\..\MainWindow.xaml"
                this.konekButton.Click += new System.Windows.RoutedEventHandler(this.konekButton_Click);

            #line default
            #line hidden
                return;

            case 37:
                this.gridUtama = ((System.Windows.Controls.Grid)(target));
                return;

            case 38:
                this.barKetinggian = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 39:
                this.barElevasi = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 40:
                this.barTemperatur = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 41:
                this.barTekanan = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 42:
                this.barYaw = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 43:
                this.barPitch = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 44:
                this.barRoll = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 45:
                this.lblLatitude = ((System.Windows.Controls.Label)(target));
                return;

            case 46:
                this.lblLongitude = ((System.Windows.Controls.Label)(target));
                return;

            case 47:
                this.lblKetinggian = ((System.Windows.Controls.Label)(target));
                return;

            case 48:
                this.lblElevasi = ((System.Windows.Controls.Label)(target));
                return;

            case 49:
                this.lblTemperatur = ((System.Windows.Controls.Label)(target));
                return;

            case 50:
                this.lblTekanan = ((System.Windows.Controls.Label)(target));
                return;

            case 51:
                this.lblYaw = ((System.Windows.Controls.Label)(target));
                return;

            case 52:
                this.lblPitch = ((System.Windows.Controls.Label)(target));
                return;

            case 53:
                this.lblRoll = ((System.Windows.Controls.Label)(target));
                return;

            case 54:
                this.lblTimer = ((System.Windows.Controls.Label)(target));
                return;

            case 55:
                this.btnRefresh = ((System.Windows.Controls.Button)(target));

            #line 225 "..\..\MainWindow.xaml"
                this.btnRefresh.Click += new System.Windows.RoutedEventHandler(this.btnRefresh_Click);

            #line default
            #line hidden
                return;

            case 56:
                this.tabLog = ((System.Windows.Controls.Grid)(target));
                return;

            case 57:
                this.datagridLog = ((System.Windows.Controls.DataGrid)(target));
                return;

            case 58:
                this.Landasan3D = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 59:
                this.DefaultGroup = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 60:
                this.group = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 61:
                this.rocket3D = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 62:
                this.myQuaternionRotation3D = ((System.Windows.Media.Media3D.QuaternionRotation3D)(target));
                return;

            case 63:
                this.btnPutus = ((System.Windows.Controls.Button)(target));

            #line 2195 "..\..\MainWindow.xaml"
                this.btnPutus.Click += new System.Windows.RoutedEventHandler(this.btnPutus_Click);

            #line default
            #line hidden
                return;

            case 64:
                this.btnCapture = ((System.Windows.Controls.Button)(target));

            #line 2197 "..\..\MainWindow.xaml"
                this.btnCapture.Click += new System.Windows.RoutedEventHandler(this.btnCapture_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
Beispiel #27
0
        public Window1()
        {
            InitializeComponent();

            Flickr.Initialize();

            cv = new PhotoCarouselView();
            ps = new PhotoStack3D();

            Transform3DGroup cvTG = new Transform3DGroup();
            cvTG.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), 5)));
            cvTG.Children.Add(new TranslateTransform3D(0, 0, -1));
            cv.Transform = cvTG;

            Transform3DGroup tg = new Transform3DGroup();
            tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), -13)));
            tg.Children.Add(new TranslateTransform3D(0, ps.Height / 2, -1.2));
            ps.Transform = tg;

            MainViewport.Children.Add(cv);
            MainViewport.Children.Add(ps);

            cv.ItemClickedOn += new PhotoBrowser.CarouselView.CarouselView.ItemClickedOnEvent(cv_ItemClickedOn);
            cv.GeoLocationAvailable += new PhotoCarouselView.GeoEventHandler(cv_GeoLocationAvailable);
            cv.GeoLocationHidden += new PhotoCarouselView.GeoEventHandler(cv_GeoLocationHidden);

            ps.GeoLocationSelected += new PhotoStack3D.GeoLocationSelectedDelegate(ps_GeoLocationSelected);
            ps.SelectionChanged += new PhotoBrowser.Stack3D.Stack3D.StackSelectionChangedEvent(ps_SelectionChanged);
            ps.BlogRequested += new PhotoStack3D.BlogRequestedDelegate(ps_BlogRequested);

            // create the globe we'll use
            earth = new InteractiveSphere();
            mapVisual = new MapVisual();
            mapVisual.searchMenuItem.Click += new RoutedEventHandler(searchMenuItem_Click);
            earth.Visual = mapVisual;

            // create the transformation applied to the globe
            earthTransform = new Transform3DGroup();
            Point3D earthPos = new Point3D(-0.2, 0.05, -1.1);
            Vector3D earthToCam = new Vector3D(0 - earthPos.X,
                                               0 - earthPos.Y,
                                               0 - earthPos.Z);
            earthToCam.Normalize();

            earthTransform.Children.Add(new ScaleTransform3D(0.0, 0.0, 0.0));
            _myQuaternionRotLong = new QuaternionRotation3D(new Quaternion(new Vector3D(0, 1, 0), 0));
            _myQuaternionRotLat = new QuaternionRotation3D(new Quaternion(new Vector3D(1, 0, 0), 0));

            earthTransform.Children.Add(new RotateTransform3D(_myQuaternionRotLong));
            earthTransform.Children.Add(new RotateTransform3D(_myQuaternionRotLat));
            earthTransform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0),
                                        Math.Acos(Vector3D.DotProduct(new Vector3D(0, 0, 1), earthToCam)) / Math.PI * 180)));

            earthTransform.Children.Add(new TranslateTransform3D((Vector3D)earthPos));
            earth.Transform = earthTransform;

            // add in the earth
            HookUpEarthEvents();
        }
Beispiel #28
0
        private void RenderMineral()
        {
            ModelVisual3D visual = new ModelVisual3D();
            visual.Content = Mineral.GetNewVisual(this.MineralType);
            _rotateTransform = new QuaternionRotation3D(Math3D.GetRandomRotation());
            visual.Transform = new RotateTransform3D(_rotateTransform);

            _viewport.Children.Add(visual);

            _camera.Position = (_camera.Position.ToVector().ToUnit() * 2.5d).ToPoint();
        }
        private void UpdateSlot(int index)
        {
            if (_slots.Count != pnlSlots.Children.Count)
            {
                throw new ApplicationException(string.Format("The list and panel are out of sync.  list={0}, panel={1}", _slots.Count.ToString(), pnlSlots.Children.Count.ToString()));
            }
            else if (_slots.Count < index)
            {
                throw new ArgumentException(string.Format("Invalid slot index: {0}, count={1}", index.ToString(), _slots.Count.ToString()));
            }

            Weapon weapon = null;
            if (_weapons != null && _weapons.Count > index)
            {
                weapon = _weapons[index];
            }

            SlotItem slot = _slots[index];

            slot.Text.Text = (index + 1).ToString();

            if (weapon == null)
            {
                #region Empty

                slot.Text.Fill = _emptyTextFill;
                slot.Text.Stroke = _emptyTextStroke;
                ((BlurEffect)slot.Text.Effect).Radius = 8;

                if (slot.WeaponVisual != null)
                {
                    slot.Viewport.Children.Remove(slot.WeaponVisual);
                }

                slot.WeaponToken = null;
                slot.WeaponRotateAnimation = null;
                slot.WeaponVisual = null;

                #endregion
            }
            else
            {
                #region Filled

                // Darken the background text
                slot.Text.Fill = _filledTextFill;
                slot.Text.Stroke = _filledTextStroke;
                ((BlurEffect)slot.Text.Effect).Radius = 3;

                // Remove visual if wrong weapon
                if (slot.WeaponToken != null && slot.WeaponToken.Value != weapon.Token)
                {
                    slot.Viewport.Children.Remove(slot.WeaponVisual);
                    slot.WeaponToken = null;
                    slot.WeaponVisual = null;
                }

                // Add weapon visual
                if (slot.WeaponToken == null)
                {
                    Model3D model = UtilityCore.Clone(weapon.Model);
                    QuaternionRotation3D quatTransform = new QuaternionRotation3D(Math3D.GetRandomRotation());
                    model.Transform = new RotateTransform3D(quatTransform);

                    slot.WeaponRotateAnimation = AnimateRotation.Create_AnyOrientation(quatTransform, 3d);

                    slot.WeaponVisual = new ModelVisual3D()
                    {
                        Content = model
                    };

                    // Pull the camera back to a good distance
                    //NOTE: The positions are nomalized by the caller after this method has finished
                    slot.Camera.Position = (slot.Camera.Position.ToVector().ToUnit() * (weapon.Radius * 2.7d)).ToPoint();

                    slot.Viewport.Children.Add(slot.WeaponVisual);
                    slot.WeaponToken = weapon.Token;
                }

                #endregion
            }
        }
        private void SceneMouseRotation(object sender, MouseEventArgs e)
        {
            if (!_IsMouseDown) return;

            Point position = Mouse.GetPosition(_ViewPort);
            Point actualPoition = new Point(position.X - _ViewPort.ActualWidth / 2, _ViewPort.ActualHeight / 2 - position.Y);
            double dx = actualPoition.X - _LastPosition.X;
            double dy = actualPoition.Y - _LastPosition.Y;
            double rotateAngle = 0.0f;

            if(dx != 0 && dy != 0)
            {
                rotateAngle = Math.Asin(Math.Abs(dy) / Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2)));
                if (dx < 0 && dy > 0)
                    rotateAngle += Math.PI / 2;
                else if (dx < 0 && dy < 0)
                    rotateAngle += Math.PI;
                else if (dx > 0 && dy < 0)
                    rotateAngle += Math.PI * 1.5;
            }
            else if (dx == 0 && dy != 0)
                rotateAngle = Math.Sign(dy) > 0 ? Math.PI / 2 : Math.PI * 1.5;
            else if (dx != 0 && dy == 0)
                rotateAngle = Math.Sign(dx) > 0 ? 0 : Math.PI;

            double axisAngle = rotateAngle + Math.PI / 2;
            Vector3D axis = new Vector3D(Math.Cos(axisAngle) * 4, Math.Sin(axisAngle) * 4, 0);
            double rotation = 0.01 * Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2));

            QuaternionRotation3D qrotation = new QuaternionRotation3D(new Quaternion(axis, rotation * 180 / Math.PI));
            _GroupRotation.Children.Add(new RotateTransform3D(qrotation));
            _LastPosition = actualPoition;
        }
        public NGonDisplayControl()
        {
            this.cameraTransformGroup = new Transform3DGroup();

            //used for zoom effects
            this.cameraScaleTransform = new ScaleTransform3D(1.0, 1.0, 1.0);
            this.cameraTransformGroup.Children.Add(this.cameraScaleTransform);

            //used for rotation effects
            this.cameraAngleRotation = new QuaternionRotation3D();
            this.cameraTransformGroup.Children.Add(new RotateTransform3D(this.cameraAngleRotation));

            InitializeComponent();

            PerspectiveCamera camera = new PerspectiveCamera();
            //Initially positioned at +3 the Z-axis looking towards the 'front' face of the N-Gon.
            camera.Position = new Point3D(0.0, 0.0, 3.0);

            //Looking down the Z-axis.
            camera.LookDirection = new Vector3D(0.0, 0.0, -1.0);

            camera.FieldOfView = 60.0;

            //Which way is up :)
            camera.UpDirection = yAxisVector;

            ViewportCamera = camera;

            //Register our camera so that animations can locate it by name.
            NameScope.GetNameScope(this).RegisterName("viewportCamera", ViewportCamera);

            //Assign our transform group to our camera and mark our viewport as needing a reset so the first time we try to animate the N-Gon (and thus
            //need our 3d view, we will set it up).
            this.viewportCamera.Transform = this.cameraTransformGroup;
            this.viewportNeedsReset = true;
        }
 /// <summary>
 ///     Rotate the rectangle by a quaternion
 /// </summary>
 /// <param name="rot">The quaternion to rotate by</param>
 /// <returns>The current rectangle instance</returns>
 public Rectangle3D Rotate(Quaternion rot)
 {
     foreach (var k in new List<string>(Corners.Keys)) {
         var q = new QuaternionRotation3D(new System.Windows.Media.Media3D.Quaternion(rot.X, rot.Y, rot.Z, rot.W));
         var r = new RotateTransform3D(q, ToPoint3D(Center));
         Corners[k] = ToVector3(r.Transform(ToPoint3D(Corners[k])));
     }
     Position = Corners["000"];
     GenerateEdges();
     GenerateFaces();
     return this;
 }
 /// <summary>
 ///     Rotate the global. Given 'delta' the distance the finger/mouse has moved.
 /// </summary>
 private void RotateGlobe(Vector delta)
 {
     if (!delta.X.Equals(0.0) || !delta.Y.Equals(0.0))
     {
         // Convert delta to a 3D vector.
         var vOriginal = new Vector3D(-delta.X, delta.Y, 0d);
         var vZ = new Vector3D(0, 0, 1);
         // Find a vector that is perpendicular with the delta vector on the XY surface. This will be the rotation axis.
         Vector3D perpendicular = Vector3D.CrossProduct(vOriginal, vZ);
         var rotate = new RotateTransform3D();
         // The QuaternionRotation3D allows you to easily specify a rotation axis.
         var quatenion = new QuaternionRotation3D {Quaternion = new Quaternion(perpendicular, 3)};
         rotate.Rotation = quatenion;
         TransformGroup.Children.Add(rotate);
         _angleBuffer = 0;
     }
 }
      public void InitializeViewer()
      {
         ///////////////////////////////////////////
         // Camera Initialize
         ///////////////////////////////////////////
         PerspectiveCamera PanoramaCamera = new PerspectiveCamera();
         PanoramaCamera.Position = new Point3D(0, -0.0, 0);
         PanoramaCamera.UpDirection = new Vector3D(0, 1, 0);
         PanoramaCamera.LookDirection = new Vector3D(0, 0, 1);
         PanoramaCamera.FieldOfView = 80;
         this.Camera = PanoramaCamera;

         FieldOfView = 80;

         ///////////////////////////////////////////
         // Light Initialize
         ///////////////////////////////////////////
         ModelVisual3D LightModel = new ModelVisual3D();
         LightModel.Content = new DirectionalLight(Colors.White, new Vector3D(0, 0, 1));
         this.Children.Add(LightModel);

         ///////////////////////////////////////////
         // Panorama Object Initialize
         ///////////////////////////////////////////

         PanoramaObject = new ModelVisual3D();
         PanoramaGeometry = new GeometryModel3D();
         PanoramaGeometry.Geometry = CreateGeometry();
         PanoramaObject.Content = PanoramaGeometry;

         RotateTransform3D RotateTransform = new RotateTransform3D();

         double x = 1.0;
         ScaleTransform3D ScaleTransform = new ScaleTransform3D()
         {
            ScaleX = x*1,
            ScaleY = x*1.65,
            ScaleZ = x*1
         };

         Transform3DGroup Group = new Transform3DGroup();
         PanoramaRotation = new QuaternionRotation3D();
         Group.Children.Add(ScaleTransform);
         Group.Children.Add(RotateTransform);

         RotateTransform.Rotation = PanoramaRotation;
         PanoramaObject.Transform = Group;

         this.Children.Add(PanoramaObject);
      }
Beispiel #35
0
 public FixedWorker(QuaternionRotation3D transform, double delta)
 {
     _isQuat = true;
     _transformQuat = transform;
     _transformAxis = null;
     _delta = delta;
 }