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

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

Post by PocketGoat »

Hmm. I tried just changing that and the shapes instantly expand to take up the entire work area. Are you sure that's all that's different from Genete's original script? Not the bit I added in the array creation part as well?
PocketGoat
Posts: 45
Joined: Mon Jun 11, 2007 9:02 am

Post by PocketGoat »

I think I've got my solution for the expanding shape problem, but my maths is too shabby to fix the difference between two points problem. The way it's set up now means if the points rotate the morph will still move in the same direction, regardless of the fact that the picture has rotated. So if a head turns upside-down a morph into a smile becomes a morph into a frown.
If someone who's better at maths could figure out how to fix this problem that would be great.

-edit: Scratch that. I haven't fixed the expanding shape problem. So, same two problems if anyone's game to fix them.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

This code has the "difference in points" already in it. What more are you trying to do? I thought the goal was to have the point motion on a frame added to the poses?

-------

This is the latest version of my modified code. The only part of the code I modified is below. Make sure you reload or relink the script in the layer when you change it. remember you have to change Genete's LAST version of the script, not yours.

This works but there is still the "offset" point motion that can't be fixed as far as I can tell. The problem is that the mixing of the different motions of points (scripted and "real") causes an offset. I think the offset is the script running "3 times" on every "click" or drag of the mouse.

There is also a problem when the bone is dragged away from any influence of the poses. There is a "snap" to the default pose instead of a gradual motion.

Code: Select all

---------------------------------------------POINT MOTION
   local fc3=mesh:CountPoints()-1  -- added to speed up loops
   for i=0, fc3 do --- move the points.
      pimoved:Set(0,0)
      pi= mesh:Point(i)
      --if (pi.fAnimPos:HasKey(frame)) then break end -- if there is a keyframe then don't overrride it.
      ---------------- begin hv edit
      local tmpPt =pi.fAnimPos:GetValue(frame)
      tmpPt=tmpPt-pi.fAnimPos:GetValue(0)
      pimoved=pimoved+tmpPt
      ---------------- end hv edit
      for k=1, maxposes do
         pimoved = pimoved + poses[layer]["points"][k][i]*w[k]
      end
      if(GE_ToggleKeyframePoses.Status==false) then
         mesh:Point(i).fPos:Set(pimoved) --move the point
      else
         pi.fAnimPos.value=pimoved -- move the point
         pi.fAnimPos:StoreValue()--this produces a keyframe and stores its valule
         moho.document:SetDirty()
      end
   end

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

Post by PocketGoat »

I re-downloaded Genete's script and it works (sort of) now, I must've modified the original somewhere along the line by accident. I don't think yours is working like you mean it to though, if I bind the points to a non-pose bone and move that bone in the animation it has no effect.

The problem with only adding the points together is that it doesn't take into account point rotation. For example, you have a head which has a pose for smiling. You turn the head sideways using the inverse kinematics tool on the head bone. The head is now on a 90 degree angle. You apply the morph to your smiling pose. The morph won't take into account that the head is now turned sideways, the corners of the mouth will go straight up. I can't test this on your script because skeletons aren't working, but on mine this is what was happening.
What you need to work out is the distance and angle between the points and apply the distance to the current angle in each frame. That way if the head turns sideways the mouth will still smile.

Am I making sense?
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Hi guys,
this awesome development needs a better version control. Do you know git ?. It is a very easy version control system specially useful for text files that allows several users create different branches of the same code without need to take care of the version you're modifying, because git does all the hard job.

This is a link to a public git repo: http://repo.or.cz/
There are much others.
I think that it is worth to keep the old (working) versions of the scripts just by doing branches of the modificaitons everyone does. It is very easy to keep ordrered and all the code is available. Not only for this but for many others.

Regarding to the rotation of poses when the bones rotates the shape I think that it won't work. Points position are in global coordinates and are the result of the matrix influence of the bones (based on the frame 0 relative position to the bone, the bone strength and the bind mode) over the points are in global coordinates. Only the bones have local coordinates to its parent. So if you want to make the poses to rotate when you rotate the bone you have to bind the poses to the skeleton! not the current shape! I suggest to create several mimmic skeletons for each pose that copies the movements of the main skeleton so them can rotate the points of the poses and the interpolated pose would rotate as well. Got it?

Cheers! and keep the good work! (better with a control revision system ;))
-G
PocketGoat
Posts: 45
Joined: Mon Jun 11, 2007 9:02 am

Post by PocketGoat »

That's a great idea Genete. Wouldn't need a mimic skeleton though if someone writes a script that is applied to the skeleton making it change on the pose frames to the same as whatever the current frame is.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Holy cow...

Bones and points? I had no idea you wanted bone motion. I probably blocked that part from my mind. ;) The trouble is with the bones already there. There is no way to have the points influenced by some bones and not others. Bones are bones. You would have to write the script and add a "bone list". So only bones with the special names would effect the points... not even sure how to do that actually.

It would probably require accessing the bone point and transformation matrix and applying the changes to the points once again adding those values into the calculations. The more you add in the slower it's going to get. Probably most of us have tested with pretty small simple files which is probably not realistic.

