Example #1
0
 public Vertex(Float3 _Position, Float2 _UV, Float4 _Color)
 {
     Position = _Position;
     UV = _UV;
     R = G = B = A = 0;
     Color = _Color;
 }
Example #2
0
        /// <summary>
        /// draws a rectangle using the provided image to the active render target
        /// </summary>
        /// <param name="_A">Left upper Coordinate</param>
        /// <param name="_B">Right upper Coordinate</param>
        /// <param name="_C">Left lower Coordinate</param>
        /// <param name="_D">Right lower Coordinate</param>
        /// <param name="_Image"></param>
        public static void DrawRectangle(Float3 _A, Float3 _B, Float3 _C, Float3 _D, Float2 _UVA, Float2 _UVB, Float2 _UVC, Float2 _UVD)
        {
            device.RenderState.DepthBufferEnable = false;
            device.RenderState.CullMode = CullMode.None;

            VertexBuffer vbo = new VertexBuffer(Graphics.device, Marshal.SizeOf(typeof(Vertex)) * 4, BufferUsage.None);
            VertexPositionTexture[] vertices = new VertexPositionTexture[]
            {
                new VertexPositionTexture(new Vector3(_A.X,_A.Y,_A.Z), new Vector2(_UVA.X,_UVA.Y)),
                new VertexPositionTexture(new Vector3(_B.X,_B.Y,_B.Z), new Vector2(_UVB.X,_UVB.Y)),
                new VertexPositionTexture(new Vector3(_C.X,_C.Y,_C.Z), new Vector2(_UVC.X,_UVC.Y)),
                new VertexPositionTexture(new Vector3(_D.X,_D.Y,_D.Z), new Vector2(_UVD.X,_UVD.Y))
            };
            vbo.SetData(vertices);
            device.VertexDeclaration = new VertexDeclaration(device, VertexPositionTexture.VertexElements);
            device.DrawUserPrimitives(PrimitiveType.TriangleStrip, vertices, 0, 2);
        }
Example #3
0
 public static float Length(Float3 _A)
 {
     return _A.Length();
 }
Example #4
0
 //Methods
 public static float Dot(Float3 _A, Float3 _B)
 {
     return _A.X * _B.X + _A.Y * _B.Y + _A.Z * _B.Z;
 }
Example #5
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;
                    HandleChildInputFirst = false;
                    return true;
                }
                else
                {
                    if (_Event.Released)
                    {
                        //handle stuff here

                        return true;
                    }
                }
            }
            else
            {
                if (localmouse.Length() < 1 && zoomstate < 0.1f && _Event.Released&&!zoomed)
                {
                    zoomed = true;
                    HandleChildInputFirst = true;
                    BringToFront();
                    return true;
                }
            }
            return false;
        }
 bool UIButton_OnControllerInput(UITouchEvent _Event)
 {
     Float3 mouse = new Float3(_Event.Position, 1);
     Float3x3 mat = GetTransformation();
     Float3x3 matinv = mat.Invert();
     Float2 localmouse = (mouse * matinv).XY;
     Value = (int)((localmouse.X * 0.5f + 0.5f) * 100);
     return false;
 }
Example #7
0
 public Float3x3(float _XX, float _XY, float _XZ, float _YX, float _YY, float _YZ, float _TX, float _TY, float _TZ)
 {
     X = new Float3(_XX, _XY, _XZ);
     Y = new Float3(_YX, _YY, _YZ);
     T = new Float3(_TX, _TY, _TZ);
 }
Example #8
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;
        }
Example #9
0
 public Vertex(Float3 _Position, Float2 _UV)
 {
     Position = _Position;
     UV = _UV;
     R = G = B = A = 255;
 }
Example #10
0
 public static Float3 operator *(Float3 _V, Float3x3 _M)
 {
     Float3 ret = new Float3(
         Float3.Dot(_V, _M.Column[0]),
         Float3.Dot(_V, _M.Column[1]),
         Float3.Dot(_V, _M.Column[2]));
     return ret;
 }
Example #11
0
        /// <summary>
        /// draws a rectangle using the provided image to the active render target
        /// </summary>
        /// <param name="_A">Left upper Coordinate</param>
        /// <param name="_B">Right upper Coordinate</param>
        /// <param name="_C">Left lower Coordinate</param>
        /// <param name="_D">Right lower Coordinate</param>
        /// <param name="_Image"></param>
        public static void DrawRectangle(Float3 _A, Float3 _B, Float3 _C, Float3 _D, Float2 _UVA, Float2 _UVB, Float2 _UVC, Float2 _UVD)
        {
            device.RenderState.DepthBufferEnable = false;
            device.RenderState.CullMode = CullMode.None;

            VertexBuffer vbo = new VertexBuffer(Graphics.device, Marshal.SizeOf(typeof(Vertex)) * 4, BufferUsage.None);
            Vertex[] vertices = new Vertex[]
            {
                new Vertex(_A, _UVA),
                new Vertex(_B, _UVB),
                new Vertex(_C, _UVC),
                new Vertex(_D, _UVD)
            };
            vbo.SetData(vertices);
            device.VertexDeclaration = new VertexDeclaration(device, Vertex.VertexElements);
            device.DrawUserPrimitives(PrimitiveType.TriangleStrip, vertices, 0, 2);
        }
Example #12
0
 public Float3x3(Float3 _X, Float3 _Y, Float3 _T)
 {
     X = _X;
     Y = _Y;
     T = _T;
 }
Example #13
0
 public static Float4x4 Translate(Float3 _Translation)
 {
     return new Float4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, _Translation.X, _Translation.Y, _Translation.Z, 1);
 }
Example #14
0
 public static Float4x4 Scale(Float3 _Scale)
 {
     return new Float4x4(_Scale.X, 0, 0, 0, 0, _Scale.Y, 0, 0, 0, 0, _Scale.Z, 0, 0, 0, 0, 1);
 }
Example #15
0
 public static Float3 Normalize(Float3 _A)
 {
     return _A / _A.Length();
 }
Example #16
0
 public Vertex(Float3 _Position, Float2 _UV)
 {
     Position = _Position;
     UV = _UV;
 }
Example #17
0
 bool UIButton_OnControllerInput(UITouchEvent _Event)
 {
     Float3 mouse = new Float3(_Event.Position, 1);
     Float3x3 mat = GetTransformation().Invert();
     Float2 localmouse = (mouse * mat).XY;
     if (localmouse.Length() < 1 && _Event.Released)
     {
         Checked = !Checked;
         return true;
     }
     return false;
 }
Example #18
0
 /// <summary>
 /// draws a rectangle using the provided image to the active render target
 /// </summary>
 /// <param name="_A">Left upper Coordinate</param>
 /// <param name="_B">Right upper Coordinate</param>
 /// <param name="_C">Left lower Coordinate</param>
 /// <param name="_D">Right lower Coordinate</param>
 /// <param name="_Image"></param>
 public static void DrawRectangle(Float3 _A, Float3 _B, Float3 _C, Float3 _D)
 {
     DrawRectangle(_A, _B, _C, _D, new Float2(0, 0), new Float2(1, 0), new Float2(0, 1), new Float2(1, 1));
 }
Example #19
0
 public void SetParameter(string _FieldName, Float3 _Float3)
 {
     shader.Parameters[_FieldName].SetValue(new Vector3(_Float3.X, _Float3.Y, _Float3.Z));
 }
Example #20
0
 public Float3x3()
 {
     X = new Float3(1, 0, 0); Y = new Float3(0, 1, 0); T = new Float3(0, 0, 1);
 }