SetMatrix

This function sets an entity's 4x4 matrix and updates the position, rotation, and scale.

Syntax

Parameters

Example

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()

local camera = Camera:Create()
camera:SetRotation(35,0,0)
camera:Move(0,0,-5)

local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

--Create a model
local entity1 = Model:Box()
entity1:SetColor(0.0,0.0,1.0)
entity1:SetPosition(-1,0,0)

local entity2 = entity1:Instance()
entity2:SetColor(0.0,1.0,0.0)

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()
world:Update()
world:Render()

entity1:Turn(0,Time:GetSpeed()*0.5,0)
entity2:SetMatrix(entity1:GetMatrix())
entity2:Turn(0,45,0)
entity2:Translate(2,0,0)

context:Sync()
end