All pastes #295283 Raw Edit

Anonymous

public text v1 · immutable
#295283 ·published 2006-12-29 06:59 UTC
rendered paste body
void setup(){
  size(400,400,P3D);
}

void draw(){
  background(255);
  noFill();
  
  //mouse x and y before translation. everything is okay
  stroke(0);  
  ellipse(mouseX,mouseY,50,50); 
    
  //go back in space, mouse x and y is now lagging behind!
  translate(0,0,-200);
  stroke(255,0,0);
  ellipse(mouseX,mouseY,50,50);
    
  //need to do some math to mouse x and y so I have the true 3D position of mouse 
  float absx = mouseX * tan(radians(60)) * 200 / width;
  float absy = mouseY * tan(radians(60)) * 200 / height;  
  stroke(0,0,255);
  ellipse(absx,absy,50,50);
}