Notifications
Clear all

[Closed] Getting nuts, transform doesn't work

Hello

I am not getting this to work at all. I have downloaded a script from Allan McKays homepage called “AMcKay_create_animVolume_v06.ms”. It’s a very useful script if you are working with animated objects together with FumeFX, let’s say I have a sphere that is animated and I want the FumeFX grid to match up with the current animation the sphere have, so the FumeFX grid is the same size as the animation trajectories is, that way the FumeFX grid is not to big.

Everything works good, first I must choose my animated object in the scene, when I do, a dummybox is created that follows the animated objects way and then make the dummybox the same size as the animated objects trajectory has. In that way, I can create a FumeFX grid in the same size as the dummybox have and manualy place the FumeFX grid to the same location as the dummybox, and then delete the dummybox.

Now, I want to do that within the script to do it even more good, I made a new pick button that aloves me to select a FumeFX grid. Then I want the size of the FumeFX grid to be the same as the dummybox is, so far, so good, that works, but the problem comes when I want to move the FumeFX grid to the same position as the dummybox are at. The grid moves, but is not placed exact over the box in XYZ…

Here is the code I did so far:


on ChooseFFX picked obj do
(

obj.name = “FumeFX01”
ChooseFFX.text = obj.name
centerpivot $FumeFX01

– match the XYZ size (Works good)

$FumeFX01.width = $AnimFFX_box.width
$FumeFX01.height = $AnimFFX_box.height
$FumeFX01.length = $AnimFFX_box.length

– match position, rotation and scale (Doesn’t work at all)

$FumeFX01.transform = $AnimFFX_box.transform

– delete dummybox (Works)

delete $AnimFFX_box

)


I get the size to work, the FumeFX grid becomes the same size as the dummybox, but the transform don’t work at all… I tried with the below code to, but none of them seems to work for me…

$FumeFX01.position.x = $AnimFFX_box.position.x
$FumeFX01.position.y = $AnimFFX_box.position.y
$FumeFX01.position.z = $AnimFFX_box.position.z

Or this two…

$FumeFX01.position = $AnimFFX_box.position
$FumeFX01.position = DummyBox.position

Can someone please help me out? I am sure of it’s pretty simple, but I can’t get it to work, so any help would be great.

Regards

6 Replies

Not a single soul who know how to fix this?

Is your $FFumeFX01 parented to anything?

I have found the same problem in trying to work with transform matrices… it seems that when you get the matrix, it’s in world space, but when you set it, it sets it relative to the object’s parent.

Consequently, before you apply the transform, you have to multiply the transformation matrix by the inverse of your target’s parent’s transform to get it in the correct space.

so this:


  $FumeFX01.transform = $AnimFFX_box.transform
 

should become this:


  tgt_xform = $AnimFFX_box.transform
  if $FumeFX01.parent != undefined then
  (
  	tgt_xform = tgt_xform * (inverse $FumeFX01.parent.transform)
  )
  $FumeFX01.transform = tgt_xform
  

That should help…

as a side note, I cannot get the xformTrans matrix method to work as it should for doing the same thing, this was the only way I could get it to function correctly.

Good luck, I hope it helps!

 PEN

I don’t have Fume so I can’t test this. Why not contact Allan as I’m sure he would be the best person to correct it.

Hello

And thanks for your help rhithyn, but I am affraid that didn’t work either, almost the same as it was before with only this code:

$FumeFX01.transform = $AnimFFX_box.transform

The FumeFX container doesn’t place itself to the position as the box is for some reasons…

PEN, you don’t need FumeFX to try this, you can use a simple box, doesn’t matter.

Here is the whole code:


