import ketai.sensors.*; import processing.vr.*; KetaiSensor sensor; float fontSize = 130*displayDensity; float rotationX, rotationY, rotationZ; float roll, pitch, yaw; PShape buddha; PVector half = new PVector(); PMatrix3D baseMat; void setup() { fullScreen(STEREO); // size(displayWidth, displayHeight, P3D); if(sensor == null){ sensor = new KetaiSensor(this); sensor.start(); } buddha = loadShape("buddha.obj"); buddha.setFill(0xffffffff); buddha.setSpecular(0xfffff7d5); textAlign(CENTER, CENTER); textSize(fontSize); half.set(width * .5, height * .5); baseMat = getMatrix(baseMat); } void draw() { background(0xff000000); scale(10); translate(60.0, 70.0, -150.0); lightSpecular(64, 64, 64); // Horizonal light. spotLight(255, 255, 255, -half.x, 1, 0, 1, 0, 0, PI, 10); // // Vertical light. spotLight(255, 255, 255, 1, -half.y, 0, 0, 1, 0, PI, 10); shape(buddha); pitch += rotationX; roll += rotationY; yaw += rotationZ; buddha.rotateY(pitch); buddha.rotateX(-roll); buddha.rotateZ(yaw); } void onGyroscopeEvent(float x, float y, float z) { rotationX = radians(x); if(round(rotationX) == 0) pitch = 0; rotationY = radians(y); if(round(rotationY) == 0) roll = 0; rotationZ = radians(z); if(round(rotationZ) == 0) yaw = 0; } void mousePressed() { pitch = roll = yaw = 0; setup(); }