PDA

View Full Version : fourByFourMatrix - how to plug it?


alredha
04-01-2008, 02:28 PM
hello

as far as i know that any object can't get its worldMatrix plugged (read only!)... right?

in the doc, it's written that the output of an fourByFourMatrix can be connected only to an attribute of matrix type, fine...while when we use getAttr command it returns an array of floats...fine too

so, i said let's use an expression to get the output and feed it with an xform command to the object :


// the node already exist and called fbfmatrix
float $mat[16];
$mat = fbfmatrix.output;

// Error: Cannot cast data of type float to float[]. //


i tried to use float instead

float $mat;
$mat = fbfmatrix.output;
// Error: Attributes must be of float, integer, or boolean types: output //

so i tried getAttr, and it works fine...

it's only that the expression is not a part of a pipe of nodes, evaluated only when i hit the edit button,

here is the network :

pointOnCurve.nn --> fbfmatrix.00 fbfmatrix.01 fbfmatrix.02
pointOnCurve.nt --> fbfmatrix.04 fbfmatrix.05 fbfmatrix.06

the same normmalizedNormal and normalizedTangent get through a cross operation (vectorProduct node)

vectorProduct.output --> fbfmatrix.08 fbfmatrix.09 fbfmatrix.10

pointonCurve.p --> fbfmatrix.12 fbfmatrix.13 fbfmatrix.14


like that i have a complete transformation matrix based on a pointOnCurve node, so whatever i change the parameter, the whole network must update,....this is not the case with getAttr in the expression.

i hope i'm clear :) thank you

alredha
04-01-2008, 03:21 PM
apparently, even the xform is not getting the values out of the expression, i need something like attr = attr ! xform is not the case, no updating!

BenBarker
04-03-2008, 06:59 PM
There should a plugin available on your plug-in list called decomposematrix. If you load this plugin, you can make a node with 'createNode' called "decomposeMatrix". This node takes a matrix input and outputs SRTs, which you can connect to any other transform. Is this what you need?

strarup
04-03-2008, 08:15 PM
Hi Redna,

I'm not quite sure why it doesn't want to take the output into an float array...
when using getAttr it works... as you allready have wrote...


proc printDaMat()
{
float $mat[16];
$mat = `getAttr fbfmatrix.output`;
print("\n");
print($mat);
print("\n");
}
printDaMat();


however when using it in the expression editor writing an expression it isn't very often not an quite good idea using melcommands to get data...
but you could e.g. try to make the float array out of the attributes like the following example.. not sure if it would work haven't tested it... :)

string $daNN = "fbfmatrix";
float $mat[16] = {($daNN+".in00"), ($daNN+".in01"), ($daNN+".in02"), ($daNN+".in03"), ($daNN+".in10"), ($daNN+".in11"), ($daNN+".in12"), ($daNN+".in13"), ($daNN+".in20"), ($daNN+".in21"), ($daNN+".in22"), ($daNN+".in23"), ($daNN+".in30"), ($daNN+".in31"), ($daNN+".in32"), ($daNN+".in33")};


however an object has a matrix attribute e.g. lets say you have a cube called cube1 then you can get the matrix attribute by calling that...
getAttr cube1.m;
is also a inverse matrix attribute an a couple of other matrix attributes on the objects...

well hope it helps a bit... :)

kind regards

Strarup

alredha
04-07-2008, 11:13 AM
There should a plugin available on your plug-in list called decomposematrix. If you load this plugin, you can make a node with 'createNode' called "decomposeMatrix". This node takes a matrix input and outputs SRTs, which you can connect to any other transform. Is this what you need?

thank you very much, that's what i was looking for, extract transformation infos from the matrix, it works really fine...


however when using it in the expression editor writing an expression it isn't very often not an quite good idea using melcommands to get data...
but you could e.g. try to make the float array out of the attributes like the following example.. not sure if it would work haven't tested it... :)

yes, that was my problem, updating!
i think when we try to feed data from attr to attr, the expression is not updating when we use mel commands like setAttr and xform,
i mean when we change an attribute's value, the DG start updating the network, once it gets through an expression node and find mel command feeding an attribute, it stops there, the only way is to make attr = attr or attr = variable.
Of course this is not the case when time changes...

thank you strarup anyway,
you know, i always find you around here trying to help :thumbsup: , god bless you :)

alredha
04-07-2008, 11:27 AM
i write this to let you know that i found a better solution to my problematic,

in my exemple i was using a pointOnCurve node that feeds a fourByFourMatrix node, and this last feed a decomposeMatrix node, and this last plugged to a transformNode, so the object follows the orientation and translation on that specific pointOnCurve param value.

i figured out that a motionPath node do the job better by:
-no flipping (follow axis, aim axis)
-the uValue in percents is based on the curve length, not the uParam

so, the uValue expressed in %, it gives the exact result,
if the curve is 2.3 cm at uValue 1
it's 1.15 cm at uValue 0.5

it's not like pointOnCurve, which is based on the u Param....

CGTalk Moderation
04-07-2008, 11:27 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.