Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions GETOOLS_SOURCE/modules/Experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
# from functools import partial

from .. import Settings
from ..utils import File
# from ..utils import File
from ..utils import Create
from ..utils import Layers
from ..utils import Selector
# from ..utils import Blendshapes
Expand All @@ -49,6 +50,9 @@ def UICreate(self, layoutMain):
# cmds.popupMenu()
# cmds.menuItem(label = "Right-Click test")
# cmds.menuItem(dividerLabel = "label", divider = True)
# cmds.menuItem(label = "Right-Click test")

cmds.columnLayout(parent = layoutMain, adjustableColumn = True, width = Settings.windowWidthMargin)

### MENU
# cmds.columnLayout("layoutMenuBar", parent = layoutMain, adjustableColumn = True)
Expand All @@ -62,41 +66,45 @@ def UICreate(self, layoutMain):
cmds.menuItem(label = "Layer Move", command = self.LayerMove)

### BUTTONS
countOffsets = 4
cmds.gridLayout(parent = layoutMain, numberOfColumns = countOffsets, cellWidth = Settings.windowWidthMargin / countOffsets, cellHeight = Settings.lineHeight)
cmds.columnLayout(parent = layoutMain, adjustableColumn = True, width = Settings.windowWidthMargin)
# cmds.button(label = "**Nucleus", command = partial(Physics.CreateNucleus, "testNucleus", None))
cmds.button(label = "Particle", command = PhysicsParticle.CreateOnSelected)
cmds.button(label = "P Aim", command = PhysicsParticle.CreateAimOnSelected)
cmds.button(label = "P Combo", command = PhysicsParticle.CreateComboOnSelected)
cmds.button(label = "Particle Point", command = PhysicsParticle.CreateOnSelected)
cmds.button(label = "Particle Aim", command = PhysicsParticle.CreateAimOnSelected)
cmds.button(label = "Particle Combo", command = PhysicsParticle.CreateComboOnSelected)
# cmds.button(label = "**P Chain", command = PhysicsParticle.CreateAimChainOnSelected)
# cmds.button(label = "Hair", command = partial(PhysicsHair.CreateNHairOnSelected, None))
cmds.separator()
cmds.button(label = "Print General Options", command = self.PrintAllOptions)
cmds.separator()
cmds.button(label = "Create Locator Projected To Mesh", command = self.CreateLocatorProjectedToMesh)

countOffsets = 2
cmds.gridLayout(parent = layoutMain, numberOfColumns = countOffsets, cellWidth = Settings.windowWidthMargin / countOffsets, cellHeight = Settings.lineHeight)
def GetCheckboxEulerFilter(*args):
self.optionsPlugin.PrintAllOptions()
cmds.button(label = "Print General Options", command = GetCheckboxEulerFilter)

### TEST LEAYER METHODS
### LAYERS
def LayerCreate(*args):
Layers.Create("testLayer")

def LayerCreateForSelected(*args):
selected = Selector.MultipleObjects()
if (selected == None):
return
Layers.CreateForSelected(selected)

def LayerDelete(*args):
Layers.Delete("testLayer")

def LayerGetSelected(*args):
Layers.GetSelected()

def LayerMove(*args):
selected = Layers.GetSelected()
if (selected == None or len(selected) < 2):
cmds.warning("Need to select at least 2 layers")
return
Layers.MoveChildrenToParent(selected[:-1], selected[-1]) # FIXME main problem is layers have no selection order, they just listed from top to bottom


### OTHER
def PrintAllOptions(self, *args):
self.optionsPlugin.PrintAllOptions()

def CreateLocatorProjectedToMesh(*args):

selected = cmds.ls(selection = True)

Create.CreateLocatorProjectedToMesh(mesh = selected[0], createInsideOutsideLogic = True)

124 changes: 117 additions & 7 deletions GETOOLS_SOURCE/utils/Create.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@
from ..utils import Text


nameGroup = "grpPolygon"
namePolygon = "customPolygon"
nameLocator = "locator_"
nameCluster = "cluster_"


