Here is what I have so far. I have replaced the points with OPENGL-anti-aliased lined. It much sweeter and faster like this.
Using the Peasycam library is optional.
Quote:import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
PeasyCam cam;
import processing.opengl.*;
import javax.media.opengl.*;
Point[] points = new Point[0];
float depth = 0;
float current_z = 0;
float current_rotation = 0;
float rotx;
float roty;
GL gl;
PGraphicsOpenGL pgl;
public String mode = "OPENGL";
void setup() {
if(mode=="OPENGL")size(600,600,OPENGL);
if(mode=="P3D")size(600,600,P3D);
lights();
hint (DISABLE_DEPTH_TEST);
hint(DISABLE_OPENGL_2X_SMOOTH);
hint(ENABLE_OPENGL_4X_SMOOTH);
if (mode == "OPENGL"){
pgl = (PGraphicsOpenGL) g;
gl = pgl.gl;
gl.glHint (gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST);
gl.glEnable (gl.GL_LINE_SMOOTH);
}
if (mode == "P3D"){
smooth();
}
cam = new PeasyCam (this,width);
float step = 50;
for(float i = 0; i < TWO_PI; i+= TWO_PI/step) {
pushMatrix();
rotateY(i);
for(float j = 0; j < TWO_PI; j+= TWO_PI/step) {
float s = 200;
float x = s*cos(j);
float y = s*sin(j);
points = (Point[]) append(points, new Point(modelX(x, y, 0), modelY(x, y, 0), modelZ(x, y, 0)));
}
popMatrix();
}
}
void draw() {
background(255);
translate(width/2, height/2);
rotx = (current_rotation/3.0)%TWO_PI;
roty = current_rotation%TWO_PI;
rotateY(roty);
rotateX(rotx);
stroke(0);
for(int i = 0; i < points.length; i++) {
//point(points[i].x, points[i].y, points[i].z);
if (i>0) line(points[i].x, points[i].y, points[i].z,points[i-1].x, points[i-1].y, points[i-1].z);
}
current_rotation += 0.005;
draw2();
}
class Point {
float x;
float y;
float z;
Point(float xpos, float ypos) {
x = xpos;
y = ypos;
}
Point(float xpos, float ypos, float zpos) {
x = xpos;
y = ypos;
z = zpos;
}
}
void draw2() {
// background(0);
translate(width/2, height/2);
rotx = (current_rotation/3.0)%TWO_PI;
roty = current_rotation%TWO_PI;
rotateY(roty);
rotateX(rotx);
//stroke(0);
for(int i = 0; i < points.length; i++) {
float mapped_value = map(modelZ(points[i].x, points[i].y, points[i].z), -200, 200, 255, 0);
stroke(mapped_value, 255 - mapped_value, mapped_value);
// point(points[i].x, points[i].y, points[i].z);
if (i>0) line(points[i].x, points[i].y, points[i].z,points[i-1].x, points[i-1].y, points[i-1].z);
}
current_rotation += 0.005;
}