Jump to content

join multiprim geo/curve into single prim


Recommended Posts

As I was not completly sure of what you wanted as result here are 2 things you can try.
First you could change your first addvertex from addvertex(0, new_prim, @ptnum); to addvertex(0, new_prim, new_pt-1);
and change the start value of i to 1.

 This will create a new primitive with the newly created point and the previous created point instead always using the same starting point.

A second option is to change the order of your vex to this.

int new_prim = addprim(0, "polyline");
addvertex(0, new_prim, 0);
for(int i=1; i<5; i++){
    vector newP = @P + {1,1,0}*i;
        
    int new_pt   = addpoint(0, newP);
    addvertex(0, new_prim, new_pt);
}

This will create a single curve containing all points from 0 to 5.
Hope one of these if what you're looking for.
 

Link to comment
Share on other sites

... i can't modify the algorhitm at this time, i will need a "post" solution. 

so maurits's option are not an option unluckily.

mestela's technique is nice but it doesn't support the branched structure, for what i experienced.

 

i'd like to have one prim for each primchunk ( = my id attribute in the example file).

Link to comment
Share on other sites

I found the piece of code that i was looking for to modify the algorithm in the creation stage.
I asked for a "post" solution at first because i knew some side fx would come along, but now i got everything under control.

My code generates one prim at each iteration, the advantage of this approach is that i can separate the various branches in chunks
after the creation stage. That's what i do using a FuseSOP set to Unique, acting only on a group of points ("primchunk_node" group).
This primchunks are used later for the "flip/unfold effect".

F1 code is much better optimized since it creates only one primitive per branch. But in this way i can't separate them afterwards, or at least
not with the FuseSOP/Unique approach. I modified the code to create one prim also for each primchunk_node. The only downside is that
while tweaking the unfold effect, if i want to change the primchunk distribution i have to re-run the solver.

Thanks for helping once again!

 

 

    ///Original - Primchunk selection after solver			
    
    int new_pt   = addpoint(0, newP);
    int new_prim = addprim(0, "polyline");
    addvertex(0, new_prim, @ptnum);
    addvertex(0, new_prim, new_pt);
    
    
	
    ///F1's - Primchunk selection in solver	

    int new_pt   = addpoint(0, newP);

    if (neighbourcount(0, @ptnum) == 1 && !@group_primchunk_node )
    {
        // Add new point to existing polyline.
        int new_prim = pointprims(0, @ptnum)[0];
        addvertex(0, new_prim, @ptnum);//addded
        addvertex(0, new_prim, new_pt);
    }
    else
    {
        // Create new generation. Seed case + branching nodes + primchunk nodes
        int new_prim = addprim(0, "polyline");
        addvertex(0, new_prim, @ptnum);
        addvertex(0, new_prim, new_pt);

        int old_prim = pointprims(0, @ptnum)[0];
        int new_branch = prim(0, "branch", old_prim) + 1;
        setprimattrib(0, "branch", new_prim, new_branch);

 

 

Attached you find the project im working on,
I started from a already done space colonization algorithm. I customized it and
worked mainly on the post solver effects to randomize growth speed and other attributes,
and on the unfold effect.

I will publish a cleaner network, when ill be done!
If you have any question feel free to ask

space_colonizer_v11.hip

  • Like 3
Link to comment
Share on other sites

ok i found that using PolyCut instead of the Fuse/unique solved the problem. So F1 code + separation post solver. :)

Convert line doesn't keep attributes, but is definitely useful in other situation.

thanks again

 

Link to comment
Share on other sites

  • 1 year later...

Hi F1!

I am back on this :)

How should I modify the above code to create only one single primitive?

At the moment is creating one new primitive each time there is a branching. Is it possible to just keep adding the points to the first created primitive?

 

I have tried to modify the conditions, addprim or primpoint function but didn't find a solution.

Thanks in advance

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...