def CreatePolygonWithLocators(countPoints=3, radius=10, rotation=0):
if countPoints < 3:
cmds.warning("Number of points must be 3 or more to create a polygon")
return None

nameGroup = "grpPolygon"
namePolygon = "customPolygon"
nameLocator = "locator_"
nameCluster = "cluster_"

### Create main group as a container for all new objects
mainGroup = cmds.group(name = Text.SetUniqueFromText(nameGroup), empty = True)
cmds.setAttr(mainGroup + ".tx", lock = True)
Expand Down Expand Up @@ -90,5 +89,116 @@ def CreatePolygonWithLocators(countPoints=3, radius=10, rotation=0):
### Select polygon
cmds.select(poly, replace = True)

return poly, locators, handles
return mainGroup, poly, locators, handles

def CreateLocatorProjectedToMesh(mesh, createInsideOutsideLogic=False, createHeightLogic=False, *args):
### Variables
_nameLocatorOriginal = "locOriginal"
_nameLocatorProjected = "locProjected"
_nameLambertMaterialProjection = "matGEToolsProjection"
_borderOffset = 0.01

### Get shape of mesh
meshShape = cmds.listRelatives(mesh, shapes = True, fullPath = False)[0]

### Create locators
locatorOriginal = cmds.spaceLocator(name = Text.SetUniqueFromText(_nameLocatorOriginal))[0]
locatorProjected = cmds.spaceLocator(name = Text.SetUniqueFromText(_nameLocatorProjected))[0]

### Create closestPointOnMesh node
closestPointOnMeshNode = cmds.createNode("closestPointOnMesh")

### Connect locators to closestPointOnMesh node
cmds.connectAttr(meshShape + ".worldMesh[0]", closestPointOnMeshNode + ".inMesh")
cmds.connectAttr(meshShape + ".worldMatrix[0]", closestPointOnMeshNode + ".inputMatrix")
cmds.connectAttr(locatorOriginal + ".translate", closestPointOnMeshNode + ".inPosition")
cmds.connectAttr(closestPointOnMeshNode + ".position", locatorProjected + ".translate")

if createInsideOutsideLogic:
### Create inside/outside logic
floatConstantNode = cmds.createNode("floatConstant")
cmds.setAttr(floatConstantNode + ".inFloat", _borderOffset)

### Create nodes for X branch
floatMathNodeX1 = cmds.createNode("floatMath")
floatLogicNodeX1 = cmds.createNode("floatLogic")
floatMathNodeX2 = cmds.createNode("floatMath")
floatLogicNodeX2 = cmds.createNode("floatLogic")
floatLogicNodeX = cmds.createNode("floatLogic")

cmds.setAttr(floatMathNodeX1 + ".operation", 0)
cmds.setAttr(floatLogicNodeX1 + ".operation", 3)
cmds.setAttr(floatMathNodeX2 + ".operation", 1)
cmds.setAttr(floatLogicNodeX2 + ".operation", 2)
cmds.setAttr(floatLogicNodeX + ".operation", 0)

cmds.connectAttr(closestPointOnMeshNode + ".inPositionX", floatMathNodeX1 + ".floatA")
cmds.connectAttr(floatConstantNode + ".outFloat", floatMathNodeX1 + ".floatB")
cmds.connectAttr(floatMathNodeX1 + ".outFloat", floatLogicNodeX1 + ".floatA")
cmds.connectAttr(closestPointOnMeshNode + ".positionX", floatLogicNodeX1 + ".floatB")

cmds.connectAttr(closestPointOnMeshNode + ".inPositionX", floatMathNodeX2 + ".floatA")
cmds.connectAttr(floatConstantNode + ".outFloat", floatMathNodeX2 + ".floatB")
cmds.connectAttr(floatMathNodeX2 + ".outFloat", floatLogicNodeX2 + ".floatA")
cmds.connectAttr(closestPointOnMeshNode + ".positionX", floatLogicNodeX2 + ".floatB")

