ジャンプ先: 概要. 戻り値. キーワード. 関連. フラグ. Python 例.
skeletonEmbed([mergedMesh=boolean], [segmentationMethod=uint], [segmentationResolution=uint])
注: オブジェクトの名前と引数を表す文字列は、カンマで区切る必要があります。これはシノプシスに示されていません。
skeletonEmbed は、取り消し可能、照会可能、および編集不可能です。
このコマンドは、メッシュ内にスケルトンを埋め込むために使用されます。なし
照会モードでは、戻り値のタイプは照会されたフラグに基づきます。
ロング ネーム(ショート ネーム) | 引数タイプ | プロパティ | ||
---|---|---|---|---|
mergedMesh(mm)
|
boolean
|
![]() |
||
|
||||
segmentationMethod(sm)
|
uint
|
![]() |
||
|
||||
segmentationResolution(sr)
|
uint
|
![]() |
||
|
![]() |
![]() |
![]() |
![]() |
import maya.cmds as cmds # First select the shape, not the transform. cmds.select( 'characterShape' , r=True ) # Embed skeleton using default parameter. cmds.skeletonEmbed( ) # Result: u'{ [...] (A JSON dictionary with the description of the embedding. }' # # For debugging: get the merged mesh that will be used cmds.skeletonEmbed( query=True , mergedMesh=True ) # Result: u'{ [...] (A JSON dictionary with the description of the merged mesh. }' # # Embed skeleton using polygon soup and 512 resolution. cmds.skeletonEmbed( segmentationMethod=3 , segmentationResolution=512 ) # This method creates a few joints to see the embedding. import json def createJointsFromEmbedding( embeddingString ): embedding = json.loads( embeddingString ) for name , position in embedding[ 'joints' ].iteritems( ): joint = cmds.createNode( 'joint' , name=name ) cmds.xform( joint , worldSpace=True , translation=position ) result = cmds.skeletonEmbed( ) createJointsFromEmbedding( result ) # This method creates a mesh from the merged mesh to see it. import json import maya.OpenMaya as OpenMaya def createMeshFromDescription( meshString ): mesh = json.loads( meshString ) meshPoints = mesh[ 'points' ] meshFaces = mesh[ 'faces' ] factor = 1.0 / mesh[ 'conversionFactor' ] # Vertices vertexArray = OpenMaya.MFloatPointArray() for i in range( 0 , len( meshPoints ) , 3 ): vertex = OpenMaya.MFloatPoint( meshPoints[ i ] * factor , meshPoints[ i + 1 ] * factor , meshPoints[ i + 2 ] * factor ) vertexArray.append( vertex ) numVertices = vertexArray.length() # Faces polygonCounts = OpenMaya.MIntArray() polygonConnects = OpenMaya.MIntArray() for face in meshFaces: for i in face: polygonConnects.append( i ) polygonCounts.append( len( face ) ) numPolygons = polygonCounts.length() fnMesh = OpenMaya.MFnMesh() newMesh = fnMesh.create( numVertices , numPolygons , vertexArray , polygonCounts , polygonConnects ) fnMesh.updateSurface() # Assign new mesh to default shading group nodeName = fnMesh.name() cmds.sets( nodeName , e=True , fe='initialShadingGroup' ) return nodeName result = cmds.skeletonEmbed( query=True , mergedMesh=True ) createMeshFromDescription( result )