playMaker

Author Topic: Dis-inheriting scale (a rather "out-there" question.)  (Read 4052 times)

Red

  • Hero Member
  • *****
  • Posts: 563
Dis-inheriting scale (a rather "out-there" question.)
« on: August 03, 2014, 01:27:41 PM »
So, I'm asking this here because I'm looking to see if I can get a stretchy-bone system into Unity that has a hierarchy to it... Since scaling is inherited, that leaves the resulting rig a total mess.

Thing is, what I've been able to hash together is a system that will nullify that scaling by essentially dis-inheriting the scaling information of the parent.

The formula is basically:

ThisObject.scale = 1/ParentObject.scale

That works to reduce the scaling back to 1,1,1... But that over-writes any scaling I might have animated into the rig that that particular bone is doing (And it only seems to work with objects that are not scaled up or down. That isn't a big issue though because you can scale things in the import settings much more cleanly.)

What I want to do, assuming it's even possible, is to take from the animation track the scale of what it should be, take the parent scale and apply the inverse values only... So that the bone, if it's animated in scale, will still animate in scale but not inherit the relative scaling that it'd get from it's parent.

... Is something like this even possible with Playmaker? With Unity? I've tried using the "Get Property" action to peek into what data I could potentially extract for this but all I see is position and rotation... No scale (even though it does animate scaling at least with the generic setting of Mecanim.) I've even tried that with the legacy animation system and there's even less data I can extract with that (no position or rotation data at all.)

Anyone want to throw me a bone here? I'm kinda wondering what I can do because all my current examples hasn't resulted in the most reliable results... Mainly because all the actions that I know of to use for something like this would over-write the scale directly and that'd only work on the first frame... So, I'd need to get the data out of the animation system itself for what the scale is supposed to be for each bone that this system would affect each time this algorithm cycles through (so I can prevent any additive scaling messes.)

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Dis-inheriting scale (a rather "out-there" question.)
« Reply #1 on: August 03, 2014, 01:42:06 PM »
I guess what I would like to know is this...

Is there a way I can reach into the animation data to get the scale data of a particular frame? IF I could, that would (hopefully) lead me to being able to get this up and running.

If I open the animator window, I can see the data for scale right there... So in some manner this information is there to be used (and abused.) But I'm at a loss for knowing what I can do to get that data.

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Dis-inheriting scale (a rather "out-there" question.)
« Reply #2 on: August 03, 2014, 02:25:24 PM »
Since I'm researching this, I wonder if this reference page would be what I'd need to learn about using to get this done...

http://docs.unity3d.com/ScriptReference/AnimationUtility.html

Basically, it looks like I could use either AnimationUtility.GetAllCurves, *.GetFloatValue or maybe *.GetEditorCurve... No idea though because the reference manual is all about programming and this is well over my head.

For example, if I needed to make this fetch the current animation frame that the game object is currently on... Then reference the animation curve data (since it does have all three scale axes separated in the "animation" window so it is present) to get what that value ought to be... Then take that data and over-write the scaling by factoring that information into the algorithm to get what that scale should be without the inherited offset...

I know this might be asking more than what Unity can even do... And if Unity can't do it it's not likely that PlayMaker can either.
« Last Edit: August 03, 2014, 02:28:59 PM by Red »

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Dis-inheriting scale (a rather "out-there" question.)
« Reply #3 on: August 03, 2014, 02:31:00 PM »
If in the end this is soemthing that I'd have to tackle in Max then I guess I could figure something out... A way to have the scaling inherited but having an expression controller on the bones to offset the scaling so that the inherited scaling is factored into the animation... But that's some seriously beefy Maxscripting mojo right there and the more complicated it gets, the greater risk it is that the rig simply won't be compatable with Unity or the exporting tools.

And to be completely honest, if this was a max-only thing that's not really going to help the others that I know are out there that are looking for ways to make a stretchy bone rig Unity compatible. Mainly because modern-gen facial animation is much more impressive when it's bone-controlled as opposed to morph controlled. Far more flexibility and much more animator-friendly.
« Last Edit: August 03, 2014, 02:43:52 PM by Red »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Dis-inheriting scale (a rather "out-there" question.)
« Reply #4 on: August 04, 2014, 08:03:35 AM »
Have you checked out UMA? It can stretch bones realtime. Maybe you can bounce some ideas off of Fernando or Joen.

I think you might be targeting a read only variable. Mecanim does some nice things but as far as I know I don't think you can directly modify animation parameters through Unity without some greater overhead work because its part of the animation rather than some data Unity controls. Then again, I haven't tried anything like this before so I'm not certain. Maybe Set Property could dig down into it? Seems like it would be a mess.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Dis-inheriting scale (a rather "out-there" question.)
« Reply #5 on: August 04, 2014, 08:51:18 AM »
Hi,

 Scaling and counter scaling is areally complex and frustrating, so be careful where you are going with this. I am experiencing lots of trouble with this, especially when thirdpart comes into play and do not take into account local scale properly, it's really messy...

So I guess you really need to experiment unfortunatly...

 Bye,

 Jean

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Dis-inheriting scale (a rather "out-there" question.)
« Reply #6 on: August 04, 2014, 01:49:12 PM »
Lane:
   Not sure what UMA is... can you linky-link me up?

Jean:
   Yeah, I was going all kinds of batty trying to work with this both in Unity and Max (when I decided to try it.) Then someone on reddit suggested adding in a dummy object to give some measure of separation which was the trick that did it (though they were thinking adding it in in Unity but that, I suspect, would really throw the animation data off since it would be changing the hierarchy.) So, taking that same inverse scaling magnitude thingamabob and applying that to the dummy object between the bones in Max gave me enough wiggle room to have the scaling matrices be regular whilst preserving the hierarchy of the bones themeslves. It's a bit of setup and had me agonizing over the code-elements... But it produced some decent results (That said, the preview panel in the animation tab in the inspector was showing the scaling as being off... But in the scene itself the animation was what I wanted it to be. So, if you take a look see at the animation that you can export from the linked file the data seems safe... but the preview panel might look off.)


Thank you for the responses.

That said, since I was facing a lot more difficulty with this in Unity I tried applying the same principles to a rig in Max... And that resulted in the behaviour that I wanted.

So, as much as this could still be a great topic (as I can see many other ways that dis-inheriting the scaling that a child object inherits from it's parent would come in handy) I'm going to link to the max file I have uploaded to my site to show you the rig itself...

Note, the usual disclaimers apply... I take no responsibility for crashes, loss of data or time or whatever if you use this... And it's only offered as-is to learn from... But this gave me a stretchy bone rig that has a (somewhat) preserved hierarchy that is unity compatible.

Oh, and I am sorry to any maya/blender users... I don't know how you'd do something like this. But if you can replace or alter the scaling control systems in your hierarchy, you could apply the same kind of "1/parentObjectScale" approach... But I make no promises... I'm a max-head through and through after-all.

http://www.badseedgames.com/SharedFiles/UnityStretchyBoneRigPrototype.zip
« Last Edit: August 04, 2014, 02:05:46 PM by Red »