PDA

View Full Version : Very weird behavior of the animated Link_constraint (bobo i need your lights) ;)


BebeteLANUITE
01-25-2006, 07:28 AM
Hello Everybody.

i made a script to animate dummies like movement of a rubiks cube.
but i have some weird result with it. :sad:

My script:

utility dummy "DummyLink"
(
group "Creation"
(
spinner sizebox "Size :" range:[1,10000,10] type:#integer
button creref "Create" width:120
button delbutton "Erase All" width:80
label espc " " height:2
)--end group

group "Link"
(
button moveh "Link Dummies H" width:100
button movev "link Dummies V" width:100
label esprot " " height:2
)--end group

on creref pressed do
(
sep=sizebox.value+(sizebox.value/2)

dummya=dummy pos:[0,0,0]
dummya=dummy pos:[sep,0,0]
dummya=dummy pos:[-sep,0,0]
dummya=dummy pos:[0,sep,0]
dummya=dummy pos:[0,-sep,0]
dummya=dummy pos:[sep,-sep,0]
dummya=dummy pos:[-sep,sep,0]
dummya=dummy pos:[-sep,-sep,0]
dummya=dummy pos:[sep,sep,0]

$Dummy01.transform.controller = link_constraint ()
$dummy02.transform.controller = link_constraint ()
$dummy03.transform.controller = link_constraint ()
$dummy04.transform.controller = link_constraint ()
$dummy05.transform.controller = link_constraint ()
$dummy06.transform.controller = link_constraint ()
$dummy07.transform.controller = link_constraint ()
$dummy08.transform.controller = link_constraint ()
$dummy09.transform.controller = link_constraint ()

$dummy*.name = "Reference"

circlrad=sizebox.value*3.2
circlehcentre=circle radius:circlrad pos:[0,0,0]
circlehcentre.wirecolor=blue
circlehcentre.name = "Controller_Horiz"

circlevgauche=circle radius:circlrad pos:[0,-sep,0]
circlevgauche.wirecolor=green
circlevgauche.rotation.x_rotation=90
circlevgauche.name = "Controller_Vert"


)--end on creref

on delbutton pressed do
(
q = querybox "Are you sure you want to erase references ?" title:"confirmation"
if q then
delete $reference*
delete $Controller_*
--else close q

)--end on delbutton


on moveh pressed do
(
Dummieshc = for hc in helpers where (in coordsys $controller_horiz hc.pos.z < 0.01) and (in coordsys $controller_horiz hc.pos.z > -0.01) do hc.transform.controller.AddTarget $controller_horiz slidertime

)--end on moveh

on movev pressed do
(
Dummiesvc = for vc in helpers where (in coordsys $controller_Vert vc.pos.z < 0.1) and (in coordsys $controller_Vert vc.pos.z > -0.1) do vc.transform.controller.AddTarget $controller_Vert slidertime

)--end on movev

)--end utility


I explain the problem.
If you test (in view axis):
- Run the script.
- click on "create" button (the system will appear)
- place the timeslider on "0"
- click on "link dummies H" button (the dummies'll be linked to the horizontal circle)
- Go to "20" with the timeslider.
- Make a Rotation of "Controller_horiz" of 180° on Z axis.
- click on "link dummies V" button
- select "controller_vert" object and create a start key at "20" for it
- Go to "40" and make it turn on x axis.
you see ?

I have a line that select dummies which are near the circle pivot.
But here it select the dummies' position at frame "0". :sad:

Test the script and you'll see.

Worse ! If you click directly on "link dummies V" after running the script. The dummies will move. That's very strange :sad:

Someone have an idea of the trick?

Thank a lot for your greatful help ;)

BebeteLANUITE
01-25-2006, 01:17 PM
I made some tests.
And i see that when i move dummies by a circle and i take the other one. This one don't see the dummies have moved. For it, all of the dummies keep the same coordinates.
Only the circle that move the dummies see their coordinates.

Hope that help you. ;)

BebeteLANUITE
01-26-2006, 07:33 AM
I have two way to success the script.
It's a coordsys problem. Other objects don't see the dummies move. For them, they are at the same coordinates. that's weird.
So to make my "controller" select the good dummies, i can :
1: Ask like coordsys the controller is actually the target of the dummy selected by the "for loop". In this case i get the coordinates of the dummy.
2: Ask like coordsys an object which have as target the same controller.

- In the first case, i don't find a command line in the maxscript reference to get the target of an object (by the object's name not by the position in the target list).
- In the second case, the coordinates don't be the same than the controller. So, to find the precise coordinates of the current dummies to know with which controller to link it, will be very hard.

