Show messages: 1-5 … 246-265 266-285 286-305 306-325 326-345 346-365 366-385 … 906-912
// Circles function Circles() { this.addInput("Center","pointarray"); this.addInput("Radius","number"); this.addInput("Elements","number"); this.addInput("Step","number"); this.addOutput("Out","objectlist"); this.properties = { radius:1, elements:1, step:1 }; } Circles.title = "Circles"; Circles.desc = "Circles"; Circles.prototype.onExecute = function() { var output = moi.geometryDatabase.createObjectList(); var centers = this.getInputData(0, new pointArray()); var len = centers.getLength(); this.properties.radius = this.getInputData(1, this.properties.radius); this.properties.elements = this.getInputData(2, this.properties.elements); if (this.properties.elements <= 0) this.properties.elements = 1; this.properties.step = this.getInputData(3, this.properties.step); if (this.properties.step <= 0) this.properties.step = 1; if (this.properties.step > len) this.properties.step = len; for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) { var cir = factory( 'circle', true, centers.getFrame(i), null, this.properties.radius ); output.addObject(cir.item(0)); } this.setOutputData(0, output); } LiteGraph.registerNodeType("Curves/Circles", Circles);
function GetBBoxes() { this.addInput("In","objectlist"); this.addInput("Elements","number"); this.addInput("Step","number"); this.addOutput("Out","objectlist"); this.addOutput("BBox Center","pointarray"); this.properties = { elements:0, step:1 }; } GetBBoxes.title = "BoundingBoxes"; GetBBoxes.desc = "Get BoundingBoxes"; GetBBoxes.prototype.onExecute = function() { var input = this.getInputData(0, moi.geometryDatabase.createObjectList()); var len = input.length; var bbox = new pointArray(); this.properties.elements = this.getInputData(1, this.properties.elements); if ((this.properties.elements <= 0) || (this.properties.elements > len)) this.properties.elements = len; this.properties.step = this.getInputData(2, this.properties.step); if (this.properties.step <= 0) this.properties.step = 1; if (this.properties.step > len) this.properties.step = len; this.setOutputData(0, input); for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) { bbox.pushPoint(input.item(i).getBoundingBox().center); } this.setOutputData(1, bbox); } LiteGraph.registerNodeType("Objects/GetBBoxes", GetBBoxes);
Attachments:
BBoxes.nod
Circles.nod
function PtArrayConcat() { this.labels = "abcdef"; this.size = [60,20]; this.internal = {a:1, b:1}; this.addOutput("Out", "pointarray"); }
// Cones function Cones() { this.addInput("Center","pointarray"); this.addInput("Radius","number"); this.addInput("Height","number"); this.addInput("Elements","number"); this.addInput("Step","number"); this.addOutput("Out","objectlist"); this.properties = { radius:1, height:1, elements:1, step:1 }; } Cones.title = "Cones"; Cones.desc = "Cones"; Cones.prototype.onExecute = function() { var output = moi.geometryDatabase.createObjectList(); var centers = this.getInputData(0, new pointArray()); this.properties.radius = this.getInputData(1, this.properties.radius); this.properties.height = this.getInputData(2, this.properties.height); var len = centers.getLength(); this.properties.elements = this.getInputData(3, this.properties.elements); if ((this.properties.elements <= 0) || (this.properties.elements > len)) this.properties.elements = len; this.properties.step = this.getInputData(4, this.properties.step); if (this.properties.step <= 0) this.properties.step = 1; if (this.properties.step > len) this.properties.step = len; for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) { var frame = centers.getFrame(i); var cone = factory('cone', true, frame, null, this.properties.radius, frame.evaluate(0,0,this.properties.height)); output.addObject(cone.item(0)); } this.setOutputData(0, output); } LiteGraph.registerNodeType("Solids/Cones", Cones); // Cylinders function Cylinders() { this.addInput("Center","pointarray"); this.addInput("Radius","number"); this.addInput("Height","number"); this.addInput("Elements","number"); this.addInput("Step","number"); this.addOutput("Out","objectlist"); this.properties = { radius:1, height:1, elements:1, step:1 }; } Cylinders.title = "Cylinders"; Cylinders.desc = "Cylinders"; Cylinders.prototype.onExecute = function() { var output = moi.geometryDatabase.createObjectList(); var centers = this.getInputData(0, new pointArray()); this.properties.radius = this.getInputData(1, this.properties.radius); this.properties.height = this.getInputData(2, this.properties.height); var len = centers.getLength(); this.properties.elements = this.getInputData(3, this.properties.elements); if ((this.properties.elements <= 0) || (this.properties.elements > len)) this.properties.elements = len; this.properties.step = this.getInputData(4, this.properties.step); if (this.properties.step <= 0) this.properties.step = 1; if (this.properties.step > len) this.properties.step = len; for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) { var frame = centers.getFrame(i); var cylF = moi.command.createFactory( 'cylinder' ); cylF.setInput(0, true); cylF.setInput(1, frame); cylF.setInput(3, this.properties.radius); cylF.setInput(4, frame.evaluate(0,0,this.properties.height)); var cyl = cylF.calculate(); output.addObject(cyl.item(0)); cylF.cancel(); } this.setOutputData(0, output); } LiteGraph.registerNodeType("Solids/Cylinders", Cylinders); // Spheres function Spheres() { // this.size = [60,20]; this.addInput("Center","pointarray"); this.addInput("Radius","number"); this.addInput("Elements","number"); this.addInput("Step","number"); this.addOutput("Out","objectlist"); this.properties = { radius:1, height:1, elements:1, step:1 }; } Spheres.title = "Spheres"; Spheres.desc = "Spheres"; Spheres.prototype.onExecute = function() { var output = moi.geometryDatabase.createObjectList(); var centers = this.getInputData(0, new pointArray()); this.properties.radius = this.getInputData(1, this.properties.radius); var len = centers.getLength(); this.properties.elements = this.getInputData(2, this.properties.elements); if ((this.properties.elements <= 0) || (this.properties.elements > len)) this.properties.elements = len; this.properties.step = this.getInputData(3, this.properties.step); if (this.properties.step <= 0) this.properties.step = 1; if (this.properties.step > len) this.properties.step = len; for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) { var frame = centers.getFrame(i); var sphF = moi.command.createFactory( 'sphere' ); sphF.setInput(0, true); sphF.setInput(1, frame); sphF.setInput(3, this.properties.radius); var sph = sphF.calculate(); output.addObject(sph.item(0)); sphF.cancel(); } this.setOutputData(0, output); } LiteGraph.registerNodeType("Solids/Spheres", Spheres);
Attachments:
CylsAndCones.nod
Image Attachments:
01_Capture.PNG
02_Capture.PNG
Message 7713.315 was deleted
// PatternSelectArray function PatternSelArray() { this.addInput("In","pointarray"); this.addOutput("Out","pointarray"); this.addOutput("Elems","number"); this.properties = { pattern:"+-", elems:0 }; } PatternSelArray.title = "PatternSelArray"; PatternSelArray.desc = "PatternSelArray"; PatternSelArray.prototype.onExecute = function() { var output = new pointArray(); var source = this.getInputData(0, new pointArray()); if (this.properties.pattern == '') this.properties.pattern = "+-"; var len = source.getLength(); var cn = 0; for (i = 0; i < len ; i++) { if ( this.properties.pattern[cn] === '1' || this.properties.pattern[cn] === '+') { var source_elem = source.getElement(i); output.push(source_elem.pt.x, source_elem.pt.y, source_elem.pt.z, source_elem.AngleX, source_elem.AngleY, source_elem.AngleZ, source_elem.Size); } cn = (cn < this.properties.pattern.length-1) ? cn+1 : 0; } this.properties.elems = output.getLength(); this.setOutputData(0, output); this.setOutputData(1, output.getLength()); } LiteGraph.registerNodeType("Arrays/PatternSelArray", PatternSelArray);
pointArray.prototype.getElement = function(n) { var shift = n*this.recordLength; var element = {"pt":this.getPoint(n), "AngleX":this.data[shift+3], "AngleY":this.data[shift+4], "AngleZ":this.data[shift+5], "Size":this.data[shift+6]}; return element; }
Attachments:
PatternSelArray.nod
Image Attachments:
01_Capture.PNG
02_Capture.PNG
Message 7713.318 was deleted
Show messages: 1-5 … 246-265 266-285 286-305 306-325 326-345 346-365 366-385 … 906-912