boincview.pde:
Code:
import damkjer.ocd.*;
import processing.opengl.*;
Camera cam;
MouseWheelEventDemo wheel;
ArrayList donuts = new ArrayList();
public static void main( String args[] ) {
PApplet.main( new String[] { "--present", "boincview" } );
}
void setup()
{
size(600,600,OPENGL);
colorMode(RGB,255,255,255,255);
frameRate(24);
wheel = new MouseWheelEventDemo();
cam = new Camera(this);
this.donuts.add(new Donut(0.95,10000.0));
this.donuts.add(new Donut(0.75,10000.0));
noStroke();
noSmooth();
}
void draw() {
background(0);
cam.feed();
lights();
for(int i=0; i<this.donuts.size(); i++){
Donut d = (Donut) this.donuts.get(i);
d.draw();
}
println(red(get(mouseX,mouseY))); // Testing
if(mouseX < 32) cam.pan(-(32-mouseX)/1000.0);
if(mouseX > width-32) cam.pan((32-(width-mouseX))/1000.0);
if(mouseY < 32) cam.tilt(-(32-mouseY)/1000.0);
if(mouseY > height-32) cam.tilt((32-(height-mouseY))/1000.0);
}
public class MouseWheelEventDemo implements MouseWheelListener {
int notches = 0;
public MouseWheelEventDemo() {
addMouseWheelListener(this);
}
public void mouseWheelMoved(MouseWheelEvent e) {
cam.zoom(-e.getWheelRotation()/20.0);
}
}
Donut.pde:
Code:
public class Donut {
String computer = "";
float fraction = 0.0;
float remaining = 0.0;
float radius = 0.0;
float posX = 0;
float posY = 0;
float posZ = 0;
boolean isHovering = false;
public Donut(float frac, float remain){
this.fraction = frac;
this.remaining = remain;
this.radius = remaining/(1-fraction)/3600;
this.posX = random(-600,600);
this.posY = random(-600,600);
this.posZ = random(-100,100);
//println(screenX(this.posX,this.posY,this.posZ) + " " + screenY(this.posX,this.posY,this.posZ)); // Testing
}
void draw(){
pushMatrix();
translate(this.posX,this.posY,this.posZ);
float theta;
int full = floor(this.fraction*16);
int transp = 255;
pushMatrix();
for(int i=0;i<16;i++){
if(i==full) transp = 64;
theta = TWO_PI/16*i;
translate(cos(theta)*this.radius,sin(theta)*this.radius,0);
fill(200+round(sin(2*theta)*40),0,0,transp);
sphere(TWO_PI*this.radius/8);
}
popMatrix();
popMatrix();
}
public float getX(){
return posX;
}
public float getY(){
return posY;
}
public float getZ(){
return posZ;
}
public float getRadius(){
return radius;
}
}
Done.
Thanks for your interest.