Currently trying to get rid of having to click, hold and drag your mouse to rotate around an object. The camera should just follow mouseX and mouseY from the start up. This is for further implementation of replacing the mouseX and mouseY with another variable as you can see in my sketch. Any feedback is much appreciated.
import peasy.*;
import controlP5.*;
import processing.video.*;
PeasyCam cam;
Capture usbcam;
ControlP5 cp5;
int pointx, pointy;
PShape s;
int cubeWidthSwitch = 0;
int distanceFactor = 1;
float c1 = 0;
float pixelBrightness = 0;
void setup() {
size (1280, 720, P3D);
frame.setResizable(true);
cp5 = new ControlP5(this);
usbcam = new Capture(this, 1280, 720, "USB Webcam");
usbcam.start();
frameRate(30);
s = loadShape("spike.obj");
s.scale(0.2);
cam = new PeasyCam(this, 500);
cam.setMinimumDistance(500);
cam.setMaximumDistance(500);
}
void draw () {
c1+=5;
c1%=255;
colorMode(HSB);
background(0);
for ( int gridX = -480 ; gridX <240 ; gridX = gridX +90 ) {
for (int gridY = -480 ; gridY < 240 ; gridY = gridY +90) {
for (int gridZ = -480 ; gridZ < 240 ; gridZ = gridZ+90) {
pushMatrix ();
translate (gridX*distanceFactor*2, gridY*distanceFactor*2, gridZ*distanceFactor*2);
translate(360, 400, 350);
fill (c1, 255, 255);
sphere(1.5);
noStroke();
popMatrix();
}
}
}
s.setFill(color(255));
shape(s);
cam.beginHUD();
gui();
cam.endHUD();
}
void gui(){
camera();
if(usbcam.available()) {
usbcam.read();
usbcam.loadPixels();
int brightest = 0;
for(int i=0; i<usbcam.pixels.length; i++) {
if(brightness(usbcam.pixels[i]) < 70) {
pixelBrightness = brightness(usbcam.pixels[i]);
brightest = i;
}
}
pointx = brightest % usbcam.width;
pointy = brightest / usbcam.width;
// image(usbcam, 0, 0);
// ellipse(pointx, pointy, 200, 200);
}
}