Do you have an idea to get the target of the current objet ?

Thanks for your help ;)

BebeteLANUITE
01-28-2006, 06:06 PM
No idea to solve my problem ? :sad:

Bobo
01-29-2006, 01:54 AM
No idea to solve my problem ? :sad:

I am really sorry and I mean no offense, but I have troubles understanding most of your descriptions. (I know writing in a foreign language is hard, I have been living in foreign countries for over 15 years)

Could you try explaining what you want in SHORT steps, algorithm-like? It might help both of us. Something like:

I want to
1. Pick object A
2. Go through all dummies
3. Get their position in coordinate system of A
4....

and so on.

As for getting the target by name, you can
1. Get the number of targets N in the controller,
2. Loop through from 1 to N,
3. Use the GetNode method to get each target,
4. Compare the name with the one you are looking for.

BebeteLANUITE
01-29-2006, 05:48 PM
Hello bobo.

there is no offense for me ;)
I know my english is very bad :sad:

I try to do this:
I have a 9 dumiies placed on a 9x9 square (like in my code)
1: I click on a button (horizontal)
2: Dummies in the same plan like the "controller_horiz" are linked to it (by link_constraint).
3: I turn the "controller_horiz" with animate button on.
4: I click on "vertical" button.
5: Dummies in the same plan like the "controller_Vert" are linked to it (by link_constraint).
6: I turn the "Controller_Vert" to animate it.

But my problem is the "controller_vert" don't know dummies moved with "controller_horiz".
When it select the dummies, it takes dummies that are not in the same plan of it.

Hope you understand my english ;)

Thank you a lot for your help bobo ;)

Bobo
01-29-2006, 05:55 PM
Hello bobo.

But my problem is the "controller_vert" don't know dummies moved with "controller_horiz".
When it select the dummies, it takes dummies that are not in the same plan of it.

Hope you understand my english ;)

Thank you a lot for your help bobo ;)

I understand now what you are trying to do (the Rubik's Cube setup, right?)
Thanks for the step-by-step explanation, this is how people should always describe their script before turning it into actual code...

I have to go shopping now, but when I come back, I will take a closer look at what is going on.

BebeteLANUITE
01-29-2006, 09:20 PM
Yess you're right, it's a rubik's cube rigging. ;)

Thank you a lot for your help bobo :thumbsup:

I wait for your reflexion.

Bobo
01-29-2006, 10:53 PM
Yess you're right, it's a rubik's cube rigging. ;)

Thank you a lot for your help bobo :thumbsup:

I wait for your reflexion.

Here are the updated handlers:


on moveh pressed do
(
for hc in helpers where (abs ((hc.transform.row4 * inverse $controller_horiz .transform).z) < 0.1) do
(
for i = hc.transform.controller.getNumTargets() to 1 by -1 do hc.transform.controller.deleteTarget i
hc.transform.controller.AddTarget $controller_horiz slidertime
)
)--end on moveh

on movev pressed do
(
for vc in helpers where (abs ((vc.transform.row4 * inverse $controller_Vert.transform).z) < 0.1) do
(
for i = vc.transform.controller.getNumTargets() to 1 by -1 do vc.transform.controller.deleteTarget i
vc.transform.controller.AddTarget $controller_Vert slidertime
)
)--end on movev

*Instead of In Coordsys, I used multiplication by the inverse of the matrix.
*Instead of .pos. I used the .row4 of the transformation matrix.
*Don't need the assignment in front of the FOR loop as you are using DO and not COLLECT.
*Don't need two checks, as -0.1 and +0.1 can be checked using ABS of the value.
*Before linking to the new circle, I delete all targets from the dummies that were filtered by the FOR loop.

Tried to rotate a couple of times in different planes with 90 and 180 degrees, seems to work...

BebeteLANUITE
01-30-2006, 06:56 PM
Hello bobo.

Thank for the time you give to my problem :thumbsup:

I test your script. It's work fine for the selection of the dummies. (i don't uderstand your script yet :p, but i analyse it ;))

But if i animate it. I have some weird results. Like the dummies don't know where they are before animate. Or take the last controller like coordsys.

What do you think about it?

The code with your modifying.

