@@ -92,16 +92,17 @@ def CreatePolygonWithLocators(countPoints=3, radius=10, rotation=0):
9292 return mainGroup , poly , locators , handles
9393
9494def CreateLocatorProjectedToMesh (mesh , createInsideOutsideLogic = False , * args ):
95- ### Names
96- nameLocatorOriginal = "locOriginal"
97- nameLocatorProjected = "locProjected"
95+ ### Variables
96+ _nameLocatorOriginal = "locOriginal"
97+ _nameLocatorProjected = "locProjected"
98+ _borderOffset = 0.01
9899
99100 ### Get shape of mesh
100101 meshShape = cmds .listRelatives (mesh , shapes = True , fullPath = False )[0 ]
101102
102103 ### Create locators
103- locatorOriginal = cmds .spaceLocator (name = nameLocatorOriginal )[0 ]
104- locatorProjected = cmds .spaceLocator (name = nameLocatorProjected )[0 ]
104+ locatorOriginal = cmds .spaceLocator (name = _nameLocatorOriginal )[0 ]
105+ locatorProjected = cmds .spaceLocator (name = _nameLocatorProjected )[0 ]
105106
106107 ### Create closestPointOnMesh node
107108 closestPointOnMeshNode = cmds .createNode ("closestPointOnMesh" )
@@ -114,9 +115,84 @@ def CreateLocatorProjectedToMesh(mesh, createInsideOutsideLogic=False, *args):
114115
115116 if createInsideOutsideLogic :
116117 ### Create inside/outside logic
117- # floatConstantNode = cmds.createNode("floatConstant")
118- # floatMathNode = cmds.createNode("floatMath")
119- # floatLogicNode = cmds.createNode("floatLogic")
120- # colorConditionNode = cmds.createNode("colorCondition")
121- print ("TODO: Create Inside Outside Logic" )
118+ floatConstantNode = cmds .createNode ("floatConstant" )
119+ cmds .setAttr (floatConstantNode + ".inFloat" , _borderOffset )
120+
121+ ### Create nodes for X branch
122+ floatMathNodeX1 = cmds .createNode ("floatMath" )
123+ floatLogicNodeX1 = cmds .createNode ("floatLogic" )
124+ floatMathNodeX2 = cmds .createNode ("floatMath" )
125+ floatLogicNodeX2 = cmds .createNode ("floatLogic" )
126+ floatLogicNodeX = cmds .createNode ("floatLogic" )
127+
128+ cmds .setAttr (floatMathNodeX1 + ".operation" , 0 )
129+ cmds .setAttr (floatLogicNodeX1 + ".operation" , 3 )
130+ cmds .setAttr (floatMathNodeX2 + ".operation" , 1 )
131+ cmds .setAttr (floatLogicNodeX2 + ".operation" , 2 )
132+ cmds .setAttr (floatLogicNodeX + ".operation" , 0 )
133+
134+ cmds .connectAttr (closestPointOnMeshNode + ".inPositionX" , floatMathNodeX1 + ".floatA" )
135+ cmds .connectAttr (floatConstantNode + ".outFloat" , floatMathNodeX1 + ".floatB" )
136+ cmds .connectAttr (floatMathNodeX1 + ".outFloat" , floatLogicNodeX1 + ".floatA" )
137+ cmds .connectAttr (closestPointOnMeshNode + ".positionX" , floatLogicNodeX1 + ".floatB" )
138+
139+ cmds .connectAttr (closestPointOnMeshNode + ".inPositionX" , floatMathNodeX2 + ".floatA" )
140+ cmds .connectAttr (floatConstantNode + ".outFloat" , floatMathNodeX2 + ".floatB" )
141+ cmds .connectAttr (floatMathNodeX2 + ".outFloat" , floatLogicNodeX2 + ".floatA" )
142+ cmds .connectAttr (closestPointOnMeshNode + ".positionX" , floatLogicNodeX2 + ".floatB" )
143+
144+ cmds .connectAttr (floatLogicNodeX1 + ".outBool" , floatLogicNodeX + ".floatA" )
145+ cmds .connectAttr (floatLogicNodeX2 + ".outBool" , floatLogicNodeX + ".floatB" )
146+
147+ ### Create nodes for Z branch
148+ floatMathNodeZ1 = cmds .createNode ("floatMath" )
149+ floatLogicNodeZ1 = cmds .createNode ("floatLogic" )
150+ floatMathNodeZ2 = cmds .createNode ("floatMath" )
151+ floatLogicNodeZ2 = cmds .createNode ("floatLogic" )
152+ floatLogicNodeZ = cmds .createNode ("floatLogic" )
153+
154+ cmds .setAttr (floatMathNodeZ1 + ".operation" , 0 )
155+ cmds .setAttr (floatLogicNodeZ1 + ".operation" , 3 )
156+ cmds .setAttr (floatMathNodeZ2 + ".operation" , 1 )
157+ cmds .setAttr (floatLogicNodeZ2 + ".operation" , 2 )
158+ cmds .setAttr (floatLogicNodeZ + ".operation" , 0 )
159+
160+ cmds .connectAttr (closestPointOnMeshNode + ".inPositionZ" , floatMathNodeZ1 + ".floatA" )
161+ cmds .connectAttr (floatConstantNode + ".outFloat" , floatMathNodeZ1 + ".floatB" )
162+ cmds .connectAttr (floatMathNodeZ1 + ".outFloat" , floatLogicNodeZ1 + ".floatA" )
163+ cmds .connectAttr (closestPointOnMeshNode + ".positionZ" , floatLogicNodeZ1 + ".floatB" )
164+
165+ cmds .connectAttr (closestPointOnMeshNode + ".inPositionZ" , floatMathNodeZ2 + ".floatA" )
166+ cmds .connectAttr (floatConstantNode + ".outFloat" , floatMathNodeZ2 + ".floatB" )
167+ cmds .connectAttr (floatMathNodeZ2 + ".outFloat" , floatLogicNodeZ2 + ".floatA" )
168+ cmds .connectAttr (closestPointOnMeshNode + ".positionZ" , floatLogicNodeZ2 + ".floatB" )
169+
170+ cmds .connectAttr (floatLogicNodeZ1 + ".outBool" , floatLogicNodeZ + ".floatA" )
171+ cmds .connectAttr (floatLogicNodeZ2 + ".outBool" , floatLogicNodeZ + ".floatB" )
172+
173+
174+ ### Create nodes for combined X and Z
175+ floatMathNodeCombined = cmds .createNode ("floatMath" )
176+ floatLogicCombinedNode = cmds .createNode ("floatLogic" )
177+ colorConditionNode = cmds .createNode ("colorCondition" )
178+
179+ cmds .connectAttr (floatLogicNodeX + ".outBool" , floatMathNodeCombined + ".floatA" )
180+ cmds .connectAttr (floatLogicNodeZ + ".outBool" , floatMathNodeCombined + ".floatB" )
181+
182+ cmds .setAttr (floatLogicCombinedNode + ".operation" , 3 )
183+
184+ cmds .connectAttr (floatMathNodeCombined + ".outFloat" , floatLogicCombinedNode + ".floatA" )
185+ cmds .connectAttr (floatLogicCombinedNode + ".outBool" , colorConditionNode + ".condition" )
186+
187+ cmds .setAttr (colorConditionNode + ".colorA" , 0 , 1 , 0 , type = "double3" )
188+ cmds .setAttr (colorConditionNode + ".colorB" , 1 , 0 , 0 , type = "double3" )
189+ cmds .setAttr (mesh + ".useOutlinerColor" , True )
190+ cmds .connectAttr (colorConditionNode + ".outColor" , mesh + ".outlinerColor" )
191+
192+ # Create Lambert and shading group
193+ material = cmds .shadingNode ("lambert" , asShader = True , name = "lambertMaterialProjection" )
194+ shadingGroup = cmds .sets (renderable = True , noSurfaceShader = True , empty = True , name = material + "SG" )
195+ cmds .connectAttr (material + ".outColor" , shadingGroup + ".surfaceShader" , force = True )
196+ cmds .sets (mesh , edit = True , forceElement = shadingGroup )
197+ cmds .connectAttr (colorConditionNode + ".outColor" , material + ".color" )
122198
0 commit comments