Disabling Mouse Wheel Zoom & Setting FlyCam Zoom

Currently I have two questions on the FlyCam:


  1. How can I disable zooming by “scrolling” the mouse-wheel?
  2. How can I manually zoom the camera? (An example would be in a fps game where the player looks down the scope of a rifle, and the camera zooms in?)

1 ) Look in the source of FlyByCamera.java just disable the mapping for the scroll events

[java]inputManager.deleteMapping("FLYCAM_ZoomIn");

inputManager.deleteMapping("FLYCAM_ZoomOut");

[/java]



2) Just move the camera, [java]cam.setLocation(someVector);[/java]

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies



for an advanced effect you can try changing the camera frustums

@wezrule

Thanks for the answer to #1, but I don’t think that #2 would work, because the player would still be able to look around, which would be different than rotating around it’s new location, so I may try this: (found it in the FlyByCamera coding)



[java]

protected void zoomCamera(float value){

// derive fovY value

float h = cam.getFrustumTop();

float w = cam.getFrustumRight();

float aspect = w / h;



float near = cam.getFrustumNear();



float fovY = FastMath.atan(h / near)

/ (FastMath.DEG_TO_RAD * .5f);

fovY += value * 0.1f;



h = FastMath.tan( fovY * FastMath.DEG_TO_RAD * .5f) * near;

w = h * aspect;



cam.setFrustumTop(h);

cam.setFrustumBottom(-h);

cam.setFrustumLeft(-w);

cam.setFrustumRight(w);

}

[/java]

Another way:

[java]flyCam.setZoomSpeed(0);[/java]

Regards!!!

Not sure if this is the proper way of doing this, however, I would think rendering from the same view as the original camera into a smaaaaal viewport and then scaling the quad it is rendered to would produce the effect you are looking for.

Might be way off base… but, worth a try since it is fairly easy to set up. Maybe someone else will chime in on the idea and let you know if it is workable or not.

EDIT: Oh, this also has the added benefit of easily being able to adjust the times zoom just by re-configuring the size of the camera’s view port.

The big problem with this method is detail I’m guessing.