PDA

View Full Version : multiple Spinner controller


Da_elf
12-16-2007, 06:39 PM
im using an orientation constraint on a bone in an arm so that its got two targets (a bone for FK and one for IK) there are therefore two weights. at 1st i had them wired so that one weight was the inverse of the other. now that im going to use maxscrpt to control the weights i needed to remove the wireing since it was messing up the maxscript. currently ive got this piece of code

spinner RightIKSpn "Right IK" pos:[58,432] width:68 height:16 range:[0,100,0] controller: $Colonel_Right_Arm_2.rotation.controller.weight[1].controller


basically this allows my spinner to alter the weight 0 of the constraint. my inverse equation was that weight#2 = ((weight#1)-100)/-1 that was when weight 1 = 100 weight 2 = 0 and when #1 = 75.... #2 = 25

so what i need now is that when my spinner changes #1 i also need #2 to change using my little equation. when i looked up spinner in the maxscript help file i didnt see anything about multiple controllers.

RustyKnight
12-16-2007, 10:51 PM
im using an orientation constraint on a bone in an arm so that its got two targets (a bone for FK and one for IK) there are therefore two weights. at 1st i had them wired so that one weight was the inverse of the other. now that im going to use maxscrpt to control the weights i needed to remove the wireing since it was messing up the maxscript. currently ive got this piece of code

spinner RightIKSpn "Right IK" pos:[58,432] width:68 height:16 range:[0,100,0] controller: $Colonel_Right_Arm_2.rotation.controller.weight[1].controller


basically this allows my spinner to alter the weight 0 of the constraint. my inverse equation was that weight#2 = ((weight#1)-100)/-1 that was when weight 1 = 100 weight 2 = 0 and when #1 = 75.... #2 = 25

so what i need now is that when my spinner changes #1 i also need #2 to change using my little equation. when i looked up spinner in the maxscript help file i didnt see anything about multiple controllers.I'm probably not the best person to answer this, but depending on how you've rigged it all together...you could use the spinners on changed event.

This is a simple script call back where you could effect a number of controls simultanously.

Otherwise I'd look at setting up some kind of scripted controller or wired parameter - linking the two controllers to the single spinner and calculating the desired result from the value of the spinner

Shane

MoonDoggie
12-16-2007, 11:22 PM
Absolutely not helping on this forum too ;) j/k.

Decipher my example to examine how callbacks work and on spinner changed do ( ) event handlers work. It'll do what you need :)

-Colin

PEN
12-17-2007, 12:30 PM
Well I'm not sure why you need to do this in the CA def? Create the spinners and wire to those with the correct math.

The first weight will have theSpinner as the expression and the second should have 100-theSpinner to invert it. Unless you have planes for something further that you are not mentioning.

MoonDoggie
12-17-2007, 03:30 PM
Paul,
Question for you related to this thread. How do you use wire params on rollout ui objects (like spinners) that haven't been created yet? If this were my problem, I would hook the event handler "on spinner changed" and then register a callback for "when parameters spinner changed" if necessary. Is there an easier way to setup direct relationships?

Thanks,
-Colin

Da_elf
12-17-2007, 05:09 PM
actually i did end up doing wiring. i had things wired when i 1st did the maxscript and for some reason i was having problems. after i took the wireing off it worked. but then when i put wiring back on things were still working so its all working well now.
thats my control pannel
http://www.elfpro3d.com/Turtles/controls.jpg

unfortunately the snap IK still isnt figured out yet. i guess ill get it one of these days. neither the locks hehe. ive atleast got it looking like what i want in my control pannel and now just need to work on the actual code behind everything. a basic sample code is this

