import processing.opengl.PGraphicsGL; float xmag, ymag = 0; float newXmag, newYmag = 0; float factor = 4; int fontsize = 20; String[] lines; int voxelcount; float vscale; float[] voxel; PGraphicsGL G; void setup() { size(750, 230, OPENGL); G=(PGraphicsGL)g; PFont font = createFont("Arial", fontsize); textFont(font); lines = loadStrings("http://www.the-mathclub.net/applet/datafile"); vscale = 0; voxelcount = lines.length / 3; voxel = new float[lines.length]; for(int i = 0; i < lines.length; i++) { voxel[i] = float(split(lines[i], '\n')[0]); if(vscale < abs(voxel[i])) { vscale = abs(voxel[i]); } } } void draw() { pushMatrix(); background(255, 224, 32); stroke(0); noFill(); rect(0,0,width-1,height-1); smooth(); // // // write out the text // // fill(0); text("PRNG Phase Space Reconstruction", 0, height - (fontsize * 0.25)); // // // translate + scale for center, and track the mouse rotation for 3d objects // // translate(width / 2, height / 2, 0); scale(height/(vscale*factor)); newXmag = mouseX/float(width) * TWO_PI; newYmag = mouseY/float(height) * TWO_PI; float diff = xmag-newXmag; if (abs(diff) > 0.01) { xmag -= diff/4.0; } diff = ymag-newYmag; if (abs(diff) > 0.01) { ymag -= diff/4.0; } rotateX(-ymag); rotateY(-xmag); // // // stroke the axis and the prjection bounding boxes // // stroke(255,128,128); line(0,0,0, vscale * 1.5, 0, 0); line(0,0,0, 0, vscale * 1.5, 0); line(0,0,0, 0, 0, vscale * 1.5); stroke(128); beginShape(LINE_STRIP); vertex(-vscale,-vscale, vscale *1.5); vertex( vscale,-vscale, vscale *1.5); vertex( vscale, vscale, vscale *1.5); vertex(-vscale, vscale, vscale *1.5); vertex(-vscale,-vscale, vscale *1.5); endShape(); beginShape(LINE_STRIP); vertex(-vscale, vscale *1.5,-vscale); vertex( vscale, vscale *1.5,-vscale); vertex( vscale, vscale *1.5, vscale); vertex(-vscale, vscale *1.5, vscale); vertex(-vscale, vscale *1.5,-vscale); endShape(); beginShape(LINE_STRIP); vertex(vscale *1.5, -vscale,-vscale); vertex(vscale *1.5, vscale,-vscale); vertex(vscale *1.5, vscale, vscale); vertex(vscale *1.5, -vscale, vscale); vertex(vscale *1.5, -vscale,-vscale); endShape(); // // // position the particles // // G.gl.glPushAttrib(G.gl.GL_TRANSFORM_BIT); //G.gl.glMatrixMode(G.gl.GL_PROJECTION); //G.gl.glPushMatrix(); //PMatrix proj = G.camera; //float[] proj_mat = new float[16]; //proj_mat[0] = proj.m00; proj_mat[1] = proj.m01; proj_mat[2] = proj.m02; proj_mat[3] = proj.m03; //proj_mat[4] = proj.m10; proj_mat[5] = proj.m11; proj_mat[6] = proj.m12; proj_mat[7] = proj.m13; //proj_mat[8] = proj.m20; proj_mat[9] = proj.m21; proj_mat[10] = proj.m22; proj_mat[11] = proj.m23; //proj_mat[12] = proj.m30; proj_mat[13] = proj.m31; proj_mat[14] = proj.m32; proj_mat[15] = proj.m33; //G.gl.glLoadMatrixf(proj_mat); G.gl.glMatrixMode(G.gl.GL_MODELVIEW); G.gl.glPushMatrix(); //PMatrix model = G.modelview; //float[] model_mat = new float[16]; //model_mat[0] = model.m00; model_mat[1] = model.m01; model_mat[2] = model.m02; model_mat[3] = model.m03; //model_mat[4] = model.m10; model_mat[5] = model.m11; model_mat[6] = model.m12; model_mat[7] = model.m13; //model_mat[8] = model.m20; model_mat[9] = model.m21; model_mat[10] = model.m22; model_mat[11] = model.m23; //model_mat[12] = model.m30; model_mat[13] = model.m31; model_mat[14] = model.m32; model_mat[15] = model.m33; //G.gl.glLoadMatrixf(model_mat); G.gl.glLoadIdentity(); G.gl.glTranslatef(0, 0, -vscale); G.gl.glScalef(height/(vscale*factor), height/(vscale*factor), height/(vscale*factor)); G.gl.glRotatef(ymag*height/TWO_PI, 1, 0, 0); G.gl.glRotatef(-xmag*width/TWO_PI/2.0, 0, 0, 1); for(int i = 0; i < voxelcount; i++) { G.gl.glColor3f(0,0,0); //stroke(0,0,0); G.gl.glBegin(G.gl.GL_POINTS); //beginShape(POINTS); G.gl.glVertex3f(voxel[i * 3 + 0], voxel[i * 3 + 1], voxel[i * 3 + 2]); //vertex(voxel[i * 3 + 0], voxel[i * 3 + 1], voxel[i * 3 + 2]); //endShape(); //beginShape(POINTS); G.gl.glColor3f(128/255.0,192/255.0,128/255.0); //stroke(128,192,128); G.gl.glVertex3f(voxel[i * 3 + 0], voxel[i * 3 + 1], vscale * 1.5); //vertex(voxel[i * 3 + 0], voxel[i * 3 + 1], vscale * 1.5 ); G.gl.glVertex3f(voxel[i * 3 + 0], vscale * 1.5 , voxel[i * 3 + 2]); //vertex(voxel[i * 3 + 0], vscale * 1.5 , voxel[i * 3 + 2]); G.gl.glVertex3f(vscale * 1.5 , voxel[i * 3 + 1], voxel[i * 3 + 2]); //vertex(vscale * 1.5 , voxel[i * 3 + 1], voxel[i * 3 + 2]); G.gl.glEnd(); //endShape(); } G.gl.glPopMatrix(); //G.gl.glMatrixMode(G.gl.GL_PROJECTION); //G.gl.glPopMatrix(); G.gl.glPopAttrib(); popMatrix(); }