RE: ldc.camera.setThirdPerson API
2021-09-01, 10:34 (This post was last modified: 2021-09-01, 10:36 by David Manley.)
2021-09-01, 10:34 (This post was last modified: 2021-09-01, 10:36 by David Manley.)
(2021-08-31, 17:54)Roland Melkert Wrote: [quote pid="42618" dateline="1630401603"]
The parameters are:
yaw, moves the camera around the look at point like the hands on a clock.
tilt, indirectly controls the 'height' of the camera stand.
roll, rotates the camera around its looking direction. e.g. 180 degrees is like holding your camera up side down while taking a picture.
LD4DStuido didn't have the roll option, but it felt more complete to always offer yaw,tilt and roll parameters for all the camera variants.
In practice you'll usually have a static tilt and a roll of zero.
[/quote]
Thank you Roland, that helped a lot. I can now demonstrate a comparison between the standard camera view rotation (from the samples scripts) and a customised rotation, which allows a user to select the degrees to rotate, the duration of the rotation while using the current view as the animation start point.
If anyone wants this rotation script, it is listed here:
Code:
function animation_parameter_prompt_gf()
-- Establish the animation's parameters.
local rotation_ln = ldc.dialog.runInput("Rotate through how many degrees?")
local duration_ln = ldc.dialog.runInput('Duration of the animation?')
if (rotation_ln ~= "") then
rotation_gn = tonumber(rotation_ln)
end
if (duration_ln ~= "") then
duration_gn = tonumber(duration_ln)
local ani_lo = ldc.animation('Configured Y-Axis Rotation')
-- Set the animation length.
ani_lo:setLength(duration_gn)
end
-- Update the macro hint.
local macro_lo=ldc.macro('Rotation Parameters')
macro_lo:setHint
(
'Set values for parameter driven rotation (' ..
tostring(rotation_gn) .. ' degrees for ' .. tostring(duration_gn) ..
' seconds).'
)
end -- animation_paramter_prompt_gf
function register()
-- Establish animation parameter defaults should the parameter macro not
-- be called.
rotation_gn = 360
duration_gn = 10
-- Macro which will prompt for the animation rotation parameters.
local macro_lo=ldc.macro('Rotation Parameters')
macro_lo:setHint
(
'Set values for parameter driven rotation (' ..
tostring(rotation_gn) .. ' degrees for ' .. tostring(duration_gn) ..
' seconds).'
)
macro_lo:setEvent('run', 'animation_parameter_prompt_gf')
-- Rotation driven by parameters.
local ani_lo=ldc.animation('Configured Y-Axis Rotation')
ani_lo:setLength(duration_gn)
ani_lo:setEvent('start', 'onRotateStart')
ani_lo:setEvent('frame', 'onRotateFrame')
end -- register
function onRotateFrame()
-- Rotate a 3rd person camera around the point the camera is looking at.
local ani_lo = ldc.animation.getCurrent()
local angle_ln = yaw_start_angle_gn + (ani_lo:getFrameTime() /
ani_lo:getLength() * rotation_gn)
local cam_lo = ldc.camera()
cam_lo:setThirdPerson
(
camera_look_at_go,
camera_distance_from_gn,
angle_ln,
pitch_angle_gn,
0
)
cam_lo:apply(0)
end -- onFrame
function onRotateStart()
-- Want to use the current camera view as the animation start point
-- and rotate around the Y axis.
local cam_lo = ldc.view():getCamera()
cam_lo:setMode(3)
-- The camera's "looking at" point and distance from it are required when
-- setting the camera position for each rotation step.
camera_look_at_go = cam_lo:getLookAt()
camera_distance_from_gn = cam_lo:getDistance()
-- Need the camera current yaw and tile as the animation rotation start points.
yaw_start_angle_gn = cam_lo:getYaw()
pitch_angle_gn = cam_lo:getTilt()
end -- onStart
register()
Regards,
David