Home General Discussion

[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
selectKeys $.controller 
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
    function setMotionToStartAtFrame bip startFrame =
    (
      bipCtrl = bip.controller
    	
      -- Obtain the subcontrollers
      vertCont = bipCtrl.vertical.controller
      horzCont = bipCtrl.horizontal.controller
      turnCont = bipCtrl.turning.controller
    	
      keys = vertCont.keys
      offset = - startFrame - keys[1].time
    	
      addOffsetTimeToControllerKeys vertCont offset	
      addOffsetTimeToControllerKeys horzCont offset	
      addOffsetTimeToControllerKeys turnCont offset
    	
      childrens = #( biped.getNode bipCtrl #pelvis,
                     biped.getNode bipCtrl #spine,
                     biped.getNode bipCtrl #neck,
                     biped.getNode bipCtrl #larm,
                     biped.getNode bipCtrl #rarm,
                     biped.getNode bipCtrl #lleg,
                     biped.getNode bipCtrl #rleg)						
    	
      for child in 1 to childrens.count do
      (
        c = childrens[child]
        addOffsetTimeToControllerKeys c.controller offset
      )
    )
    
    function addOffsetTimeToControllerKeys ctrl offset =
    (
      keys = ctrl.keys
      for i in 1 to keys.count do
      (
        k = biped.getKey ctrl i
        k.time = k.time + offset
      )
    )
    
  • 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
    function addOffsetTimeToControllerKeys ctrl offset =
    (
      biped.deselectKeys ctrl
      biped.selectKeys ctrl
      biped.moveKeys ctrl offset
    )
    
    
    function setMotionToStartAtFrame bip startFrame =
    (
      bipCtrl = bip.controller
    
      -- Obtain the subcontrollers
      vertCont = bipCtrl.vertical.controller
      horzCont = bipCtrl.horizontal.controller
      turnCont = bipCtrl.turning.controller
    
      keys = vertCont.keys
      offset = - startFrame - keys[1].time
    
      addOffsetTimeToControllerKeys vertCont offset	
      addOffsetTimeToControllerKeys horzCont offset	
      addOffsetTimeToControllerKeys turnCont offset
    
      childrens = #( biped.getNode bipCtrl #pelvis,
                     biped.getNode bipCtrl #spine,
                     biped.getNode bipCtrl #neck,
                     biped.getNode bipCtrl #larm,
                     biped.getNode bipCtrl #rarm,
                     biped.getNode bipCtrl #lleg,
                     biped.getNode bipCtrl #rleg)	
    
      for child in 1 to childrens.count do
      (
        c = childrens[child]
        addOffsetTimeToControllerKeys c.controller offset
      )
    )
    
Sign In or Register to comment.