MoI discussion forum
MoI discussion forum

Full Version: Nodebundle for playing with nodes

Show messages:  1-16  …  1197-1216  1217-1236  1237-1256  1257-1276  1277-1296  1297-1316  1317-1336  …  1857-1859

Thread Split: Some posts in this thread have been moved here

From: James (JFH)
21 Oct 2018   [#1257]
Hi All,

I have included a new "Shell" node in the attached construct2.js

ATM shell offset is parametric but only in normal direction. Flipping the direction is easily achieved by pairing with "Flip" node (also included)

At a later date, I will see if I can add "centreline" mode, but for now it suits my purposes.

By way of demonstration, I applied shelling to nod file previously posted (with coarser pattern and no subd smoothing) . Please also find attached.

A great weekend to all,
James



UPDATED: another simple example of shell node attached

Image Attachments:
wovenShell.jpg 


From: James (JFH)
21 Oct 2018   [#1258] In reply to [#1257]
Hi All,

I have updated construct2.js to include additional new "Extend" node which performs analogous to "Constuct/Extend" tool: extending a curve to meet a boundary curve or surface.

Have a great weekend
James


Image Attachments:
extend.gif 


From: speedy (AL2000)
22 Oct 2018   [#1259]
Good morning James
excellent work with the New Extension Construct2
I have a problem, as you will see from the screnshot , opening your files
shell, I get an error message .......
Does it depend on some awkward setting in my program?
I simply replaced it in the UI / Nodeeditor folder
your new script to replace the existing one
image at this link:
http://www.mediafire.com/file/49654g68o20zgcf/Shell-problem.jpg/file
James
Thanks in advance
al
From: James (JFH)
22 Oct 2018   [#1260] In reply to [#1259]
Hi All,

Al (Speedy 2000) has drawn my attention to the fact that shell node only works in V4.
I will endeavour to fix this issue, but it may be a while.

All the best to everyone,
James
From: Karsten (KMRQUS)
24 Oct 2018   [#1261] In reply to [#1242]
Hello James,
please try this code. It seems there is sometimes a timing problem with the copy/paste stuff. Very untested.
code:
// extractPts
 function extractPts()
 {
 this.addInput("In","objectlist");
 this.addOutput("Out","objectlist");
this.addOutput("ptarray", "pointarray");
 }

 extractPts.title = "extractPts";
 extractPts.desc = "extractPts";

 extractPts.prototype.onExecute = function()
 {
 var inObj = this.getInputData(0, moi.geometryDatabase.createObjectList());
 var output = moi.geometryDatabase.createObjectList();
 var selPts = moi.geometryDatabase.createObjectList();
    var originXYZ = moi.VectorMath.createPoint(0, 0, 0);
var temp = moi.geometryDatabase.createObjectList();
	         var pts = new pointArray(false);
//////
	 moi.geometryDatabase.selectAll();
	var existings=moi.geometryDatabase.getSelectedObjects(); //Locking the database objects
	 moi.geometryDatabase.deselectAll();
////////
	 if (inObj.length > 0 )
 {  var tempname=getUID(6);
for(var i=0;i<inObj.length;i++){temp.addObject(inObj.item(i));temp.item(i).name=tempname;};
moi.geometryDatabase.addObjects(temp);
temp.setProperty('showPoints', 1);
moi.geometryDatabase.selectAll();
temp.setProperty('selected', 0);
existings.setProperty('selected', 0);
 moi.geometryDatabase.copyToClipboardCommand(temp); 
moi.geometryDatabase.pasteFromClipboard();
//setTimeout( doNothing, 500);
 selPts=moi.geometryDatabase.getSelectedObjects();
for(var i=0;i<selPts.length;i++)pts.pushPoint(selPts.item(i).pt);
if(selPts.length>0)output = factory('copy',selPts,originXYZ,originXYZ,true);
 moi.geometryDatabase.selectNamed(tempname);
        temp=moi.geometryDatabase.getSelectedObjects();
	moi.geometryDatabase.deselectAll();
        var delfac = moi.command.createFactory( 'delete' );
	delfac.setInput( 0, temp );
	delfac.commit();
	delfac.cancel();
	existings=moi.geometryDatabase.createObjectList();
 } 
 this.setOutputData(0, output);
this.setOutputData(1, pts);
 }
 LiteGraph.registerNodeType("Objects2/extractPts", extractPts);


Have a nice day
Karsten

p.s.: For V4 Michael will give us some new features in the API that will make a lot of things easier.

Message 7777.1262 was deleted


From: James (JFH)
24 Oct 2018   [#1263] In reply to [#1261]
Thanks Karsten,

Work perfectly....I wish I had your skills. You're a champion!

Thanks again
James
From: speedy (AL2000)
25 Oct 2018   [#1264]
Hi Karsten
this morning I saw a bit of light at the bottom
to the tunnel ..... I managed to insert your script
extrPts in Object2 -Alleluja
it works great, even with the V3 ,
you are a GREAT , and believe me ,
your "forced" absence has been very heavy
have a nice day
al
Ps:
Courage;
We say ... dead a pope it does another one
From: James (JFH)
29 Oct 2018   [#1265]
Hi All,

I have rewritten "Shell" node for multiprocessing and reattached "construct2.js" to earlier post:
http://moi3d.com/forum/index.php?webtag=MOI&msg=7777.1258

Here is an experiment where shelling is varied across an array of hexagon extrudes
in response to proximity of 3 attractors. Although similar could be achieved by offsetting or scaling curves prior to extrude, shelling makes the process much simpler.

James

Also requires "reRange node" in arraysExt.js to be found here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=7777.1251

Image Attachments:
3shellAttractors.gif 


From: Frenchy Pilou (PILOU)
29 Oct 2018   [#1266]
Nice result!
From: James (JFH)
12 Nov 2018   [#1267]
Hi All,

I have been trying without success to write a simple node for assign a style to geometry.
See my attempt below:

// SetStyle
function SetStyle()
{
this.addInput("obj","objectlist");
this.addInput("idx","numarray");

this.addOutput("Out","objectlist");
}

SetStyle.title = "SetStyle";
SetStyle.desc = "SetStyle";

SetStyle.prototype.onExecute = function()
{
var objects = this.getInputData(0, moi.geometryDatabase.createObjectList());
var index = this.getInputData(1,index);

var output = objects.setProperty('styleIndex', index);

this.setOutputData(0, output);
}
LiteGraph.registerNodeType("Objects2/SetStyle", SetStyle);

The aim here is quite modest, but ideally the node would not just assign existing indexed styles but instead add new styles with RGB inputs prior to assignment.

Any help would be appreciated
James
From: Michael Gibson
12 Nov 2018   [#1268] In reply to [#1267]
Hi James, this line looks a little suspicious to me:

var index = this.getInputData(1,index);

That's passing in index which I guess is undefined at that time, and then assigning the return value to index too?

For adding new styles, you can use either:

var style = moi.geometryDatabase.addStyle();

or

var style = moi.geometryDatabase.findStyle( 'name', true /* Create if not found */ );

The second one will return an existing style if there is already one with that name, or create a new one if none of that name currently exist.

Then on a style there are read/write properties for .name and .color and the style's index value is a read only property .index .


Does that help with anything? Let me know if you're still stuck.

- Michael
From: Karsten (KMRQUS)
12 Nov 2018   [#1269] In reply to [#1267]
Hello James,

Have a look to this:
code:
    // SetStyle
 function SetStyle()
 {
 this.addInput("obj","objectlist");
 this.addInput("idx","numarray");

 this.addOutput("Out","objectlist");
	  this.properties = {Style: [0]};
 }

 SetStyle.title = "SetStyle";
 SetStyle.desc = "SetStyle";

 SetStyle.prototype.onExecute = function()
 {
 var objects = this.getInputData(0, moi.geometryDatabase.createObjectList());
        this.properties.Style = this.getInputData(1, this.properties.Style);
//for(var i=0; i<objects.length; i++)objects.item(i).styleIndex = this.properties.Style[0];
objects.setProperty('styleIndex', this.properties.Style[0]);
 var output = objects;
 this.setOutputData(0, output);
 }
 LiteGraph.registerNodeType("Objects2/SetStyle", SetStyle);


Have a nice day
Karsten

p.s.: Don't forget - you are working with Arrays!!! It's not like arays in C, where the adress/name points to the first element;-)

Message 7777.1270 was deleted


From: James (JFH)
12 Nov 2018   [#1271] In reply to [#1269]
Hi Karsten,

Thanks again for setStyle node.
At the risk of appearing ungrateful (which I'm not at all, quite the opposite), would it be difficult to make this node multiprocessing?

To colour facets in accordance to distance from an attractor, it was necessary to replicate the geometry 8 times & remove those facets with ptDist that have been remapped to range between 0 - 7 and rounded to integers and then tested in series. This approach quickly becomes cumbersome with each additional style attribution.





I have also attached the .nod file, however on running, the colours will appear different to those above because they will instead index default styles.

The ideal solution would be a setColor node that had inputs for Red, Green, & Blue values and handled the indexing automatically. Whether setColor and setStyle nodes should be combined into a single node or separate nodes, I'm not sure which is best....

Your thoughts?
James
From: Karsten (KMRQUS)
13 Nov 2018   [#1272] In reply to [#1271]
Hello James,

I'm not sure which way is the best, but a RGB input would create a lot of styles or you have to create and delete again and again. I made a while ago a function for coloring vectors and for the curvature analysis, that create some kind of rainbow styles. It uses sigmoid functions to calculate the RGB parts for blending the colors. It's not perfect, but short code:-) I've included it in the SetStyle-node. So you can put a value between 0 and 254 to choose a color. The node is now multiprocessing the input objects. It's a proposal. Maybe we will find a better solution later.

code:
    // SetStyle
 function SetStyle()
 {
 this.addInput("obj","objectlist");
 this.addInput("idx","numarray");

 this.addOutput("Out","objectlist");
	  this.properties = {/*mode: ["Long", "Long", "Short"],*/Style: [0]};
 }

 SetStyle.title = "SetStyle";
 SetStyle.desc = "SetStyle";
    SetStyle.prototype.onAdded = function (){this.rbID = createRainbow();}
 SetStyle.prototype.onExecute = function()
 {
            var data = this.processInOut("Long" /*this.properties.mode[0]*/, this.multiProcess, null, this.properties.Style);
            this.properties.Style = data.inputs[1];
            this.setOutputData(0, data.outputs[0]);
        
    };


    SetStyle.prototype.multiProcess = function (obj, style)
    {
        var out = [];
        obj.setProperty('styleIndex', this.rbID[style]);
        out[0]=obj;
        return out;
    };
 
 LiteGraph.registerNodeType("Objects2/SetStyle", SetStyle);


Have a nice day
Karsten

Attachments:
colorset.nod


From: James (JFH)
13 Nov 2018   [#1273] In reply to [#1272]
Thanks Karsten,

>> It's not perfect, but short code:-) <<

No, this really is an elegant solution, and yes the code is amazingly compact.
Is "createRainbow()" a function you wrote for colouring vectors, that you are calling here?
Clever!

>> It's a proposal. Maybe we will find a better solution later. <<

It is true that control of colour spectrum it limited, however there is a lot of ways to manipulate
the output: varying the range input into reRange node and reMapper widget as well as shifting vales with addition/subtraction etc.


Thanks again Karsten, it's brilliant
I'm so grateful for your skills and efforts,
James

PS I have attached here objects2.js with new node to replace existing in extensions folder, for anyone who may be interested.

Image Attachments:
colorset.jpg 


From: Karsten (KMRQUS)
14 Nov 2018   [#1274] In reply to [#1273]
Hello James,

the result looks great. And yes, the function is to create styles for vectors and the curvature analysis. You can find it in the basicfunctions.js. It returns an array of the indices of the created styles.

Have a nice day
Karsten

Image Attachments:
sigmoid-xlsx.png 


From: speedy (AL2000)
14 Nov 2018   [#1275]
Hello Friends
I want to share this work with you;
the Leonardo's Bridge, perhaps one of the first examples of autoparting bridge in History_
How many interested people find images and files at this link:
http://www.mediafire.com/file/2hv5r5rp9wi5w93/Lonardo%2527sBridge.zip/file
Have a nice evening all
alberto

Ps-Good shot Karsten....
SetStyle is wonderful-
From: James (JFH)
14 Nov 2018   [#1276] In reply to [#1274]
Hi Karsten,

Thank you for posting "sigmoid-xlsx.png", it helped tremendously in comprehending how the indexed colour spectrum is computed, but also hints at future development of the node. Imagine the inclusion of an RGB input on the node fed with 3 concatenated reMapper widgets with 3 different wave forms for each colour range. The widget needs further development to do this, and perhaps in the future it could even have an additional RGB mode where 3 graph curve appear together on widget interface similar to your image. In this way any conceivable spectrum would be possible. Nevertheless, setStyle node is fine the way it is; for now.




Also........and let me start by saying that this is just an enquiry, not a request for action:

Is it possible for extractPoints nodes to be multiprocessing? By that I mean, is it possible for it to treat closed curves discretely?

The attached image contains 5 n-gons of varied side length from which points are extracted to define a closed curve shown in red. Desirably however the result should be as shown in blue outputs.

I have included mPathArray approach (shown in green) by way of comparison, though, of course, only works appropriately if polys are equilateral and with similar number of sides, which is not the case here. Hence, x-length, y-length & z-length cannot be used to group points.

Is there even a way of handling groups of points of unequal number?

Please let me know,
And let me reiterate, this is just a question not a request....
you have done so much for me of late, my friend,
James

Image Attachments:
m_ExtractPts.gif 


Show messages:  1-16  …  1197-1216  1217-1236  1237-1256  1257-1276  1277-1296  1297-1316  1317-1336  …  1857-1859