From decc2d3aa5ba8dc583dae5396a5ae8ca738412dd Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 25 Jul 2024 18:15:24 +0300 Subject: Lua api for Follow Camera control --- indra/newview/scripts/lua/test_camera_control.lua | 52 +++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 indra/newview/scripts/lua/test_camera_control.lua (limited to 'indra/newview/scripts/lua/test_camera_control.lua') diff --git a/indra/newview/scripts/lua/test_camera_control.lua b/indra/newview/scripts/lua/test_camera_control.lua new file mode 100644 index 0000000000..db76201932 --- /dev/null +++ b/indra/newview/scripts/lua/test_camera_control.lua @@ -0,0 +1,52 @@ +local Floater = require 'Floater' +local LLAgent = require 'LLAgent' +local leap = require 'leap' +local startup = require 'startup' +local inspect = require 'inspect' + +local flt = Floater('luafloater_camera_control.xml') + +function getValue(ctrl_name) + return flt:request({action="get_value", ctrl_name=ctrl_name}).value +end + +function setValue(ctrl_name, value) + flt:post({action="set_value", ctrl_name=ctrl_name, value=value}) +end + +function flt:commit_update_btn(event_data) + lock_focus = getValue('lock_focus_ctrl') + lock_camera = self:request({action="get_value", ctrl_name='lock_camera_ctrl'}).value + + local camera_pos = {getValue('cam_x'),getValue('cam_y'),getValue('cam_z')} + local focus_pos = {getValue('focus_x'),getValue('focus_y'),getValue('focus_z')} + + + LLAgent.setCamera{camera_pos=camera_pos,focus_pos=focus_pos, + focus_locked = lock_focus,camera_locked = lock_camera} + + self:post({action="add_text", ctrl_name="events_editor", + value = {'Updating FollowCam params', 'camera_pos:', camera_pos, 'focus_pos:', focus_pos, 'lock_focus:', lock_focus, 'lock_camera:', lock_camera}}) +end + +function flt:commit_agent_cam_btn(event_data) + agent_pos = LLAgent.getRegionPosition() + setValue('cam_x', math.floor(agent_pos[1])) + setValue('cam_y', math.floor(agent_pos[2])) + setValue('cam_z', math.floor(agent_pos[3])) +end + +function flt:commit_agent_focus_btn(event_data) + agent_pos = LLAgent.getRegionPosition() + setValue('focus_x', math.floor(agent_pos[1])) + setValue('focus_y', math.floor(agent_pos[2])) + setValue('focus_z', math.floor(agent_pos[3])) +end + +function flt:commit_reset_btn(event_data) + LLAgent.removeCamParams() + LLAgent.setFollowCamActive(false) +end + +startup.wait('STATE_LOGIN_WAIT') +flt:show() -- cgit v1.2.3 From 4edcebdb31b7d49faf94b60a66c9921e90e23899 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 25 Jul 2024 18:29:06 +0300 Subject: Script clean up --- indra/newview/scripts/lua/test_camera_control.lua | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'indra/newview/scripts/lua/test_camera_control.lua') diff --git a/indra/newview/scripts/lua/test_camera_control.lua b/indra/newview/scripts/lua/test_camera_control.lua index db76201932..e7ad69b473 100644 --- a/indra/newview/scripts/lua/test_camera_control.lua +++ b/indra/newview/scripts/lua/test_camera_control.lua @@ -1,8 +1,6 @@ local Floater = require 'Floater' local LLAgent = require 'LLAgent' -local leap = require 'leap' local startup = require 'startup' -local inspect = require 'inspect' local flt = Floater('luafloater_camera_control.xml') @@ -16,17 +14,16 @@ end function flt:commit_update_btn(event_data) lock_focus = getValue('lock_focus_ctrl') - lock_camera = self:request({action="get_value", ctrl_name='lock_camera_ctrl'}).value + lock_camera = getValue('lock_camera_ctrl') + local camera_pos = {getValue('cam_x'), getValue('cam_y'), getValue('cam_z')} + local focus_pos = {getValue('focus_x'), getValue('focus_y'), getValue('focus_z')} - local camera_pos = {getValue('cam_x'),getValue('cam_y'),getValue('cam_z')} - local focus_pos = {getValue('focus_x'),getValue('focus_y'),getValue('focus_z')} - - - LLAgent.setCamera{camera_pos=camera_pos,focus_pos=focus_pos, - focus_locked = lock_focus,camera_locked = lock_camera} + LLAgent.setCamera{camera_pos=camera_pos, focus_pos=focus_pos, + focus_locked=lock_focus, camera_locked=lock_camera} self:post({action="add_text", ctrl_name="events_editor", - value = {'Updating FollowCam params', 'camera_pos:', camera_pos, 'focus_pos:', focus_pos, 'lock_focus:', lock_focus, 'lock_camera:', lock_camera}}) + value = {'Updating FollowCam params', 'camera_pos:', camera_pos, 'focus_pos:', focus_pos, + 'lock_focus:', lock_focus, 'lock_camera:', lock_camera}}) end function flt:commit_agent_cam_btn(event_data) -- cgit v1.2.3 From ffeb738afda99fca98a9c1ba7704d7f6144da70c Mon Sep 17 00:00:00 2001 From: nat-goodspeed Date: Wed, 31 Jul 2024 06:30:19 -0400 Subject: Represent the many "LLAgent" "setCameraParams" args in an array. This encapsulates the boilerplate associated with passing each distinct parameter to its corresponding LLFollowCamMgr method. --- indra/newview/scripts/lua/test_camera_control.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/scripts/lua/test_camera_control.lua') diff --git a/indra/newview/scripts/lua/test_camera_control.lua b/indra/newview/scripts/lua/test_camera_control.lua index e7ad69b473..9b35cdf8cd 100644 --- a/indra/newview/scripts/lua/test_camera_control.lua +++ b/indra/newview/scripts/lua/test_camera_control.lua @@ -45,5 +45,5 @@ function flt:commit_reset_btn(event_data) LLAgent.setFollowCamActive(false) end -startup.wait('STATE_LOGIN_WAIT') +startup.wait('STATE_STARTED') flt:show() -- cgit v1.2.3