I’m trying to calculate the point, which the Camera is looking on.
The Camera has a Rotation around the X-axis and the Y-axis.
I want to calculate the point, which is 1cm away and on the same line, as my Camera.
I know how to calculate something like this in 2D but when I get to 3D, I get in trouble.
This is for 2D (only x and z axis):
float c = 1f;
float a = c * Math.cos(Math.toRadians(rotationY));
float b = (Math.sin(Math.toRadians(rotationY)) * c);
newPosition.z -= a;
newPosition.x += b;
But with 3D I need help.
I hope somebody here knows the awnser.
One way would be to take the inverse of the camera’s view matrix, and then transform a point 1cm in front of the camera by this matrix.
If your camera first is rotated by X degrees around the X axis, and Y degrees around the y axis, then in pseudocode it might look like this: