diff --git a/camera.lua b/camera.lua index 8eb30b2a8fbc45ecbda4a30e5a7334c332e14865..d7790e7bcc34212ff0d63c5ae3e114f87a1f7d4d 100644 --- a/camera.lua +++ b/camera.lua @@ -6,11 +6,11 @@ camera = {class = "camera"} camera.__index = camera -- Creates a camera at transform t with horizontal fov f, --- near plane distance nd and far plane distance fd -function camera.new(t, f, nd, fd) +-- near plane distance nd, far plane distance fd, and sceen shift (xs, ys) +function camera.new(t, f, xs, ys, nd, fd) local xres, yres, _, _ = aegisub.video_size() local c = {transform = t, aspect = xres / yres, fov = f or 80 / 180 * math.pi, - near = nd or 1, far = fd or 1000000000} + near = nd or 1, far = fd or 1000000000, shiftx = xs or 0, shifty = ys or 0} setmetatable(c, camera) return c end diff --git a/examples/Test.ass b/examples/Test.ass index 74559ac8e96fdef746b7bf4bf5dd822947bd1684..2a981dcdf6716dd22341dcfa427498aa5a3f8ff1 100644 --- a/examples/Test.ass +++ b/examples/Test.ass @@ -14,8 +14,7 @@ Last Style Storage: Default Video File: ?dummy:24.000000:120:1920:1080:0:0:0: Video AR Value: 1.777778 Video Zoom Percent: 0.500000 -Scroll Position: 4 -Active Line: 7 +Active Line: 5 [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding diff --git a/shape.lua b/shape.lua index 3cb3ff2a37764ab4e9728e49bdc161495ccc0342..cbf57cfed2be422d252bd9352faac9e7856ed92f 100644 --- a/shape.lua +++ b/shape.lua @@ -102,6 +102,7 @@ function shape:draw(subs, line, tags, cull, cam, ambient, lights) local camp = cam and cam.transform:position(true) or vector.zero(3) local xres, yres, _, _ = aegisub.video_size() + local hxr, hyr = xres / 2, yres / 2 local m = proj * view * tm @@ -119,8 +120,8 @@ function shape:draw(subs, line, tags, cull, cam, ambient, lights) local l = table.copy(line) l.text = (tags and "{" .. tags .. "}" or "") .. (face.tags and "{" .. face.tags .. "}" or "") - .. "{\\an7\\pos(" .. (xres / 2) .. ", " .. (yres / 2) .. ")\\p1}" - .. "m " .. (v:x() * xres / 2) .. " " .. (-v:y() * yres / 2) .. " " + .. "{\\an7\\pos(" .. (hxr + cam.shiftx) .. ", " .. (hyr - cam.shifty) .. ")\\p1}" + .. "m " .. (v:x() * hxr) .. " " .. (-v:y() * hyr) .. " " local face_center = vector.zero(4) @@ -128,8 +129,7 @@ function shape:draw(subs, line, tags, cull, cam, ambient, lights) v = m * (vs[i] + c) face_center = face_center + v v = (1 / v:w()) * v - l.text = l.text .. "l " .. ( v:x() * xres / 2) .. " " - .. (-v:y() * yres / 2) .. " " + l.text = l.text .. "l " .. ( v:x() * hxr) .. " " .. (-v:y() * hyr) .. " " end face_center = (1 / #vs) * face_center