minecraft-in-24h-jam/objects/obj_camera/Draw_0.gml

18 lines
594 B
Plaintext
Raw Normal View History

draw_clear(c_black);
var camera = camera_get_active();
var xfrom = obj_player.x;
var yfrom = obj_player.y;
var zfrom = obj_player.z;
var xto = xfrom + dcos( obj_player.look_dir );
var yto = yfrom + dsin( obj_player.look_dir );
var zto = zfrom + dsin( obj_player.look_pitch );
var viewmat = matrix_build_lookat(xfrom, yfrom, zfrom, xto, yto, zto, 0, 0, -1 );
var projmat = matrix_build_projection_perspective_fov( CAMERA_FOV, WINDOW_ASPECT, CAMERA_ZNEAR, CAMERA_ZFAR );
camera_set_view_mat( camera, viewmat );
camera_set_proj_mat( camera, projmat );
camera_apply( camera );