diff --git a/LuaScript/AviUtlScriptContext.cs b/LuaScript/AviUtlScriptContext.cs index 8e61fee..2e7f109 100644 --- a/LuaScript/AviUtlScriptContext.cs +++ b/LuaScript/AviUtlScriptContext.cs @@ -42,6 +42,8 @@ namespace LuaScript public int Index { get; init; } public int Num { get; init; } + public IReadOnlyList SceneObjects { get; init; } = []; + public double RxRad => Rx * Math.PI / 180d; public double RyRad => Ry * Math.PI / 180d; public double RzRad => Rz * Math.PI / 180d; @@ -81,6 +83,33 @@ namespace LuaScript internal void MarkPixelsDirty() => _isPixelsDirty = true; + public bool TryGetObject(string tag, out SceneObjectInfo info) + { + SceneObjectInfo? fallback = null; + var objects = SceneObjects; + for (int i = 0; i < objects.Count; i++) + { + var candidate = objects[i]; + if (!string.Equals(candidate.Tag, tag, StringComparison.Ordinal)) + continue; + if (candidate.Exist) + { + info = candidate; + return true; + } + fallback ??= candidate; + } + + if (fallback is { } value) + { + info = value; + return true; + } + + info = default; + return false; + } + public unsafe (double r, double g, double b, double a) GetPixel(int x, int y) { EnsurePixelBuffer(); diff --git a/LuaScript/LuaScriptEffectProcessor.cs b/LuaScript/LuaScriptEffectProcessor.cs index 423ae8b..1434ccd 100644 --- a/LuaScript/LuaScriptEffectProcessor.cs +++ b/LuaScript/LuaScriptEffectProcessor.cs @@ -9,6 +9,8 @@ using Vortice.Mathematics; using YukkuriMovieMaker.Commons; using YukkuriMovieMaker.Player.Video; using YukkuriMovieMaker.Player.Video.Effects; +using YukkuriMovieMaker.Project; +using YukkuriMovieMaker.Project.Items; namespace LuaScript { @@ -57,6 +59,7 @@ namespace LuaScript private bool _isFirst = true; private ID2D1Image? _cachedInput; private RenderKey _cachedKey; + private SceneObjectInfo[] _cachedSceneObjects = []; private DrawDescription? _cachedOutputDesc; private bool _cachedPixelsModified; @@ -110,7 +113,10 @@ namespace LuaScript desc.TimelineDuration.Time.TotalSeconds, inDesc); - if (!_isFirst && key == _cachedKey) + var sceneObjects = BuildSceneObjects(desc); + + if (!_isFirst && key == _cachedKey && + _cachedSceneObjects.AsSpan().SequenceEqual(sceneObjects)) { effectOutput = _cachedPixelsModified ? _transformEffect?.Output : null; return _cachedOutputDesc ?? inDesc; @@ -120,7 +126,7 @@ namespace LuaScript int imgW = Math.Max(1, (int)Math.Ceiling(bounds.Right - bounds.Left)); int imgH = Math.Max(1, (int)Math.Ceiling(bounds.Bottom - bounds.Top)); - var ctx = BuildContext(in key, imgW, imgH); + var ctx = BuildContext(in key, imgW, imgH, sceneObjects); ctx.SetPixelLoader(() => LoadInputPixels(bounds, imgW, imgH)); DrawDescription outDesc = inDesc; @@ -159,13 +165,68 @@ namespace LuaScript _isFirst = false; _cachedKey = key; + _cachedSceneObjects = sceneObjects; _cachedOutputDesc = outDesc; _cachedPixelsModified = pixelsModified; return outDesc; } - private static AviUtlScriptContext BuildContext(in RenderKey key, int imgW, int imgH) + private static SceneObjectInfo[] BuildSceneObjects(EffectDescription desc) + { + var scenes = desc.Scenes; + if (scenes is null) + return []; + + Scene? scene = null; + foreach (var info in scenes) + { + if (info is Scene candidate && candidate.ID == desc.SceneId) + { + scene = candidate; + break; + } + } + if (scene is null) + return []; + + int timelineFrame = desc.TimelinePosition.Frame; + int fps = desc.FPS; + var items = scene.Timeline.Items; + var result = new List(items.Count); + + foreach (var item in items) + { + if (item is not VisualItem visual) + continue; + var tag = item.Remark; + if (string.IsNullOrEmpty(tag)) + continue; + + int length = item.Length; + int local = Math.Clamp(timelineFrame - item.Frame, 0, length); + bool exist = item.Frame <= timelineFrame && timelineFrame < item.Frame + length; + + double x = visual.X.GetValue(local, length, fps); + double y = visual.Y.GetValue(local, length, fps); + double z = visual.Z.GetValue(local, length, fps); + double zoom = visual.Zoom.GetValue(local, length, fps) / 100d; + double rz = visual.Rotation.GetValue(local, length, fps); + + double opacity = visual.Opacity.GetValue(local, length, fps) / 100d; + double timeSec = fps > 0 ? local / (double)fps : 0d; + double durationSec = fps > 0 ? length / (double)fps : 0d; + double fadeIn = visual.FadeIn <= 0d ? 1d : Math.Min(1d, timeSec / visual.FadeIn); + double fadeOut = visual.FadeOut <= 0d ? 1d : Math.Min(1d, (durationSec - timeSec) / visual.FadeOut); + double alpha = opacity * Math.Min(fadeIn, fadeOut) * 255d; + + result.Add(new SceneObjectInfo(tag, exist, x, y, z, zoom, rz, alpha, item.Layer)); + } + + return [.. result]; + } + + private static AviUtlScriptContext BuildContext(in RenderKey key, int imgW, int imgH, SceneObjectInfo[] sceneObjects) { var zoom = key.InputDesc.Zoom; double zoomAvg = (zoom.X + zoom.Y) / 2d; @@ -216,6 +277,7 @@ namespace LuaScript IsPaused = key.Usage == TimelineSourceUsage.Paused, SceneId = key.SceneId.ToString(), TimeRatio = key.Length > 0 ? key.Frame / (double)key.Length : 0d, + SceneObjects = sceneObjects, }; } diff --git a/LuaScript/LuaScriptEngine.cs b/LuaScript/LuaScriptEngine.cs index fb20a54..1c9d9d6 100644 --- a/LuaScript/LuaScriptEngine.cs +++ b/LuaScript/LuaScriptEngine.cs @@ -216,7 +216,7 @@ namespace LuaScript script.Globals["scene"] = sceneTable; var objTable = new Table(script); - RegisterPixelCallbacks(objTable); + RegisterObjectCallbacks(objTable); script.Globals["obj"] = objTable; var animTable = new Table(script); @@ -246,7 +246,7 @@ namespace LuaScript if (!ReferenceEquals(script.Globals.Get("obj").Table, _objTable)) { var objTable = new Table(script); - RegisterPixelCallbacks(objTable); + RegisterObjectCallbacks(objTable); script.Globals["obj"] = objTable; _objTable = objTable; _objTableSnapshot = null; @@ -397,8 +397,21 @@ namespace LuaScript script.Globals[key] = DynValue.Nil; } - private void RegisterPixelCallbacks(Table obj) + private void RegisterObjectCallbacks(Table obj) { + obj["getobject"] = DynValue.NewCallback((execCtx, args) => + { + _activeCancellation.ThrowIfCancellationRequested(); + if (_activeContext is null || args.Count == 0) + return DynValue.Nil; + var tag = args[0]; + if (tag.Type != DataType.String) + return DynValue.Nil; + if (!_activeContext.TryGetObject(tag.String, out var info)) + return DynValue.Nil; + return BuildObjectTable(execCtx.GetScript(), info); + }); + obj["getpixel"] = DynValue.NewCallback((_, args) => { _activeCancellation.ThrowIfCancellationRequested(); @@ -438,6 +451,29 @@ namespace LuaScript obj["putpixeldata"] = DynValue.NewCallback((_, _) => DynValue.Void); } + private static DynValue BuildObjectTable(Script script, SceneObjectInfo info) + { + var table = new Table(script) + { + ["exist"] = info.Exist, + ["x"] = info.X, + ["y"] = info.Y, + ["z"] = info.Z, + ["zoom"] = info.Zoom, + ["sx"] = info.Zoom, + ["sy"] = info.Zoom, + ["rx"] = 0d, + ["ry"] = 0d, + ["rz"] = info.Rz, + ["rxr"] = 0d, + ["ryr"] = 0d, + ["rzr"] = info.Rz * Math.PI / 180d, + ["alpha"] = info.Alpha, + ["layer"] = info.Layer, + }; + return DynValue.NewTable(table); + } + private void ReadBackGlobals(AviUtlScriptContext ctx) { if (_objTable is null) return; diff --git a/LuaScript/SceneObjectInfo.cs b/LuaScript/SceneObjectInfo.cs new file mode 100644 index 0000000..d0e804c --- /dev/null +++ b/LuaScript/SceneObjectInfo.cs @@ -0,0 +1,13 @@ +namespace LuaScript +{ + internal readonly record struct SceneObjectInfo( + string Tag, + bool Exist, + double X, + double Y, + double Z, + double Zoom, + double Rz, + double Alpha, + int Layer); +} diff --git a/LuaScript/docs/LuaScript.ar-sa.txt b/LuaScript/docs/LuaScript.ar-sa.txt index d710350..a078b46 100644 --- a/LuaScript/docs/LuaScript.ar-sa.txt +++ b/LuaScript/docs/LuaScript.ar-sa.txt @@ -189,6 +189,41 @@ - جدول obj - الدوال - + ○ obj.getobject(tag) + يحصل على معلومات الرسم الحالية لكائن آخر يحمل الوسم المحدد. + ※ يطابق الوسم النص المُدخل في حقل "ملاحظة (Remark)" للعنصر الهدف. + ※ عند وجود عدة عناصر تحمل الوسم نفسه، يُعاد العنصر الظاهر في + الإطار الحالي بأولوية. وإن لم يكن أي منها ظاهرًا، يُعاد أول + عنصر مطابق. + ※ القيم المُعادة هي إحداثيات العنصر ودورانه ومقياسه الخاصة به. + ولا تتضمن التحويلات الناتجة عن التحكم بالمجموعة أو التحكم + بالكاميرا أو التأثيرات الأعلى. + ※ تستخدم كل قيمة نظام الوحدات نفسه المستخدم في جدول obj. + tag : النص المضبوط في ملاحظة العنصر الهدف + القيمة المُعادة : جدول معلومات الكائن. يُعيد nil عند عدم وجود + عنصر مطابق. + .exist : هل هو ظاهر في الإطار الحالي (boolean) + .x : إحداثي العرض الأساسي X + .y : إحداثي العرض الأساسي Y + .z : إحداثي العرض الأساسي Z + .zoom : المقياس (1.0 يعني الحجم الأصلي) + .sx : المقياس في اتجاه X (= zoom) + .sy : المقياس في اتجاه Y (= zoom) + .rx : زاوية الدوران حول المحور X (بالدرجات، دائمًا 0) + .ry : زاوية الدوران حول المحور Y (بالدرجات، دائمًا 0) + .rz : زاوية الدوران حول المحور Z (بالدرجات) + .rxr : زاوية الدوران حول المحور X (بالراديان، دائمًا 0) + .ryr : زاوية الدوران حول المحور Y (بالراديان، دائمًا 0) + .rzr : زاوية الدوران حول المحور Z (بالراديان) + .alpha : الشفافية (0.0 - 255.0، مع تطبيق التلاشي) + .layer : رقم الطبقة التي وُضع فيها + مثال: + local funnel = obj.getobject("funnel") + if funnel then + obj.x = funnel.x + obj.y = funnel.y + end + ○ obj.getpixel(x, y) يسترد معلومات البكسل عند الإحداثيات المحددة. * تحدث نقل بيانات الصورة من GPU إلى CPU عند الاستدعاء الأول (مع عبء معالجة). diff --git a/LuaScript/docs/LuaScript.en-us.txt b/LuaScript/docs/LuaScript.en-us.txt index d0cac20..897a705 100644 --- a/LuaScript/docs/LuaScript.en-us.txt +++ b/LuaScript/docs/LuaScript.en-us.txt @@ -192,6 +192,43 @@ - obj Table - Functions - + o obj.getobject(tag) + Gets the current drawing information of another object that has + the specified tag. + * The tag matches the string entered in the target item's + "Remark" field. + * If multiple items share the same tag, the item currently + visible at the present frame is returned with priority. + If none is visible, the first matching item is returned. + * The returned values are the item's own coordinates, rotation + and scale. Transforms from group control, camera control or + upper effects are NOT included. + * Each value uses the same unit system as the obj table. + tag : The string set in the target item's remark + Return : An object information table. Returns nil when no + matching item exists. + .exist : Whether it is visible at the current frame (boolean) + .x : Display base coordinate X + .y : Display base coordinate Y + .z : Display base coordinate Z + .zoom : Scale (1.0 = original size) + .sx : Scale along X (= zoom) + .sy : Scale along Y (= zoom) + .rx : Rotation angle around X axis (degrees, always 0) + .ry : Rotation angle around Y axis (degrees, always 0) + .rz : Rotation angle around Z axis (degrees) + .rxr : Rotation angle around X axis (radians, always 0) + .ryr : Rotation angle around Y axis (radians, always 0) + .rzr : Rotation angle around Z axis (radians) + .alpha : Opacity (0.0 - 255.0, fade applied) + .layer : Layer number where it is placed + Example: + local funnel = obj.getobject("funnel") + if funnel then + obj.x = funnel.x + obj.y = funnel.y + end + o obj.getpixel(x, y) Retrieves pixel information at the specified coordinates. * A GPU->CPU image data transfer occurs on the first call (involves processing overhead). diff --git a/LuaScript/docs/LuaScript.es-es.txt b/LuaScript/docs/LuaScript.es-es.txt index 8af37d1..7753f7b 100644 --- a/LuaScript/docs/LuaScript.es-es.txt +++ b/LuaScript/docs/LuaScript.es-es.txt @@ -189,6 +189,44 @@ - Tabla obj - Funciones - + o obj.getobject(tag) + Obtiene la información de dibujo actual de otro objeto que tiene + la etiqueta especificada. + * La etiqueta coincide con el texto introducido en el campo + "Observación (Remark)" del elemento de destino. + * Si varios elementos comparten la misma etiqueta, se devuelve + con prioridad el elemento visible en el fotograma actual. + Si ninguno es visible, se devuelve el primer elemento que + coincida. + * Los valores devueltos son las coordenadas, rotación y escala + propias del elemento. NO se incluyen las transformaciones por + control de grupo, control de cámara o efectos superiores. + * Cada valor usa el mismo sistema de unidades que la tabla obj. + tag : El texto definido en la observación del elemento de destino + Retorno : Una tabla de información del objeto. Devuelve nil cuando + no existe ningún elemento coincidente. + .exist : Si es visible en el fotograma actual (boolean) + .x : Coordenada base de visualización X + .y : Coordenada base de visualización Y + .z : Coordenada base de visualización Z + .zoom : Escala (1.0 = tamaño original) + .sx : Escala en X (= zoom) + .sy : Escala en Y (= zoom) + .rx : Ángulo de rotación en el eje X (grados, siempre 0) + .ry : Ángulo de rotación en el eje Y (grados, siempre 0) + .rz : Ángulo de rotación en el eje Z (grados) + .rxr : Ángulo de rotación en el eje X (radianes, siempre 0) + .ryr : Ángulo de rotación en el eje Y (radianes, siempre 0) + .rzr : Ángulo de rotación en el eje Z (radianes) + .alpha : Opacidad (0.0 - 255.0, fundido aplicado) + .layer : Número de capa donde está colocado + Ejemplo: + local funnel = obj.getobject("funnel") + if funnel then + obj.x = funnel.x + obj.y = funnel.y + end + o obj.getpixel(x, y) Obtiene información del píxel en las coordenadas especificadas. * Se produce una transferencia de datos de imagen GPU→CPU en la primera llamada (con sobrecarga de procesamiento). diff --git a/LuaScript/docs/LuaScript.id-id.txt b/LuaScript/docs/LuaScript.id-id.txt index dd6b009..24a487f 100644 --- a/LuaScript/docs/LuaScript.id-id.txt +++ b/LuaScript/docs/LuaScript.id-id.txt @@ -189,6 +189,44 @@ - Tabel obj - Fungsi - + o obj.getobject(tag) + Mengambil informasi gambar terkini dari objek lain yang memiliki + tag yang ditentukan. + * Tag cocok dengan teks yang dimasukkan pada kolom + "Catatan (Remark)" item target. + * Jika beberapa item berbagi tag yang sama, item yang sedang + tampil pada frame saat ini dikembalikan dengan prioritas. + Jika tidak ada yang tampil, item pertama yang cocok + dikembalikan. + * Nilai yang dikembalikan adalah koordinat, rotasi, dan skala + milik item itu sendiri. Transformasi dari kontrol grup, + kontrol kamera, atau efek di atasnya TIDAK disertakan. + * Setiap nilai menggunakan sistem satuan yang sama dengan tabel obj. + tag : Teks yang diatur pada catatan item target + Kembali : Tabel informasi objek. Mengembalikan nil jika tidak ada + item yang cocok. + .exist : Apakah tampil pada frame saat ini (boolean) + .x : Koordinat dasar tampilan X + .y : Koordinat dasar tampilan Y + .z : Koordinat dasar tampilan Z + .zoom : Skala (1.0 = ukuran asli) + .sx : Skala arah X (= zoom) + .sy : Skala arah Y (= zoom) + .rx : Sudut rotasi sumbu X (derajat, selalu 0) + .ry : Sudut rotasi sumbu Y (derajat, selalu 0) + .rz : Sudut rotasi sumbu Z (derajat) + .rxr : Sudut rotasi sumbu X (radian, selalu 0) + .ryr : Sudut rotasi sumbu Y (radian, selalu 0) + .rzr : Sudut rotasi sumbu Z (radian) + .alpha : Opasitas (0.0 - 255.0, fade diterapkan) + .layer : Nomor layer tempat ditempatkan + Contoh: + local funnel = obj.getobject("funnel") + if funnel then + obj.x = funnel.x + obj.y = funnel.y + end + o obj.getpixel(x, y) Mengambil informasi piksel pada koordinat yang ditentukan. * Transfer data gambar GPU→CPU terjadi pada panggilan pertama (dengan overhead pemrosesan). diff --git a/LuaScript/docs/LuaScript.ja-jp.txt b/LuaScript/docs/LuaScript.ja-jp.txt index 59a7cd7..e1f7e09 100644 --- a/LuaScript/docs/LuaScript.ja-jp.txt +++ b/LuaScript/docs/LuaScript.ja-jp.txt @@ -192,6 +192,40 @@ - obj テーブル - 関数 - + ○obj.getobject(tag) + 指定したタグを持つ他のオブジェクトの現在の描画情報を取得します。 + ※ タグは対象アイテムの「備考」に入力した文字列と一致します。 + ※ 同じタグを持つアイテムが複数ある場合、現在のフレームで表示中の + アイテムを優先して返します。表示中のものが無い場合は最初に + 一致したアイテムを返します。 + ※ 取得できる値はアイテム自身の座標・回転・拡大率です。 + グループ制御・カメラ制御・上位エフェクトによる変形は含まれません。 + ※ 各値は obj テーブルと同一の単位系です。 + tag : 対象アイテムの備考に設定した文字列 + 戻り値 : オブジェクト情報テーブル。一致するアイテムが存在しない場合は + nil を返します。 + .exist : 現在のフレームで表示中かどうか (boolean) + .x : 表示基準座標 X + .y : 表示基準座標 Y + .z : 表示基準座標 Z + .zoom : 拡大率 (1.0 で等倍) + .sx : X 方向の拡大率 (= zoom) + .sy : Y 方向の拡大率 (= zoom) + .rx : X 軸回転角度 (度, 常に 0) + .ry : Y 軸回転角度 (度, 常に 0) + .rz : Z 軸回転角度 (度) + .rxr : X 軸回転角度 (ラジアン, 常に 0) + .ryr : Y 軸回転角度 (ラジアン, 常に 0) + .rzr : Z 軸回転角度 (ラジアン) + .alpha : 不透明度 (0.0 ~ 255.0, フェード反映済み) + .layer : 配置レイヤー番号 + 例: + local funnel = obj.getobject("funnel") + if funnel then + obj.x = funnel.x + obj.y = funnel.y + end + ○obj.getpixel(x, y) 指定座標のピクセル情報を取得します。 ※ 初回呼び出し時に GPU→CPU への画像データ転送が発生します(処理負荷を伴います)。 diff --git a/LuaScript/docs/LuaScript.ko-kr.txt b/LuaScript/docs/LuaScript.ko-kr.txt index 4c6f569..336a163 100644 --- a/LuaScript/docs/LuaScript.ko-kr.txt +++ b/LuaScript/docs/LuaScript.ko-kr.txt @@ -189,6 +189,39 @@ - obj 테이블 - 함수 - + ○ obj.getobject(tag) + 지정한 태그를 가진 다른 오브젝트의 현재 그리기 정보를 취득합니다. + ※ 태그는 대상 아이템의 "비고(Remark)"에 입력한 문자열과 일치합니다. + ※ 같은 태그를 가진 아이템이 여러 개인 경우, 현재 프레임에서 + 표시 중인 아이템을 우선하여 반환합니다. 표시 중인 것이 없으면 + 처음으로 일치한 아이템을 반환합니다. + ※ 취득되는 값은 아이템 자신의 좌표·회전·확대율입니다. + 그룹 제어·카메라 제어·상위 이펙트에 의한 변형은 포함되지 않습니다. + ※ 각 값은 obj 테이블과 동일한 단위 체계입니다. + tag : 대상 아이템의 비고에 설정한 문자열 + 반환값 : 오브젝트 정보 테이블. 일치하는 아이템이 없으면 nil을 반환합니다. + .exist : 현재 프레임에서 표시 중인지 여부 (boolean) + .x : 표시 기준 좌표 X + .y : 표시 기준 좌표 Y + .z : 표시 기준 좌표 Z + .zoom : 확대율 (1.0이 등배) + .sx : X 방향 확대율 (= zoom) + .sy : Y 방향 확대율 (= zoom) + .rx : X축 회전 각도 (도, 항상 0) + .ry : Y축 회전 각도 (도, 항상 0) + .rz : Z축 회전 각도 (도) + .rxr : X축 회전 각도 (라디안, 항상 0) + .ryr : Y축 회전 각도 (라디안, 항상 0) + .rzr : Z축 회전 각도 (라디안) + .alpha : 불투명도 (0.0 ~ 255.0, 페이드 반영됨) + .layer : 배치 레이어 번호 + 예: + local funnel = obj.getobject("funnel") + if funnel then + obj.x = funnel.x + obj.y = funnel.y + end + ○ obj.getpixel(x, y) 지정 좌표의 픽셀 정보를 취득합니다. ※ 최초 호출 시 GPU→CPU로의 이미지 데이터 전송이 발생합니다(처리 부하 수반). diff --git a/LuaScript/docs/LuaScript.zh-cn.txt b/LuaScript/docs/LuaScript.zh-cn.txt index 3339259..812fd65 100644 --- a/LuaScript/docs/LuaScript.zh-cn.txt +++ b/LuaScript/docs/LuaScript.zh-cn.txt @@ -189,6 +189,38 @@ - obj 表 - 函数 - + ○ obj.getobject(tag) + 获取具有指定标签的其他对象的当前绘制信息。 + ※ 标签与目标项目“备注(Remark)”中输入的字符串相匹配。 + ※ 当多个项目拥有相同标签时,优先返回在当前帧显示中的项目。 + 若没有显示中的项目,则返回第一个匹配的项目。 + ※ 获取的值是项目自身的坐标、旋转和缩放。 + 不包含组控制、摄像机控制以及上层特效造成的变换。 + ※ 各数值使用与 obj 表相同的单位体系。 + tag : 设置在目标项目备注中的字符串 + 返回值 : 对象信息表。当不存在匹配项目时返回 nil。 + .exist : 是否在当前帧显示中 (boolean) + .x : 显示基准坐标 X + .y : 显示基准坐标 Y + .z : 显示基准坐标 Z + .zoom : 缩放率 (1.0 为原始大小) + .sx : X 方向缩放率 (= zoom) + .sy : Y 方向缩放率 (= zoom) + .rx : X 轴旋转角度 (度, 恒为 0) + .ry : Y 轴旋转角度 (度, 恒为 0) + .rz : Z 轴旋转角度 (度) + .rxr : X 轴旋转角度 (弧度, 恒为 0) + .ryr : Y 轴旋转角度 (弧度, 恒为 0) + .rzr : Z 轴旋转角度 (弧度) + .alpha : 不透明度 (0.0 ~ 255.0, 已应用淡入淡出) + .layer : 所在图层编号 + 示例: + local funnel = obj.getobject("funnel") + if funnel then + obj.x = funnel.x + obj.y = funnel.y + end + ○ obj.getpixel(x, y) 获取指定坐标的像素信息。 * 首次调用时发生 GPU→CPU 的图像数据传输(存在处理开销)。 diff --git a/LuaScript/docs/LuaScript.zh-tw.txt b/LuaScript/docs/LuaScript.zh-tw.txt index e6e3dfa..93d958d 100644 --- a/LuaScript/docs/LuaScript.zh-tw.txt +++ b/LuaScript/docs/LuaScript.zh-tw.txt @@ -189,6 +189,38 @@ - obj 表 - 函式 - + ○ obj.getobject(tag) + 取得具有指定標籤的其他物件的目前繪製資訊。 + ※ 標籤與目標項目「備註(Remark)」中輸入的字串相符。 + ※ 當多個項目擁有相同標籤時,優先回傳在目前影格顯示中的項目。 + 若沒有顯示中的項目,則回傳第一個相符的項目。 + ※ 取得的值是項目自身的座標、旋轉與縮放。 + 不包含群組控制、攝影機控制以及上層特效造成的變換。 + ※ 各數值使用與 obj 表相同的單位體系。 + tag : 設定於目標項目備註中的字串 + 回傳值 : 物件資訊表。當不存在相符項目時回傳 nil。 + .exist : 是否在目前影格顯示中 (boolean) + .x : 顯示基準座標 X + .y : 顯示基準座標 Y + .z : 顯示基準座標 Z + .zoom : 縮放率 (1.0 為原始大小) + .sx : X 方向縮放率 (= zoom) + .sy : Y 方向縮放率 (= zoom) + .rx : X 軸旋轉角度 (度, 恆為 0) + .ry : Y 軸旋轉角度 (度, 恆為 0) + .rz : Z 軸旋轉角度 (度) + .rxr : X 軸旋轉角度 (弧度, 恆為 0) + .ryr : Y 軸旋轉角度 (弧度, 恆為 0) + .rzr : Z 軸旋轉角度 (弧度) + .alpha : 不透明度 (0.0 ~ 255.0, 已套用淡入淡出) + .layer : 所在圖層編號 + 範例: + local funnel = obj.getobject("funnel") + if funnel then + obj.x = funnel.x + obj.y = funnel.y + end + ○ obj.getpixel(x, y) 取得指定座標的像素資訊。 * 首次呼叫時發生 GPU→CPU 的影像資料傳輸(存在處理負擔)。