Home General Discussion
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

[Maxscript] Biped moveKeys

Hi,

I've been trying for a while to code in maxscript a function to move all the keys of a biped on the time line to make the motion start at an other time. But it's just a nightmare and I did not find any simple way to do it...

For others stuffs than a biped the following work fine
  1. selectKeys $.controller
  2. moveKeys $.controller offset


But when it comes to the biped it's just a nightmare
the moveKeys function move only the keys of controller (not the keys of the whole biped)
the moveKey function set the values of all keys to zero, and then lose the motion of the given bone
I did not find any function to get a collection of all the keys of a biped to try to modify the .time attribute by hand...

Any idea how to do it? It should definitely be possible as when you select the root of the biped manually and move the key frames with the mouth it just move the whole motion...

Thanks

Ludovic

Replies

  • r_fletch_r
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Try posting this in tech talk. you're more likely to get a response.
  • lhoyet
    Strange I remember going in tech subforum before posting... must have made an error. Is is possible for a moderator to move the topic?

    Anyway I found my answer, so if anyone get the same problem here is how I solved it
    1. function setMotionToStartAtFrame bip startFrame =
    2. (
    3. bipCtrl = bip.controller
    4. -- Obtain the subcontrollers
    5. vertCont = bipCtrl.vertical.controller
    6. horzCont = bipCtrl.horizontal.controller
    7. turnCont = bipCtrl.turning.controller
    8. keys = vertCont.keys
    9. offset = - startFrame - keys[1].time
    10. addOffsetTimeToControllerKeys vertCont offset
    11. addOffsetTimeToControllerKeys horzCont offset
    12. addOffsetTimeToControllerKeys turnCont offset
    13. childrens = #( biped.getNode bipCtrl #pelvis,
    14. biped.getNode bipCtrl #spine,
    15. biped.getNode bipCtrl #neck,
    16. biped.getNode bipCtrl #larm,
    17. biped.getNode bipCtrl #rarm,
    18. biped.getNode bipCtrl #lleg,
    19. biped.getNode bipCtrl #rleg)
    20. for child in 1 to childrens.count do
    21. (
    22. c = childrens[child]
    23. addOffsetTimeToControllerKeys c.controller offset
    24. )
    25. )
    26.  
    27. function addOffsetTimeToControllerKeys ctrl offset =
    28. (
    29. keys = ctrl.keys
    30. for i in 1 to keys.count do
    31. (
    32. k = biped.getKey ctrl i
    33. k.time = k.time + offset
    34. )
    35. )
  • Mark Dygert
    It looks like you're using methods that pertain to standard objects, biped is its own animal and as such is a bit of a headache to deal with when creating and manipulating keys.

    More than likely you'll need to find out what the current keys and attributes are, per biped controller, then create new keys where you want them and destroy the old keys. It won't be as simple as select keys, move keys. Which is one of the reasons people hate biped, the maxscript side of things is crazy complex and very different than the way everything else is handled in max... yea for buying plug-ins and stuffing them in max!! good job guys!
  • lhoyet
    Thanks to someone on another forum, I've got my answer...
    Here is the solution
    1. function addOffsetTimeToControllerKeys ctrl offset =
    2. (
    3. biped.deselectKeys ctrl
    4. biped.selectKeys ctrl
    5. biped.moveKeys ctrl offset
    6. )
    7.  
    8.  
    9. function setMotionToStartAtFrame bip startFrame =
    10. (
    11. bipCtrl = bip.controller
    12.  
    13. -- Obtain the subcontrollers
    14. vertCont = bipCtrl.vertical.controller
    15. horzCont = bipCtrl.horizontal.controller
    16. turnCont = bipCtrl.turning.controller
    17.  
    18. keys = vertCont.keys
    19. offset = - startFrame - keys[1].time
    20.  
    21. addOffsetTimeToControllerKeys vertCont offset
    22. addOffsetTimeToControllerKeys horzCont offset
    23. addOffsetTimeToControllerKeys turnCont offset
    24.  
    25. childrens = #( biped.getNode bipCtrl #pelvis,
    26. biped.getNode bipCtrl #spine,
    27. biped.getNode bipCtrl #neck,
    28. biped.getNode bipCtrl #larm,
    29. biped.getNode bipCtrl #rarm,
    30. biped.getNode bipCtrl #lleg,
    31. biped.getNode bipCtrl #rleg)
    32.  
    33. for child in 1 to childrens.count do
    34. (
    35. c = childrens[child]
    36. addOffsetTimeToControllerKeys c.controller offset
    37. )
    38. )
Sign In or Register to comment.