Пример #1
0
 //Resetting rotation angles and all that
 void Reset()
 {
     RotationAngle = 0;
     Zoom = 1;
     qAxis = DCL.Maths.Quaternion.j;
     if(SelectedIndex==2 && Latitude<=180 && UseGPS)
         UpdatePositionVisualisation();
 }
Пример #2
0
        /// <summary>
        /// Sets the default rotation for the RotateDefault() method.
        /// </summary>
        /// <param name="Axis1">A quaternion or a Vector3 object that represents the first axis. It is assumed that the axis starts at the origin.</param>
        /// <param name="RotationAngle1">The angle of rotation around the first axis.</param>
        /// <param name="Axis2">A quaternion or a Vector3 object that represents the second axis. It is assumed that the axis starts at the origin.</param>
        /// <param name="RotationAngle2">The angle of rotation around the second axis.</param>
        /// <param name="Axis3">A quaternion or a Vector3 object that represents the third axis. It is assumed that the axis starts at the origin.</param>
        /// <param name="RotationAngle3">The angle of rotation around the third axis.</param>
        public void SetDefaultRotation(My.Quaternion Axis1, float RotationAngle1,
                                        My.Quaternion Axis2, float RotationAngle2,
                                        My.Quaternion Axis3, float RotationAngle3)
        {
            My.Quaternion qRot1 = My.Quaternion.RotationQuaternion(Axis1, RotationAngle1);
            My.Quaternion qRot2 = My.Quaternion.RotationQuaternion(Axis2, RotationAngle2);
            My.Quaternion qRot3 = My.Quaternion.RotationQuaternion(Axis3, RotationAngle3);

            DefaultRotation = qRot3 * qRot2 * qRot1;
        }
