Hi community
I want to create a rotation with mouse, this code allow calculate angles
private Vector2f calcularAnguloX()
{
Vector2f posicionMouse = inputManager.getCursorPosition();
Vector3f click3d = cam.getWorldCoordinates(posicionMouse, 0f).clone();
Vector3f vectorPuntero = click3d.subtract(pocicionCerca); //Vector click mouse
Vector3f vectorProyXZ = new Vector3f(vectorPuntero.x, 0, vectorPuntero.z); //Projection vector1
Vector3f vectorProyYZ = new Vector3f(0, vectorPuntero.y, vectorPuntero.z); //Projection vector2
Vector3f vectorCentroCam = cam.getWorldCoordinates(
new Vector2f(
(this.getCamera().getWidth() / 2),
(this.getCamera().getHeight() / 2)), 0f).clone(); //vector camera
Vector3f vectorCentro = vectorCentroCam.subtract(pocicionCerca).normalize();
float angleAxeY = vectorCentro.angleBetween(vectorProyXZ.normalize()); //calculate angle in y
float angleAxeX = vectorCentro.angleBetween(vectorProyYZ.normalize()); //calculate angle in x
// if (posicionMouse.getX() > (this.getCamera().getWidth() / 2))
// {
// angleRadians1 = (float) (Math.PI*angleRadians1 *4 -angleRadians1);
// }
if (posicionMouse.getY() > (this.getCamera().getHeight() / 2))
{
angleAxeX = (float) ((2*Math.PI) - angleAxeX); // angle for rotation in Y... this value is aplicate a quaternion in unitary vector in Y
}
System.out.println("valor de angleRadians2 "+ Math.toDegrees(angleAxeX));
System.out.println("posicion y "+posicionMouse.getY());
return new Vector2f(angleAxeY, angleAxeX);
}
the result is here video
the angle is very small why?
Thanks