utility dummy "DummyLink"
(
group "Creation"
(
spinner sizebox "Size :" range:[1,10000,10] type:#integer
button creref "Create" width:120
button delbutton "Erase All" width:80
label espc " " height:2
)--end group

group "Link"
(
button moveh "Link Dummies H" width:100
button movev "link Dummies V" width:100
label esprot " " height:2
)--end group

on creref pressed do
(
sep=sizebox.value+(sizebox.value/2)

dummya=dummy pos:[0,0,0]
dummya=dummy pos:[sep,0,0]
dummya=dummy pos:[-sep,0,0]
dummya=dummy pos:[0,sep,0]
dummya=dummy pos:[0,-sep,0]
dummya=dummy pos:[sep,-sep,0]
dummya=dummy pos:[-sep,sep,0]
dummya=dummy pos:[-sep,-sep,0]
dummya=dummy pos:[sep,sep,0]

$Dummy01.transform.controller = link_constraint ()
$dummy02.transform.controller = link_constraint ()
$dummy03.transform.controller = link_constraint ()
$dummy04.transform.controller = link_constraint ()
$dummy05.transform.controller = link_constraint ()
$dummy06.transform.controller = link_constraint ()
$dummy07.transform.controller = link_constraint ()
$dummy08.transform.controller = link_constraint ()
$dummy09.transform.controller = link_constraint ()

$dummy*.name = "Reference"

circlrad=sizebox.value*3.2
circlehcentre=circle radius:circlrad pos:[0,0,0]
circlehcentre.wirecolor=blue
circlehcentre.name = "Controller_Horiz"

circlevgauche=circle radius:circlrad pos:[0,-sep,0]
circlevgauche.wirecolor=green
circlevgauche.rotation.x_rotation=90
circlevgauche.name = "Controller_Vert"


)--end on creref

on delbutton pressed do
(
q = querybox "Are you sure you want to erase references ?" title:"confirmation"
if q then
delete $reference*
delete $Controller_*
--else close q

)--end on delbutton


on moveh pressed do
(
for hc in helpers where (abs ((hc.transform.row4 * inverse $controller_horiz .transform).z) < 0.1) do
(
for i = hc.transform.controller.getNumTargets() to 1 by -1 do hc.transform.controller.deleteTarget i
hc.transform.controller.AddTarget $controller_horiz slidertime
)
)--end on moveh

on movev pressed do
(
for vc in helpers where (abs ((vc.transform.row4 * inverse $controller_Vert.transform).z) < 0.1) do
(
for i = vc.transform.controller.getNumTargets() to 1 by -1 do vc.transform.controller.deleteTarget i
vc.transform.controller.AddTarget $controller_Vert slidertime
)
)--end on movev
)--end utility



thanks a lot for your help :thumbsup:

Bobo
01-30-2006, 11:37 PM
Hello bobo.

Thank for the time you give to my problem :thumbsup:

I test your script. It's work fine for the selection of the dummies. (i don't uderstand your script yet :p, but i analyse it ;))

But if i animate it. I have some weird results. Like the dummies don't know where they are before animate. Or take the last controller like coordsys.


This is correct. My version is not animatable, because each time you press a button, the linking from the previous turn would be removed and a new one will be created, basically replacing one linking with another.

I guess you would have to play with the weights of the links instead and animate them to 0 for all other targets and to 100 for the current one...

BebeteLANUITE
01-31-2006, 06:41 AM
Hello bobo.

I think is it too.
For your trick. Link_constraint don't have "weight". Is only one "controller" per time.

Do you know a tools that link objects to severals objects with weight ?
Because it will be a good idea.

Do you know why when a dummy is link to a controller, his movements are not visible to other controllers and even all objects?
Because is where is my problem. Just to select and link dummies to the good controller.

Thank you so much bobo !! ;)

Bobo
01-31-2006, 02:23 PM
Hello bobo.

I think is it too.
For your trick. Link_constraint don't have "weight". Is only one "controller" per time.

Do you know a tools that link objects to severals objects with weight ?
Because it will be a good idea.

Do you know why when a dummy is link to a controller, his movements are not visible to other controllers and even all objects?
Because is where is my problem. Just to select and link dummies to the good controller.

Thank you so much bobo !! ;)

Yeah, wrong controller :) But you can KEYFRAME the change from one parent to the other in the Link Constraint, right? (This is what it is for after all - animating the parenting and changing the parent).

You were using the .POS property of the dummies. I changed the code to use the .ROW4 of the Transformation Matrix (which is created by the Link Constraint itself) so everybody should "see" the changes. The only thing I did wrong was removing the previous linking and adding new parents in all affected dummies instead of creating keyframes at the current time in the Link Constraint...

BebeteLANUITE
02-03-2006, 02:05 PM
Hello bobo :thumbsup:
How are you ? ;)

Thank so much for your help.
I didn't know the row4 matrix.

In my code, Instead of .pos, i put the .transform.row4 to select the good dummies to link to the good controller. I got to give precise coordinates to make the selection.
:D IT WORKS !!! :D .

