POSITION: Grid


#1

This was more of an exercise for me to mess around in Magma than is useful. It generates a grid inside a PRT Maker, with rows, columns and custom spacing. The only advantage over a PRT Volume->Cube is that the spacing is non-uniform across the 3 axis.

[code](–MAGMAFLOW2–
global MagmaFlowEditor_EditBLOPHistory = #()
magmaNode.note=""
node0 = magmaNode.createNode “InputChannel”
magmaNode.setNumNodeInputs node0 0
magmaNode.setNumNodeOutputs node0 1
magmaNode.setNodeProperty node0 “channelName” “Index”
magmaNode.setNodeProperty node0 “channelType” “”
magmaNode.DeclareExtensionProperty node0 “Exposed”
magmaNode.SetNodeProperty node0 “Exposed” false
magmaNode.DeclareExtensionProperty node0 “Name”
magmaNode.SetNodeProperty node0 “Name” “Particle Index”
magmaNode.DeclareExtensionProperty node0 “Position”
magmaNode.SetNodeProperty node0 “Position” [-110,-330]

node1 = magmaNode.createNode “Output”
magmaNode.setNumNodeInputs node1 1
magmaNode.setNumNodeOutputs node1 0
magmaNode.setNodeProperty node1 “channelName” “Position”
magmaNode.setNodeProperty node1 “channelType” “float32[3]”
magmaNode.DeclareExtensionProperty node1 “Position”
magmaNode.SetNodeProperty node1 “Position” [170,490]

node2 = magmaNode.createNode “ToVector”
magmaNode.setNumNodeInputs node2 3
magmaNode.setNumNodeOutputs node2 1
magmaNode.setNodeInputDefaultValue node2 1 0.0
magmaNode.setNodeInputDefaultValue node2 2 0.0
magmaNode.setNodeInputDefaultValue node2 3 0.0
magmaNode.DeclareExtensionProperty node2 “Position”
magmaNode.SetNodeProperty node2 “Position” [890,-310]

node3 = magmaNode.createNode “InputValue”
magmaNode.setNumNodeInputs node3 0
magmaNode.setNumNodeOutputs node3 1
magmaNode.setNodeProperty node3 “forceInteger” true
ctrl=bezier_float(); ctrl.value = 10.0
magmaNode.setNodeProperty node3 “controller” ctrl
magmaNode.DeclareExtensionProperty node3 “Exposed”
magmaNode.SetNodeProperty node3 “Exposed” true
magmaNode.DeclareExtensionProperty node3 “Name”
magmaNode.SetNodeProperty node3 “Name” “X Count”
magmaNode.DeclareExtensionProperty node3 “Position”
magmaNode.SetNodeProperty node3 “Position” [-110,-430]

node4 = magmaNode.createNode “ToFloat”
magmaNode.setNumNodeInputs node4 1
magmaNode.setNumNodeOutputs node4 1
magmaNode.DeclareExtensionProperty node4 “Position”
magmaNode.SetNodeProperty node4 “Position” [350,-430]

node5 = magmaNode.createNode “Modulo”
magmaNode.setNumNodeInputs node5 2
magmaNode.setNumNodeOutputs node5 1
magmaNode.setNodeInputDefaultValue node5 1 0
magmaNode.setNodeInputDefaultValue node5 2 1
magmaNode.DeclareExtensionProperty node5 “Position”
magmaNode.SetNodeProperty node5 “Position” [210,-430]

node6 = magmaNode.createNode “Modulo”
magmaNode.setNumNodeInputs node6 2
magmaNode.setNumNodeOutputs node6 1
magmaNode.setNodeInputDefaultValue node6 1 0
magmaNode.setNodeInputDefaultValue node6 2 1
magmaNode.DeclareExtensionProperty node6 “Position”
magmaNode.SetNodeProperty node6 “Position” [320,-160]

node26 = magmaNode.createNode “Multiply”
magmaNode.setNumNodeInputs node26 2
magmaNode.setNumNodeOutputs node26 1
magmaNode.setNodeInputDefaultValue node26 1 1.0
magmaNode.setNodeInputDefaultValue node26 2 1.0
magmaNode.DeclareExtensionProperty node26 “Position”
magmaNode.SetNodeProperty node26 “Position” [570,30]

node8 = magmaNode.createNode “InputValue”
magmaNode.setNumNodeInputs node8 0
magmaNode.setNumNodeOutputs node8 1
magmaNode.setNodeProperty node8 “forceInteger” true
ctrl=bezier_float(); ctrl.value = 10.0
magmaNode.setNodeProperty node8 “controller” ctrl
magmaNode.DeclareExtensionProperty node8 “Exposed”
magmaNode.SetNodeProperty node8 “Exposed” true
magmaNode.DeclareExtensionProperty node8 “Name”
magmaNode.SetNodeProperty node8 “Name” “Y Count”
magmaNode.DeclareExtensionProperty node8 “Position”
magmaNode.SetNodeProperty node8 “Position” [-110,-380]

node9 = magmaNode.createNode “Multiply”
magmaNode.setNumNodeInputs node9 2
magmaNode.setNumNodeOutputs node9 1
magmaNode.setNodeInputDefaultValue node9 1 1.0
magmaNode.setNodeInputDefaultValue node9 2 1.0
magmaNode.DeclareExtensionProperty node9 “Position”
magmaNode.SetNodeProperty node9 “Position” [170,-160]

node10 = magmaNode.createNode “Divide”
magmaNode.setNumNodeInputs node10 2
magmaNode.setNumNodeOutputs node10 1
magmaNode.setNodeInputDefaultValue node10 1 1.0
magmaNode.setNodeInputDefaultValue node10 2 1.0
magmaNode.DeclareExtensionProperty node10 “DefaultsType”
magmaNode.SetNodeProperty node10 “DefaultsType” “Float”
magmaNode.DeclareExtensionProperty node10 “Position”
magmaNode.SetNodeProperty node10 “Position” [580,-80]

node11 = magmaNode.createNode “Multiply”
magmaNode.setNumNodeInputs node11 2
magmaNode.setNumNodeOutputs node11 1
magmaNode.setNodeInputDefaultValue node11 1 1.0
magmaNode.setNodeInputDefaultValue node11 2 1.0
magmaNode.DeclareExtensionProperty node11 “Position”
magmaNode.SetNodeProperty node11 “Position” [580,-160]

node28 = magmaNode.createNode “Multiply”
magmaNode.setNumNodeInputs node28 2
magmaNode.setNumNodeOutputs node28 1
magmaNode.setNodeInputDefaultValue node28 1 1.0
magmaNode.setNodeInputDefaultValue node28 2 1.0
magmaNode.DeclareExtensionProperty node28 “Position”
magmaNode.SetNodeProperty node28 “Position” [720,-280]

node13 = magmaNode.createNode “Floor”
magmaNode.setNumNodeInputs node13 1
magmaNode.setNumNodeOutputs node13 1
magmaNode.DeclareExtensionProperty node13 “Position”
magmaNode.SetNodeProperty node13 “Position” [580,-280]

node29 = magmaNode.createNode “ToFloat”
magmaNode.setNumNodeInputs node29 1
magmaNode.setNumNodeOutputs node29 1
magmaNode.DeclareExtensionProperty node29 “Position”
magmaNode.SetNodeProperty node29 “Position” [170,30]

node27 = magmaNode.createNode “InputValue”
magmaNode.setNumNodeInputs node27 0
magmaNode.setNumNodeOutputs node27 1
magmaNode.setNodeProperty node27 “forceInteger” false
ctrl=bezier_float(); ctrl.value = 1.0
magmaNode.setNodeProperty node27 “controller” ctrl
magmaNode.DeclareExtensionProperty node27 “Exposed”
magmaNode.SetNodeProperty node27 “Exposed” true
magmaNode.DeclareExtensionProperty node27 “Name”
magmaNode.SetNodeProperty node27 “Name” “Z Spacing”
magmaNode.DeclareExtensionProperty node27 “Position”
magmaNode.SetNodeProperty node27 “Position” [570,100]

node16 = magmaNode.createNode “ToFloat”
magmaNode.setNumNodeInputs node16 1
magmaNode.setNumNodeOutputs node16 1
magmaNode.DeclareExtensionProperty node16 “Position”
magmaNode.SetNodeProperty node16 “Position” [580,-220]

node17 = magmaNode.createNode “Divide”
magmaNode.setNumNodeInputs node17 2
magmaNode.setNumNodeOutputs node17 1
magmaNode.setNodeInputDefaultValue node17 1 1.0
magmaNode.setNodeInputDefaultValue node17 2 1.0
magmaNode.DeclareExtensionProperty node17 “DefaultsType”
magmaNode.SetNodeProperty node17 “DefaultsType” “Float”
magmaNode.DeclareExtensionProperty node17 “Position”
magmaNode.SetNodeProperty node17 “Position” [300,30]

node30 = magmaNode.createNode “Floor”
magmaNode.setNumNodeInputs node30 1
magmaNode.setNumNodeOutputs node30 1
magmaNode.DeclareExtensionProperty node30 “Position”
magmaNode.SetNodeProperty node30 “Position” [430,30]

node19 = magmaNode.createNode “ToFloat”
magmaNode.setNumNodeInputs node19 1
magmaNode.setNumNodeOutputs node19 1
magmaNode.DeclareExtensionProperty node19 “Position”
magmaNode.SetNodeProperty node19 “Position” [450,-80]

node20 = magmaNode.createNode “ToFloat”
magmaNode.setNumNodeInputs node20 1
magmaNode.setNumNodeOutputs node20 1
magmaNode.DeclareExtensionProperty node20 “Position”
magmaNode.SetNodeProperty node20 “Position” [170,90]

node21 = magmaNode.createNode “ToFloat”
magmaNode.setNumNodeInputs node21 1
magmaNode.setNumNodeOutputs node21 1
magmaNode.DeclareExtensionProperty node21 “Position”
magmaNode.SetNodeProperty node21 “Position” [450,-160]

node25 = magmaNode.createNode “Multiply”
magmaNode.setNumNodeInputs node25 2
magmaNode.setNumNodeOutputs node25 1
magmaNode.setNodeInputDefaultValue node25 1 1.0
magmaNode.setNodeInputDefaultValue node25 2 1.0
magmaNode.DeclareExtensionProperty node25 “Position”
magmaNode.SetNodeProperty node25 “Position” [490,-430]

node23 = magmaNode.createNode “InputValue”
magmaNode.setNumNodeInputs node23 0
magmaNode.setNumNodeOutputs node23 1
magmaNode.setNodeProperty node23 “forceInteger” false
ctrl=bezier_float(); ctrl.value = 1.0
magmaNode.setNodeProperty node23 “controller” ctrl
magmaNode.DeclareExtensionProperty node23 “Exposed”
magmaNode.SetNodeProperty node23 “Exposed” true
magmaNode.DeclareExtensionProperty node23 “Name”
magmaNode.SetNodeProperty node23 “Name” “X Spacing”
magmaNode.DeclareExtensionProperty node23 “Position”
magmaNode.SetNodeProperty node23 “Position” [490,-360]

node24 = magmaNode.createNode “InputValue”
magmaNode.setNumNodeInputs node24 0
magmaNode.setNumNodeOutputs node24 1
magmaNode.setNodeProperty node24 “forceInteger” false
ctrl=bezier_float(); ctrl.value = 1.0
magmaNode.setNodeProperty node24 “controller” ctrl
magmaNode.DeclareExtensionProperty node24 “Exposed”
magmaNode.SetNodeProperty node24 “Exposed” true
magmaNode.DeclareExtensionProperty node24 “Name”
magmaNode.SetNodeProperty node24 “Name” “Y Spacing”
magmaNode.DeclareExtensionProperty node24 “Position”
magmaNode.SetNodeProperty node24 “Position” [720,-200]

try(magmaNode.setNodeInput node1 1 node2 1)catch()
try(magmaNode.setNodeInput node2 1 node25 1)catch()
try(magmaNode.setNodeInput node2 2 node28 1)catch()
try(magmaNode.setNodeInput node2 3 node26 1)catch()
try(magmaNode.setNodeInput node4 1 node5 1)catch()
try(magmaNode.setNodeInput node5 1 node0 1)catch()
try(magmaNode.setNodeInput node5 2 node3 1)catch()
try(magmaNode.setNodeInput node6 1 node0 1)catch()
try(magmaNode.setNodeInput node6 2 node9 1)catch()
try(magmaNode.setNodeInput node26 1 node30 1)catch()
try(magmaNode.setNodeInput node26 2 node27 1)catch()
try(magmaNode.setNodeInput node9 1 node3 1)catch()
try(magmaNode.setNodeInput node9 2 node8 1)catch()
magmaNode.setNodeInput node10 1 -1 1
try(magmaNode.setNodeInput node10 2 node19 1)catch()
try(magmaNode.setNodeInput node11 1 node21 1)catch()
try(magmaNode.setNodeInput node11 2 node10 1)catch()
try(magmaNode.setNodeInput node28 1 node13 1)catch()
try(magmaNode.setNodeInput node28 2 node24 1)catch()
try(magmaNode.setNodeInput node13 1 node16 1)catch()
try(magmaNode.setNodeInput node29 1 node0 1)catch()
try(magmaNode.setNodeInput node16 1 node11 1)catch()
try(magmaNode.setNodeInput node17 1 node29 1)catch()
try(magmaNode.setNodeInput node17 2 node20 1)catch()
try(magmaNode.setNodeInput node30 1 node17 1)catch()
try(magmaNode.setNodeInput node19 1 node3 1)catch()
try(magmaNode.setNodeInput node20 1 node9 1)catch()
try(magmaNode.setNodeInput node21 1 node6 1)catch()
try(magmaNode.setNodeInput node25 1 node4 1)catch()
try(magmaNode.setNodeInput node25 2 node23 1)catch()

)
[/code]


#2

I like it very much! Great job!


#3

Sorry for newbie question, but what do we do with this code? Paste it where? Or is it a schema to reproduce with magma flow nodes?
Thank you.


#4

Just put it into your text editor, save it as a .magmascript and load it into your magma modifier.

Cool exercise!


#5

Even better:

*Click the SELECT ALL button above the code.
*Press Ctrl+C to copy into the Windows Clipboard
*Go to Max, open the Magma editor and press Ctrl+V to paste from Clipboard
RESULT: The flow will be recreated the way the original poster created it!

Since the flow contains several exposed controls and it looks like I forgot to perform an update of the exposed nodes when pasting, you will also have to select Expose>UPDATE Exposed Inputs. I will log this as a bug to fix…