Example #1
0
        private static Matrix4x4 CreateViewportTransform(int width, int height, float viewportScale)
        {
            var actualWidth  = (int)(width * viewportScale);
            var actualHeight = (int)(height * viewportScale);
            var actualXmin   = (width - actualWidth) / 2;
            var actualYmin   = (height - actualHeight) / 2;

            var viewport = Matrix4x4Utils.Viewport(actualXmin, actualYmin, actualWidth, actualHeight);

            return(viewport);
        }
Example #2
0
        private static Matrix4x4 CreateProjectionTransform(bool usePerspectiveProjection, Vector3 center, Vector3 eye)
        {
            if (!usePerspectiveProjection)
            {
                return(Matrix4x4.Identity);
            }

            var distance = new Vector3(center.X - eye.X, center.Y - eye.Y, center.Z - eye.Z).Length();

            return(Matrix4x4Utils.OrthographicProjection(distance));
        }
Example #3
0
        private static Matrix4x4 CreateViewTransform(Vector3 center, Vector3 eye, Vector3 up)
        {
            var view = Matrix4x4Utils.LookAt(center, eye, up);

            return(view);
        }