ljilekor
11-15-2006, 08:53 AM
Doh!!! Should have posted this in the MEL section of the forum... Sorry 4 this.
I'm used to code in various languages but I'm kinda new to MEL. I have trouble dealing with its limitations on arrays.
I need to create a custom posing system. Therefore I need to store transformations together with my selected objects.
Ok, so I store the objects selection in a basic string array.
string $selectionList[] = `ls -sl`;
I'd like to store the transformatiom matrix (float[16]) and have an extra index refering to the index of the according selected object. This way it's easy to refer to an objects transform matrix : $selectionList[INDEX] matix is float[INDEX][16];
I can't use float arrays with multiple dimensions. :banghead: A workaround : MEL supports matrices with a specified size so... I query for the number of selected objects and I know how many elements are in a float 'matrix' that I'll query later with the xform -q -m. (there are 16)
So I know the size of the two dimensions in the matrix
int $cnt = size ($selectionList);
matrix $storedTransforms[$cnt][16];
int $i;
for ($i=0 ; $i<$cnt ; ++$i){
$storedTransforms[$i][] = `xform -q -m -os $selectionList[$i]`;
}
MEL doesn't accept a variable in the matrix' declaration :
matrix $storedTransforms[$cnt][16];
This doesn't work either :
$storedTransforms[$i][] = `xform -q -m -os $selectionList[$i]`;
or
$storedTransforms[$i] = `xform -q -m -os $selectionList[$i]`;
...
Hope everything's clear enough.
How can I make this stuff work properly????
I'm used to code in various languages but I'm kinda new to MEL. I have trouble dealing with its limitations on arrays.
I need to create a custom posing system. Therefore I need to store transformations together with my selected objects.
Ok, so I store the objects selection in a basic string array.
string $selectionList[] = `ls -sl`;
I'd like to store the transformatiom matrix (float[16]) and have an extra index refering to the index of the according selected object. This way it's easy to refer to an objects transform matrix : $selectionList[INDEX] matix is float[INDEX][16];
I can't use float arrays with multiple dimensions. :banghead: A workaround : MEL supports matrices with a specified size so... I query for the number of selected objects and I know how many elements are in a float 'matrix' that I'll query later with the xform -q -m. (there are 16)
So I know the size of the two dimensions in the matrix
int $cnt = size ($selectionList);
matrix $storedTransforms[$cnt][16];
int $i;
for ($i=0 ; $i<$cnt ; ++$i){
$storedTransforms[$i][] = `xform -q -m -os $selectionList[$i]`;
}
MEL doesn't accept a variable in the matrix' declaration :
matrix $storedTransforms[$cnt][16];
This doesn't work either :
$storedTransforms[$i][] = `xform -q -m -os $selectionList[$i]`;
or
$storedTransforms[$i] = `xform -q -m -os $selectionList[$i]`;
...
Hope everything's clear enough.
How can I make this stuff work properly????
