Hi all,
I have drawn a cube in the scene and I am trying to change the colour of the cube based on where I am looking. Currently I am just trying to measure the distance from the reticle position and the position of the cube. It appears to change the colour once but then never changes it again. Am I using the calculate function incorrectly? Or is there some other facepalm I have missed? Thanks.
import processing.vr.*;
PGraphicsVR p = new PGraphicsVR();
float retX, retY, x, y, z;
color col = color(0, 150, 255);
float d;
void setup() {
fullScreen(MONO);
x = width/2;
y = height/2;
z = -650;
}
void calculate() {
//this function is called once per frame immediately before draw
//use it to update variable values
retX = p.cameraX;
retY = p.cameraY;
}
void draw() {
//this is called twice per frame, once per eye
background(185);
lights();
d = dist(retX, retY, x, y);
if (d > 150) col = color(255, 0, 255);
else if (d < 150) col = color(0, 150, 255);
println(d);
fill(col);
translate(x, y, z);
box(475);
drawReticule();
}
void drawReticule() {
eye();
fill(255, 200, 0);
stroke(255, 200);
strokeWeight(5);
point(retX, retY, 100);
}