We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Dear all,
I as a part of a 3D interface that I'm working on, I would like to be able to create a line between a 2D point and 3D point. In order to understand my question better, here is a simplified code:
import peasy.*;
PeasyCam cam;
void setup() {
size(1600, 900, P3D);
smooth();
frameRate(60);
lights();
cam = new PeasyCam(this, 100);
}
void draw() {
background(255);
cam.beginHUD();
rect(0, 0, 50, 50);
cam.endHUD();
translate(mouseX, mouseY);
box(10,10,10);
}
I would like that a line would be connecting a 2D point (for example the lower right corner of the 2D square) with one of the corners (3D point) of the cube. So even if the cube would be rotating, the line would be connecting both points by constantly updating itself.
Has anyone an idea how this could be done? Maybe by defining 2 PVectors, one as a 2D and the other as 3D?
Any help is highly appreciated. Regards,
L
Answers
Have a look at https://processing.org/reference/screenX_.html
First attempt, not using the mouse but controlling the x and y position with the arrow keys.
Kf
Thank you kfrajer, thank you a lot really!