cmds.connectAttr(floatLogicNodeX1 + ".outBool", floatLogicNodeX + ".floatA")
cmds.connectAttr(floatLogicNodeX2 + ".outBool", floatLogicNodeX + ".floatB")

### Create nodes for Z branch
floatMathNodeZ1 = cmds.createNode("floatMath")
floatLogicNodeZ1 = cmds.createNode("floatLogic")
floatMathNodeZ2 = cmds.createNode("floatMath")
floatLogicNodeZ2 = cmds.createNode("floatLogic")
floatLogicNodeZ = cmds.createNode("floatLogic")

cmds.setAttr(floatMathNodeZ1 + ".operation", 0)
cmds.setAttr(floatLogicNodeZ1 + ".operation", 3)
cmds.setAttr(floatMathNodeZ2 + ".operation", 1)
cmds.setAttr(floatLogicNodeZ2 + ".operation", 2)
cmds.setAttr(floatLogicNodeZ + ".operation", 0)

cmds.connectAttr(closestPointOnMeshNode + ".inPositionZ", floatMathNodeZ1 + ".floatA")
cmds.connectAttr(floatConstantNode + ".outFloat", floatMathNodeZ1 + ".floatB")
cmds.connectAttr(floatMathNodeZ1 + ".outFloat", floatLogicNodeZ1 + ".floatA")
cmds.connectAttr(closestPointOnMeshNode + ".positionZ", floatLogicNodeZ1 + ".floatB")

cmds.connectAttr(closestPointOnMeshNode + ".inPositionZ", floatMathNodeZ2 + ".floatA")
cmds.connectAttr(floatConstantNode + ".outFloat", floatMathNodeZ2 + ".floatB")
cmds.connectAttr(floatMathNodeZ2 + ".outFloat", floatLogicNodeZ2 + ".floatA")
cmds.connectAttr(closestPointOnMeshNode + ".positionZ", floatLogicNodeZ2 + ".floatB")

cmds.connectAttr(floatLogicNodeZ1 + ".outBool", floatLogicNodeZ + ".floatA")
cmds.connectAttr(floatLogicNodeZ2 + ".outBool", floatLogicNodeZ + ".floatB")


### Create nodes for combined X and Z
floatMathNodeCombined = cmds.createNode("floatMath")
floatLogicCombinedNode = cmds.createNode("floatLogic")
colorConditionNode = cmds.createNode("colorCondition")

cmds.connectAttr(floatLogicNodeX + ".outBool", floatMathNodeCombined + ".floatA")
cmds.connectAttr(floatLogicNodeZ + ".outBool", floatMathNodeCombined + ".floatB")

cmds.setAttr(floatLogicCombinedNode + ".operation", 3)

cmds.connectAttr(floatMathNodeCombined + ".outFloat", floatLogicCombinedNode + ".floatA")
cmds.connectAttr(floatLogicCombinedNode + ".outBool", colorConditionNode + ".condition")

cmds.setAttr(colorConditionNode + ".colorA", 0, 1, 0, type = "double3")
cmds.setAttr(colorConditionNode + ".colorB", 1, 0, 0, type = "double3")
cmds.setAttr(mesh + ".useOutlinerColor", True)
cmds.connectAttr(colorConditionNode + ".outColor", mesh + ".outlinerColor")

# Create Lambert and shading group
material = cmds.shadingNode("lambert", asShader = True, name = Text.SetUniqueFromText(_nameLambertMaterialProjection))
shadingGroup = cmds.sets(renderable = True, noSurfaceShader = True, empty = True, name = Text.SetUniqueFromText(material + "SG"))
cmds.connectAttr(material + ".outColor", shadingGroup + ".surfaceShader", force = True)
cmds.sets(mesh, edit = True, forceElement = shadingGroup)
cmds.connectAttr(colorConditionNode + ".outColor", material + ".color")

if createHeightLogic:
# nodeDistanceDimension = cmds.createNode("distanceDimShape")
# cmds.distanceDimension(startPoint = (0, 2, 2), endPoint = (1, 5, 6))
print("TODO: createHeightLogic")