Page 1 of 1

matrix 4x4 to matrix 4x3 conversion

PostPosted: Fri Nov 25, 2016 7:50 am
by ruthenoid
How can I convert a matrix 4x4 (from Maya) to octane's 4x3 (scatter)?
Is it a matter of rotating it and stripping a row or is this somewhat more complicated ?

thank you!

Re: matrix 4x4 to matrix 4x3 conversion

PostPosted: Fri Nov 25, 2016 8:12 am
by calus
here is my simple mel script to convert maya transform matrix to octane matrix, you can see how it is re-ordered

Code: Select all
{string $selection[] = `ls -sl -tr`;
int $n = 0;
string $octMatrix[] ;
for ($transform in $selection) {
    float $matrix[] = `xform -q -ws -m $transform`;
    $octMatrix[$n] = $matrix[0]+" "+$matrix[4]+" "+$matrix[8]+" "+$matrix[12]+" "+$matrix[1]+" "+$matrix[5]+" "+$matrix[9]+" "+$matrix[13]+" "+$matrix[2]+" "+$matrix[6]+" "+$matrix[10]+" "+$matrix[14]+" ";
    $n=$n+1;
    }
print $octMatrix;
}

Re: matrix 4x4 to matrix 4x3 conversion

PostPosted: Fri Nov 25, 2016 8:20 am
by ruthenoid
Awsome!
Thank you, calus!

Re: matrix 4x4 to matrix 4x3 conversion

PostPosted: Sun Nov 27, 2016 10:17 pm
by roeland
Yes normally this is the case. Octane only supports affine transforms, it does not support projective transform matrices. In mathematical terms this means the last row of the matrix will be (0, 0, 0, 1). This row is not explicitly stored in Octane.