Undertale Yellow script viewer

← back to main script listing

gml_GlobalScript_d3d_set_perspective

(view raw script w/o annotations or w/e)
1
function d3d_set_perspective(argument0) //gml_Script_d3d_set_perspective
2
{
3
    var __persp = argument0
4
    if (global.__d3d == false)
5
        __persp = false
6
    var __mat = camera_get_proj_mat(camera_get_default())
7
    if __persp
8
        __mat[11] = 1
9
    else
10
        __mat[11] = 0
11
    camera_set_proj_mat(camera_get_default(), __mat)
12
    var __numcams = 0
13
    var __cams = []
14
    for (var __i = 0; __i < 8; __i++)
15
    {
16
        if (view_camera[__i] != -1)
17
        {
18
            __cams[(__numcams * 3)] = view_camera[__i]
19
            __cams[(__numcams * 3 + 1)] = view_camera[__i]
20
            __cams[(__numcams * 3 + 2)] = view_camera[__i]
21
            __numcams++
22
        }
23
    }
24
    for (var __currroom = room_first; __currroom != -1; __currroom = room_next(__currroom))
25
    {
26
        for (__i = 0; __i < 8; __i++)
27
        {
28
            var __cam = room_get_camera(__currroom, __i)
29
            if (__cam != -1)
30
            {
31
                __cams[__numcams] = __cam
32
                __numcams++
33
            }
34
        }
35
    }
36
    for (__i = 0; __i < __numcams; __i++)
37
    {
38
        __cam = __cams[__i]
39
        __mat = camera_get_proj_mat(__cam)
40
        var __ispersp = __mat[11] != 0
41
        if (__ispersp != __persp)
42
        {
43
            if (camera_get_view_width(__cam) > 0)
44
            {
45
                var __width = camera_get_view_width(__cam)
46
                var __height = camera_get_view_height(__cam)
47
                if __persp
48
                {
49
                    var __projmat = matrix_build_projection_perspective(1, (-((__height / __width))), 1, 32000)
50
                    camera_set_proj_mat(__cam, __projmat)
51
                }
52
                else
53
                {
54
                    __projmat = matrix_build_projection_ortho(__width, __height, -16000, 16000)
55
                    camera_set_proj_mat(__cam, __projmat)
56
                }
57
            }
58
        }
59
    }
60
}