Hi Marius! Nice to see you... I remember that we had a talk about this in Barcelona. I did work on a sceneGraph. I still have problems on some basic elements, on how you link the Library with the PApplet, so it's hard to start to put the things all together.
The problem is that I'll have to pass PApplet to every constructor. I'm not fine with this way to declare objects. I know that the first solution above will work, but I want to remove the PApplet reference each time I create Object. It might seems too much esthetic, but I can't imagine working with this in design.
Code:
Vertex(x,y,z,this);
Face(Vertex[], this);
Cube(x,y,z,dx,dy,dz,this);
Pyramid(x,y,z,dx,dy,dz,this);
Scene(this);
//....
//so on, this, this, this...
I would prefer something like:
Code:
Vertex(x,y,z);
Face(Vertex[]);
Cube(x,y,z,dx,dy,dz);
Pyramid(x,y,z,dx,dy,dz);
Scene();
//or, at least, myGeo.Vertex(x,y,z);
As you know PovRAY, you probably remember great things with the pseudoCode like:
Code:
Vertex a,b;
Vertex c = a+b;
I'm still thinking that it's more easy to read that way. At the end, I left that way to do it in Java, but I might still be nostalgic. Again, passing PApplet on every new object, since I don't have a 'this' key on my keyboard yet, I won't be happy with this Library for everyday design.
There's an anonther way to do it?
...
I tried something else (Make a superClass where you pass PApplet only once and where everything would be inner, but again, I feel that it's a wrong way:
Code:
public class SuperGeo {
public PApplet p5;
public SuperGeo(PApplet p5){
this.p5 = p5;
}
public class Vertex{
float x,y,z;
Vertex(){}
Vertex(float _x, float _y, float _z){
x=_x;
y=_y;
z=_z;
}
public void add(float k){ x+=k; y+=k; z+=k;}
public void add(float k, float l){ x+=k; y+=l; }
public void add(float k, float l, float m){ x+=k; y+=l; z+=l;}
//...
public void draw(){
p5.ellipse(x,y,3,3); //Will use PApplet to draw an ellipse.
}
}
}