From 505e2b4b59db6cab5374a53022ed740113806796 Mon Sep 17 00:00:00 2001 From: Turanszki Janos Date: Sat, 2 Mar 2019 22:02:00 +0000 Subject: [PATCH] added two sample scripts --- scripts/move_object.lua | 23 +++++++++++++++++++++++ scripts/rotate_model.lua | 17 +++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 scripts/move_object.lua create mode 100644 scripts/rotate_model.lua diff --git a/scripts/move_object.lua b/scripts/move_object.lua new file mode 100644 index 000000000..fe7b1bc45 --- /dev/null +++ b/scripts/move_object.lua @@ -0,0 +1,23 @@ +-- This script will load a teapot model with lights, and move the teapot's lid up and down + +backlog_post("---> START SCRIPT: move_object.lua") + +scene = GetScene() +scene.Clear() +LoadModel("../models/teapot.wiscene") +top_entity = scene.Entity_FindByName("Top") -- query the teapot lid object by name +transform_component = scene.Component_GetTransform(top_entity) +rest_matrix = transform_component.GetMatrix() + +runProcess(function() + local t = 0 + while true do + t = t + 0.1 + transform_component.ClearTransform() + transform_component.MatrixTransform(rest_matrix) + transform_component.Translate(Vector(0, math.sin(t) * 0.5 + 0.5, 0)) -- up and down + update() + end +end) + +backlog_post("---> END SCRIPT: move_object.lua") diff --git a/scripts/rotate_model.lua b/scripts/rotate_model.lua new file mode 100644 index 000000000..2f428c091 --- /dev/null +++ b/scripts/rotate_model.lua @@ -0,0 +1,17 @@ +-- This script will load a teapot model with lights and rotate the whole model + +backlog_post("---> START SCRIPT: rotate_model.lua") + +scene = GetScene() +scene.Clear() +model_entity = LoadModel("../models/teapot.wiscene") +transform_component = scene.Component_GetTransform(model_entity) + +runProcess(function() + while true do + transform_component.Rotate(Vector(0, 0.1)) -- rotate around y axis + update() + end +end) + +backlog_post("---> END SCRIPT: rotate_model.lua")