Created
June 8, 2021 07:49
-
-
Save blockinhead/7cc01bd60c117adb821f69ee308ca6c7 to your computer and use it in GitHub Desktop.
Revisions
-
blockinhead created this gist
Jun 8, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ import pymel.core as pm import random def ramp_to_curve(curve, anim_length=20, color1=(0.01, 0.01, 0.01), color2=(1, 1, 1)): ramp = pm.shadingNode('ramp', asTexture=True) place2d = pm.shadingNode('place2dTexture', asUtility=True) place2d.outUV >> ramp.uvCoord place2d.outUvFilterSize >> ramp.uvFilterSize ramp.cel[2].ep.set(1) ramp.cel[0].color.set(color1) ramp.cel[1].color.set(color2) ramp.cel[2].color.set(color1) anim_curve = pm.createNode('animCurveTU') anim_curve.addKeys((1, anim_length), (0, 1)) anim_curve.setPostInfinityType('cycle') anim_curve.output >> ramp.cel[0].ep add1 = pm.createNode('addDoubleLinear') anim_curve.output >> add1.input1 add1.input2.set(0.05) add1.output >> ramp.cel[1].ep add2 = pm.createNode('addDoubleLinear') anim_curve.output >> add2.input1 add2.input2.set(0.1) add2.output >> ramp.cel[2].ep ramp.outColor >> curve.aiCurveShader curve.aiMode.set(1) curve.aiCurveWidth.set(0.01) curve.aiRenderCurve.set(1) pts=[] for i in range(10): pts.append([0, i, 0]) curve = pm.curve(editPoint=pts) ramp_to_curve(curve=curve, anim_length=15 + random.randrange(8), color2=(random.uniform(0.5, 1), random.uniform(0.2, 1), 1))