Skip to content

azagoruyko/controlShape

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is controlShape?

controlShape is a Maya shape node that can be attached to whole meshes or their faces.

controlShape

https://www.youtube.com/watch?v=8aVKpmMS_aA

Features

  • Static and dynamic meshes.
  • Scale by a normal.
  • Color and opacity control.

How to use

Compile the plugin for the Maya version you want using Visual Studio. No dependencies required.

Use the following code to create or parent controlShapes.

import pymel.core as pm

def makeControlShape():
    ls = pm.ls(sl=True)
    faces = pm.ls(sl=True, fl=True, type="float3")
    
    sh = pm.createNode("controlShape")
    if faces:
        mesh = faces[0].node()
        mesh.outMesh >> sh.mesh
        sh.meshInWorldSpace.set(True)        
    
        indices = [f.index() for f in faces]        
        sh.meshFaces.set(indices, type="Int32Array")
        sh.meshMatrix.set(mesh.getParent().wm.get())
        
    elif ls:
        pm.connectAttr(ls[0].outMesh, sh.mesh)
        pm.disconnectAttr(ls[0].outMesh, sh.mesh)
        sh.getParent().setMatrix(ls[0].wm.get())
        
def parentControlShape():
    ls = pm.ls(sl=True)
    if ls and len(ls) == 2:
        controlShape, control = ls
        
        for sh in controlShape.listRelatives(s=True, type="controlShape"):
            pm.parent(sh, control, r=True, s=True)
            sh.rename(control+"Shape")
            
            if not sh.meshInWorldSpace.get():
                sh.meshMatrix.set(controlShape.getMatrix() * control.wim.get())
                                
        pm.delete(controlShape)
    else:
        pm.warning("Select controlShape and transform")    

#makeControlShape() # select mesh/mesh faces
#parentControlShape() # select controlShape transform and a control you want to parent to.

makeControlShape can be applied to both whole meshes and mesh faces. In the first case there will be a static mesh control created. The second one case creates a dynamic deformable shape control.

About

Mesh shaped controls for Maya

Resources

License

Stars

Watchers

Forks

Packages

No packages published