Connect all Objects with Spline


#1

Hi Everyone,

I’m trying to connect all objects in a Null-Object with a spline. If I use the tracer and set it to “connect all objects”, it connects everything with one line. What i need is, to connect every object, with every other object. The image shows what i mean. Version 1 is what the tracer makes. Version 2 is what i need. Would be nice if it is also possible with Thinking Particles.

Thanks for your help.

Simon


#2

This question’s been popping up fairly often…

Anyways, here’s the code that’ll handle child objects. Paste the script into a COFFEE tag attached to a Spline Object and it should work.


 main(doc,op)
 {
 var i, j, k, pointcount;
 
 i = 0;
 var a = op->GetDown();//count number of children
 while(a != NULL){
 	a = a->GetNext();
 	i++;
 }
 //allocate array for coordinates
 pointcount = i;
 var pointadr = new(array, pointcount);
 
 a = op->GetDown();
 pointadr[0] = a->GetPosition();
 for(i = 1; i<pointcount; i++){//get coordinates of children
 	a = a->GetNext();
 	pointadr[i] = a->GetPosition();
 }
 
 k = 0;//count number of splines needed
 for(i = 0; i<pointcount-1; i++){
 	for(j = i; j<pointcount-1; j++){
 		k++;
 	}
 }
 var vc = new(VariableChanged);
 
 vc->Init(pointcount, k*2);//allocate points
 op->Message(MSG_POINTS_CHANGED, vc);
 
 vc->Init(op->GetSegmentCount(), k);//allocate segments
 op->Message(MSG_SEGMENTS_CHANGED, vc);
 print(k," ");
 
 var gg = op->GetSegmentCount();
 print(gg, " ");
 
 var segmentcount = new(array, k);
 for(i = 0; i < k; i++){
 	segmentcount[i] = 2;
 }
 print(segmentcount[3], " ");
 print(op->SetSegments(segmentcount), " ");//assign 2 points per segment
 println(op->GetSegmentCount());
 k = 0;// generate point pairs
 for(i = 0; i < pointcount; i++){
 	for(j = i; j < pointcount-1; j++){
 		op->SetPoint(k, pointadr[i]);
 		k++;
 		op->SetPoint(k, pointadr[j+1]);
 		k++;
 	}
 }
 
 op->Message(MSG_UPDATE);
 }
 

Here’s a scene file that shows how it works.

I guess this can be further developed into a generator object much like the Mograph Tracer. Unfortunately I don’t have the time do make it, as I’m working on a few plugins at the moment.

Cheers!

-gene


#3

Thank you very much. This is exactly what i was looking for.
Is there a simple way to make it work with thinking Particles? That would be great.

Thanks for your help.


#4

It is doable, unfortunately I still haven’t touched particles with COFFEE or C++. I am trying to develop this into a true “Tracer Object” variant, but so far I’m only at the point where I can only use the coordinates of the objects in a List parameter. I’ve yet to implement using points from polygon and spline objects, and particles.


#5

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.