Geen omschrijving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ExpressionWaveGenerator.gizmo 3.8KB

123456789101112131415161718192021222324252627
  1. #! /Applications/Nuke7.0v3/NukeX7.0v3.app/../Nuke7.0v3.app/Contents/MacOS/Nuke7.0v3 -nx
  2. version 7.0 v3
  3. Gizmo {
  4. inputs 0
  5. help "Allows the easy creation of a variety of Waveform Expressions for use in manipulating knob values."
  6. addUserKnob {20 main l Main}
  7. addUserKnob {26 unnamed_1 l "" +STARTLINE T " "}
  8. addUserKnob {68 type l "Wave Type" t "Controls what type of wave to generate." M {Random Noise Sine Triangle Square Sawtooth/Sawtooth "Sawtooth/Sawtooth (Parabolic)" "Sawtooth/Sawtooth (Parabolic reversed)" "Sawtooth/Sawtooth (Exponential)" Bounce "" "" "" "" ""}}
  9. addUserKnob {7 minVal l "Min Value" t "Minimum value you want the wave to reach." R 0 10}
  10. addUserKnob {7 maxVal l "Max Value" t "Maximum value you want the wave to reach." -STARTLINE R 0 10}
  11. maxVal 1
  12. addUserKnob {7 waveLength l WaveLength t "Controls the frequency or cycle length of the wave. The number of frames before the pattern repeats." R 0 50}
  13. waveLength 10
  14. addUserKnob {7 offset l Offset t "Offsets the frame value to allow control of values at a certain frame" R 0 10}
  15. addUserKnob {26 unnamed l "" +STARTLINE T " "}
  16. addUserKnob {22 expButton l "Generate Expression" T "node = nuke.thisNode()\ntype = node.knob('type').getValue()\nexpText = node.knob('expText')\nexpFormula = node.knob('formula')\nexpResult = node.knob('expResult')\ndef setExp():\n if type == 0: #Random\n exp = 'random((frame+%s)/%s) * (%s-%s) + %s' %(offset,waveLength,maxVal,minVal,minVal)\n if type == 1: #Noise\n exp = '(noise((frame+%s)/%s)+1)/2 * (%s-%s) + %s' %(offset,waveLength,maxVal,minVal,minVal)\n if type == 2: #Sine\n exp = '(sin(2*pi*(frame+%s)/%s)+1)/2 * (%s-%s) + %s' %(offset,waveLength,maxVal,minVal,minVal)\n if type == 3: #Triangle\n exp = '(asin(sin(2*pi*(frame+%s)/%s))/pi+0.5) * (%s-%s) + %s' %(offset,waveLength,maxVal,minVal,minVal)\n if type == 4: #Square\n exp = 'int(sin(2*pi*(frame+%s)/%s)+1) * (%s-%s) + %s' %(offset,waveLength,maxVal,minVal,minVal)\n if type == 5: #Sawtooth\n exp = '((frame+%s) %% %s)/%s * (%s-%s) + %s' %(offset,waveLength,waveLength,maxVal,minVal,minVal)\n if type == 6: #Sawtooth(Parabolic)\n exp = 'sin((4.93480220054468*(frame+%s)/(pi*%s)) %% (pi/2)) * (%s-%s) + %s' %(offset,waveLength,maxVal,minVal,minVal)\n if type == 7: #Sawtooth(Parabolic Reversed)\n exp = 'cos((4.93480220054468*(frame+%s)/(pi*%s)) %% (pi/2)) * (%s-%s) + %s' %(offset,waveLength,maxVal,minVal,minVal)\n if type == 8: #Sawtooth (Exponential)\n exp = '(exp(2*pi*((frame+%s) %% %s)/%s)-1)/exp(2*pi) * (%s-%s) + %s' %(offset,waveLength,waveLength,maxVal,minVal,minVal)\n if type == 9: #Bounce\n exp = 'abs(sin(pi*(frame + %s)/%s))* (%s-%s) + %s' %(offset,waveLength,maxVal,minVal,minVal)\n return exp\n\nwaveLength = 'waveLength'\noffset = 'offset'\nmaxVal = 'maxVal'\nminVal = 'minVal'\nexpResult.setExpression(setExp())\nexpFormula.setValue(setExp())\n\nwaveLength = node.knob('waveLength').getValue()\noffset = node.knob('offset').getValue()\nmaxVal = node.knob('maxVal').getValue()\nminVal = node.knob('minVal').getValue()\nexpText.setValue(setExp())" +STARTLINE}
  17. addUserKnob {26 ""}
  18. addUserKnob {7 expResult l Result t "The calculated result of the wave at the given frame. Link to this value if you want to control the expression from this node."}
  19. expResult {{"random((frame+offset)/waveLength) * (maxVal-minVal) + minVal"}}
  20. addUserKnob {26 unnamed_2 l "" +STARTLINE T " "}
  21. addUserKnob {1 expText l Expression t "The wave in expression form. For copying to another knobs expression value."}
  22. expText "random((frame+0.0)/10.0) * (1.0-0.0) + 0.0"
  23. addUserKnob {26 unnamed_3 l "" +STARTLINE T " "}
  24. addUserKnob {1 formula l Formula t "The formula that generates the wave."}
  25. formula "random((frame+offset)/waveLength) * (maxVal-minVal) + minVal"
  26. }
  27. end_group