spinner OOSpn "OO" pos:[35,58] width:68 height:16 range:[0,100,0] Controller: ($Colonel_Head.modifiers[#morpher])[1].controller
button OOBtn "X" pos:[67,81] width:15 height:15
on OOBtn pressed do
(
deselectKeys $Colonel_Head
selectKeys ($Colonel_Head.modifiers[#morpher])[1] currentTime
deleteKeys ($Colonel_Head.modifiers[#morpher])[1].controller #selection
)


or


spinner RightIKSpn "Right IK" pos:[58,432] width:68 height:16 range:[0,100,0] controller: $Colonel_Right_Arm_2.rotation.controller.weight[1].controller
button RightIKDBtn "X" pos:[114,456] width:15 height:15
on RightIKDBtn pressed do
(
deselectKeys $Colonel_Right_Arm_2
selectkeys $colonel_right_arm_2 currenttime
deleteKeys $colonel_right_arm_2 #selection
)

then i wired the peramiter of the 2nd weight in the rotation controller to the 1st weight using weight 1 = (((weight 0)-100)/-1) with a 1 way wire going from weight0 as the master controlling weight 1 (the weights are named 0 and 1 in the controller but in maxscript they are titled 1 and 2)

MoonDoggie
12-17-2007, 05:14 PM
Looking good, can't wait to see it in action :)

PEN
12-17-2007, 06:30 PM
Oh sorry, thinking it was a Ca Def not a floating UI. You can't is then the answer. What you really need is a call back that updates the UI as the time changes. This way you can just use the event handler to drive what ever you want.

Although a cleaner method would be to create a Ca Def that has the tracks that will be driven. Wire to those as you need and drive those Ca def attributes with the floating UI. You could directly connect to them and wouldn't need the call back to update the spinners.

Da_elf
12-19-2007, 01:23 PM
call me stupid but whats a Ca Def?

MoonDoggie
12-19-2007, 02:54 PM
It's the gospel that PEN preaches around here.

Da_elf
12-19-2007, 03:08 PM
ah. my guess is its complicated then?

MoonDoggie
12-19-2007, 03:32 PM
Not really. It's a custom attribute def. It allows you basically to store a variable on a node/modifier/etc, and then you are able to wire the spinner to the custom attribute, and the custom attribute to whatever you wanted to control. Fairly straightforward, PEN could tell you the real power of them I suppose. I haven't played with them too much.

-Colin

Da_elf
12-20-2007, 08:42 PM
well. i need to find the bend controller for a spinner. need the spinner to be linked to the angle of a bend modifier. the stupid listner never gives me the correct syntax on anything

PEN
12-20-2007, 10:04 PM
It's the gospel that PEN preaches around here.

That sounds harsh.

Of course you can add custom attributes using the parameter editor and you don't have to write them your self at all.

MoonDoggie
12-20-2007, 10:05 PM
by going to your animation curve editor, and selecting your box, or whatever has the bend modifier on it, and expanding it, you'll see the track "angle", under "bend", this should give you understanding that the bend modifier has a property called angle, to which is assigned a default controller @ .controller, using this logic


spinner spn_angle "Angle" controller:$Box01.modifiers[#Bend].angle.controller


should work

Da_elf
12-24-2007, 05:34 PM
sorry. already went down that line of logic and it doesnt work
i get
unable to convert:undefined to type:controller

MoonDoggie
12-27-2007, 05:17 AM
I tried it and believed it worked. Maybe it didn't. I'll check again.

Da_elf
12-28-2007, 01:00 AM
nope. i tried a few times and it never works

Da_elf
01-02-2008, 06:17 PM
--(they need a delete post button on the forum)--

Da_elf
01-02-2008, 06:29 PM
i still have not figured out that bend modifier problem and my new one comes with using a possition constriant.

if i use the code

$Colonel_Eye_focus_dummy.pos.controller.weight[2] = 100

then i can alter one of the weights. however im trying to code something to delete a keyframe created for that weight


button XFree1 "X" pos:[392,288] width:15 height:15
on XFree1 pressed do
(
deselectKeys $Colonel_Eye_focus_dummy
selectKeys $Colonel_Eye_focus_dummy.pos.controller.weight[2] currentTime
deleteKeys $Colonel_Eye_focus_dummy.pos.controller.weight[2] #selection
)


currently im using

button XFree1 "X" pos:[392,288] width:15 height:15
on XFree1 pressed do
(
deselectKeys $Colonel_Eye_focus_dummy
selectkeys $Colonel_Eye_focus_dummy currenttime
deleteKeys $Colonel_Eye_focus_dummy #selection
)

which basically deletes the keyframes for everything with that object at that frame number but ive got 3 weights and i only want to get rid of the keyframe for that single weight only

U.S.S. Speed
01-02-2008, 08:01 PM
I will try to help with that Bend problem... However it may be wrong... So there you go. ;)

I had what I think was the same problem with controller of a spinner. (was a slider, but meh, same thing)

I had to rely on :

on MySpinner changed SpinnerState do
(
MyNode.controller.weight = SpinnerState
)

or something like that... I know it's not elegant, but it worked for me.

Or maybe I didn't understood your problem. :D

CGTalk Moderation
01-02-2008, 08:01 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.