In my testing I had to release the points on my first test because using "fAnimPos" allowed the points to be moved by the pose bones. That is what that is... it's ALL the animation including bone motion. So ALL the bones effect the points.

-------

A smile pose would never work with a head turn pose. Are you saying just "one" front smile pose? You would still need a 3/4 smile pose as well as a front smile pose to mix them "evenly". I don't see how you can mix and match different poses and get a complete solution that you might be thinking of. I could be wrong.

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

Post by PocketGoat »

Not a 3/4 head, turning the head 90 degrees on its side. It was just an example to illustrate that if a part of a model with a morph is rotated by the skeleton then the morph would be pulling the points in the wrong direction.

I've decided to settle on making the pose script run only once per frame to fix the expanding shape problem. It's a little bit inconvenient that you can't see the change you're making dynamically, but scrubbing back and forth a frame isn't too annoying.

I wrote the script that changes the skeleton on the pose frames to be the same as whatever the current frame is, and that works fine, but when calculating the pose difference the pose script ignores the movement the bones have caused. I'm guessing because fAnimPos doesn't include bone effects. Can't seem to use fPos across frames though.

It's late again, so I think I'll call it quits for today. Is there a way to "bake" bone effects into point animation? If I could do that then I think I'll pretty much have everything sorted to my satisfaction.
User avatar
Víctor Paredes
Site Admin
Posts: 5658
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

PocketGoat wrote:It's late again, so I think I'll call it quits for today. Is there a way to "bake" bone effects into point animation? If I could do that then I think I'll pretty much have everything sorted to my satisfaction.
There is somewhere a script which makes that, I don't remember where, it's old stuff, but maybe vern remember or can find it.
Just a not expert question -maybe I'm not understanding it right- if you use bones, you will lose the ability of change color, curvature or not points parameters?
PocketGoat
Posts: 45
Joined: Mon Jun 11, 2007 9:02 am

Post by PocketGoat »

No, the idea is to keep all the stuff the morphs currently have but add the ability to use a normal skeleton as well. So you can rig a guy normally and then also have morphs for expressions, or turning from front to side view, or both.
It's a pain to not be able to use morphs and a normal skeleton, so I'm trying to bring them both together. I'm most of the way there :P
Tomorrow I'll look into the baking thing and then I want to change the script so you can have multiple bone selectors and pose set ups on the same vector layer.
PocketGoat
Posts: 45
Joined: Mon Jun 11, 2007 9:02 am

Post by PocketGoat »

Does anyone know (heyvern, I'm looking at you) how to take the absolute position of a point on a different frame from the current one?
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Post by chucky »

................Image................Image
Test with head turns using pose array script ,duplicate mouth layers using visibly that behave like switches and still run the pose array script and a parent body skeleton.
Haven't tried the new script versions yet but I'm watching thread with great interest, any breakthroughs here would be great . :D
So far with the head turns It might take more inbetweens than initially suspected.The great thing is that the mouth switches are independent of the head turns, isn't that basically one of the holy grails?
Looks like we can already have that. :D
So any advances that can have bones that are poseable with independent movement beyond the position they take after the pose has changed its initial position would be awesome. I can't see how you guys can do that,two sets of bones controlling the same points.
Whatever you can come up with beyond the current tantalising but limited possibilities seems fantastic. Good luck script gurus. 8)
User avatar
madrobot
Posts: 667
Joined: Mon Apr 07, 2008 3:07 pm

Post by madrobot »

chucky wrote:So any advances that can have bones that are poseable with independent movement beyond the position they take after the pose has changed its initial position would be awesome.
That sentence exploded my head like Scanners.
Not what I needed Monday morning.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I haven't examined the code thoroughly enough yet... how hard would it be to use the pose array script INSIDE A SWITCH LAYER?

Imagine you have a mouth switch layer. Each mouth shape in the switch has the poses on the same frames as other vector layers. Could the pose array script be modified to work on layers inside a switch based on bones in the parent layer instead of the switch?

So what you end up with is just one mouth switch layer. The pose script is in the SWITCH layer not the layers in the switch. The script reads those "pose" frames just like other vector layers but it's reading the layers in the switch.

Now you get the same effect as your sample Chucky, but it's easier to use because you can just use the switch for the mouths. They pose just like the poses but you have the switching as well.

This is not the perfect solution but I almost certain it can work. Almost certain... not 100% certain... maybe... 60% certain... give or take a margin of error of possibly 5 to 10 percent.

Dagnabbit... you're starting to make my hideously complex 2.5D head rig obsolete! ;) Maybe I could combine the two somehow... where the head rig falls apart I could use this pose trick. When the bone that turns the head reaches a certain point it uses an "alternate pose" to complete the turn.

Wish I could spend more time investigating but I have a few projects going on right now.

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

Post by PocketGoat »

I can't find a way to get the absolute position of a point on a frame other than the current one, so I can't finish what I was intending with the script. It's still possible to use bones, morphs and point animation together but if a bone rotates a part of an image, an arm for example, then the morphs are going to be pulling the points in the wrong direction since they don't take into account that the arm has rotated.
If I rewrote the entire script to use images in a switch layer instead of the first few frames as references then that'd be a solution, but that's altogether more work than I'm game for at the moment.
Post Reply