Aligning Worldspace Rotation At A Specific Time?

hey there

I'm trying to align one object too another at a time which is different from the current time. So I can't use the xform command as I normally would.

Current I'm using the getAttr command with -t flag and doing pointMatrixMult of the translate point and the parentMatrix. Which is returning the worldspace point.

How can I get the world space rotation? I'm thinking that I might need to convert it to a vector....

OR is there some way that I can just apply the worldMatrix..(I tried using setAttr, but to no avail)??

????

(also I have to use mel... so no api solutions please)

darn! I had to read this 3 times
ok you want to get an objects ws rotation at a specific time without changing the time. right?

hmm... you could make a proc that looks for the nodes that lead to the root and take every rotation via getAttr -t and then calculate the final rotation.. I don't know if this works .. but as xform doesn't work in time..

is this going to be a expression of somekind

thanks guys, sorry about the confusing post, I was babbling.

ewerybody:

The proc is an interesting idea... it might get a bit tricky when stuff is orient constrained to multiple transforms.. but it might just work!

I'll see if anyone has any other ideas before I give that a bash. I was hoping for some wizz bang equation that would do all the work for me

Joojaa:

no it's not an expression. are you going to suggest that I disable the viewport refresh somehow and then use xform? and if so how would you do that?

Yes well actualy, i was going to tell you a trick regarding this.

set the global timenodes time to whatever you want using setAttr (its important not to uise currentTime), then inside the same proc querry it with xform and then setAttr the current time back to what it was. Its important that you do this all in one script run so no pausing in between or maya will update the viewport. BUT if you do this in one go maya will not, and thius only refreshes the atributes you ask (to this end it gets calculated 2 times unless you turn cache o but ususaly ist not SO expensive). This would work reasonably well even inside a expression but itd be slow.

(if fact if you ever want to querry or bake stuff over time DONT use currentTime because you get mcuh faster interacion without it)

Thats excellent!

Thanks Joojaa!

I do find that there is still a minor ui refresh. You can see it on the time slider if you run the command repeatedly.

I called this proc from a shelf button (incrementing the target time by 1 before each call)

global proc world_align_at_time(string $obj, string $target_obj, float $target_time, float $current_time)
{
float $rot_var[];
float $tra_var[];

setAttr time1.outTime $target\_time;

$rot\_var = `xform -q -ws -ro $target\_obj`;
$tra\_var = `xform -q -ws -t $target\_obj`;

xform -ws -ro  $rot\_var[0] $rot\_var[1] $rot\_var[2] $obj;
xform -ws -t  $tra\_var[0] $tra\_var[1] $tra\_var[2] $obj;

setAttr time1.outTime $current\_time;

}

you can notice the time slider glitching every now and then if you bash away on the shelf button
The glitch is more frequent if you call the proc multiple times within the same script...

any ideas...

but all in all a very good solution!

thanks again!

Well if you want to be realy proper ask for the attrinute after you set time back and mark the time fresh and with some luck (more or less not) yyoull be in time to avoid the refresh.