Hi Karsten,
thanks anyway and, if you want, take a look at my "Circles" and "GetBBoxes" nodes
that i posted some minutes ago.
Ciao!
Marco.
P.S.
How funny can be playing with nodes !!
Here's my other 3 nodes that follow the same rules of my "Circles" and "GetBBoxes" :
code:
// 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);