Exemplo n.º 1
0
 public UIBackground(string _Name, Control _Parent)
     : base(_Name, _Parent)
 {
     Transformation = new Float3x3(1, 0, 0, 0, 1, 0, 0, 0, 1);
     shader = ShaderCompiler.Compile(System.IO.File.ReadAllText("Default.fx"));
     OnControllerInput += new OnControllerInputHandler(UIButton_OnControllerInput);
 }
Exemplo n.º 2
0
 public UIFloor(string _Name, Control _Parent)
     : base(_Name, _Parent)
 {
     RelativeToParent = false;
     ZoomedTransform = new Float3x3(0.9f, 0, 0, 0, 0.9f, 0, 0, 0, 1);
     OnControllerInput += new OnControllerInputHandler(UIButton_OnControllerInput);
 }
Exemplo n.º 3
0
 public void SetParameter(string _FieldName, Float3x3 _Value)
 {
     shader.Parameters[_FieldName].SetValue(new float[]
     {
         _Value.X.X,_Value.X.Y,_Value.X.Z,
         _Value.Y.X,_Value.Y.Y,_Value.Y.Z,
         _Value.T.X,_Value.T.Y,_Value.T.Z
     });
 }
Exemplo n.º 4
0
 public static Float3x3 operator *(Float3x3 _A, Float3x3 _B)
 {
     // THIS ONE WORKS
     Float3x3 ret = new Float3x3(
         Float3.Dot(_A.Row[0], _B.Column[0]), Float3.Dot(_A.Row[0], _B.Column[1]), Float3.Dot(_A.Row[0], _B.Column[2]),
         Float3.Dot(_A.Row[1], _B.Column[0]), Float3.Dot(_A.Row[1], _B.Column[1]), Float3.Dot(_A.Row[1], _B.Column[2]),
         Float3.Dot(_A.Row[2], _B.Column[0]), Float3.Dot(_A.Row[2], _B.Column[1]), Float3.Dot(_A.Row[2], _B.Column[2]));
     return ret;
 }
Exemplo n.º 5
0
        public UIAnalog(string _Name, Control _Parent)
            : base(_Name, _Parent)
        {
            Transformation = new Float3x3(0.1f, 0, 0, 0, 0.1f, 0, 0, 0, 1);
            ZoomedTransformation = new Float3x3(0.9f, 0, 0, 0, 0.9f, 0, 0, 0, 1);

            font = new SpriteFont("./content/Arial.png", "./content/Arial.xml");
            NormalTransformation = Transformation;
            OnControllerInput += new OnControllerInputHandler(UIButton_OnControllerInput);
        }
Exemplo n.º 6
0
        public UIButton(string _Name, Control _Parent)
            : base(_Name, _Parent)
        {
            Transformation = new Float3x3(0.1f, 0, 0, 0, 0.1f, 0, 0, 0, 0);
            shader = ShaderCompiler.Compile(System.IO.File.ReadAllText("Default.fx"));
            loadingshader = ShaderCompiler.Compile(System.IO.File.ReadAllText("Loading.fx"));

            font = new SpriteFont("./content/Arial.png", "./content/Arial.xml");

            OnControllerInput += new OnControllerInputHandler(UIButton_OnControllerInput);
        }
Exemplo n.º 7
0
        bool UIButton_OnControllerInput(UITouchEvent _Event)
        {
            Float3 mouse = new Float3(_Event.Position, 1);
            Float3x3 mat = GetTransformation();
            Float3x3 matinv = mat.Invert();
            Float2 localmouse = (mouse * matinv).XY;

            if (zoomed)
            {
                if (localmouse.Length() > 1 && _Event.Released)
                {
                    zoomed = false;
                    return true;
                }
                else
                {
                    if (_Event.Pressed)
                    {
                        OffsetAngle = -(float)Math.Atan2(localmouse.Y, localmouse.X);
                        OffsetValue = Value - OffsetAngle / ((float)Math.PI * 2);
                    }

                    float angle = -(float)Math.Atan2(localmouse.Y, localmouse.X);

                    float shortestangle = angle - OffsetAngle;
                    if (shortestangle > Math.PI) shortestangle = ((float)Math.PI * 2) - shortestangle;
                    if (shortestangle < -Math.PI) shortestangle = ((float)Math.PI * 2) + shortestangle;

                    Value += shortestangle / ((float)Math.PI * 2);

                    OffsetAngle = angle;

                    if (Value > 1) Value = 1f;
                    if (Value < 0) Value = 0;
                    return true;
                }
            }
            else
            {
                if (localmouse.Length() < 1 && _Event.Released)
                {
                    NormalTransformation = Transformation;
                    RelativeToParent = false;
                    zoomed = true;
                    BringToFront();
                    return true;
                }
            }
            return false;
        }
Exemplo n.º 8
0
 public override void Update()
 {
     OverviewTransform = Float3x3.Rotate(Rotation) * Float3x3.Scale(new Float2(0.5f, 0.2f)) * Float3x3.Translate(new Float2(0, ((float)Level - 2) / 4.0f));
     base.Update();
 }
Exemplo n.º 9
0
 public static Float3x3 Interpolate(Float3x3 _A, Float3x3 _B, float _T)
 {
     float t = _T;
     float t1 = 1 - t;
     Float3x3 result = new Float3x3(
      _A.X * t1 + _B.X * t,
      _A.Y * t1 + _B.Y * t,
      _A.T * t1 + _B.T * t);
     return result;
 }
Exemplo n.º 10
0
        public Float3x3 Invert()
        {
            Matrix m = new Matrix(
                X.X, X.Y, 0, X.Z,
                Y.X, Y.Y, 0, Y.Z,
                0, 0, 1, 0,
                T.X, T.Y, 0, T.Z);

            //m = Matrix.Transpose(Matrix.Invert(Matrix.Transpose(m)));
            m = Matrix.Invert(m);

            Float3x3 r = new Float3x3();
            r.X.X = m.M11;
            r.X.Y = m.M12;
            r.X.Z = m.M14;

            r.Y.X = m.M21;
            r.Y.Y = m.M22;
            r.Y.Z = m.M24;

            r.T.X = m.M41;
            r.T.Y = m.M42;
            r.T.Z = m.M44;

            return r;
        }