1
0
Fork 0
VMC_Processing_Step3/VMC_Processing_Step3.pde

78 lines
1.5 KiB
Text
Raw Normal View History

2019-01-07 22:32:13 +00:00
import ketai.sensors.*;
import processing.vr.*;
KetaiSensor sensor;
float fontSize = 130*displayDensity;
2019-01-13 20:45:04 +00:00
float rotationX, rotationY, rotationZ;
float roll, pitch, yaw;
PShape buddha;
PVector half = new PVector();
PMatrix3D baseMat;
2019-01-07 22:32:13 +00:00
void setup()
{
fullScreen(STEREO);
2019-01-13 20:45:04 +00:00
// size(displayWidth, displayHeight, P3D);
if(sensor == null){
sensor = new KetaiSensor(this);
sensor.start();
}
buddha = loadShape("buddha.obj");
buddha.setFill(0xffffffff);
buddha.setSpecular(0xfffff7d5);
2019-01-07 22:32:13 +00:00
textAlign(CENTER, CENTER);
textSize(fontSize);
2019-01-13 20:45:04 +00:00
half.set(width * .5, height * .5);
baseMat = getMatrix(baseMat);
2019-01-07 22:32:13 +00:00
}
void draw()
{
2019-01-13 20:45:04 +00:00
background(0xff000000);
2019-01-07 22:32:13 +00:00
scale(10);
translate(60.0, 70.0, -150.0);
2019-01-13 20:45:04 +00:00
lightSpecular(64, 64, 64);
2019-01-07 22:32:13 +00:00
2019-01-13 20:45:04 +00:00
// Horizonal light.
spotLight(255, 255, 255,
-half.x, 1, 0,
1, 0, 0,
PI, 10);
2019-01-07 22:32:13 +00:00
2019-01-13 20:45:04 +00:00
// // Vertical light.
spotLight(255, 255, 255,
1, -half.y, 0,
0, 1, 0,
PI, 10);
2019-01-07 22:32:13 +00:00
2019-01-13 20:45:04 +00:00
shape(buddha);
pitch += rotationX;
roll += rotationY;
yaw += rotationZ;
2019-01-07 22:32:13 +00:00
buddha.rotateY(pitch);
buddha.rotateX(-roll);
2019-01-16 09:43:38 +00:00
buddha.rotateZ(yaw);
2019-01-07 22:32:13 +00:00
}
void onGyroscopeEvent(float x, float y, float z)
{
2019-01-13 20:45:04 +00:00
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;
}
2019-01-07 22:32:13 +00:00
2019-01-13 20:45:04 +00:00
void mousePressed()
{
pitch = roll = yaw = 0;
setup();
2019-01-07 22:32:13 +00:00
}