PDA

View Full Version : Help with Brad Noble Rig IK/FK Snap Button


Mahlon
06-29-2006, 06:54 PM
Hey guys,

Contunuing with my dissection of Brad Noble's arm, I'm happy to say that I've been able to copy it, and what's more, actually understand what's going on. So everything is working great (IK/FK switch, swivel, and hand orientation, I'll get to twisting bones later) --- except for one aspect... that's the "IK to FK/Fk to IK Snap" Buttons and the "Lock Hand/Unlock Hand" buttons.

In Brad Noble's script to create and assign functions to the buttons in the attribute holder, he has variables which refer to a Node_Storage and a position script which is on a helper object named skeleton_rig_node_storage.

Now, I've tried to duplicate his script exactly (except that I have different names for my objects, but I account for those in my script). Here are the problems I'm getting, though, when I try to run the script:
(also, at the bottom of this post is my max file and script file if you want to have a first hand look)

First, here is an image of the position script on the Helper I have created for node storage:

http://www.lutanian.com/Problem/Node%20Storage%20Position%20Script.jpg

if you open the attached max file, you'll see that the variables are all assigned nodes of corresponding objects. So far so good.

When I try to run the "Arm IKFK Snap Script", which I created by copying relevant portions of Brad's script, I get the following error:

http://www.lutanian.com/Problem/Error.jpg

And here's an image of text from the script and where the error is occuring. I don't understand why he's using this.Node_Storage.node.position.controller.getnode, and what it means. Where does Node_Storage.node come from?
I know that it must be defining these variables, but I'm not sure logically what's going on and, of course, why I'm getting the error. I have nodes assigned to variables in the 'position script' on the helper object which I've named Node_Storage.

http://www.lutanian.com/Problem/IKFK%20Snap%20Script.jpg


Could someone explain a little about this node storage thing in really simple terms? And maybe why I'm getting the error? I've looked up Node in the maxscript help, but couldn't decipher much from available topics.

Thanks again, so much for you help so far, and I hope (if I can get this IKFK Snap figured out) that I can go ahead and finish the rig. It's really nice so far, and the IKFK Snap would be icing on the cake.

Mahlon

eek
06-30-2006, 04:25 AM
Its a way for a rig to reference a script without being name independant essentially. So hes making a ca variable for the object, then referencing via 'this' eg.

ca test attribute test_attribs
(
parameters test_param
(
test_val type:#float
)
)

custattributes.add $.pos.controller test

Then in the script you could have is:

scr = "this.test_val"
$.pos.controller.script = scr

But in 8, a scriptcontroller variable can be a node eg. 'chuck' then all you do is chuck.pos.controller etc etc, and it will rename itself, if you rename the object. Theres also reference monitor, but thats another thing.


So 'node storage' is a parameter.
'get node' is a command to get an object via a name thats why at the end is "ik etc" but hmm.. isnt that 'getnodebyname'.

thisvariable = thisnodes.parameter.itscontroller.getnode "theboject" - hmm... maybe its pulling the controller from another object or referencing it.

Chinwagon
06-30-2006, 08:35 AM
My ears are burning!
OK Mahlon, do you REALLY want to know the secret? It looks to me like you're just about there.
How it works is that there is a node store custom attribute called node_storage within the IK/FK snap custom attribute. That node is assigned to an object called (funnily enough) "Skeleton rig node storage". If you select the left IK arm control and type $.modifiers[1].IK_Arm_snap_L.node_storage.node in the listener you'll see it.
That object has a position script controller on it with variables created of all of the objects in the rig that are relevant to the IK/FK snap functions (and the relevant objects assigned to those nodes).
How it used to be done was that I would create nodes for each necessary object in the CAs using scripting but I would get dependency loop problems that I would have to work around. Since 3dsmax8 has the new weak references in the position script controllers, I just refer to one object with the position script controller and use that as it's quicker to calculate and a much more visual way of adding and removing the appropriate nodes.
The node_store CA was made by script using what I learned from the tutorial on Martin Breidt's website (http://www.breidt.net/scripts/script_controllers.pdf). It's considered an old method now but it still works for me.
As you've found, I then retrieve those nodes by their name in the position script controller (using .getnode you can use their name as I do, or the index number) when the IK/FK snap button are pressed and align the various positions and rotations to them.
Simple! ...although it took me ages to learn.
:¬)

Mahlon
07-01-2006, 07:01 PM
Thanks eek. Thanks Chinwagon (sorry to make your ears burn :) ).

I think I'm just about there, too. So there's a ca called 'node_storage' which is part of another custom attribute? And the node storage somehow (through the Snap script) gets the position/rotation information from the helper object called skeleton_rig_node storage?

I think I can get the ca called "node storage" where its supposed to go, but I'm not sure just yet how to make it 'connected' so-to-speak to the "skeleton rig node storage".

I'm going over the .pdf (thanks), and seeing if I can get it solved.

Mahlon

Mahlon
07-03-2006, 04:37 AM
I guess I just don't know how to write the code to make it happen. I can get nodeStore on an object (a la the pdf), but I don't know the code to write to get nodeStore into the IKtoFK Snap custom attribute -- and then how to make that get the variables stored in the $skeleton_rig_node_storage position script -- except I'm thinking that that's the part in the IK Snap ca.

Forgive me for shooting in the dark, but that's all I can do, as I don't yet speak the language. The tutorials I've done in MaxScript Help have helped, but it's something you can't learn in a few days, and I'm woefully deficient in thinking like a programmer. I'm am trying, though.

Thanks again for the help. Any more you want to offer up is most appreciated. I'm not necessarily just wanting an easy answer (though I do want to get the rig finished) but I would like to understand what I'm doing -- not just copy-cat blindly.

Mahlon

Mahlon
07-05-2006, 09:17 PM
Ok, so in this test scene; I’ve got a sphere01 which has an attribute holder modifier on it.
http://www.lutanian.com/Problem/For%20CGTalk/Attribute%20Holder.jpg

http://www.lutanian.com/Problem/For%20CGTalk/trackview.jpg

It has a custom attribute called “IK snap”. I’m trying to put a node store ca (like Brad mentioned above) on the IK snap CA. But I don’t know the proper syntax. Does what I have in the script below make sense? It’s "kind of" coming from the pdf to which Brad refers.


Brad, you also mention that this is considered an old method (in the pdf). Is there another way that I might accomplish this? Newer way?



Thanks again,
Mahlon

http://www.lutanian.com/Problem/For%20CGTalk/maxscript%20Question.jpg

CGTalk Moderation
07-05-2006, 09:17 PM
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.