/** * Construct a new integrator. * * @param in_camera The camera to be integrated. * @param in_input The input to be sampled. * * @return A new integrator */ public static JCameraFPSStyleAngularIntegratorType newIntegrator( final JCameraFPSStyleType in_camera, final JCameraFPSStyleInputType in_input) { return new JCameraFPSStyleAngularIntegrator(in_camera, in_input); }
@Override public void integrate( final float time) { this.speed_horizontal = this.integrateHorizontal(time); this.integrateVertical(time); }
/** * Return a new integrator for the given camera and input using the default * integrator implementations. * * @param in_camera The camera * @param in_input The input * * @return A new integrator */ public static JCameraFPSStyleIntegratorType newIntegrator( final JCameraFPSStyleType in_camera, final JCameraFPSStyleInputType in_input) { final JCameraFPSStyleAngularIntegratorType ai = JCameraFPSStyleAngularIntegrator.newIntegrator(in_camera, in_input); final JCameraFPSStyleLinearIntegratorType li = JCameraFPSStyleLinearIntegrator.newIntegrator(in_camera, in_input); return JCameraFPSStyleIntegrator.newIntegratorWith(ai, li); }
private void integrateVertical( final float time) { final float r = this.input.takeRotationVertical(); final float s = this.speed_vertical + (r * (this.acceleration_vertical * time)); final float sc = Clamp.clamp( s, -this.maximum_speed_vertical, this.maximum_speed_vertical); this.camera.cameraRotateAroundVertical(sc); this.speed_vertical = JCameraFPSStyleAngularIntegrator .applyDrag(sc, this.drag_vertical, time); }
/** * Return a new integrator for the given camera and input using the default * integrator implementations. * * @param in_camera The camera * @param in_input The input * * @return A new integrator */ public static JCameraFPSStyleIntegratorType newIntegrator( final JCameraFPSStyleType in_camera, final JCameraFPSStyleInputType in_input) { final JCameraFPSStyleAngularIntegratorType ai = JCameraFPSStyleAngularIntegrator.newIntegrator(in_camera, in_input); final JCameraFPSStyleLinearIntegratorType li = JCameraFPSStyleLinearIntegrator.newIntegrator(in_camera, in_input); return JCameraFPSStyleIntegrator.newIntegratorWith(ai, li); }
private void integrateVertical( final double time) { final double r = this.input.takeRotationVertical(); final double s = this.speed_vertical + (r * (this.acceleration_vertical * time)); final double sc = Clamp.clamp( s, -this.maximum_speed_vertical, this.maximum_speed_vertical); this.camera.cameraRotateAroundVertical(sc); this.speed_vertical = JCameraFPSStyleAngularIntegrator .applyDrag(sc, this.drag_vertical, time); }
@Override JCameraFPSStyleAngularIntegratorType newIntegrator( final @NonNull JCameraFPSStyleType c, final @NonNull JCameraFPSStyleInputType i) { return JCameraFPSStyleAngularIntegrator.newIntegrator(c, i); } }
@Override public void integrate( final double time) { this.speed_horizontal = this.integrateHorizontal(time); this.integrateVertical(time); }
private float integrateHorizontal( final float time) { final float r = this.input.takeRotationHorizontal(); final float s = this.speed_horizontal + (r * (this.acceleration_horizontal * time)); final float sc = Clamp.clamp( s, -this.maximum_speed_horizontal, this.maximum_speed_horizontal); /** * If applying the movement resulted in a value that was clamped, then * remove all speed in that direction by returning zero. Otherwise, the * user has to achieve a greater than or equal speed in the opposite * direction just to get the camera to appear to start moving. */ final boolean clamped = this.camera.cameraRotateAroundHorizontal(sc); if (clamped) { return 0.0f; } return JCameraFPSStyleAngularIntegrator.applyDrag( sc, this.drag_horizontal, time); }
/** * Construct a new integrator. * * @param in_camera The camera to be integrated. * @param in_input The input to be sampled. * * @return A new integrator */ public static JCameraFPSStyleAngularIntegratorType newIntegrator( final JCameraFPSStyleType in_camera, final JCameraFPSStyleInputType in_input) { return new JCameraFPSStyleAngularIntegrator(in_camera, in_input); }
@Test(expected = IllegalArgumentException.class) public void testCameraIncorrect() { final JCameraFPSStyleType c0 = JCameraFPSStyle.newCamera(); final JCameraFPSStyleType c1 = JCameraFPSStyle.newCamera(); final JCameraFPSStyleInputType i = JCameraFPSStyleInput.newInput(); final JCameraFPSStyleAngularIntegratorType ai = JCameraFPSStyleAngularIntegrator.newIntegrator(c0, i); final JCameraFPSStyleLinearIntegratorType li = JCameraFPSStyleLinearIntegrator.newIntegrator(c1, i); JCameraFPSStyleIntegrator.newIntegratorWith(ai, li); }
private double integrateHorizontal( final double time) { final double r = this.input.takeRotationHorizontal(); final double s = this.speed_horizontal + (r * (this.acceleration_horizontal * time)); final double sc = Clamp.clamp( s, -this.maximum_speed_horizontal, this.maximum_speed_horizontal); /** * If applying the movement resulted in a value that was clamped, then * remove all speed in that direction by returning zero. Otherwise, the * user has to achieve a greater than or equal speed in the opposite * direction just to get the camera to appear to start moving. */ final boolean clamped = this.camera.cameraRotateAroundHorizontal(sc); if (clamped) { return 0.0f; } return JCameraFPSStyleAngularIntegrator.applyDrag( sc, this.drag_horizontal, time); }
@Test(expected = IllegalArgumentException.class) public void testInputIncorrect() { final JCameraFPSStyleType c = JCameraFPSStyle.newCamera(); final JCameraFPSStyleInputType i0 = JCameraFPSStyleInput.newInput(); final JCameraFPSStyleInputType i1 = JCameraFPSStyleInput.newInput(); final JCameraFPSStyleAngularIntegratorType ai = JCameraFPSStyleAngularIntegrator.newIntegrator(c, i0); final JCameraFPSStyleLinearIntegratorType li = JCameraFPSStyleLinearIntegrator.newIntegrator(c, i1); JCameraFPSStyleIntegrator.newIntegratorWith(ai, li); } }