I just have a last question ;)

I try to put "in coordsys $controller" before "$dummy.transform.row4" but it give me the coordinates in coordsys of the world, i think.

--- It possible to do it or the row4 can't be see through another coordsys ? ---

Why this question? I explain to you ;)
if i animate the rubiks cube. with the actual code, I must animate all of the rubiks swaps ,before.
After, i can move the entire rubiks to make jumps or somethings like that.
If i make the swaps and the movements. I can't put an other swap because the system will not able to select the good dummies to link. Due to the precise coordinates i put.

In a old code, i use the coordsys of the controller (like you show me ;) ) to select the dummies. It's more sure because even the system move the coordsys of the controller stay the same and continue to select the good dummies to link.
But i have this problem of invisible movement of linking objects. That's be fix with the Row4.

Do you understand my thinking ?


Thanks a lot for your powerful help mister Bobo ;)

Bobo
02-03-2006, 02:34 PM
Hello bobo :thumbsup:
How are you ? ;)


I try to put "in coordsys $controller" before "$dummy.transform.row4" but it give me the coordinates in coordsys of the world, i think.

--- It possible to do it or the row4 can't be see through another coordsys ? ---



In my code, I had

(vc.transform.row4 * inverse $controller_Vert.transform)


This is sort of equivalent to using in coordsys, with the difference that in this particaluar case, it gives you the desired result ;)
Since the Link Constraint is a Transform controller (on top level of the controllers hieararchy), the .transform property returns the FINAL matrix calculated by the Link Constraint. .ROW4 returns the position (translation component) of that matrix, which is the world coordinate of your dummy in this case. Multiplying it by the inverse of the transformation matrix of another object transforms the dummy position into the coordinate system of that object, in this case the $controller_Vert. This multiplication by the inverse of a matrix is what IN COORDSYS does internally anyway. But telling your script to use the explicit matrices of both objects guarantees the correct result in this case.
The Link Constraint is a special case - it does ANIMATED PARENTING (LINKING) to other objects, which technically means transforming the children in the coordinate system of the parent. Thus accessing the .pos via MAXScript would return the position of the dummy stored in the Position controller below the Link Constraint, and in this particular case the .pos would contain the translation in parent space relative to the current parent set in the Link Constraint, not the world position.

Using this knowledge and reading a bit more about matrix3 values should help you transform anything into any space.

Or wait for my upcoming DVD ;)

Btw, you have picked one of the most complex animation cases one could imagine... and doing well so far :thumbsup:

marktsang
02-03-2006, 02:53 PM
Btw, you have picked one of the most complex animation cases one could imagine... and doing well so far

do you really think it is one of the most complex bobo?

i did a rubixs cube rig some time ago , and made it in few hours and found it very easy. http://www.sitesled.com/members/marktsang/portfolio/rigging/movies/rubix.swf

mark

Bobo
02-03-2006, 08:34 PM
do you really think it is one of the most complex bobo?

i did a rubixs cube rig some time ago , and made it in few hours and found it very easy. http://www.sitesled.com/members/marktsang/portfolio/rigging/movies/rubix.swf

mark

I think FOR A NEWBIE, rotation with changing parents and multiple degrees of freedom is heavy. Most people start with "I want a spinner to rotate a box" ;)

BebeteLANUITE
02-03-2006, 09:32 PM
To marktsang :

Yes, Bobo is right. I'am new in scripting.
I start learning maxscript because I have an animation of a rubiks to do.
I start scripting 4 weeks ago and i don't imagine this rigging so complicated.
I wanted to have the most ergonomic tool as possible.
Fully animatable and modifiable.

I success with the help of bobo, halfvector and joconnell. I can do it :thumbsup:
There is some things to do to make the tool fully ergonomic. But i am very happy :D

I have a lot of tool ideas to automatize some repetitives functions ;)

To bobo :
I wait for your DVD ;).

Thanks a lot again for your help :thumbsup:

BebeteLANUITE
02-06-2006, 07:16 AM
Oh god !! :eek:
Bobo, you're a king of maxscript, man !! :eek:

I put your line code in my script (about inverse matrix)
It works greatfully !! :thumbsup:

I'am not oblige to animate my rubiks cube in place before make it jump.
I can make the jumping and animate the swaps after. I can animate the jumping in the same time of the swaps. My code take a very good ergonomical way. :D
That's so much cool. :D

I put some ergonomical functions in the script and i can begin to make an example of animation.

Thanks !! Thanks !! Thank !! Mista Bobo :thumbsup:

CGTalk Moderation
02-06-2006, 07:16 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.