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
105 changes: 87 additions & 18 deletions nodes/vvvv.nodes.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
// VVVV.js is freely distributable under the MIT license.
// Additional authors of sub components are mentioned at the specific code locations.

/**
* The Node Pin Type
* @mixin
* @property {String} typeName "Node"
*/
VVVV.PinTypes.Node = {
typeName: "Node"
}
Expand All @@ -28,10 +33,10 @@ VVVV.Nodes.IOBoxNode = function(id, graph) {
this.auto_evaluate = false;

// input pins
var inputnodeIn = this.addInputPin('Input Node', [], this, true, VVVV.PinTypes.Node);
var inputnodeIn = this.addInputPin('Input Node', [], VVVV.PinTypes.Node);

// output pins
var outputnodeOut = this.addOutputPin('Output Node', [], this, VVVV.PinTypes.Node);
var outputnodeOut = this.addOutputPin('Output Node', [], VVVV.PinTypes.Node);

this.initialize = function() {
inputnodeIn.connectionChangedHandlers['nodepin'] = function() {
Expand Down Expand Up @@ -96,7 +101,7 @@ VVVV.Nodes.IOBoxNode.prototype = new VVVV.Core.Node();
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NODE: Switch (Node Input)
Author(s): Matthias Zauner
Author(s): Matthias Zauner, David Gann
Original Node Author(s): VVVV Group
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
Expand All @@ -105,37 +110,53 @@ VVVV.Nodes.SwitchNodeInput = function(id, graph) {
this.constructor(id, "Switch (Node Input)", graph);

this.meta = {
authors: ['Matthias Zauner'],
authors: ['Matthias Zauner, David Gann'],
original_authors: ['VVVV Group'],
credits: [],
compatibility_issues: ['No dynamic pin count yet']
compatibility_issues: ['Dynamic Input works only after copy and paste node']
};

var switchIn = this.addInputPin("Switch", [0], this);
var inputcountIn = this.addInvisiblePin("Input Count", [2], this);
var inputIn = []

var outputOut = this.addOutputPin("Output", [0.0], this);

var switchIn = this.addInputPin("Switch", [0], VVVV.PinTypes.Value);
var inputCountIn = this.addInvisiblePin("Input Count", [2], VVVV.PinTypes.Value);
var inputIn = [];

this.initialize = function() {
var inputCount = Math.max(2, inputCountIn.getValue(0));
VVVV.Helpers.dynamicPins(this, inputIn, inputCount, function(i) {
return this.addInputPin('Input '+(i+1), [], VVVV.PinTypes.Node);
})
}

/*
this.initialize = function() {
var inputCount = inputcountIn.getValue(0);
var inputCount = inputCountIn.getValue(0);
for (var i=inputIn.length; i<inputCount; i++) {
inputIn[i] = this.addInputPin("Input "+(i+1), [], this, true, VVVV.PinTypes.Node);
inputIn[i] = this.addInputPin("Input "+(i+1), [], VVVV.PinTypes.Node);
}
inputIn.length = inputCount;
}

*/
var outputOut = this.addOutputPin("Output", [], VVVV.PinTypes.Node);

this.evaluate = function() {

if (inputcountIn.pinIsChanged()) {
if(inputCountIn.pinIsChanged())
this.initialize();
var maxSize = this.getMaxInputSliceCount();

for (var i=0; i<maxSize; i++) {
outputOut.setValue(i, inputIn[Math.round(Math.abs(switchIn.getValue(i)))%inputIn.length].getValue(i));
}

outputOut.setSliceCount(maxSize);
}


/*
if (switchIn.getValue(0)==undefined) {
outputOut.setValue(0, undefined);
return;
}

var pin = inputIn[Math.round(Math.abs(switchIn.getValue(0)))%inputIn.length]
var slices = pin.getSliceCount();

Expand All @@ -144,6 +165,54 @@ VVVV.Nodes.SwitchNodeInput = function(id, graph) {
}
outputOut.setSliceCount(slices);
}
*/


}
VVVV.Nodes.SwitchNodeInput.prototype = new VVVV.Core.Node();

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NODE: Select (Node)
Author(s): Matthias Zauner
Original Node Author(s): VVVV Group
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

VVVV.Nodes.SelectNode = function(id, graph) {
this.constructor(id, "Select (Node)", graph);

this.meta = {
authors: ['David Gann'],
original_authors: ['VVVV Group'],
credits: [],
compatibility_issues: []
};

var inputIn = this.addInputPin("Input Node", [], VVVV.PinTypes.Node);
var selectIn = this.addInputPin("Select", [1], VVVV.PinTypes.Value);

var outputOut = this.addOutputPin("Output", [], VVVV.PinTypes.Node);
var formerSliceOut = this.addOutputPin("Former Slice", [0], VVVV.PinTypes.Value);

this.evaluate = function() {
var maxSize = this.getMaxInputSliceCount();

var outputIndex = 0;
for (var i=0; i<maxSize; i++) {
for (var j=0; j<selectIn.getValue(i); j++) {
outputOut.setValue(outputIndex, inputIn.getValue(i));
formerSliceOut.setValue(outputIndex, i);
outputIndex++;
}
}
outputOut.setSliceCount(outputIndex);
formerSliceOut.setSliceCount(outputIndex);
}

}
VVVV.Nodes.SwitchNodeInput.prototype = new VVVV.Core.Node();
VVVV.Nodes.SelectNode.prototype = new VVVV.Core.Node();




Loading