not yet, but let me prepare a reply with some images and the class, so you should better get what i need.
I'm quite near tho. and, i don't pretend you to do this job for me, absolutely. If you got time just point me in the direction.
Here it is the trunk. It is made of a set of cylinders and (for now) they are generated/positioned that way:
a) i add a new particle to the list. The new particle's coords are randomly picked form a set of the many point defined by a function wich randomly draws the coordinates of a semisphere whose center is placed at the same location of the parent particle (the one below the new one) and whose radius is a certain value (fixed)- it's tricky, but it's a sketch
This couple (and the next ones) of particle made a spring.
b) for each spring:
for ( int i = 0; i < physics.numberOfSprings(); ++i )
{
Spring e = physics.getSpring( i );
Particle a = e.getOneEnd();
Particle b = e.getTheOtherEnd();
/*
get two particles coords and pass to the Cylinder class
70, 70 are the top and bottom radius
and a & b are used to retrieve the coords for the topRadius and bottomRadius initial position
*/
c = new Cylinder(70, 70, a, b);
c.render();
}
c) the Cylinder class:
class Cylinder
{
float topRadius;
float bottomRadius;
int sides = 30;
Particle a;
Particle b;
Cylinder(float _topRadius, float _bottomRadius, Particle _a, Particle _b)
{
a = _a;
b = _b;
topRadius =_topRadius;
bottomRadius = _bottomRadius;
}
void render()
{
float angle = 0;
float angleIncrement = TWO_PI / sides;
pushMatrix();
noStroke();
beginShape(QUAD_STRIP);
for (int i = 0; i < sides + 1; ++i) {
vertex(a.position().x()+topRadius*cos(angle), a.position().y(), a.position().z()+ topRadius*sin(angle));
vertex(b.position().x()+bottomRadius*cos(angle), b.position().y(), b.position().z()+ bottomRadius*sin(angle));
angle += angleIncrement;
}
endShape();
popMatrix();
}
}
Using your trig system i cannot make them rotate properly.
Using just my intuition, i got the result you see in teh pictures, where each new cyclinder is positioned correctly, but not really rotated, but rather distorted.
I need them to be rotated.
That way i should be able to create some branch correctly rotated, and the magnetic force should avoid the branches to overlap.
That's the idea.