Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 24-10-2006, 03:27 AM   #1
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 368
Thanks: 0
Thanked 0 Times in 0 Posts
Default smart switch

I have a creature model that is basically just a body and 2 arms. The arms use an IK solver. The model is rigged so that I can move the body without moving the arms. This way, the arms can be posed so that when the body is bobbing and rotating, the arms appear to be supporting the body. Like a legless man using his arms to hold himself up.

There are going to be times when I want the arms to move with the body. For instance, times when the creature uses its arms to throw itself into the air. At those times I want the arms to move with the body but still be animatable. In other words, I want the arms to be parented to the controller that I use to move the body but also able to move relative to its following of the body. I decided that I can't just set up a point constraint between the body controller and the IK controllers on the creature's wrists because.

If I parent the IK controllers on the creature's wrists to the body controller then the arms will move with the body and I will also be able to move the arms relative to the body (have them swing around while the creature moves through the air). The problem is that you can't turn off the parenting of the arm IK controls to the body so that I can also have the body move without moving the arms. (NOTE: Parenting, not Parent constraint)

My solution was to make an attribute on the body controller that could be keyed from 0 (off) to 1 (on) and then write an expression that would either parent or unparent the arm IK controls from the body controller based on the state on the attribute.


The creature body controller is called Monster_handle
The custom attribute is called IK_mag

Here is the script I wrote:

float $mag= `getAttr Monster_handle.IK_mag`;

if ($mag==0)
{
select -r Lft_wrist_ctr ;
parent -w;
select -cl;
select -r Rg_wrist_ctr ;
parent -w;
}
if ($mag==1)
{
select -r Lft_wrist_ctr;
select -tgl Monster_handle;
parent;
select -cl;
select -r Rg_wrist_ctr;
select -tgl Monster_handle;
parent;
}


The script works well enough but during animation it generates error messages since the state of the IK_mag attribute is being evaluated at everyframe which causes the expression to try to parent the control objects every frame (if IK_mag==1) or unparent them every frame (if IK_mag==0). In other words, the expression is trying to parent something that is already parented or unparent something that is already unparented.

My problem is that I don't know enough MEL to write a routine that will not execute the parenting/unparenting commands if the IK_mag attribute hasn't changed from the previous frame.

Can anyone help me? Is there a way to write a routine that basically states "if nothing has changed then skip to the next frame"?
__________________
James Rogers
www.morphicmotion.com

Last edited by Velusion : 24-10-2006 at 03:32 AM.
Velusion is offline   Reply With Quote
Old 24-10-2006, 05:26 PM   #2
AlphaFlyte
Subscriber
 
AlphaFlyte's Avatar
 
Join Date: Nov 2003
Location: Sweden
Posts: 326
Thanks: 0
Thanked 3 Times in 3 Posts
Default

This sound like an evil workaround for the problem in my ears. I am no expert by far and by any means, but I think what you want is the possibility to switch between forward kinematics and inverse kinematics with an on / off switch or some such.

Now how to rig and set this up is a book's worth alone, and way beyond my own knowledge thus far.
__________________
Currently working on reclaiming Space
The Salvation Prophecy
AlphaFlyte is offline   Reply With Quote
Old 24-10-2006, 06:03 PM   #3
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 368
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'll try to post a short clip later on today to better explain what I'm doing. I don't think it's an IK/FK problem though. It has to do with being able to turn parenting (not parent constrain) on and off. I think the video I will post will explain it all.. stay tuned.
__________________
James Rogers
www.morphicmotion.com
Velusion is offline   Reply With Quote
Old 24-10-2006, 08:11 PM   #4
Xander-0
Registered User
 
Xander-0's Avatar
 
Join Date: Feb 2005
Location: This Place
Posts: 220
Thanks: 0
Thanked 2 Times in 1 Post
Default

waaaay simpler method to do this;

after parenting the ikSolver to the control for it, you can parent that control to the controller for the whole body. This means that if you move the body, all the controllers with it (so when the creature jumps, the legs go too....). So how do you get it to bob around with its legs held steady on the ground (or anywhere)? Simple - create a locator. Then, point constrain (preferably, although I suppose occasionally a parent constraint can be used) the ikSolver's control handle to the locator (they don't even have to be in the same loaction either, although for obvious reasons doing this makes sense.). This will keep the feet in one posistion, allowing the body to move around without disturbing them. And it even has a built-in switch - when you want the thing to jump from that spot, simply set that point contraint's attribute to '0', and away you go.

That help?
__________________
Book Wise

http://X4nd5r.deviantart.com
Xander-0 is offline   Reply With Quote
Old 25-10-2006, 03:26 AM   #5
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 368
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry I didn't have time to prepare a video clip to show you guys but it looks like you understand my rigging/mel problem...

Xander-0,
Your idea seems promising. I haven't had time to test it but one thing that jumps to mind is the offset between the locator and the IK handle control once you point constrain them together. I agree that you can turn the constraint off but I think that once you turn it back on, the IK handle will snap back to the original offset position. I actually came up with a solution that was very close to the one you came up with but as I have already mentioned, once you turn the constraint back on, the IK control goes right back to the position of the point constraint plus the original offset. This is why I have been pursuing an expression that simply parents and unparents the IK handle to the body control. Again, my script works but the error message is just something I'd rather not have to look at. I'm still open to any and all ideas.
__________________
James Rogers
www.morphicmotion.com
Velusion is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.