read pos/rot from a file and apply to listed scene objects

Hi, I have this script which reads a txt file with xyz positions and a mesh name
How can I add xyz rotations aswell or change this to rotation only.

Sample.txt format
478,733,-46,mesh01

(
file = memStreamMgr.openFile @"C:\sample.txt"

while NOT file.eos() do
(
local line = filterString (file.readLine()) ", "
if line.count == 4 AND isValidNode (local obj = getNodeByName line[4]) do
obj.pos = [line[1] as float, line[2] as float, line[3] as float]
)
memStreamMgr.close file
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
radioactive's picture

read pos/rot from a file and apply to listed scene objects

I found a solution elsewhere

(rotate script)

(
    file = memStreamMgr.openFile @"C:\position.txt"

    while NOT file.eos() do
    (
        local line = filterString (file.readLine()) ", "
        if line.count == 4 AND isValidNode (local obj = getNodeByName line[4]) do
            obj.pos = [line[1] as float, line[2] as float, line[3] as float]
    )
    memStreamMgr.close file
)

(position script)

(
    file = memStreamMgr.openFile @"C:\rotation.txt"

    while NOT file.eos() do
    (
        local line = filterString (file.readLine()) ", "
        if line.count == 4 AND isValidNode (local obj = getNodeByName line[4]) do
            obj.rotation = eulerAngles (line[1] as float) (line[2] as float) (line[3] as float)
    )
    memStreamMgr.close file
)

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.