I am very interested in the latest peasycam features which allow you to set to handle camera operations like pan/zoom/rotate etc through other interaction besides the mouse through handlers. Although I cannot figure out how these work. I think it should work something like this
while this code works great except that when adding peasycam something goes wrong, I cant figure it out. I suspect it has something to do with the way that peasycam deals with matrix transformations.
void mousePressed(){
if (mouseButton==LEFT && vertexMouseOver>-1)
{
vertexKlicked = vertexMouseOver;
zModelKlick = zModelMouseOver;
pcam.setMouseControlled(false);
// calculate transformation matrix for projecting mouse coords
// to the plane where the current selected vertex is
// this doesn't work!
screen2Model = modvwInv;
screen2Model.apply(cam);
}
}
void hitDetect() {
// mouse hit detection using screnX, screenY
vertices2D = new int[0];
vertexMouseOver = -1;
for(int i=0; i<vertices3D.length; i=i+3) {
int x = int(screenX(vertices3D[i], vertices3D[i+1], vertices3D[i+2]));
int y = int(screenY(vertices3D[i], vertices3D[i+1], vertices3D[i+2]));