<commit_before>//
// $Id$

package com.threerings.jme.input;

import com.jme.math.FastMath;
import com.jme.math.Matrix3f;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;

import com.jme.input.InputHandler;
import com.jme.input.InputSystem;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.RelativeMouse;
import com.jme.input.action.*;
import com.jme.input.action.InputActionEvent;

import com.threerings.jme.JmeApp;
import com.threerings.jme.Log;

/**
 * Sets up camera controls for moving around from a top-down perspective,
 * suitable for strategy games and their ilk. The "ground" is assumed to
 * be the XY plane.
 */
public class GodViewHandler extends InputHandler
{
    /**
     * Creates the handler.
     *
     * @param cam The camera to move with this handler.
     * @param api The API from which to create a KeyBindingManager.
     */
    public GodViewHandler (Camera cam, String api)
    {
        _camera = cam;
        setKeyBindings(api);
        addActions(cam);
    }

    /**
     * Configures the minimum and maximum z-axis elevation allowed for the
     * camera.
     */
    public void setZoomLimits (float minZ, float maxZ)
    {
        _minZ = minZ;
        _maxZ = maxZ;
    }

    /**
     * Configures limits on the camera roll.
     */
    public void setRollLimits (float minAngle, float maxAngle)
    {
        _minRoll = minAngle;
        _maxRoll = maxAngle;
    }

    /**
     * Configures limits on the distance the camera can be panned.
     */
    public void setPanLimits (float minX, float minY, float maxX, float maxY)
    {
        _minX = minX;
        _minY = minY;
        _maxX = maxX;
        _maxY = maxY;
    }

    /**
     * Sets the camera zoom level to a value between zero (zoomed in
     * maximally) and 1 (zoomed out maximally). Zoom limits must have
     * already been set up via a call to {@link #setZoomLimits}.
     */
    public void setZoomLevel (float level)
    {
        Log.info("Zoom " + level + " " + _camera.getLocation());
        level = Math.max(0f, Math.min(level, 1f));
        _camera.getLocation().z = _minZ + (_maxZ - _minZ) * level;
        _camera.update();
    }

    /**
     * Returns the current camera zoom level.
     */
    public float getZoomLevel ()<commit_msg>Ixnay on the verbose logging.<commit_after>//
// $Id$

package com.threerings.jme.input;

import com.jme.math.FastMath;
import com.jme.math.Matrix3f;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;

import com.jme.input.InputHandler;
import com.jme.input.InputSystem;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.RelativeMouse;
import com.jme.input.action.*;
import com.jme.input.action.InputActionEvent;

import com.threerings.jme.JmeApp;
import com.threerings.jme.Log;

/**
 * Sets up camera controls for moving around from a top-down perspective,
 * suitable for strategy games and their ilk. The "ground" is assumed to
 * be the XY plane.
 */
public class GodViewHandler extends InputHandler
{
    /**
     * Creates the handler.
     *
     * @param cam The camera to move with this handler.
     * @param api The API from which to create a KeyBindingManager.
     */
    public GodViewHandler (Camera cam, String api)
    {
        _camera = cam;
        setKeyBindings(api);
        addActions(cam);
    }

    /**
     * Configures the minimum and maximum z-axis elevation allowed for the
     * camera.
     */
    public void setZoomLimits (float minZ, float maxZ)
    {
        _minZ = minZ;
        _maxZ = maxZ;
    }

    /**
     * Configures limits on the camera roll.
     */
    public void setRollLimits (float minAngle, float maxAngle)
    {
        _minRoll = minAngle;
        _maxRoll = maxAngle;
    }

    /**
     * Configures limits on the distance the camera can be panned.
     */
    public void setPanLimits (float minX, float minY, float maxX, float maxY)
    {
        _minX = minX;
        _minY = minY;
        _maxX = maxX;
        _maxY = maxY;
    }

    /**
     * Sets the camera zoom level to a value between zero (zoomed in
     * maximally) and 1 (zoomed out maximally). Zoom limits must have
     * already been set up via a call to {@link #setZoomLimits}.
     */
    public void setZoomLevel (float level)
    {
//         Log.info("Zoom " + level + " " + _camera.getLocation());
        level = Math.max(0f, Math.min(level, 1f));
        _camera.getLocation().z = _minZ + (_maxZ - _minZ) * level;
        _camera.update();
    }

    /**
     * Returns the current camera zoom level.
     */
    public float getZoomLevel ()
{'fraction_non_alphanumeric': 0.10226049515608181, 'fraction_numerical': 0.002152852529601722, 'mean_word_length': 2.408657373440939, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3867037', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1478, 'n_words': 446}