Пример #1
0
        public void Rotation()
        {
            var positionAndOrientation = new MyPositionAndOrientation(
                    new SerializableVector3D(10.0d, -10.0d, -2.5d),
                    new SerializableVector3(0.0f, 0.0f, -1.0f),
                    new SerializableVector3(0.0f, 1.0f, 0.0f));

            // -90 around Z
            var quaternion = Quaternion.CreateFromYawPitchRoll(0, 0, -VRageMath.MathHelper.PiOver2);
            var o = positionAndOrientation.ToQuaternion() * quaternion;
            var on = Quaternion.Normalize(o);
            var p = new MyPositionAndOrientation(on.ToMatrix());

            var quaternion2 = QuaternionD.CreateFromYawPitchRoll(0, 0, -Math.PI / 2);
            var o2 = positionAndOrientation.ToQuaternionD() * quaternion2;
            var on2 = QuaternionD.Normalize(o2);
            var p2 = new MyPositionAndOrientation(on2.ToMatrixD());

            var quaternion3 = new System.Windows.Media.Media3D.Quaternion(new System.Windows.Media.Media3D.Vector3D(0, 0, 1), -90d);
            var x3 = positionAndOrientation.ToQuaternionD();
            var o3 = new System.Windows.Media.Media3D.Quaternion(x3.X, x3.Y, x3.Z, x3.W)*quaternion3;
            var on3 = o3;
            on3.Normalize();


            double num = on3.X * on3.X;
            double num3 = on3.Z * on3.Z;
            double num4 = on3.X * on3.Y;
            double num5 = on3.Z * on3.W;
            double num8 = on3.Y * on3.Z;
            double num9 = on3.X * on3.W;
            var M21 = (2.0d * (num4 - num5));
            var M22 = (1.0d - 2.0d * (num3 + num));
            var M23 = (2.0d * (num8 + num9));

            var up3 = new Vector3D(M21, M22, M23);

            


            var fwd = new SerializableVector3(0.0f, 0.0f, -1.0f);
            var up = new SerializableVector3(1.0f, 0.0f, 0.0f);

            Assert.AreEqual(fwd.X, p.Forward.X, "Forward.X Should Equal");
            Assert.AreEqual(fwd.Y, p.Forward.Y, "Forward.Y Should Equal");
            Assert.AreEqual(fwd.Z, p.Forward.Z, "Forward.Z Should Equal");
            Assert.AreEqual(up.X, p.Up.X, "Up.X Should Equal");
            Assert.AreEqual(up.Y, p.Up.Y, "Up.Y Should Equal");
            Assert.AreEqual(up.Z, p.Up.Z, "Up.Z Should Equal");
        }
		public Vector3Wrapper(SerializableVector3 v)
		{
			_vector = v;
		}
 public MyPositionAndOrientation(Vector3D position, Vector3 forward, Vector3 up)
 {
     Position = position;
     Forward  = forward;
     Up       = up;
 }
 public MyPositionAndOrientation(ref MatrixD matrix)
 {
     Position = matrix.Translation;
     Forward  = (Vector3)matrix.Forward;
     Up       = (Vector3)matrix.Up;
 }
 public MyPositionAndOrientation(ref MatrixD matrix)
 {
     Position = matrix.Translation;
     Forward = (Vector3)matrix.Forward;
     Up = (Vector3)matrix.Up;
 }
 public MyPositionAndOrientation(Vector3D position, Vector3 forward, Vector3 up)
 {
     Position = position;
     Forward = forward;
     Up = up;
 }
Пример #7
0
 public void UpdateColor(SerializableVector3 vector3)
 {
     _dataModel.UpdateColor(vector3);
 }
Пример #8
0
 public void UpdateColor(SerializableVector3 vector3)
 {
     Cube.ColorMaskHSV = vector3;
     SetColor(vector3);
 }
Пример #9
0
        public void SetColor(SerializableVector3 vector3)
        {
            Color = new System.Windows.Media.SolidColorBrush(vector3.ToSandboxMediaColor());
            ColorText = Color.ToString();
            ColorHue = vector3.X;
            ColorSaturation = vector3.Y;
            ColorLuminance = vector3.Z;

            RaisePropertyChanged(() => ColorText);
            RaisePropertyChanged(() => ColorHue);
            RaisePropertyChanged(() => ColorSaturation);
            RaisePropertyChanged(() => ColorLuminance);
        }