3D Box
in
Core Library Questions
•
1 year ago
First, sorry for my bad english!
I want to make a programm, where a 3D box is in the center of the screen and the box should "look" at my cursor.
My problem is that the box isn't looking on my cursor - can anybody help me?
Here's the short code:
import processing.opengl.*;
float alpha=0;
void setup() {
size(800, 480, OPENGL);
smooth();
}
void draw() {
background(0);
textSize(40);
stroke(125);
translate(width/2, height/2);
alpha = PI/width*mouseX;
rotateX(radians(20));
rotateZ(-alpha);
drawBox();
}
void drawBox() {
stroke(255, 0, 0);
line(-300, 0, 0, 0, 0, 0);
text("This line should touch my cursor", -330, 0, 0);
box(50);
}
Thank you for EVERY USEFUL ANSWER! :-)
1