سؤال

How I can import rotation from file? I need Quaternions Currently I can only import object location.

Structure of txt file:

x,y,z,xrot,yrot,zrot,wrot,nameofobject

Here is my script:

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

while NOT file.eos() do
(
    local line = filterString (file.readLine()) ", "
    if line.count == 8 AND isValidNode (local obj = getNodeByName line[8]) do
        obj.pos = [line[1] as float, line[2] as float, line[3] as float]
)
   memStreamMgr.close file
)
هل كانت مفيدة؟

المحلول

Since the only thing that changed since your last question is the structure of the text file, I presume you are creating it yourself – if that is the case, change the comma to a different separator, for example a pipe, and save complete node transform matrix. Anyway, to answer your question as it stands, instead of setting position, set the transform like this:

obj.transform = translate (quat xrot yrot zrot wrot as matrix3) [x, y, z]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top