{"id":326,"date":"2013-07-25T00:04:37","date_gmt":"2013-07-24T15:04:37","guid":{"rendered":"http:\/\/humrevlife.com\/?p=326"},"modified":"2013-07-25T00:04:37","modified_gmt":"2013-07-24T15:04:37","slug":"mwp-motionbuilder-with-python%e3%80%80%e3%81%9d%e3%81%ae10%e3%80%80%e3%80%8cfbactor%e3%81%aetrs%ef%bc%88translationrotationscale%e3%82%92%e5%8f%96%e5%be%97%e3%83%bb%e8%a8%ad%e5%ae%9a%e3%81%99","status":"publish","type":"post","link":"https:\/\/humrevlife.com\/?p=326","title":{"rendered":"MWP (Motionbuilder With Python)\u3000\u305d\u306e10\u3000\u300cFBActor\u306eTRS\uff08Translation,Rotation,Scale)\u3092\u53d6\u5f97\u30fb\u8a2d\u5b9a\u3059\u308b\u300d"},"content":{"rendered":"<p>\u5c11\u3057\u3067\u3082\u81ea\u52d5\u7684\u306b\u52d5\u304b\u305d\u3046\u3068\u601d\u3063\u305f\u3068\u6642\u306b\u4f55\u6c17\u306a\u304f\u56f0\u308b\u306e\u304cActor\u4eba\u5f62\u3002<\/p>\n<p><a title=\"MWP (Motionbuilder With Python)\u3000\u305d\u306e4\u3000\u300cTranslation,Rotation,Scaling\u5024\u306e\u53d6\u5f97,\u8a2d\u5b9a\u300d\" href=\"http:\/\/humrevlife.com\/?p=169\">\u305d\u306e4<\/a>\u3067\u8aac\u660e\u3057\u305f\u3068\u304a\u308aTRS\uff08Translation,Rotation,Scale)\u3092GetVector\u3067\u53d6\u5f97\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001 SetVector\u306f\u6a5f\u80fd\u3057\u307e\u305b\u3093\u3002 \u306a\u305c\u306a\u306e\u304b\uff1f<\/p>\n<p><strong>\u308f\u304b\u308a\u307e\u305b\u3093\uff01<\/strong><\/p>\n<p>\u306a\u305c\u306a\u3089\u30fb\u30fb\u30fbFBActor\u30af\u30e9\u30b9\u306f<strong>BlackBox<\/strong>\u306a\u306e\u3067\u3059\uff01<\/p>\n<p>\u8aac\u660e\u306b\u306a\u3063\u3066\u3044\u307e\u305b\u3093\u304c\u8b0e\u3060\u3089\u3051\u306a\u306e\u3067\u3042\u307e\u308a\u6df1\u304f\u8003\u3048\u306a\u3044\u65b9\u5411\u3067\u3002<\/p>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u3001SetVector\u306e\u4ee3\u308f\u308a\u306b\u306a\u308bAttribute\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u25a0\u30a2\u30af\u30bf\u30fc\u30dc\u30c7\u30a3\u306eTRS\u3092\u8a2d\u5b9a\u3059\u308bAttribute<\/p>\n<p>[python]<br \/>\nSetActorTranslation\u3000#Hips\u306b\u3057\u304b\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u305b\u3093<br \/>\nSetDefinitionScaleVector<br \/>\nSetDefinitionRotationVector<br \/>\n[\/python]<\/p>\n<p>\u30a2\u30af\u30bf\u30fc\u4eba\u5f62\u306eTranslation\u306fHips\u306b\u96c6\u7d04\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u30ad\u30e3\u30e9\u30e2\u30c7\u30eb\u306e\u69cb\u9020\u3068\u6bd4\u8f03\u3057\u3066\u3082\u4e00\u822c\u7684\u306a\u306e\u3067\u3057\u3087\u3046\u306d\u3002<\/p>\n<p>\u306a\u306e\u3067\u30a2\u30af\u30bf\u30fc\u4eba\u5f62\u306f\u5404\u30d1\u30fc\u30c4\u6bce\u306e\u79fb\u52d5\u306f\u57fa\u672c\u7684\u306b\u306f\u3054\u6cd5\u5ea6\u306e\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u30a2\u30af\u30bf\u30fc\u30dc\u30c7\u30a3\u306f\u5404\u30a2\u30af\u30bf\u30fc\u306e\u4f53\u306e\u5f62\u306b\u5408\u308f\u305b\u3066\u4f53\u3092\u4f5c\u3063\u3066\u3042\u3052\u308b\u4e8b\u304c\u76ee\u7684\u306e\u306f\u305a\u3002<\/p>\n<p>\u30de\u30cb\u30d4\u30e5\u30ec\u30fc\u30bf\u30fc\u3092\u4f7f\u3063\u3066\u30dc\u30c7\u30a3\u30d1\u30fc\u30c4\u6bce\u306e\u79fb\u52d5\u306a\u3093\u3066\u306e\u306f\u5e38\u5957\u624b\u6bb5\u306a\u306e\u3067\u3053\u308c\u307e\u305f\u8b0e\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001pivot\u306e\u4f4d\u7f6e\u3060\u3051\u306f\u79fb\u52d5\u3067\u304d\u307e\u3059\u3002\u5bc4\u308a\u9053\u306a\u306e\u3067\u3053\u308c\u306f\u6700\u5f8c\u306b\u66f8\u304d\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u25a0\u30a2\u30af\u30bf\u30fc\u30dc\u30c7\u30a3\u306eTRS\u3092\u8a2d\u5b9a\u3059\u308b<\/p>\n<p>[python]<br \/>\n#!\/usr\/bin\/env python<br \/>\n# -*- coding: utf-8 -*-<br \/>\nfrom pyfbsdk import FBSystem,FBApplication,FBActor,FBVector3d,FBSkeletonNodeId,FBModelTransformationType<\/p>\n<p>## get method<br \/>\ndef GetTRS( pObj, pBool ):<br \/>\n    lTransform = [<br \/>\n            FBModelTransformationType.kModelTranslation,<br \/>\n            FBModelTransformationType.kModelRotation,<br \/>\n            FBModelTransformationType.kModelScaling<br \/>\n            ]<br \/>\n    lTRS = [FBVector3d(),FBVector3d(),FBVector3d()]<br \/>\n    for i in range(len(lTRS)):<br \/>\n        pObj.GetVector(lTRS[i],lTransform[i],pBool)<br \/>\n    return lTRS<\/p>\n<p>## main<br \/>\nIS_GLOBAL = True<br \/>\nlComps = FBSystem().Scene.Components<br \/>\nlBodyTRSDic = {};<br \/>\nlActor = FBApplication().CurrentActor<br \/>\nif not lActor:<br \/>\n    lActor = FBActor(&quot;mike&quot;)<br \/>\n    FBApplication().CurrentActor = lActor<\/p>\n<p>for lComp in lComps:<br \/>\n    if lComp and &quot;ActorBodyMesh&quot; in lComp.LongName:<br \/>\n        lTRS = GetTRS(lComp, IS_GLOBAL)<br \/>\n        lBodyTRSDic[lComp.Name] = lTRS #Dictionary\u578b\u306bkey\u3068value\u3092\u8a2d\u5b9a\u3059\u308b<\/p>\n<p>lActor.SetActorTranslation(lBodyTRSDic[&quot;Hips&quot;][0]) #Hips\u306b\u3057\u304bTrans\u306f\u8a2d\u5b9a\u3067\u304d\u306a\u3044\u3002<\/p>\n<p>for enum in FBSkeletonNodeId.values:<br \/>\n    lNodeId = FBSkeletonNodeId.values[enum] #node\u306e\u540d\u524d\u3092\u53d6\u5f97<br \/>\n    lDicName = lNodeId.name.split(&quot;kFBSkeleton&quot;)[1].split(&quot;Index&quot;)[0] #node\u540d\u3092Dictionary\u578b\u306b\u767b\u9332\u3057\u305fkey\u306e\u540d\u524d\u3068\u540c\u3058\u306b\u3059\u308b<br \/>\n    if lBodyTRSDic.has_key(lDicName):<br \/>\n        lRot = lBodyTRSDic[lDicName][1]<br \/>\n        lScl = lBodyTRSDic[lDicName][2]<br \/>\n        lRot[0] += 10<br \/>\n        lScl[0] += 10<br \/>\n        lActor.SetDefinitionRotationVector(lNodeId,lRot) #node\u3092\u6307\u5b9a\u3057\u3066\u5024\u3092\u8a2d\u5b9a\u3059\u308b<br \/>\n        lActor.SetDefinitionScaleVector(lNodeId,lScl) #node\u3092\u6307\u5b9a\u3057\u3066\u5024\u3092\u8a2d\u5b9a\u3059\u308b<\/p>\n<p>[\/python]<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u25a0pivot\u4f4d\u7f6e\u306b\u95a2\u3059\u308bAttribute<\/p>\n<p>[python]<\/p>\n<p>FBPropertyVector3d ChestPosition<br \/>\nFBPropertyVector3d HeadPosition<br \/>\nFBPropertyVector3d HipsPosition<br \/>\nFBPropertyVector3d LeftAnklePosition<br \/>\nFBPropertyVector3d LeftCollarPosition<br \/>\nFBPropertyVector3d LeftElbowPosition<br \/>\nFBPropertyVector3d LeftFootPosition<br \/>\nFBPropertyVector3d LeftHipPosition<br \/>\nFBPropertyVector3d LeftKneePosition<br \/>\nFBPropertyVector3d LeftShoulderPosition<br \/>\nFBPropertyVector3d LeftWristPosition<br \/>\nFBPropertyVector3d NeckPosition<br \/>\nFBPropertyVector3d RightAnklePosition<br \/>\nFBPropertyVector3d RightCollarPosition<br \/>\nFBPropertyVector3d RightElbowPosition<br \/>\nFBPropertyVector3d RightFootPosition<br \/>\nFBPropertyVector3d RightHipPosition<br \/>\nFBPropertyVector3d RightKneePosition<br \/>\nFBPropertyVector3d RightShoulderPosition<br \/>\nFBPropertyVector3d RightWristPosition<br \/>\n[\/python]<\/p>\n<p>\u79fb\u52d5\u3055\u305b\u308b\u3068\u304d\u306e\u6ce8\u610f\u70b9\u3068\u3057\u3066\u306f<\/p>\n<p>\u2460\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4e2d\u592e\u304cpivot\u4f4d\u7f6e\u3058\u3083\u306a\u3044<br \/>\n\u2461\u5024\u306fLocal\u8868\u793a<br \/>\n\u2462Global\u5ea7\u6a19\u8ef8\u306b\u6cbf\u3063\u3066\u52d5\u304f<\/p>\n<p>\u3068\u3044\u30463\u70b9\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u2460\u3042\u308a\u3048\u308b\u8a71<br \/>\n\u2461Motionbuilder\u3067\u306f\u65e5\u5e38\u8336\u98ef\u4e8b<br \/>\n\u2462\u30fb\u30fb\u30fb\u3048\uff1f<\/p>\n<p>\u2462\u306f\u3082\u3057\u304b\u3057\u3066pivot\u306b\u95a2\u3057\u3066\u50d5\u304c\u77e5\u8b58\u4e0d\u8db3\u306a\u3060\u3051\u306a\u306e\u304b\u3082\u30fb\u30fb\u30fb\uff1f<\/p>\n<p>\u4f7f\u3044\u306b\u304f\u3044\u3063\u305f\u3089\u3042\u308a\u3083\u3057\u306a\u3044\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5c11\u3057\u3067\u3082\u81ea\u52d5\u7684\u306b\u52d5\u304b\u305d\u3046\u3068\u601d\u3063\u305f\u3068\u6642\u306b\u4f55\u6c17\u306a\u304f\u56f0\u308b\u306e\u304cActor\u4eba\u5f62\u3002 \u305d\u306e4\u3067\u8aac\u660e\u3057\u305f\u3068\u304a\u308aTRS\uff08Translation,Rotation,Scale)\u3092GetVector\u3067\u53d6\u5f97\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001 SetVe &#8230;","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[40,78,54,25,237,26,28,18,79,80],"class_list":["post-326","post","type-post","status-publish","format-standard","hentry","category-motionbuilder","category-python","tag-fb","tag-fbactor","tag-fbsystem","tag-mb","tag-motionbuilder","tag-py","tag-pyfbsdk","tag-python-2","tag-setdefinitionrotationvector","tag-setdefinitionscalevector"],"_links":{"self":[{"href":"https:\/\/humrevlife.com\/index.php?rest_route=\/wp\/v2\/posts\/326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/humrevlife.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/humrevlife.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/humrevlife.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/humrevlife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326"}],"version-history":[{"count":7,"href":"https:\/\/humrevlife.com\/index.php?rest_route=\/wp\/v2\/posts\/326\/revisions"}],"predecessor-version":[{"id":354,"href":"https:\/\/humrevlife.com\/index.php?rest_route=\/wp\/v2\/posts\/326\/revisions\/354"}],"wp:attachment":[{"href":"https:\/\/humrevlife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/humrevlife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/humrevlife.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}