Translations of this page:



Movement using matrix4x4

Example data:


In this example, we will be using matrix4x4 the transformation matrix to move a SubItem object.
The example script turns the object by 1 degree per frame around the Z-axis.

local m =
local sub = vci.assets.GetTransform("sub")
local baseposition
local baserotation
local basescale
local rotq
local rotation = Quaternion.Euler(0, 0, 1)--Local rotation
local translation = Vector3.__new(0,0,0)--Local transpose
local scale = Vector3.__new(1,1,1)--Local scale
function updateAll()
    baseposition = sub.GetLocalPosition()--Vector3
    baserotation = sub.GetLocalRotation()--Quaternion
    basescale = sub.GetLocalScale()--Vector3
    m.setTRS(translation,rotation,scale)--Set a transformation matrix on m
    rotq = m.rotation --Quaternion solved by the transformation matrix
    baserotation = rotq*baserotation
    baseposition = m.MultiplyPoint3x4(baseposition)--Can be used for parallel translation
    basescale = Vector3.__new(scale.x*basescale.x,scale.y*basescale.y,scale.z*basescale.z)
    sub.SetLocalRotation(baserotation)--Apply the rotation
    sub.SetLocalPosition(baseposition)--Apply the position
    sub.SetLocalScale(basescale)--Apply the scale
en/vci/sample/mat4.txt · Last modified: 2022/03/06 23:15 by Ramen

Page Tools