I’m trying to control the camera view using a MIDI controller.
For each knob, we want to control it by attaching it to X, Y, and Z.
But when I do X,Y,Z control in my code, when I touch the X knob, other knobs such as Y,Z are converted to initial values.
We want the initial value to always be stored as the last value.
I want to know an example of how to modify what part.
Regards.
import themidibus.*;
MidiBus myBus;
int ccChannel;
int ccNumber;
int ccValue;
void setup() {
size(400, 400, P3D);
//background(0);
MidiBus.list();
myBus = new MidiBus(this, 0, 1);
}
void draw() {
//model
noStroke();
background(0);
lights();
translate(0, height/2, -height/2);
fill(153);
box(50);
translate(width, 0.0);
fill(255);
sphere(50);
//camera
camera(ctlX(), ctlY(), ctlZ(),// eye, eyeY, eyeZ
0.0, 0.0, 0.0, //centerX, centerT, centerZ
0.0, 1.0, 0.0);//upX, upY, upZ)
println(ctlX(), ctlY(), ctlZ());
}
void controllerChange(int channel, int number, int value) {
ccChannel = channel;
ccNumber = number;
ccValue = value;
println("channel " + channel, "number " + number, "value " + value);
}
float ctlX() {
float x = 0.1;
if (ccNumber == 16) {
x = map(ccValue, 0, 127, 0.0, 200.0);
}
return x;
}
float ctlY() {
float y = 0.1;
if (ccNumber == 17) {
y = map(ccValue, 0, 127, 0.0, 200.0);
}
return y;
}
float ctlZ() {
float z = 0.1;
if (ccNumber == 18) {
z = map(ccValue, 0, 127, 0.0, 800.0);
}
return z;
}