Hello everyone,
would it be possible to add the getter and setter methods for the attribute fieldOfView in the Camera.java class to make it easier to read and write in the next release of jme 3.4?
public void setFieldOfView(float fov) {}
public float getFieldOfView() {}
something like that so you don’t have to use a wrapper class like in the example?
public class MainCamera {
private Camera cam;
private float fieldOfView;
private float near;
private float far;
/**
* Initialize the application camera to a
* 45 degree fov, 0.1 near plane, and 1000 far plane.
*
* @param cam
*/
public MainCamera(Camera cam) {
this(cam, 45, 0.1f, 1000); // 45 is the default JME fov
}
/**
* Initialize the specified camera to the specified parameters.
*
* @param cam
* @param fov
* @param near
* @param far
*/
public MainCamera(Camera cam, float fov, float near, float far) {
this.cam = cam;
this.fieldOfView = fov;
this.near = near;
this.far = far;
resetCamera();
}
public void setFieldOfView(float f) {
if (this.fieldOfView == f) {
return;
}
this.fieldOfView = f;
resetCamera();
}
public float getFieldOfView() {
return fieldOfView;
}
public void setNear(float f) {
if (this.near == f) {
return;
}
this.near = f;
resetCamera();
}
public float getNear() {
return near;
}
public void setFar(float f) {
if (this.far == f) {
return;
}
this.far = f;
resetCamera();
}
public float getFar() {
return far;
}
private void resetCamera() {
float aspect = (float) cam.getWidth() / (float) cam.getHeight();
cam.setFrustumPerspective(fieldOfView, aspect, near, far);
}
}
Will the field of view always measured vertically, in degrees? Most angles in JME are measured in radians. Also, for some applications it might make more sense to measure the field of view horizontally.
Apparently the setFrustumPerspective method provides as input a value in degrees on the vertical axis.
If it helps, I can give you an example of how the fov is modified in a typical third person shooter game. In several tutorials I have noticed that typically when the player activates the aim with the firearm the fov varies.