Пример #3
0
        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        /*protected override void UnloadContent()
        {

        }*/
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            #region Handling touches
            Touches = TouchPanel.GetState();
            if (Touches.Count == 1)
            {
                #region One touch => Rotate
                if (Touches[0].State == TouchLocationState.Moved &&
                       Touches[0].Position.X > this[SelectedIndex].DrawingArea.X &&
                       Touches[0].Position.X < this[SelectedIndex].DrawingArea.X + this[SelectedIndex].DrawingArea.Width &&
                       Touches[0].Position.Y > this[SelectedIndex].DrawingArea.Y &&
                       Touches[0].Position.Y < this[SelectedIndex].DrawingArea.Y + this[SelectedIndex].DrawingArea.Height)
                {
                    TouchLocation prevTouch;
                    if (Touches[0].TryGetPreviousLocation(out prevTouch))
                    {
                        float deltaX = Touches[0].Position.X - prevTouch.Position.X;
                        float deltaY = Touches[0].Position.Y - prevTouch.Position.Y;

                        if (Math.Abs(deltaX) > 0 || Math.Abs(deltaY) > 0)
                        {

                            qNew = (new My.Quaternion(0, deltaY, deltaX, 0)).Normalize().Approximate(0.5f);
                            qAxis = qNew;
                        }
                        RotationAngle = (qAxis.Y * deltaX + qAxis.X * deltaY) / 100;
                    }
                }
                else
                    RotationAngle = 0;
                #endregion

                #region One touch => Click on a Button

                if (IsTrial && Touches[0].State == TouchLocationState.Pressed &&
                       Touches[0].Position.X > 300 && Touches[0].Position.X < 430 &&
                       Touches[0].Position.Y > 0 && Touches[0].Position.Y < 40)
                    //(new MarketplaceDetailTask() { ContentIdentifier = "6efbe3f4-8476-e011-81d2-78e7d1fa76f8" }).Show();
                    Guide.ShowMarketplace(PlayerIndex.One);

                if (Touches[0].State == TouchLocationState.Pressed && SelectedIndex==2 &&
                       Touches[0].Position.X > 435 && Touches[0].Position.X < 480 &&
                       Touches[0].Position.Y > 0 && Touches[0].Position.Y < 40)
                    if (IsTrial)
                        Guide.BeginShowMessageBox("Trial version", "Location services are available only in the full version!", new string[] { "Buy now", "Buy later" }, 0, MessageBoxIcon.Alert, new AsyncCallback(OnBuyMessageClosed), null);
                    else
                        Guide.BeginShowMessageBox("Location settings", "This application can use the built-in location services.\n\nYour location will be used ONLY to indicate your position on the globe.\n\nEnable the access to and use of location from the location services?", new string[] { "Enable", "Disable" }, 0, MessageBoxIcon.Alert, new AsyncCallback(OnGPSSettingsClosed), null);
                #endregion
            }
            else if (Touches.Count > 1 && !ChangingPages)
            {
                #region Multitouch => Resize
                RotationAngle = 0;

                //first touch
                if (Touches[0].State == TouchLocationState.Pressed || Touches[1].State == TouchLocationState.Pressed)
                {
                    touchesDistance = Math.Sqrt((Touches[0].Position.X - Touches[1].Position.X) * (Touches[0].Position.X - Touches[1].Position.X) +
                                        (Touches[0].Position.Y - Touches[1].Position.Y) * (Touches[0].Position.Y - Touches[1].Position.Y));
                }
                //moving fingers
                else if (Touches[0].State == TouchLocationState.Moved || Touches[1].State == TouchLocationState.Moved)
                {
                    double newTouchesDistance = Math.Sqrt((Touches[0].Position.X - Touches[1].Position.X) * (Touches[0].Position.X - Touches[1].Position.X) +
                                        (Touches[0].Position.Y - Touches[1].Position.Y) * (Touches[0].Position.Y - Touches[1].Position.Y));
                    Zoom = (float)(newTouchesDistance / touchesDistance) * Zoom;
                    Zoom = Math.Max(Math.Min(3f/Planet.Radius, Zoom), 0.7f);
                    touchesDistance = newTouchesDistance;
                }
                #endregion
            }
            #endregion

            #region Rotation

            switch (SelectedIndex)
            {
                case 0: //Mercury
                    Planet.RotateComposition(qAxis, RotationAngle, Planet.Axis, MERCURY_ROTATION_SPEED);
                    break;
                case 1: //Venus
                    Planet.RotateComposition(qAxis, RotationAngle, Planet.Axis, VENUS_ROTATION_SPEED);
                    break;
                case 2: //Earth
                    Planet.RotateComposition(qAxis, RotationAngle, Planet.Axis, EARTH_ROTATION_SPEED);

                    MoonAxis = (Vector3)My.Quaternion.Rotate(MoonAxis, qAxis, RotationAngle);
                    Moon.RotateComposition(qAxis, RotationAngle, MoonAxis, MOON_ROTATION_SPEED);
                    break;
                case 3: //Mars
                    Planet.RotateComposition(qAxis, RotationAngle, Planet.Axis, MARS_ROTATION_SPEED);

                    Moon.RotateComposition(qAxis, RotationAngle, Planet.Axis, PHOBOS_ROTATION_SPEED);
                    Moon2.RotateComposition(qAxis, RotationAngle, Planet.Axis, DEIMOS_ROTATION_SPEED);
                    break;
                case 4: //Jupiter
                    Planet.RotateComposition(qAxis, RotationAngle, Planet.Axis, JUPITER_ROTATION_SPEED);

                    Moon.RotateComposition(qAxis, RotationAngle, Planet.Axis, EUROPA_ROTATION_SPEED);
                    Moon2.RotateComposition(qAxis, RotationAngle, Planet.Axis, IO_ROTATION_SPEED);
                    Moon3.RotateComposition(qAxis, RotationAngle, Planet.Axis, GANYMEDE_ROTATION_SPEED);
                    Moon4.RotateComposition(qAxis, RotationAngle, Planet.Axis, CALLISTO_ROTATION_SPEED);
                    break;
                case 5: //Saturn
                    Planet.RotateComposition(qAxis, RotationAngle, Planet.Axis, SATURN_ROTATION_SPEED);

                    Moon.RotateComposition(qAxis, RotationAngle, Planet.Axis, TITAN_ROTATION_SPEED);
                    Moon2.RotateComposition(qAxis, RotationAngle, Planet.Axis, RHEA_ROTATION_SPEED);
                    Moon3.RotateComposition(qAxis, RotationAngle, Planet.Axis, DIONE_ROTATION_SPEED);
                    Moon4.RotateComposition(qAxis, RotationAngle, Planet.Axis, TETHYS_ROTATION_SPEED);
                    MoonAxis = (Vector3)My.Quaternion.Rotate(MoonAxis, qAxis, RotationAngle);
                    Moon5.RotateComposition(qAxis, RotationAngle, MoonAxis, IAPETUS_ROTATION_SPEED); //Iapetus has another axis
                    Moon6.RotateComposition(qAxis, RotationAngle, Planet.Axis, ENCELADUS_ROTATION_SPEED);
                    Moon7.RotateComposition(qAxis, RotationAngle, Planet.Axis, MIMAS_ROTATION_SPEED);

                    foreach (FlatRingSector f in SaturnRing)
                        f.Rotate(qAxis, RotationAngle);
                    break;
                case 6: //Uran
                    Planet.RotateComposition(qAxis, RotationAngle, Planet.Axis, URANUS_ROTATION_SPEED);

                    Moon.RotateComposition(qAxis, RotationAngle, Planet.Axis, TITANIA_ROTATION_SPEED);
                    Moon2.RotateComposition(qAxis, RotationAngle, Planet.Axis, OBERON_ROTATION_SPEED);
                    Moon3.RotateComposition(qAxis, RotationAngle, Planet.Axis, ARIEL_ROTATION_SPEED);
                    Moon4.RotateComposition(qAxis, RotationAngle, Planet.Axis, UMBRIEL_ROTATION_SPEED);
                    Moon5.RotateComposition(qAxis, RotationAngle, Planet.Axis, MIRANDA_ROTATION_SPEED);
                    break;
                case 7: //Neptun
                    Planet.RotateComposition(qAxis, RotationAngle, Planet.Axis, EARTH_ROTATION_SPEED);

                    MoonAxis = (Vector3)My.Quaternion.Rotate(MoonAxis, qAxis, RotationAngle);
                    Moon.RotateComposition(qAxis, RotationAngle, MoonAxis, TRITON_ROTATION_SPEED);
                    Moon2.RotateComposition(qAxis, RotationAngle, Planet.Axis, NEREID_ROTATION_SPEED);
                    Moon3.RotateComposition(qAxis, RotationAngle, Planet.Axis, PROTEUS_ROTATION_SPEED);
                    break;
            }
            #endregion

            #region Updating texts
            //New Axis
            //tAxis = String.Format("Axis: ({0:G4}; {1:G4}; {2:G4})", qAxis.X, qAxis.Y, qAxis.Z);

            //ANGLES OF ROTATION
            //angAroundAxis += MathHelper.ToDegrees(0.025f); if (angAroundAxis > 360) angAroundAxis -= 360;
            //angAroundEarth += MathHelper.ToDegrees(0.005f); if (angAroundEarth > 360) angAroundEarth -= 360;

            //tAngleA = String.Format("Around axis:  {0}°", (int)angAroundAxis);
            //tAngleB = String.Format("Around earth: {0}°", (int)angAroundEarth);
            #endregion

            base.Update(gameTime);
        }
Пример #4
0
 /// <summary>
 /// Sets the default rotation for the RotateDefault() method.
 /// </summary>
 /// <param name="Axis">A quaternion or a Vector3 object that represents the axis.</param>
 /// <param name="RotationAngle">The angle of rotation around the axis.</param>
 public void SetDefaultRotation(My.Quaternion Axis, float RotationAngle)
 {
     DefaultRotation = My.Quaternion.RotationQuaternion(Axis, RotationAngle);
 }