Aiv.Fast2D.Mesh.ApplyMatrix C# (CSharp) Method

ApplyMatrix() private method

private ApplyMatrix ( ) : void
return void
        private void ApplyMatrix()
        {
            if (this.noMatrix)
                return;

            // WARNING !!! OpenTK uses row-major while OpenGL uses column-major
            Matrix4 m =
                Matrix4.CreateTranslation(-this.pivot.X, -this.pivot.Y, 0) *
            #if !__MOBILE__
                Matrix4.CreateScale(this.scale.X, this.scale.Y, 1) *
            #else
                Matrix4.Scale(this.scale.X, this.scale.Y, 1) *
            #endif
                Matrix4.CreateRotationZ(this.rotation) *
                // here we do not re-add the pivot, so translation is pivot based too
                Matrix4.CreateTranslation(this.position.X, this.position.Y, 0);

            if (this.Camera != null)
            {
                m *= this.Camera.Matrix();
            }
            else if (Window.Current.CurrentCamera != null)
            {
                m *= Window.Current.CurrentCamera.Matrix();
            }

            Matrix4 mvp = m * Window.Current.OrthoMatrix;

            // pass the matrix to the shader
            this.shader.SetUniform("mvp", mvp);
        }