/** * Creates a new instance of <code>CurveLookAtController</code>. * * @param curveController * The curve interpolation controller that does the work of finding the correct position to look at, can * not be <code>null</code>. * @param worldUp * The world up vector, can not be <code>null</code>. */ public CurveLookAtController(final CurveInterpolationController curveController, final ReadOnlyVector3 worldUp) { super(); if (null == curveController) { throw new IllegalArgumentException("curveController can not be null!"); } _curveController = curveController; _previous = new Vector3(_curveController.getControlFrom()); setWorldUp(worldUp); }
/** * Creates a new instance of <code>CurveLookAtController</code>. * * @param curveController * The curve interpolation controller that does the work of finding the correct position to look at, can * not be <code>null</code>. * @param worldUp * The world up vector, can not be <code>null</code>. */ public CurveLookAtController(final CurveInterpolationController curveController, final ReadOnlyVector3 worldUp) { super(); if (null == curveController) { throw new IllegalArgumentException("curveController can not be null!"); } _curveController = curveController; _previous = new Vector3(_curveController.getControlFrom()); setWorldUp(worldUp); }
@Override public void update(final double time, final Spatial caller) { if (null == caller) { throw new IllegalArgumentException("caller can not be null!"); } final Vector3 interpolated = Vector3.fetchTempInstance(); final Matrix3 rotation = Matrix3.fetchTempInstance(); _curveController.interpolateVectors(_curveController.getControlFrom(), _curveController.getControlTo(), _curveController.getDelta(), interpolated); MathUtils.matrixLookAt(_previous, interpolated, _worldUp, rotation); if (isLocalRotation()) { caller.setRotation(rotation); } else { caller.setWorldRotation(rotation); } _previous.set(interpolated); Matrix3.releaseTempInstance(rotation); Vector3.releaseTempInstance(interpolated); }
@Override public void update(final double time, final Spatial caller) { if (null == caller) { throw new IllegalArgumentException("caller can not be null!"); } final Vector3 interpolated = Vector3.fetchTempInstance(); final Matrix3 rotation = Matrix3.fetchTempInstance(); _curveController.interpolateVectors(_curveController.getControlFrom(), _curveController.getControlTo(), _curveController.getDelta(), interpolated); MathUtils.matrixLookAt(_previous, interpolated, _worldUp, rotation); if (isLocalRotation()) { caller.setRotation(rotation); } else { caller.setWorldRotation(rotation); } _previous.set(interpolated); Matrix3.releaseTempInstance(rotation); Vector3.releaseTempInstance(interpolated); }