View Full Version : Two/one/no-handed weapon rigging (pivot question)
ThreeHams 07-04-2005, 08:24 PM I've been working on a character rig in 3ds max which includes four weapons, all of which can be gripped and used interchangably, holstered/sheathed, and moved independently of the character. Everything is working out well except the staff. At the moment, I can animate it, but it definitely isn't ideal.
http://www.landofsunshine.net/absinthe/temp/characterstudy/progress05.jpg
The way this currently is set up, the IK arm becomes constrained to a control on the staff. The controls for both hands are parented to the staff itself, which is what is actually animated. This gives really smooth rotation (and makes spinning moves very, very easy) but, unfortunately, I only have one pivot to work with. Considering the movements I have in mind, I'm going to have it held at different points on the staff.
I'd like to have a pivot that can float along the staff and drive its rotation. so either hand can easily lead a strike. Unfortunately, every constraint setup I can think of causes a dependency loop. I've seen animatable pivots before (in Puppetshop and CS 4, for instance) but I can't seem to find any information on how to create them along even a simple line like this. A multiple-pivot system (like a foot rig) won't work in this case, since there's no base plane like there is on a foot. A simple two-point IK system would work, but would be a real pain to animate smoothly. Any ideas on how I could accomplish what I'm looking for?
|
|
JHaywood
07-04-2005, 09:04 PM
Ultimately you want to be able to move the control while keeping the staff in the same position right? The only thing I can think of is creating a script controller, or callback function, that will counter move the staff when the control is moved. I did something similar to this where the slice plane of a slice modifier is kept in the center of another object as the object with the modifier on it is moved around. A programmer at work helped me figure it out, so I'll see if the same, or similar, expression used for that will work in this case also once I get to work tomorrow.
ThreeHams
07-04-2005, 09:58 PM
That's a great idea. It's definitely a very different (and much simpler) way of thinking than I was doing.
JHaywood
07-05-2005, 11:50 PM
I tried a couple scripts within script controllers that almost work, but not quite. So I'm still researching the issue. I think it would be very helpful overall to figure this out. Stay tuned. :)
JHaywood
07-06-2005, 02:41 AM
Okay, here's an option. Bear with me.
You have four objects.
1) Staff
2) Dummy01
3) Dummy02
4) Dummy03
Align 1, 2, and 3 together so they're aligned on their position and rotation axes.
Link 1 and 2 to 3, but not to each other.
Add an Orientation Controller to 1, and make 2 it's target. So 1 will follow 2's rotation.
On object 4, add a script controller to the Scale, or whatever. The only reason it's here is to hold the script controller and avoid dependency loops.
In the script controller properties, without overwriting what's already there, add this:
dependsOn $Dummy01
with animate off ($Staff.pivot = $Dummy01.center)
Now you can move Dummy01 wherever you want on the staff and rotate it, and the staff will rotate around the center of it. For some reason, keys get added to the staff and mess it up if you don't put the 'with animate off' context in there.
See the attached file. If you play the animation, you can watch the staff rotate around different pivot points. Then try moving Dummy01 around and rotating it. Dummy02 is there so that both the Staff and Dummy01 can be moved together.
ThreeHams
07-06-2005, 04:27 PM
Pretty nice, but 3ds max appears to have a nasty glitch when undoing an action with an animated pivot.
To demonstrate:
- Open the file you sent me.
- Move to frame 30 and change Dummy01's keyframe (just move it somewhere else)
- Move to frame 25 and Undo.
Whoa! If you move back to frame 0, the whole staff has shifted over, but its pivot has stayed in the same place. I'll have some time later tonight to look into this, maybe try to find a way to work around it since it works so fluidly otherwise.
ThreeHams
07-06-2005, 05:08 PM
Wow. Saving the file (including autosave) while the pivot is in transition also causes it to glitch out. Animating the pivot attribute on an object doesn't seem entirely stable in Max 7...
JHaywood
07-06-2005, 06:04 PM
Wow. Animating the pivot attribute on an object doesn't seem entirely stable in Max 7...
Can't say I'm surprised. :) This probably relates to the bigger issue of why Max doesn't have an animatable pivot by defualt.
ThreeHams
07-06-2005, 07:42 PM
CS 4, on the other hand, does come with a built-in animatable pivot. I wonder if it'd be worth trying to hijack it from that.
JHaywood
07-06-2005, 09:30 PM
you're talking about the biped feet right? I'm guessing the pivot of the feet is placed more than animated. What I mean is that there are predefined locations for the pivot, you can't move it wherever you want, unlike the feet in a Puppetshop rig. Those are pretty slick and I'd like to know how he did that. :)
ThreeHams
07-07-2005, 12:27 AM
Puppetshop is great! I've thought about shoehorning this rig into it, but I'm not sure how well the layers I already have will play along with it. I also wonder what he's managed to add to the latest versions, since they're exclusively used at Bioware right now...
I know Paul Neale was talking about writing an animatable pivot modifier at some point, but I don't think he ever released it. Not that I blame him... I'd rather see his fourth rigging DVD right now, anyway. :)
JHaywood
07-07-2005, 12:51 AM
Yes, but we'll crack this yet. :)
Here's another option:
obj = box()
theMod = bend()
--theMod = xForm()
addModifier obj theMod
fs = float_script ()
obj.length.controller = fs
str = stringStream ""
format "bx = $Box01\n" to:str
format "objTM = bx.objectTransform\n" to:str
format "modTM = getModContextTM bx bx.modifiers[1]\n" to:str
format "with animate off (bx.pivot = theMod.center * (inverse modTM) * objTM)\n\n" to:str
format "25.0" to:str
str = str as string
fs.script = str
This one gets closer because you don't need multiple objects. But there's still a problem. After you run the script, you can move the Center of the Bend modifier to move the box's pivot around. And since the Center can be animated so can the pivot!
The buggy part though, is that if you create an animation where the pivot moves around to a few different places, like I animated the staff in the first try, and then you just scrub the time slider back and forth real fast, the box will move around in the scene independently from how it was animated. Very frustrating.
ThreeHams
07-07-2005, 01:02 AM
Hey, I found a similar solution a couple minutes ago in this thread:
http://cgtalk.com/showthread.php?t=207691&highlight=xform+pivot
There's a video tutorial in there that involves using an Xform modifier. The cube works pretty well, but I'm just now trying it with a staff. There seem to be some strange problems that pop up, and it's definitely not very easy to make changes to keyframes in the middle of an animation.
I'll keep posting. This is a lot more fun when it's not just me banging my head against the desk :).
JHaywood
07-07-2005, 01:31 AM
Yep, a programmer here at work got me thinking about using the modifier gizmos. I like the idea of animating the Center since in a real animation, you're probably not going to animate the pivot point that often, but it seems cumbersome to animate the gizmo as well. But that's definitely a way to go if all else fails.
The animatable pivot in puppetshop was pretty tricky to get to work and I had to do a little bit of SDK work to make it function 100%. Other then that, yea it works ok so far ;)
I think though it can be done with a scripted controller, especially since they are now pretty fast in 7, but back when i wrote it in max5 it wasn't really an option.
When the next version of Puppetshop is announced (looking at next spring-ish) I can probably share a lot more. Lots (!) of new goodies added.
Doesn't really help answer your question much, I realise that, sorry.
-Kees
JHaywood
07-07-2005, 03:09 AM
Thanks for the input. I realize you can't share too much about the tool. I tried poking around in your scripts, but apparently all the good stuff is in the .mse files. ;)
Can you tell us if we're on the right track at least? :)
ThreeHams
07-07-2005, 04:13 AM
Got something, but unfortunately, instancing an animation controller on a point helper and center gizmo causes a strange result - moving the point causes both the center and the Xform gizmo to move together. The end result might actually work for what I'm trying to do, but it definitely isn't what we're trying to accomplish here, and could probably be done without an Xform modifier at all.
I tried using script controllers to counterbalance the movement, but my one week's experience in Maxscript just ended up breaking things more :hmm:. I think it's a local vs. world transform issue, but I'm not sure. Here are a couple files in case you want to play around with them.
Here (http://www.landofsunshine.net/absinthe/temp/pivot/staff-helpers1.zip) and here (http://www.landofsunshine.net/absinthe/temp/pivot/staff-helpers2.zip).
ThreeHams
07-07-2005, 04:45 AM
Actually... hmmm... those files I just sent you can be accomplished with the staff, two helpers, and no modifiers. Unfortunately, the counter movement seems to create a dependency loop. My head hurts.
JHaywood
07-07-2005, 06:05 AM
The animations look good. What are the point helpers for?
If you want to read up on where I got some of my information, look up "Modifier Sub-Object Transform Properties" in the maxScript reference.
James,
The way I did the animatable pivot is to have 2 helpers that counter move/rotate.
IkChain is linked to helperA and HelperA is linked to HelperB
IKChain -> helperA -> HelperB
When HelperB move and rotates, HelperA counters this movement and rotation to keep the IK chain in the same location.
The math is a little harder to understand then what I am describing here, but this is the basics of it that might get you going.
I am leaving out a few things that I cannot share right now, but perhaps you will find these out when you start playing with this. Once you have the counter moving on both objects working, you will find out that that is not all there is to it to work intuitively...
At that point, Character Studio should be able to give you a hint...take a good look what happens when you switch the pivot and if the pivot actually switches on that frame, or the next ... ;)
-Kees
ThreeHams
07-07-2005, 03:58 PM
hmmm... I didn't even think of using an IK chain as a base. The concept seems simple enough - it's the math that's the problem. Still, it'll be nice to finally learn enough Maxscript to do something more just turning off Turbosmooth globally :).
JHaywood - The point helpers are just linked to the Center and Gizmo parts of the Xform modifier by instancing the animation controllers on each. On another attempt, I linked them together with a script controller, but it accomplishes the same thing. It's too bad they don't work the way I expected them to, but it looks like it's easier to just avoid using the modifiers altogether.
JHaywood
07-07-2005, 04:33 PM
The simplest approach is manipulating the pivot of the staff, or any object, directly. This seems to work fine until you start moving keys, playing the animation, or scrubbing the time slider back and forth, which of course you hardly ever do when you're animating right? :) It seems like Max is sometimes moving the object before it's moving the pivot. If there were some way to ensure that when you went to a new frame, the pivot got calculated before the position, I think it would work fine. So that's one approach to keep researching.
And then Kees was kind enough to give us another road to go down. I'll definitely chew on this one also. :)
CGTalk Moderation
07-07-2005, 04:33 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.