diff --git a/lowpoly-walking-simulator/lowpoly-walking-simulator.yyp b/lowpoly-walking-simulator/lowpoly-walking-simulator.yyp index d0c5826..6f9521c 100644 --- a/lowpoly-walking-simulator/lowpoly-walking-simulator.yyp +++ b/lowpoly-walking-simulator/lowpoly-walking-simulator.yyp @@ -36,13 +36,14 @@ "resources":[ {"id":{"name":"OpenVR","path":"extensions/OpenVR/OpenVR.yy",},}, {"id":{"name":"obj_camera","path":"objects/obj_camera/obj_camera.yy",},}, + {"id":{"name":"obj_controller_test","path":"objects/obj_controller_test/obj_controller_test.yy",},}, {"id":{"name":"obj_init","path":"objects/obj_init/obj_init.yy",},}, {"id":{"name":"obj_test","path":"objects/obj_test/obj_test.yy",},}, {"id":{"name":"obj_vr_system","path":"objects/obj_vr_system/obj_vr_system.yy",},}, {"id":{"name":"rm_game","path":"rooms/rm_game/rm_game.yy",},}, {"id":{"name":"rm_init","path":"rooms/rm_init/rm_init.yy",},}, {"id":{"name":"create_projection_matrix","path":"scripts/create_projection_matrix/create_projection_matrix.yy",},}, - {"id":{"name":"create_view_matrix","path":"scripts/create_view_matrix/create_view_matrix.yy",},}, + {"id":{"name":"transpose_matrix","path":"scripts/transpose_matrix/transpose_matrix.yy",},}, {"id":{"name":"Shader1","path":"shaders/Shader1/Shader1.yy",},}, {"id":{"name":"spr_test","path":"sprites/spr_test/spr_test.yy",},}, ], diff --git a/lowpoly-walking-simulator/objects/obj_camera/Create_0.gml b/lowpoly-walking-simulator/objects/obj_camera/Create_0.gml index 7fca142..556bf31 100644 --- a/lowpoly-walking-simulator/objects/obj_camera/Create_0.gml +++ b/lowpoly-walking-simulator/objects/obj_camera/Create_0.gml @@ -1,9 +1,42 @@ /// @description 여기에 설명 삽입 // 이 에디터에 코드를 작성할 수 있습니다 -view_matrix = create_view_matrix(0,0,0, - 1,0,0, - 0,1,0, - 0,0,1 - ); -projection_matrix = create_projection_matrix(16,9,8,6000); \ No newline at end of file +global.camera_x = 0; +global.camera_y = 0; +global.camera_z = 0; +global.camera_pitch = 0; +global.camera_yaw = 0; +global.camera_roll = 0; + +global.projection_matrix = create_projection_matrix(16,9,8,6000); + +function set_view_matrix(){ + global.view_pos_matrix = [ + 1,0,0,-global.camera_x, + 0,1,0,-global.camera_y, + 0,0,1,-global.camera_z, + 0,0,0,1 + ]; + var view_yaw_rotation_matrix = [ + cos(global.camera_yaw),0,-sin(global.camera_yaw),0, + 0, 1,0, 0, + sin(global.camera_yaw),0,cos(global.camera_yaw), 0, + 0, 0,0, 1 + ]; + var view_pitch_rotation_matrix = [ + 1,0,0,0, + 0,cos(global.camera_pitch),sin(global.camera_pitch),0, + 0,-sin(global.camera_pitch),cos(global.camera_pitch),0, + 0,0,0,1 + ]; + var view_roll_rotation_matrix = [ + cos(global.camera_roll),sin(global.camera_roll),0,0, + -sin(global.camera_roll),cos(global.camera_roll),0,0, + 0,0,1,0, + 0,0,0,1 + ]; + global.view_rotation_matrix = matrix_multiply(view_roll_rotation_matrix,matrix_multiply(view_pitch_rotation_matrix,view_yaw_rotation_matrix)); +} + +global.camera_z = -1000; +set_view_matrix(); \ No newline at end of file diff --git a/lowpoly-walking-simulator/objects/obj_camera/Draw_0.gml b/lowpoly-walking-simulator/objects/obj_camera/Draw_0.gml index 9bbce1f..127599c 100644 --- a/lowpoly-walking-simulator/objects/obj_camera/Draw_0.gml +++ b/lowpoly-walking-simulator/objects/obj_camera/Draw_0.gml @@ -1,7 +1,9 @@ /// @description 여기에 설명 삽입 // 이 에디터에 코드를 작성할 수 있습니다 + +set_view_matrix(); var _camera = camera_get_active(); -camera_set_view_mat(_camera,matrix_build_lookat(0,0,-1000,500,500,0,0,0,1)); -camera_set_proj_mat(_camera,projection_matrix); +camera_set_view_mat(_camera,transpose_matrix(matrix_multiply(global.view_rotation_matrix,global.view_pos_matrix),4,4)); +camera_set_proj_mat(_camera,transpose_matrix(global.projection_matrix,4,4)); camera_apply(_camera); \ No newline at end of file diff --git a/lowpoly-walking-simulator/objects/obj_controller_test/Create_0.gml b/lowpoly-walking-simulator/objects/obj_controller_test/Create_0.gml new file mode 100644 index 0000000..2869b8f --- /dev/null +++ b/lowpoly-walking-simulator/objects/obj_controller_test/Create_0.gml @@ -0,0 +1,9 @@ +/// @description 여기에 설명 삽입 +// 이 에디터에 코드를 작성할 수 있습니다 +spd = 10; + +mouse_sensitivity = 0.001; +mouse_x_prev = device_mouse_x_to_gui(0); +mouse_y_prev = device_mouse_x_to_gui(0); + +window_mouse_set_locked(true); \ No newline at end of file diff --git a/lowpoly-walking-simulator/objects/obj_controller_test/Step_0.gml b/lowpoly-walking-simulator/objects/obj_controller_test/Step_0.gml new file mode 100644 index 0000000..cac2dcb --- /dev/null +++ b/lowpoly-walking-simulator/objects/obj_controller_test/Step_0.gml @@ -0,0 +1,23 @@ +/// @description 여기에 설명 삽입 +// 이 에디터에 코드를 작성할 수 있습니다 +a = 0; +if(keyboard_check(ord("W"))){ + a = 1; + global.camera_x += spd*sin(global.camera_yaw); + global.camera_z += spd*cos(global.camera_yaw); +} +if(keyboard_check(ord("A"))){ + global.camera_x += -spd*cos(global.camera_yaw); + global.camera_z += spd*sin(global.camera_yaw); +} +if(keyboard_check(ord("S"))){ + global.camera_x += -spd*sin(global.camera_yaw); + global.camera_z += -spd*cos(global.camera_yaw); +} +if(keyboard_check(ord("D"))){ + global.camera_x += spd*cos(global.camera_yaw); + global.camera_z += -spd*sin(global.camera_yaw); +} + +global.camera_yaw += mouse_sensitivity*(window_mouse_get_delta_x()); +global.camera_pitch += -mouse_sensitivity*(window_mouse_get_delta_y()); \ No newline at end of file diff --git a/lowpoly-walking-simulator/objects/obj_controller_test/obj_controller_test.yy b/lowpoly-walking-simulator/objects/obj_controller_test/obj_controller_test.yy new file mode 100644 index 0000000..d20190b --- /dev/null +++ b/lowpoly-walking-simulator/objects/obj_controller_test/obj_controller_test.yy @@ -0,0 +1,36 @@ +{ + "$GMObject":"", + "%Name":"obj_controller_test", + "eventList":[ + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + ], + "managed":true, + "name":"obj_controller_test", + "overriddenProperties":[], + "parent":{ + "name":"Objects", + "path":"folders/Objects.yy", + }, + "parentObjectId":null, + "persistent":false, + "physicsAngularDamping":0.1, + "physicsDensity":0.5, + "physicsFriction":0.2, + "physicsGroup":1, + "physicsKinematic":false, + "physicsLinearDamping":0.1, + "physicsObject":false, + "physicsRestitution":0.1, + "physicsSensor":false, + "physicsShape":1, + "physicsShapePoints":[], + "physicsStartAwake":true, + "properties":[], + "resourceType":"GMObject", + "resourceVersion":"2.0", + "solid":false, + "spriteId":null, + "spriteMaskId":null, + "visible":true, +} \ No newline at end of file diff --git a/lowpoly-walking-simulator/options/extensions/display_mouse_lock.json b/lowpoly-walking-simulator/options/extensions/display_mouse_lock.json new file mode 100644 index 0000000..afe75e9 --- /dev/null +++ b/lowpoly-walking-simulator/options/extensions/display_mouse_lock.json @@ -0,0 +1,4 @@ +{ + "$GMExtensionConfigSet": "GMExtensionConfigSet", + "configurables": null +} \ No newline at end of file diff --git a/lowpoly-walking-simulator/rooms/rm_game/rm_game.yy b/lowpoly-walking-simulator/rooms/rm_game/rm_game.yy index 34898c2..748f5f9 100644 --- a/lowpoly-walking-simulator/rooms/rm_game/rm_game.yy +++ b/lowpoly-walking-simulator/rooms/rm_game/rm_game.yy @@ -17,6 +17,7 @@ {"name":"inst_141D2E27","path":"rooms/rm_game/rm_game.yy",}, {"name":"inst_1003B785","path":"rooms/rm_game/rm_game.yy",}, {"name":"inst_709C3E3F","path":"rooms/rm_game/rm_game.yy",}, + {"name":"inst_6DFDD5B9","path":"rooms/rm_game/rm_game.yy",}, ], "isDnd":false, "layers":[ @@ -31,6 +32,7 @@ {"$GMRInstance":"","%Name":"inst_141D2E27","colour":4294967295,"frozen":false,"hasCreationCode":false,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_141D2E27","objectId":{"name":"obj_test","path":"objects/obj_test/obj_test.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":1.0,"scaleY":1.0,"x":-608.0,"y":640.0,}, {"$GMRInstance":"","%Name":"inst_1003B785","colour":4294967295,"frozen":false,"hasCreationCode":false,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_1003B785","objectId":{"name":"obj_test","path":"objects/obj_test/obj_test.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":1.0,"scaleY":1.0,"x":-480.0,"y":-544.0,}, {"$GMRInstance":"","%Name":"inst_709C3E3F","colour":4294967295,"frozen":false,"hasCreationCode":false,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_709C3E3F","objectId":{"name":"obj_test","path":"objects/obj_test/obj_test.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":1.0,"scaleY":1.0,"x":640.0,"y":-864.0,}, + {"$GMRInstance":"","%Name":"inst_6DFDD5B9","colour":4294967295,"frozen":false,"hasCreationCode":false,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_6DFDD5B9","objectId":{"name":"obj_controller_test","path":"objects/obj_controller_test/obj_controller_test.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":21.0,"scaleY":19.0,"x":0.0,"y":0.0,}, ],"layers":[],"name":"Instances","properties":[],"resourceType":"GMRInstanceLayer","resourceVersion":"2.0","userdefinedDepth":false,"visible":true,}, {"$GMRInstanceLayer":"","%Name":"camera","depth":100,"effectEnabled":true,"effectType":null,"gridX":32,"gridY":32,"hierarchyFrozen":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"inheritSubLayers":true,"inheritVisibility":true,"instances":[ {"$GMRInstance":"","%Name":"inst_1DC451FD","colour":4294967295,"frozen":false,"hasCreationCode":false,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_1DC451FD","objectId":{"name":"obj_camera","path":"objects/obj_camera/obj_camera.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":1.0,"scaleY":1.0,"x":0.0,"y":0.0,}, diff --git a/lowpoly-walking-simulator/rooms/rm_init/rm_init.yy b/lowpoly-walking-simulator/rooms/rm_init/rm_init.yy index a52fa71..2ce440e 100644 --- a/lowpoly-walking-simulator/rooms/rm_init/rm_init.yy +++ b/lowpoly-walking-simulator/rooms/rm_init/rm_init.yy @@ -38,7 +38,7 @@ }, "sequenceId":null, "views":[ - {"hborder":32,"hport":768,"hspeed":-1,"hview":768,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":1366,"wview":1366,"xport":0,"xview":0,"yport":0,"yview":0,}, + {"hborder":32,"hport":1080,"hspeed":-1,"hview":1080,"inherit":false,"objectId":null,"vborder":32,"visible":true,"vspeed":-1,"wport":1920,"wview":1920,"xport":0,"xview":0,"yport":0,"yview":0,}, {"hborder":32,"hport":768,"hspeed":-1,"hview":768,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":1366,"wview":1366,"xport":0,"xview":0,"yport":0,"yview":0,}, {"hborder":32,"hport":768,"hspeed":-1,"hview":768,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":1366,"wview":1366,"xport":0,"xview":0,"yport":0,"yview":0,}, {"hborder":32,"hport":768,"hspeed":-1,"hview":768,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":1366,"wview":1366,"xport":0,"xview":0,"yport":0,"yview":0,}, @@ -50,7 +50,7 @@ "viewSettings":{ "clearDisplayBuffer":true, "clearViewBackground":false, - "enableViews":false, + "enableViews":true, "inheritViewSettings":false, }, "volume":1.0, diff --git a/lowpoly-walking-simulator/scripts/create_projection_matrix/create_projection_matrix.gml b/lowpoly-walking-simulator/scripts/create_projection_matrix/create_projection_matrix.gml index 6702586..38f43b6 100644 --- a/lowpoly-walking-simulator/scripts/create_projection_matrix/create_projection_matrix.gml +++ b/lowpoly-walking-simulator/scripts/create_projection_matrix/create_projection_matrix.gml @@ -6,7 +6,7 @@ function create_projection_matrix(w, h, n, f){ return [ n/r, 0, 0, 0, 0, n/t, 0, 0, - 0, 0, f/(f-n), 1, - 0, 0, -n*f/(f-n), 0 + 0, 0, f/(f-n), -n*f/(f-n), + 0, 0, 1, 0 ]; } \ No newline at end of file diff --git a/lowpoly-walking-simulator/scripts/create_view_matrix/create_view_matrix.gml b/lowpoly-walking-simulator/scripts/create_view_matrix/create_view_matrix.gml deleted file mode 100644 index c526e96..0000000 --- a/lowpoly-walking-simulator/scripts/create_view_matrix/create_view_matrix.gml +++ /dev/null @@ -1,10 +0,0 @@ -// v2.3.0에 대한 스크립트 어셋 변경됨 자세한 정보는 -// https://help.yoyogames.com/hc/en-us/articles/360005277377 참조 -function create_view_matrix(xx,yy,zz,rx,ry,rz,ux,uy,uz,fx,fy,fz){ - return [ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 1 - ]; -} \ No newline at end of file diff --git a/lowpoly-walking-simulator/scripts/transpose_matrix/transpose_matrix.gml b/lowpoly-walking-simulator/scripts/transpose_matrix/transpose_matrix.gml new file mode 100644 index 0000000..20c7bf2 --- /dev/null +++ b/lowpoly-walking-simulator/scripts/transpose_matrix/transpose_matrix.gml @@ -0,0 +1,12 @@ +// v2.3.0에 대한 스크립트 어셋 변경됨 자세한 정보는 +// https://help.yoyogames.com/hc/en-us/articles/360005277377 참조 +function transpose_matrix(original_arr,w,h){ + var _arr = []; + for(var i = 0; i < w; i++){ + for(var j = 0; j < h; j++){ + _arr[j + i*h] = original_arr[i + j*w]; + } + } + + return _arr; +} \ No newline at end of file diff --git a/lowpoly-walking-simulator/scripts/create_view_matrix/create_view_matrix.yy b/lowpoly-walking-simulator/scripts/transpose_matrix/transpose_matrix.yy similarity index 75% rename from lowpoly-walking-simulator/scripts/create_view_matrix/create_view_matrix.yy rename to lowpoly-walking-simulator/scripts/transpose_matrix/transpose_matrix.yy index 34336b8..2e75fb4 100644 --- a/lowpoly-walking-simulator/scripts/create_view_matrix/create_view_matrix.yy +++ b/lowpoly-walking-simulator/scripts/transpose_matrix/transpose_matrix.yy @@ -1,9 +1,9 @@ { "$GMScript":"", - "%Name":"create_view_matrix", + "%Name":"transpose_matrix", "isCompatibility":false, "isDnD":false, - "name":"create_view_matrix", + "name":"transpose_matrix", "parent":{ "name":"Scripts", "path":"folders/Scripts.yy",