Exemplo n.º 1
0
        public static void FromVector(ref Vector3F dir, out SphericalDirectionF result)
        {
            result.Horizontal = MathEx.Atan2(dir.Y, dir.X);
            float dir2Length = MathEx.Sqrt(dir.X * dir.X + dir.Y * dir.Y);

            result.Vertical = MathEx.Atan2(dir.Z, dir2Length);
        }
Exemplo n.º 2
0
        public static SphericalDirectionF Multiply(SphericalDirectionF d, QuaternionF q)
        {
            SphericalDirectionF result;

            Multiply(ref d, ref q, out result);
            return(result);
        }
Exemplo n.º 3
0
        public static SphericalDirectionF Negate(SphericalDirectionF v)
        {
            SphericalDirectionF result;

            Negate(ref v, out result);
            return(result);
        }
Exemplo n.º 4
0
        public static SphericalDirectionF Subtract(SphericalDirectionF v1, SphericalDirectionF v2)
        {
            SphericalDirectionF result;

            Subtract(ref v1, ref v2, out result);
            return(result);
        }
Exemplo n.º 5
0
        public static SphericalDirectionF Add(SphericalDirectionF v1, SphericalDirectionF v2)
        {
            SphericalDirectionF result;

            Add(ref v1, ref v2, out result);
            return(result);
        }
Exemplo n.º 6
0
        public static void Multiply(ref SphericalDirectionF d, ref QuaternionF q, out SphericalDirectionF result)
        {
            Vector3F vector;

            d.GetVector(out vector);
            Vector3F vector2;

            QuaternionF.Multiply(ref vector, ref q, out vector2);
            SphericalDirectionF.FromVector(ref vector2, out result);
        }
