Get child bone "real" position after parent bone r

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

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
heyvern
Posts: 7043
Joined: Thu Sep 01, 2005 8:49 pm

Post by heyvern »

Efrontier/LM really really needs a special place for script writers to upload scripts like this.

It would be a place JUST for scripts, descriptions, updates. Just scripts. No comments or additional posts.

Yes we could do it here, in theory, but it isn't the same thing. If all the "pinned" script posts got really long in the scripts forum it would be hard to read the actual scripting questions. I think it should be a top level forum category. Or a sub topic under scripting (can you do that with this forum software?)

it would have a spot for each person writing scripts, so they don't get "lost" in all the new posts. And possibly some way for users to evaluate their functionality. Like, a rating system. I don't want to hurt any feelings but not all scripts are created equally. I'm not that good so I would rate mine very low. ;)

-vern
User avatar
bupaje
Posts: 1175
Joined: Fri Nov 12, 2004 8:44 am
Location: California
Contact:

Post by bupaje »

Actually I guess we can do it ourselves since moderators can make topics sticky (don't like the sound of that!). ColdHardFlash does this in their plugins forum

http://bbs.coldhardflash.com/viewtopic.php?t=214

We could do a similar listing of scripts by author, allow no responses. One or more of the moderators can manage -all someone has to do is a PM them and say "you missed adding this one" or "I have a new link for my script can you change it" type thing.

Basically just an index to locations of all these assets.
[url=http://burtabreu.animationblogspot.com:2gityfdw]My AnimationBlogSpot[/url:2gityfdw]
User avatar
heyvern
Posts: 7043
Joined: Thu Sep 01, 2005 8:49 pm

Post by heyvern »

Excellent idea Bupaje!

It could be just one thread that is sticky with each persons name in a separate "post" with links!

Cool idea!

-vern
User avatar
rylleman
Posts: 750
Joined: Tue Feb 15, 2005 8:22 am
Location: sweden
Contact:

Post by rylleman »

Good idea, sometimes it takes forever to locate a script you know exists but you just can't remember what it's called or who wrote it.
User avatar
heyvern
Posts: 7043
Joined: Thu Sep 01, 2005 8:49 pm

Post by heyvern »

Rasheed, you are THE MAN!

I have... some tears in my eyes as I write this. I've been playing with that script and I just don't have the words to describe how exciting it is.

I just can't believe I can use constraints on those darn bones now!!!

You have no idea how cool this is.

Of course, it limits the use of OTHER layer scripts... I will have to see how much of a hassle that will be. So far I have no need yet for other layer scripts on the bone layers. I could probably combine them if absolutely necessary.

On a side note regarding this type of scripting, is it possible to somehow put it in that "utilities"... thingy? Sort of, make it "universal"?

For instance a utility script that has the guts, then a layer script that would call it. That would allow for sort of "multiple" layer script possibilities.

I have no idea what those utility scripts do or how they work. I only know that Fazek has one for his tools and it seems like it might work.

-vern
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 12:30 am
Location: The Netherlands

Post by Rasheed »

bupaje wrote:Hi Rasheed. Your really going off on the scripting - great. :) Do you mind posting a formal description with your script? I haven't tried all of the different scripts popping up and it might be useful to be able to have a simple blurb "This script does x, y,z. Use it if you need to a, b,c." for those who are coming on this for the first time. We may have to collect and pin a few more threads for the various authors as was done for macton.
Sure, I will try and write an easy to understand recipe and put that as a text file into the zip archive. Of course, this script isn't as general purpose as some of the scripts of the earlier authors, because it was written at a request.

At this moment, I'm not confident enough to call myself a programmer, like some of the script authors. I need lots more experience before I want my own pinned thread with useful scripts. The scripts until now were just target practice. I'm confident I can do much better. Putting a formal description in this forum want require me to service the problems people encounter with my scripts. I don't think I'm ready for that yet.

I also think that a forum is not the best medium to present scripts. The various websites I've seen from Moho/AS are much more appropriate.
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 12:30 am
Location: The Netherlands

Post by Rasheed »

heyvern wrote:On a side note regarding this type of scripting, is it possible to somehow put it in that "utilities"... thingy? Sort of, make it "universal"?

For instance a utility script that has the guts, then a layer script that would call it. That would allow for sort of "multiple" layer script possibilities.
Now that would be worthy of a sticky thread, because it would extend the functionality of Moho/AS. As I understand it, utilities scripts are routines that can be called by all other scripts. However, I think you'd always need a layer script to do the dynamic stuff.

It would be nice if you could put some of the routines into a utilities script, so you can call the ones you need from within your layer script. I image you would only have to call a routine "ActivateTransRotate()" to activate this feature, and "ActivateMasterBones()" to activate the master part of the master control script, and "ActivateSlaveBones()" to activate the control part, etc. Then you could have as much functionality at your disposal as you need.

However, I doubt if I'm already an accomplished enough programmer to pull this of.
User avatar
heyvern
Posts: 7043
Joined: Thu Sep 01, 2005 8:49 pm

Post by heyvern »

Running into a tiny problem.

I have a pretty complex bone rig but the script works great on the bones.

However, it somehow is interfering with point motion. With the layer script embedded the points won't move with the bones.

If I fiddle with points in the vector layer the points "jump" to the proper position influenced by the bones, but as soon as the time line moves or a bone is touched the point motion goes away.

Is it possible there is something in the script that is deactivating that bone motion? Could it be one of those matrix's is overwriting the point motion? It looked like you got it working without trouble on your tests. It may be my rig is causing the trouble.

EDIT:

Yes there is a tiny problem. The points won't follow any bone using a child.tmp as a constraint. It is weird. I think it might have to do with some sort of screen refresh issue possibly?

-vern
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 12:30 am
Location: The Netherlands

Post by Rasheed »

Well, Genete requested that the bone translation shouldn't be recorded in the Timeline. Point motion depends on the keys in the Selected Bone Translation channel of the .tmp bones. If you put in the keys manually, by clicking on the bones with the Translate Bone tool, the points will move.

OTOH if you've downloaded the latest version, you can turn on the recording of the Timeline by making record equal to true, in the first line of the TransRotate.lua file. Now every frame that is visited by the script will record the Bone Translation values of the .tmp bones in the Timeline.

I hope that this fixes your problem.

BTW It is simply choosing between

Code: Select all

slave.fPos = vec 
and

Code: Select all

slave.fAnimPos.SetValue(moho.frame, vec)
The first doesn't record the slave bone's position, and the latter does. A nice factoid to know.

I was also thinking of including a feature that only records a key if it differs from the value in the previous frame (in all frames but zero).

So I keep tinkering and tweaking this script.
User avatar
heyvern
Posts: 7043
Joined: Thu Sep 01, 2005 8:49 pm

Post by heyvern »

Yeehaa!

Thanks dude. I tried that earlier but I forgot to reload the script!!!!!

:oops:

-vern
User avatar
heyvern
Posts: 7043
Joined: Thu Sep 01, 2005 8:49 pm

Post by heyvern »

Hold on a sec...

I have that bone master script that doesn't put keys on every frame. It only keys if the there is key on the master bones.

How hard would it be to do that?

Here's the problem... I have a main rotation bone that controls all these other bones that use the script.

I would want the translation keyed only when that master rotation bone is actually keyed with movement. And it doesn't really have any name that fits into the whole thing. Basically I have the "master" bone with a constraint to this master rotation bone. This then cascades down to many other bones. Ultimately it would be nice to have everything work just from the rotation of this master rotation bone.

I'm just curious why it has to key on every frame. I suppose I could modify the script for my own use to key when the master rotation bone is keyed.

You know what? I could poke around and see if I can figure it out on my own. You've done so much already.

-vern
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 12:30 am
Location: The Netherlands

Post by Rasheed »

Thanks, that would be nice, Vern.

BTW The approach I described didn't work. Perhaps your method is more productive.
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 12:30 am
Location: The Netherlands

Post by Rasheed »

There is a problem if you use this method.

Suppose there is a childBone, rootBone and a childBone.x. If you move, rotate, or scale rootBone, there will be no key for childBone, and therefore no key for childBone.x.

You could argue that you should look for any parent, grandparent, up to the root bone, but that would involve a lot of extra checking, and what if one of those bones is dynamically linked to an unrelated bone. I think it is best to check if there are any bone position, bone angle or bone scale keys at that frame, so for all bones in the bone layer.

This could be done in the function ControlledBones(), that already scans all the bones, and which could return an extra parameter hasBoneKeys, which is either true or false.

Edit: I have just done that. The updated layer script can be found at the same location: TransRotate.zip

I left in the record feature (now recordAll), because when you remove the layer script, the dynamic tweening that is done by the layer script is lost. You might want to keep those keys, because rotating bones move in an arc, and bone translations are in a straight line.
User avatar
heyvern
Posts: 7043
Joined: Thu Sep 01, 2005 8:49 pm

Post by heyvern »

This is great! Thank you very much!

I am going to think about one other option I can really try on my own. (I just finished dinner... having my coffee... ready to dig in and you already did it for me! ;) )

In MY very special use of this script, I would ALWAYS need to key those controlled bones only on the same key frame as my master rotation bone. These bones control a head turn so all the keys would need to be identical anyway. I would never do anything with them unless they are moved by the rotation of that one master rotation bone.

I could simply add in something extra to identify that one single bone, or give it a special extension that would be used to add the keys for these other controlled bones.

As I said though, this is a specialized need for my purposes. It might not be usable in all situations. This new script is much better. At least i don't have a bazillion key frames. ;)

In reality all those keys don't really hurt anything. They get updated anyway and the motion is the same. All it might do is make the file size larger. It did however make it very hard to see specific translations in the time line for other bones. I couldn't tell where the action was taking place without selecting a specific bone I knew had the right keys.

-vern
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 12:30 am
Location: The Netherlands

Post by Rasheed »

Well, go right ahead! This script was your idea to start with, I just provided some of my time to develop it, so you didn't have to. I'm sure you could have come up with a similar solution as I have on your own.

I am simply happy that I was able to help.
Post Reply