Attach switch layer to a point in another layer

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
CartoonLearning.com
Posts: 22
Joined: Wed Sep 16, 2009 6:08 pm
Location: Michigan
Contact:

Attach switch layer to a point in another layer

Post by CartoonLearning.com »

Does anyone have a plugin that will let me attach the origin of a switch layer folder to a point in another layer (not involving a bone)?

For example: I'm rigging a character with the shoulder to wrist as one layer of a switch layer file with multiple stages of bending. I have switch layer hands to attach to the end of this. I would use bones and parent the switch layer bone to the radius/ulna bone, but the distance between the shoulder and wrist changes as the arm bends, especially if the arm is rotating toward the camera. I don't want to use the typical humorous and radius/ulna in this particular case.

Anyone know of a plugin?

Thanks,
Eric
Free Anime Studio content at
http://www.CartoonLearning.com

Learn Anime Studio at
http://www.animationtrainer.com
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I would have to say there probably is no easy way to "lock" the hands to arm using the technique you described.

AS 7 has a new feature for binding layers to a path, however this probably won't work because you want to bind a layer to the point motion of switch layers. The follow path feature doesn't work in that case.

A script like that would be difficult due to the switch layers. you would need to track the points of the active switch layer and the movement of the points during transition. The math makes my head spin ;). Never even tried to access the point motion inside a switch in this way.

I am not saying it isn't possible but... there are easier better ways to rig an arm which doesn't require that type of thing. Foreshortening and smooth bending is possible using bones instead of switch layers. Then the hands can easily be bound to a hand bone.

Can you explain why you need the arm rigged in this way? There might be a better way to do it.

-vern
User avatar
CartoonLearning.com
Posts: 22
Joined: Wed Sep 16, 2009 6:08 pm
Location: Michigan
Contact:

Post by CartoonLearning.com »

The arm was just an example.

I don't know the programming side, but in my mind I can picture the ability to add a second "origin point" that's not related to shearing or layer translation. The switch layer could then be attached to the 2nd origin. (I use the word origin because it would be nice to be able to use this feature with image layers as well as vector layers.)

Actually, there's no reason a second origin would be needed. How difficult would it be to be able to attach one layer to another layer's origin?
Free Anime Studio content at
http://www.CartoonLearning.com

Learn Anime Studio at
http://www.animationtrainer.com
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

CartoonLearning.com wrote:Actually, there's no reason a second origin would be needed. How difficult would it be to be able to attach one layer to another layer's origin?
Hmm... would this solve the problem of the changing arm length and the hand attached to the arm? Binding one layer to another layers origin would probably be quite easy actually but doesn't really solve the problem of the arm length changing since the origin stays the same. The hand "switch" still would not stay attached to the "end" of the arm.

Maybe I don't understand why you need this feature. It could be done so easily using bones. If you bind two or more layers to the same bone you get the same effect. Moving a bone moves the layer and its origin point. If two layers are bound to a bone then by default the origins are "bound" so to speak. You would still be able to rotate the bound layer independently of the bone binding or you could put a bone in the switch and use that.

----------------

Or are you talking about binding a layer to a vector layers POINT origin center point? The center of the bounding box around a group of points? That is a totally different "origin". Not impossible to script and could be an interesting experiment. Very intriguing.

Could you post some kind of example of what you are doing? An animation possibly or AS file? I don't think I "get it" yet.

-vern
User avatar
CartoonLearning.com
Posts: 22
Joined: Wed Sep 16, 2009 6:08 pm
Location: Michigan
Contact:

Post by CartoonLearning.com »

Thanks for your help, Vern. For now, I think I found a decent work-around for what I needed to do.

In the meantime, do you know of a plugin that would allow me to control switch layers automatically when bones hit set angles?

i.e. As a bone's angle changed from 10 degrees to 20, 30, 40, and 50, it would automatically switch from switch layer 1 to 2, 3, 4, and 5.

Anything like that exist?
Free Anime Studio content at
http://www.CartoonLearning.com

Learn Anime Studio at
http://www.animationtrainer.com
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Yes something like that does exist. I can't remember if I posted it on the forum yet or not.

I created a switch control script. It was designed so I could control a switch layer using a single bone rotation in the parent layer. The way it worked is 360 would be divided by the number of layers in a switch. Rotating the controlling bone would then make the switch change based on the angle. It is not "automatic" and requires that you rotate a control bone to make the switch layer change. I was tired of having to select a switch layer to change it. This made it much easier.

I suppose a modification to the script might work to have a specific switch layer selected when a bone hits a certain angle. It would probably need to be based on the bone name, the bone name would have the angle and layer name to select... hmmm.... just thinking out loud. When I get a chance I will take a look at it again.

-vern
Post Reply