Exemplo n.º 7
0
 public bool Equals(SphericalDirectionF v, float epsilon)
 {
     if (Math.Abs(Horizontal - v.Horizontal) > epsilon)
     {
         return(false);
     }
     if (Math.Abs(Vertical - v.Vertical) > epsilon)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 8
0
 public void Write(SphericalDirectionF source)
 {
     Write(source.Horizontal);
     Write(source.Vertical);
 }
Exemplo n.º 9
0
 public SphericalDirection(SphericalDirectionF source)
 {
     Horizontal = source.Horizontal;
     Vertical   = source.Vertical;
 }
Exemplo n.º 10
0
        //

        static SimpleTypes()
        {
            //string
            RegisterType(typeof(string), delegate(string value)
            {
                if (value == null)
                {
                    return("");
                    //throw new Exception( "GetSimpleTypeValue: string type, value = null" );
                }
                return(value);
            }, "");

            //bool
            RegisterType(typeof(bool), delegate(string value)
            {
                string lower = value.ToLower();
                if (value == "1" || lower == "yes" || lower == "true")
                {
                    return(true);
                }
                else if (value == "0" || lower == "no" || lower == "false")
                {
                    return(false);
                }
                else
                {
                    return(bool.Parse(value));
                }
            }, false);

            //sbyte
            RegisterType(typeof(sbyte), delegate(string value) { return(sbyte.Parse(value)); }, 0);

            //byte
            RegisterType(typeof(byte), delegate(string value) { return(byte.Parse(value)); }, 0);

            //char
            RegisterType(typeof(char), delegate(string value) { return(char.Parse(value)); }, 0);

            //short
            RegisterType(typeof(short), delegate(string value) { return(short.Parse(value)); }, 0);

            //ushort
            RegisterType(typeof(ushort), delegate(string value) { return(ushort.Parse(value)); }, 0);

            //int
            RegisterType(typeof(int), delegate(string value) { return(int.Parse(value)); }, 0);

            //uint
            RegisterType(typeof(uint), delegate(string value) { return(uint.Parse(value)); }, (uint)0);

            //long
            RegisterType(typeof(long), delegate(string value) { return(long.Parse(value)); }, (long)0);

            //ulong
            RegisterType(typeof(ulong), delegate(string value) { return(ulong.Parse(value)); }, (ulong)0);

            //float
            RegisterType(typeof(float), delegate(string value) { return(float.Parse(value)); }, 0.0f);

            //double
            RegisterType(typeof(double), delegate(string value) { return(double.Parse(value)); }, 0.0);

            //decimal
            RegisterType(typeof(decimal), delegate(string value) { return(decimal.Parse(value)); }, (decimal)0.0);

            //Vec2
            RegisterType(typeof(Vector2F), delegate(string value) { return(Vector2F.Parse(value)); }, Vector2F.Zero);

            //Range
            RegisterType(typeof(RangeF), delegate(string value) { return(RangeF.Parse(value)); }, RangeF.Zero);

            //Vec3
            RegisterType(typeof(Vector3F), delegate(string value) { return(Vector3F.Parse(value)); }, Vector3F.Zero);

            //Vec4
            RegisterType(typeof(Vector4F), delegate(string value) { return(Vector4F.Parse(value)); }, Vector4F.Zero);

            //Bounds
            RegisterType(typeof(BoundsF), delegate(string value) { return(BoundsF.Parse(value)); }, BoundsF.Zero);

            //Quat
            RegisterType(typeof(QuaternionF), delegate(string value) { return(QuaternionF.Parse(value)); }, QuaternionF.Identity);

            //ColorValue
            RegisterType(typeof(ColorValue), delegate(string value) { return(ColorValue.Parse(value)); }, ColorValue.Zero);

            //ColorValuePowered
            RegisterType(typeof(ColorValuePowered), delegate(string value) { return(ColorValuePowered.Parse(value)); }, ColorValuePowered.Zero);

            //ColorPacked
            RegisterType(typeof(ColorByte), delegate(string value) { return(ColorByte.Parse(value)); }, ColorByte.Zero);

            //SphereDir
            RegisterType(typeof(SphericalDirectionF), delegate(string value) { return(SphericalDirectionF.Parse(value)); }, SphericalDirectionF.Zero);

            //Vec2I
            RegisterType(typeof(Vector2I), delegate(string value) { return(Vector2I.Parse(value)); }, Vector2I.Zero);

            //Vec3I
            RegisterType(typeof(Vector3I), delegate(string value) { return(Vector3I.Parse(value)); }, Vector3I.Zero);

            //Vec4I
            RegisterType(typeof(Vector4I), delegate(string value) { return(Vector4I.Parse(value)); }, Vector4I.Zero);

            //Rect
            RegisterType(typeof(RectangleF), delegate(string value) { return(RectangleF.Parse(value)); }, RectangleF.Zero);

            //RectI
            RegisterType(typeof(RectangleI), delegate(string value) { return(RectangleI.Parse(value)); }, RectangleI.Zero);

            //Degree
            RegisterType(typeof(DegreeF), delegate(string value) { return(DegreeF.Parse(value)); }, DegreeF.Zero);

            //Radian
            RegisterType(typeof(RadianF), delegate(string value) { return(RadianF.Parse(value)); }, RadianF.Zero);

            //Vec2D
            RegisterType(typeof(Vector2), delegate(string value) { return(Vector2.Parse(value)); }, Vector2.Zero);

            //RangeD
            RegisterType(typeof(Range), delegate(string value) { return(Range.Parse(value)); }, Range.Zero);

            //RangeI
            RegisterType(typeof(RangeI), delegate(string value) { return(RangeI.Parse(value)); }, RangeI.Zero);

            //Vec3D
            RegisterType(typeof(Vector3), delegate(string value) { return(Vector3.Parse(value)); }, Vector3.Zero);

            //Vec4D
            RegisterType(typeof(Vector4), delegate(string value) { return(Vector4.Parse(value)); }, Vector4.Zero);

            //BoundsD
            RegisterType(typeof(Bounds), delegate(string value) { return(Bounds.Parse(value)); }, Bounds.Zero);

            //QuatD
            RegisterType(typeof(Quaternion), delegate(string value) { return(Quaternion.Parse(value)); }, Quaternion.Identity);

            //SphereDirD
            RegisterType(typeof(SphericalDirection), delegate(string value) { return(SphericalDirection.Parse(value)); }, SphericalDirection.Zero);

            //RectD
            RegisterType(typeof(Rectangle), delegate(string value) { return(Rectangle.Parse(value)); }, Rectangle.Zero);

            //DegreeD
            RegisterType(typeof(Degree), delegate(string value) { return(Degree.Parse(value)); }, Degree.Zero);

            //RadianD
            RegisterType(typeof(Radian), delegate(string value) { return(Radian.Parse(value)); }, Radian.Zero);

            //Angles
            RegisterType(typeof(AnglesF), delegate(string value) { return(AnglesF.Parse(value)); }, AnglesF.Zero);

            //AnglesD
            RegisterType(typeof(Angles), delegate(string value) { return(Angles.Parse(value)); }, Angles.Zero);

            //Mat2F
            RegisterType(typeof(Matrix2F), delegate(string value) { return(Matrix2F.Parse(value)); }, Matrix2F.Zero);

            //Mat2D
            RegisterType(typeof(Matrix2), delegate(string value) { return(Matrix2.Parse(value)); }, Matrix2.Zero);

            //Mat3F
            RegisterType(typeof(Matrix3F), delegate(string value) { return(Matrix3F.Parse(value)); }, Matrix3F.Zero);

            //Mat3D
            RegisterType(typeof(Matrix3), delegate(string value) { return(Matrix3.Parse(value)); }, Matrix3.Zero);

            //Mat4F
            RegisterType(typeof(Matrix4F), delegate(string value) { return(Matrix4F.Parse(value)); }, Matrix4F.Zero);

            //Mat4D
            RegisterType(typeof(Matrix4), delegate(string value) { return(Matrix4.Parse(value)); }, Matrix4.Zero);

            //PlaneF
            RegisterType(typeof(PlaneF), delegate(string value) { return(PlaneF.Parse(value)); }, PlaneF.Zero);

            //PlaneD
            RegisterType(typeof(Plane), delegate(string value) { return(Plane.Parse(value)); }, Plane.Zero);

            //Transform
            RegisterType(typeof(Transform), delegate(string value) { return(Transform.Parse(value)); }, Transform.Identity);

            //UIMeasureValueDouble
            RegisterType(typeof(UIMeasureValueDouble), delegate(string value) { return(UIMeasureValueDouble.Parse(value)); }, new UIMeasureValueDouble());

            //UIMeasureValueVec2
            RegisterType(typeof(UIMeasureValueVector2), delegate(string value) { return(UIMeasureValueVector2.Parse(value)); }, new UIMeasureValueVector2());

            //UIMeasureValueRect
            RegisterType(typeof(UIMeasureValueRectangle), delegate(string value) { return(UIMeasureValueRectangle.Parse(value)); }, new UIMeasureValueRectangle());

            RegisterType(typeof(RangeVector3F), delegate(string value) { return(RangeVector3F.Parse(value)); }, RangeVector3F.Zero);
            RegisterType(typeof(RangeColorValue), delegate(string value) { return(RangeColorValue.Parse(value)); }, RangeColorValue.Zero);

            //no Parse methods. This is complex structures. This is not simple types? or just can't parse?
            //Box
            //Capsule
            //Cone
            //Line3
            //Line2
            //Ray
            //Frustum?

            RegisterConvertDoubleToFloatTypes();
        }
        void ProcessVertex(ref Vector3F position, out Vector3F result)
        {
            Matrix4? nullable = new Matrix4?(PosCenter.Value.ToMatrix4());
            Matrix4  matrix4  = nullable ?? Matrix4.Identity;
            Matrix4F matrix4f = matrix4.ToMatrix4F();
            bool     inv      = matrix4f.Inverse();

            MatrixInv = inv;

            ResPosVec1 = matrix4f * Pos1n.Value.Position.ToVector3F();

            result = position;
            var sc        = new Vector3F(0.2f, 0.2f, 0.2f);
            var rposition = position * sc;

            var   l_r01   = (float)Pos01n.Value.Scale.X;
            var   relp01  = (Pos01n.Value.Position).ToVector3F();
            var   l_dist1 = (rposition - relp01);
            float l_l01   = l_dist1.Length();

            var   l_r02   = (float)Pos02n.Value.Scale.X;
            var   relp02  = (Pos02n.Value.Position).ToVector3F();
            var   l_dist2 = (rposition - relp02);
            float l_l02   = l_dist2.Length();

            var   l_r03   = (float)Pos03n.Value.Scale.X;
            var   relp03  = (Pos03n.Value.Position).ToVector3F();
            var   l_dist3 = (rposition - relp03);
            float l_l03   = l_dist3.Length();

            var   l_r04   = (float)Pos04n.Value.Scale.X;
            var   relp04  = (Pos04n.Value.Position).ToVector3F();
            var   l_dist4 = (rposition - relp04);
            float l_l04   = l_dist4.Length();

            var f = ((ResPos1.Value.Position - PosCenter.Value.Position) / sc).ToVector3F().GetNormalize();
            SphericalDirectionF sd = new SphericalDirectionF(f.X, f.Y);
            float       ax         = MathEx.Acos(f.X);
            float       ay         = MathEx.Asin(f.X);
            QuaternionF q          = new AnglesF().ToQuaternion();


            if (l_l01 <= l_r01)
            {
                var relp1 = matrix4f * Pos1n.Value.Position.ToVector3F();
                result = relp1;
            }
            if (l_l02 <= l_r02)
            {
                var relp2 = matrix4f * Pos2n.Value.Position.ToVector3F();;
                result = relp2;
            }
            if (l_l03 <= l_r03)
            {
                var relp3 = matrix4f * Pos3n.Value.Position.ToVector3F();;
                result = relp3;
            }
            if (l_l04 <= l_r04)
            {
                var relp4 = matrix4f * Pos4n.Value.Position.ToVector3F();;
                result = relp4;
            }
        }
Exemplo n.º 12
0
 public static void Negate(ref SphericalDirectionF v, out SphericalDirectionF result)
 {
     result.Horizontal = -v.Horizontal;
     result.Vertical   = -v.Vertical;
 }
Exemplo n.º 13
0
 public static void Subtract(ref SphericalDirectionF v1, ref SphericalDirectionF v2, out SphericalDirectionF result)
 {
     result.Horizontal = v1.Horizontal - v2.Horizontal;
     result.Vertical   = v1.Vertical - v2.Vertical;
 }