animation - Mapping and Binding Joints and Bones -


when using mecanim-rigged character in unity, can bind mocap device segments onto mecanim bones , animate character, don't have find or mecanim bones, because defined , accessible through humanbodybones , use of animator.

(at least, think case, please correct me if wrong...)

so, example, through simple process follows, map own animation segments onto mecanim character , animate live mocap device:

    private dictionary<xsanimationsegment, humanbodybones> mecanimbones;       public enum xsanimationsegment     {         pelvis = 0,         .         .         .         neck = 21,         head = 22     }       int[] segmentorder =     {         (int)xsanimationsegment.pelvis,         .         .         .         (int)xsanimationsegment.neck,         (int)xsanimationsegment.head     };        protected void mapmecanimbones()     {         mecanimbones = new dictionary<xsanimationsegment, humanbodybones>();          mecanimbones.add(xsanimationsegment.pelvis, humanbodybones.hips);         .         .         .         mecanimbones.add(xsanimationsegment.neck, humanbodybones.neck);         mecanimbones.add(xsanimationsegment.head, humanbodybones.head);     } 

so, bind model's joint called pelvis unity's mecanim hips. no need hips, etc... can bone's transform using:

xsanimationsegment segid = (xsanimationsegment)segmentorder[i];              humanbodybones boneid = mecanimbones[(xsanimationsegment)segmentorder[i]]; transform tmptransf = animator.getbonetransform(boneid); 

now, trying mapping on different skeleton, , use mocap device animate it. obviously, have find joints , map & bind them mocap segments. so, forget mecanim now, , let's add jt @ beginning of joints of new skeleton distinguish it:

    private dictionary<xsanimationsegment, bradbodybones> bradbones;      public enum xsanimationsegment     {         pelvis = 0,         .         .         .                                 neck = 21,         head = 22     }       int[] segmentorder =     {         (int)xsanimationsegment.pelvis,         .         .         .         (int)xsanimationsegment.neck,         (int)xsanimationsegment.head     };       public enum bradbodybones     {         jtpelvis = 0,         .         .         .         jtskulla = 21,         jtskullb = 22     } 

now, mapping & binding function, think, should following:

    protected void mapbradbones()     {         bradbones = new dictionary<xsanimationsegment, bradbodybones>();          gameobject jtpelvis = this.transform.find("chrbrad/characterroot/jtroot/jtpelvis").gameobject;         bradbones.add(xsanimationsegment.pelvis, bradbodybones.jtpelvis);         .         .         .         // rest of joints; e.g. neck, head, etc...     } 

but not think should do, because @ later point in script, error message in following code snippet thrown:

        (int = 0; < xssegmentcount; i++)         {             xsanimationsegment segid = (xsanimationsegment)segmentorder[i];             bradbodybones boneid = bradbones[(xsanimationsegment)segmentorder[i]];             try             {                 if (boneid == bradbodybones.jtpelvis)                 {                     //                 }                 else                 {                     // dos omething else                 }             }             catch (exception e)             {                 debug.log("cannot find " + boneid + " in " + model.name + e);                                  return false;             }         } 

i appreciate help/advice/tips on how deal situation.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -