i have a script request! (Poses)

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

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
Víctor Paredes
Site Admin
Posts: 5815
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

I'll give a try today at office. If it works at you said it would be great (very). It's so cool this script still being improved!
PocketGoat
Posts: 45
Joined: Mon Jun 11, 2007 9:02 am

Post by PocketGoat »

It's still rough, selgin, so don't be too harsh :P
I'll try and fix the weird shape expanding thing later, a solution just wasn't immediately springing to mind. It's only a problem when you move the view, or select something. Just scrub forward and back on the timeline and it's fixed, in the meantime.
PocketGoat
Posts: 45
Joined: Mon Jun 11, 2007 9:02 am

Post by PocketGoat »

Don't forget that it takes into account point animation, so if you don't copy your neutral pose into the first frame of the animation after the pose set up you're going to get some strange results. That kept tripping me up, so I just thought I'd mention it.
And start labeling your pose bones from "pose2" onwards. Pose1 is the neutral pose, which isn't used except to compare the other poses to. Everything else is the same, I think.
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

The problem with the expanding shape is that the script always runs 3 times... or at least 1 time every time you click or do anything in a frame. Layer scripts constantly run all the time.

If you do something that uses and CHANGES the points positions on the current frame then the values are constantly added to the points values... it's an eternal loop... if you let it go too far it could expand to envelop the entire solar system... the galaxy! THE UNIVERSE! ;)


-vern
User avatar
Víctor Paredes
Site Admin
Posts: 5815
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

Thank you pocketgoat! It's a great improvement, even when it have some bugs which I'm sure can be solved. With this add of editing points and animate them this become in a ten times better script. I hope the rest of our fancy scripters haven't forgot this thread :roll:.
User avatar
madrobot
Posts: 670
Joined: Mon Apr 07, 2008 3:07 pm

Post by madrobot »

I can picture special agents rapelling down off Vern's roof,
smashing through the window and flame-throwering his PC,
right after he hit "send"
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

madrobot wrote:I can picture special agents rapelling down off Vern's roof,
smashing through the window and flame-throwering his PC,
right after he hit "send"
I thought that was happening this morning... but it was just some squirrels on the roof. ;)

-vern
PocketGoat
Posts: 45
Joined: Mon Jun 11, 2007 9:02 am

Post by PocketGoat »

Any ideas how to fix the expanding shape thing, heyvern? It doesn't save the weird values when you refresh the frame. Is there some function to do that manually?
This is the first script I've played around with, so I really have no idea how to get it to do much.
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I would need to look at the code a little closer and test out where it's happening. I don't have time right now but when I get a chance I will try to look it over.

Basically look at the code... if there is a spot where you access the point positions of the current frame "moho.frame" and then adding something to it then that will cause the expanding or continuously movie points. Each time the points position is changed it adds onto it again... and it changes... then the script runs accessing the new values... adds again... etc etc... forever...

... I had to rent another storage unit to hold those expanding shapes... ;)

I've gotten around this in some scripts by using a custom function I created that only runs the script ONCE per frame. However there are drawbacks to this because changes aren't updated. For instance moving a bone won't update the point positions because the script doesn't run again.

-vern
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Okay... I just remembered something.

What you need to do is change the order of the code execution. It is getting the point positions after changing them which causes that "loop". You need to get the "unchanged" point position and save it somehow. In a variable or table. Each frame that has keys or point motion that is different from the poses would then update that list. You need a list that of point positions that have the pose motion "subtracted" so they can be applied "fresh" each time the script runs.

This is going to be a performance hog I think with really dense mesh files. It has to get the point positions on the frame before the script changes them... do the calculations for the poses and bones... then apply the previous values to the pose values. Each frame does it over again.

Remember you can't get the point locations AFTER any changes have been made or you get that feedback loop.

Hey this script runs pretty dang fast on my PC. I guess I never tried it there before. I was using it on the mac which is a dog.

-vern
DarthFurby
Posts: 510
Joined: Sat Jul 29, 2006 1:34 pm
Location: New York City
Contact:

Post by DarthFurby »

Hi PocketGoat, using the new script I can indeed adjust points between poses but I can't seem to control where to place them. Here is my test file:

http://darthfurby.com/as/poses090514.zip

Maybe I did something wrong? I don't know, but big thumbs up for taking a crack at this!
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Yes Darth,

That is due to the point locations constantly updating while the script runs. You can't "grab" the points because they keep changing their locations. Notice that the preview doesn't match the construction curves? There is a spot in the code where the points are changing before the frame is refreshed. I think there is a way around this but I have to get my brain into "Script" mode... I'm in "creative" mode at the moment. ;)


-vern
DarthFurby
Posts: 510
Joined: Sat Jul 29, 2006 1:34 pm
Location: New York City
Contact:

Post by DarthFurby »

Hey, at least you have a "script" mode to switch to, I'm stuck in "1+1=2" mode.
PocketGoat
Posts: 45
Joined: Mon Jun 11, 2007 9:02 am

Post by PocketGoat »

This is more a proof of concept at this stage DarthFurby. At least it means with a little more work that it'll be possible to use poses with bone or point animation, or even multiple pose setups on the same layer.

Also, I've realized I'm not storing the point difference's properly, so there'll be some strange results because of that. I'm working on it though.
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I have encountered this "loop" issue many times when creating scripts for bones. My bones will gradually start sliding away and the zoom off into... the outermost edges of the workspace. Very annoying. I always forget the exact steps to fix this issue.

The redrawing of the screen that doesn't match the vectors may actually be a different issue. It has to do with how AS updates the view. For example you may not WANT to update the view at the END of a process. You may want to do it at the FRONT or beginning of a function to update THE LAST loop through the modification.

Think about this for a moment...

The points are in position X on a frame. Your function gets that position does stuff to it blah blah to get a new value Y. Then X = X + Y.

Then that function ends. If you update the view immediately the point is in a new position. Now the script or another function runs again... the new position is used. If instead you updated at the BEGINNING of the function you can grab the OLD values of the points position before doing any modifications.

It could be that the code that is changing point values based on the poses is running first... then the other bit of code is adding on top of that value instead of waiting to do it once at the end.

I'm talking out my arse... I have no clue really. ;)

DarthFurby wrote:Hey, at least you have a "script" mode to switch to, I'm stuck in "1+1=2" mode.
When I'm not in "script" mode... I can't even do 1+1=2... more like "1984" and "2+2=5". ;) I always put the exact same number of equal packets in my 24 oz coffee... I when I'm not in "code" mode I have to count them like 3 times. ;)

-vern
Post Reply