Skip to content
This repository was archived by the owner on Jul 25, 2021. It is now read-only.
This repository was archived by the owner on Jul 25, 2021. It is now read-only.

Document that objects have a hidden scale #33

@Benjamin-Dobell

Description

@Benjamin-Dobell

Was just helping a user out on Discord regarding the fact that there's a hidden scale in TTS that's presently not exposed via any UI or any Lua APIs.

However, you can obtain this scale as follows:

local CARD_GUID = 'cafebf'

---@param obj tts__Object
---@return Vector
local function getObjectTransformScale(obj)
    local rotation = obj.getRotation()
    local onesVector = Vector(1, 1, 1):rotateOver('z', rotation.z):rotateOver('x', rotation.x):rotateOver('y', rotation.y)
    local scale = obj.positionToLocal(obj.getPosition():add(onesVector))
    return scale
end

function onLoad()
    local obj = getObjectFromGUID(CARD_GUID)
    print("Public scale:\n" .. logString(obj.getScale()))
    print("Hidden scale:\n" .. logString(getObjectTransformScale(obj)))
end

This scale comes into play most prominently with cards. Basically depending on the aspect ratio of your cards you'll have a different "object transform scale". However, by default, your cards will always report getScale() as Vector(1, 1, 1).

This scale particularly comes into play when you're trying to accurately convert from known pixel coordinates on your cards to in-game coordinates, say if you're trying to place a decal in a precise location on a card face.

Honestly, I'm not even sure how to properly document this without confusing people further, but it really is important in certain situations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions