Hey Victor -- just want to say thanks so much for all your help so far
It's not that I'm worried about the complexity of the transform. Just that the order is important. If both the box() and the SuperPoint need to move mouseY distance vertically, but one in the positive direction and the other in the negative direction, then I need to call scale()
before I call translate() -- but have it only apply in one case and not the other (which doesn't really make sense).
Furthermore, I think it's more than just a scale(1, -1, 1) difference between the two cases. Here's a sketch that calls perspective() every frame so long as you're holding the mouse down:
Code:
import com.hardcorepawn.*;
import processing.opengl.*;
SuperPoint p;
void setup() {
size(640, 480, OPENGL);
p=new SuperPoint(this);
for(int i = 0; i < 100000; i++) {
p.addPoint(
random(-100,100), random(-100,100), random(-100,100),
random(1), random(1), random(1), random(1));
}
}
void draw() {
background(0);
if(mousePressed)
perspective();
pushMatrix();
translate(mouseX, mouseY, -512);
rotateX(radians(mouseY));
rotateY(radians(mouseX));
rotateZ(radians(mouseX));
box(200);
popMatrix();
pushMatrix();
if(mousePressed) {
if(keyPressed) {
translate(0, height, 0);
scale(1, -1, 1);
translate(mouseX, mouseY, -512);
rotateX(radians(mouseY));
rotateY(radians(mouseX));
rotateZ(radians(mouseX));
} else {
translate(mouseX, height - mouseY, -512);
rotateX(-radians(mouseY));
rotateY(radians(mouseX));
rotateZ(-radians(mouseX));
}
} else {
translate(mouseX, mouseY, -512);
rotateX(radians(mouseY));
rotateY(radians(mouseX));
rotateZ(radians(mouseX));
}
p.draw(3);
popMatrix();
}
You can see that the corollary of:
Code:
translate(mouseX, mouseY, -512);
rotateX(radians(mouseY));
rotateY(radians(mouseX));
rotateZ(radians(mouseX));
Can't be accomplished by simply preceding it with a scale(1, -1, 1), but has to be done:
Code:
translate(mouseX, height - mouseY, -512);
rotateX(-radians(mouseY));
rotateY(radians(mouseX));
rotateZ(-radians(mouseX));
If you have an idea of something I can tell OpenGL that will effectively accomplish this same thing (negative scale with height offset, negative x and z rotations)... that would be super helpful!