rollout ToolsRoll “Tools” width:496 height:288
(
groupBox grp2 “Create FumeFX grid for animated object” pos:[24,16] width:208 height:104
pickButton ChooseOBJ “Select animated object” pos:[48,48] width:152 height:24 toolTip:“Select the object in the scene that is animated”
pickButton ChooseFFX “Select FumeFX grid” pos:[48,80] width:152 height:24 toolTip:“Select the FumeFX grid”

on ChooseOBJ picked obj do
(
myOBJ = chooseOBJ.object

slidertime = animationrange.start
for i = animationrange.start to animationrange.end do
(
min1 = (box scale:[.1,.1,.1] name:“track_min1” position:myobj.min)
max1 = (box scale:[.1,.1,.1] name:“track_max1” position:myobj.max)
min2 = (box scale:[.1,.1,.1] name:“track_min2” position:[max1.position.x, min1.position.y, min1.position.z] renderable:false)
min3 = (box scale:[.1,.1,.1] name:“track_min3” position:[min1.position.x, max1.position.y, min1.position.z] renderable:false)
min4 = (box scale:[.1,.1,.1] name:“track_min4” position:[max1.position.x, max1.position.y, min1.position.z] renderable:false)
max2 = (box scale:[.1,.1,.1] name:“track_max2” position:[min1.position.x, max1.position.y, max1.position.z] renderable:false)
max3 = (box scale:[.1,.1,.1] name:“track_max3” position:[max1.position.x, min1.position.y, max1.position.z] renderable:false)
max4 = (box scale:[.1,.1,.1] name:“track_max4” position:[min1.position.x, min1.position.y, max1.position.z] renderable:false)
slidertime +=1
)
fooCollect = $track_* as array
for i = 1 to fooCollect.count do
(
addmodifier fooCollect[i] (edit_mesh())
collapsestack fooCollect[i]
)
for i = 1 to (fooCollect.count – 1) do
(
meshop.attach fooCollect[foocollect.count] fooCollect[i] – attaches all to one mesh
)
final_myobj = fooCollect[fooCollect.count]
(
newmin1 = (dummy name:“boundary_min1” position:final_myobj.min)
newmax1 = (dummy name:“boundary_max1” position:final_myobj.max)
newmin2 = (dummy name:“boundary_min2” position:[newmax1.position.x, newmin1.position.y, newmin1.position.z] renderable:false)
newmin3 = (dummy name:“boundary_min3” position:[newmin1.position.x, newmax1.position.y, newmin1.position.z] renderable:false)
newmin4 = (dummy name:“boundary_min4” position:[newmax1.position.x, newmax1.position.y, newmin1.position.z] renderable:false)
hide newmin1
)

delete final_myobj

A1=$boundary_min4
B1=$boundary_min3
C1=$boundary_min2
D1=$boundary_max1

MyLength = distance A1 C1
MyWidth = distance A1 B1
MyHeight = distance A1 D1

var_x = (B1.position.x + ((distance A1 B1)/2) )
var_y = (C1.position.y + ((distance A1 C1)/2) )
var_z = (D1.position.z – ((distance A1 D1)/2) )

DummyBox = (box name:“AnimFFX_box”)

DummyBox.length = MyLength
DummyBox.width = MyWidth
DummyBox.height = MyHeight
centerpivot DummyBox
DummyBox.position = [var_x,var_y,var_z]
delete $boundary_*
)

on ChooseFFX picked obj do
(
obj.name = “FumeFX01”
ChooseFFX.text = obj.name
centerpivot $FumeFX01

$FumeFX01.width = $AnimFFX_box.width
$FumeFX01.height = $AnimFFX_box.height
$FumeFX01.length = $AnimFFX_box.length

–$FumeFX01.position.x = $AnimFFX_box.position.x
–$FumeFX01.position.y = $AnimFFX_box.position.y
–$FumeFX01.position.z = $AnimFFX_box.position.z

–$FumeFX01.transform = $AnimFFX_box.transform

tgt_xform = $AnimFFX_box.transform
if $FumeFX01.parent != undefined then
(
tgt_xform = tgt_xform * (inverse $FumeFX01.parent.transform)
)
$FumeFX01.transform = tgt_xform
delete $AnimFFX_box

)
)


But maybe Allan can answer and have some ideas… Hard nut to solve for me…

bb = #()
 bb = nodeLocalBoundingBox $AnimFFX_box 
 $FumeFX01.position = $AnimFFX_box.position * [1,1,0]	+ [0,0,bb[1].z]

the incorrect positioning happens because using “centerpivot” on the fume fx container does not affect the Z component of the pivot point, the above code compensates for that. You could also use $fumeFx01.pivot = $fumeFX01.center instead, like so:

$FumeFX01.pivot = $FumeFX01.center
$FumeFX01.position = $AnimFFX_box.position

Wow, that really worked out for me, big thanks Furball89 and rhithyn for your help!