Exemplo n.º 1
0
        public RotateToState(RotateTo action, Node target)
            : base(action, target)
        {
            DistanceAngleX = action.DistanceAngleX;
            DistanceAngleY = action.DistanceAngleY;
            DistanceAngleZ = action.DistanceAngleZ;

            var sourceRotation = Target.Rotation.ToEulerAngles();

            // Calculate X
            StartAngleX = sourceRotation.X;
            StartAngleX = StartAngleX > 0 ? StartAngleX % 360.0f : StartAngleX % -360.0f;
            DiffAngleX  = DistanceAngleX - StartAngleX;
            if (DiffAngleX > 180)
            {
                DiffAngleX -= 360;
            }
            if (DiffAngleX < -180)
            {
                DiffAngleX += 360;
            }

            //Calculate Y
            StartAngleY = sourceRotation.Y;
            StartAngleY = StartAngleY > 0 ? StartAngleY % 360.0f : StartAngleY % -360.0f;
            DiffAngleY  = DistanceAngleY - StartAngleY;
            if (DiffAngleY > 180)
            {
                DiffAngleY -= 360;
            }
            if (DiffAngleY < -180)
            {
                DiffAngleY += 360;
            }

            //Calculate Z
            StartAngleZ = sourceRotation.Z;
            StartAngleZ = StartAngleZ > 0 ? StartAngleZ % 360.0f : StartAngleZ % -360.0f;
            DiffAngleZ  = DistanceAngleZ - StartAngleZ;
            if (DiffAngleZ > 180)
            {
                DiffAngleZ -= 360;
            }
            if (DiffAngleZ < -180)
            {
                DiffAngleZ += 360;
            }
        }
Exemplo n.º 2
0
		public RotateToState (RotateTo action, Node target)
			: base (action, target)
		{ 
			DistanceAngleX = action.DistanceAngleX;
			DistanceAngleY = action.DistanceAngleY;
			DistanceAngleZ = action.DistanceAngleZ;

			var sourceRotation = Target.Rotation;

			// Calculate X
			StartAngleX = sourceRotation.X;
			StartAngleX = StartAngleX > 0 ? StartAngleX % 360.0f : StartAngleX % -360.0f;
			DiffAngleX = DistanceAngleX - StartAngleX;
			if (DiffAngleX > 180)
				DiffAngleX -= 360;
			if (DiffAngleX < -180)
				DiffAngleX += 360;

			//Calculate Y
			StartAngleY = sourceRotation.Y;
			StartAngleY = StartAngleY > 0 ? StartAngleY % 360.0f : StartAngleY % -360.0f;
			DiffAngleY = DistanceAngleY - StartAngleY;
			if (DiffAngleY > 180)
				DiffAngleY -= 360;
			if (DiffAngleY < -180)
				DiffAngleY += 360;

			//Calculate Z
			StartAngleZ = sourceRotation.Z;
			StartAngleZ = StartAngleZ > 0 ? StartAngleZ % 360.0f : StartAngleZ % -360.0f;
			DiffAngleZ = DistanceAngleZ - StartAngleZ;
			if (DiffAngleZ > 180)
				DiffAngleZ -= 360;
			if (DiffAngleZ < -180)
				DiffAngleZ += 360;
		}