diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Animation.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Animation.java deleted file mode 100644 index b808f9d3..00000000 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/Animation.java +++ /dev/null @@ -1,10 +0,0 @@ -package pp.mdga.client.animation; - -abstract class Animation { - - abstract void play(); - - abstract void stop(); - - abstract boolean isOver(); -} diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/AnimationHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/AnimationHandler.java deleted file mode 100644 index cee17634..00000000 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/AnimationHandler.java +++ /dev/null @@ -1,29 +0,0 @@ -package pp.mdga.client.animation; - -import pp.mdga.client.MdgaApp; - -public class AnimationHandler { - private MdgaApp app; - - private Animation animation = null; - - public AnimationHandler(MdgaApp app) { - this.app = app; - } - - public void playAnimation(MdgaAnimation type) { - - } - - public void update() { - if (null == animation) { - return; - } - - if (animation.isOver()) { - animation = null; - - //trigger next state in model - } - } -} diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/EmptyAnimation.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/EmptyAnimation.java deleted file mode 100644 index b51d5535..00000000 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/EmptyAnimation.java +++ /dev/null @@ -1,18 +0,0 @@ -package pp.mdga.client.animation; - -class EmptyAnimation extends Animation { - @Override - void play() { - //nothing - } - - @Override - void stop() { - //nothing - } - - @Override - boolean isOver() { - return true; - } -} diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/InitControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/InitControl.java index dfe3f312..f618e32e 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/InitControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/InitControl.java @@ -5,6 +5,12 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.AbstractControl; +/** + * An abstract control class that serves as a base for initializing spatial objects + * in jMonkeyEngine. This class overrides the controlUpdate and controlRender methods + * from the AbstractControl class, providing default empty implementations, + * and adds the ability to initialize spatial objects when they are set. + */ public abstract class InitControl extends AbstractControl { @Override @@ -17,6 +23,12 @@ protected void controlRender(RenderManager rm, ViewPort vp) { } + /** + * Sets the spatial object to be controlled. This method also initializes the spatial + * if it is being set for the first time. + * + * @param spatial The spatial object to control. + */ @Override public void setSpatial(Spatial spatial) { if (this.spatial == null && spatial != null) { @@ -25,6 +37,12 @@ public void setSpatial(Spatial spatial) { } } + /** + * Initializes the spatial object. This method can be overridden by subclasses + * to define custom initialization logic for the spatial. + * This method is called automatically when the spatial is set for the first time. + */ protected void initSpatial() { + // Default empty implementation. Override to add initialization logic. } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/MdgaAnimation.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/MdgaAnimation.java deleted file mode 100644 index cddf535d..00000000 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/MdgaAnimation.java +++ /dev/null @@ -1,4 +0,0 @@ -package pp.mdga.client.animation; - -public enum MdgaAnimation { -} diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/MoveControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/MoveControl.java index e8bbf8b6..621eb118 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/MoveControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/MoveControl.java @@ -4,6 +4,15 @@ import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; +/** + * A control that smoothly moves a spatial from an initial position to an end position + * using a quadratic interpolation, with the option to perform an action after the movement is complete. + * The movement path includes an intermediate "middle" position at a specified height. + * + *

Movement speed can be adjusted by modifying the MOVE_SPEED constant. The movement easing follows + * an ease-in-out curve to create a smooth start and stop effect. + *

+ */ public class MoveControl extends InitControl { private boolean moving; @@ -15,6 +24,14 @@ public class MoveControl extends InitControl { private float progress = 0; private final Runnable actionAfter; + /** + * Creates a new MoveControl with specified initial and end positions, and an action to run after the movement. + * The movement follows a path with a midpoint at a fixed height. + * + * @param initPos The starting position of the spatial. + * @param endPos The target position of the spatial. + * @param actionAfter A Runnable that will be executed after the movement finishes. + */ public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){ moving = false; this.initPos = initPos; @@ -27,12 +44,23 @@ public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){ this.actionAfter = actionAfter; } + /** + * Initializes the movement by resetting the progress and setting the moving flag to true. + * This is called automatically when the spatial is set. + */ @Override protected void initSpatial() { moving = true; progress = 0; } + /** + * Updates the movement of the spatial by interpolating its position along the defined path. + * The movement is smoothed using an easing function. + * Once the movement reaches the target, the {@link #end()} method is called to finish the movement. + * + * @param tpf Time per frame, the time elapsed since the last frame. + */ @Override protected void controlUpdate(float tpf) { if(!moving) return; @@ -42,17 +70,25 @@ protected void controlUpdate(float tpf) { if(progress == 1) end(); } + /** + * Ends the movement by stopping the interpolation, running the action after the movement, + * and removing this control from the spatial. + */ private void end(){ moving = false; actionAfter.run(); spatial.removeControl(this); } - @Override - protected void controlRender(RenderManager rm, ViewPort vp) { - - } - + /** + * Performs quadratic interpolation between three points. + * + * @param p1 The initial point. + * @param p2 The middle point. + * @param p3 The final point. + * @param t The interpolation parameter (0 <= t <= 1). + * @return The interpolated point. + */ private Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) { // Quadratic interpolation: (1-t)^2 * p1 + 2 * (1-t) * t * p2 + t^2 * p3 float oneMinusT = 1 - t; @@ -61,22 +97,14 @@ private Vector3f quadInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) { .add(p3.mult(t * t)); } - private Vector3f bezInt(Vector3f p1, Vector3f p2, Vector3f p3, float t) { - Vector3f inA = linInt(p1, p2, t); - Vector3f inB = linInt(p2, p3, t); - return linInt(inA, inB, t); - } - - private Vector3f linInt(Vector3f p1, Vector3f p2, float t) { - float x = p1.getX() + t * (p2.getX() - p1.getX()); - float y = p1.getY() + t * (p2.getY() - p1.getY()); - float z = p1.getZ() + t * (p2.getZ() - p1.getZ()); - return new Vector3f(x, y, z); - } - + /** + * A smooth ease-in-out function for interpolation. + * It accelerates and decelerates the interpolation for a smoother effect. + * + * @param x The interpolation parameter (0 <= x <= 1). + * @return The adjusted interpolation value. + */ private float easeInOut(float x){ return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2); - } - } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/SymbolControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/SymbolControl.java index cf442659..3bc3e10a 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/SymbolControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/SymbolControl.java @@ -7,7 +7,19 @@ import com.jme3.scene.control.AbstractControl; import pp.mdga.game.BonusCard; -public class SymbolControl extends AbstractControl { +/** + * A control that manages the animation of symbols representing different bonus card states. + * The symbol can animate with zoom, rotation, and translation effects based on the state of the bonus card. + * + *

The control supports three main states: SHIELD, SWAP, and TURBO. Each state has its own specific animation logic: + *

+ *

+ */ +public class SymbolControl extends InitControl { private boolean zoomingIn = false; private boolean zoomingOut = false; private float zoomSpeed = 1f; @@ -18,7 +30,12 @@ public class SymbolControl extends AbstractControl { private Quaternion initialRotation = null; private float y = 5; - + /** + * Updates the symbol animation based on the current bonus card state. + * The method calls the corresponding update method for each state (SHIELD, SWAP, TURBO). + * + * @param tpf Time per frame, the time elapsed since the last frame. + */ @Override protected void controlUpdate(float tpf) { if (state == null) return; @@ -30,11 +47,12 @@ protected void controlUpdate(float tpf) { } } - @Override - protected void controlRender(RenderManager rm, ViewPort vp) { - - } - + /** + * Updates the symbol when the state is SHIELD. The symbol zooms in and then zooms out. + * When the zooming out finishes, the symbol is removed from the parent spatial. + * + * @param tpf Time per frame, the time elapsed since the last frame. + */ private void shieldUpdate(float tpf) { if (zoomingIn) { progress += tpf * zoomSpeed; @@ -57,6 +75,12 @@ private void shieldUpdate(float tpf) { } } + /** + * Updates the symbol when the state is SWAP. The symbol rotates 360 degrees. + * After the rotation finishes, the symbol is removed from the parent spatial. + * + * @param tpf Time per frame, the time elapsed since the last frame. + */ private void swapUpdate(float tpf) { if (initialRotation == null) { initialRotation = spatial.getLocalRotation().clone(); @@ -80,6 +104,12 @@ private void swapUpdate(float tpf) { } } + /** + * Updates the symbol when the state is TURBO. The symbol moves along the Y-axis with a zoom effect. + * After the movement finishes, the symbol is removed from the parent spatial. + * + * @param tpf Time per frame, the time elapsed since the last frame. + */ private void turboUpdate(float tpf) { if (zoomingIn) { progress += tpf * zoomSpeed; @@ -103,6 +133,10 @@ private void turboUpdate(float tpf) { } } + /** + * Starts the SHIELD animation by zooming the symbol in and out. + * The symbol will first zoom in and then zoom out, and will be removed from the parent spatial once done. + */ public void shield() { if (state != null) throw new RuntimeException("another state is avtive"); state = BonusCard.SHIELD; @@ -112,6 +146,10 @@ public void shield() { spatial.setLocalScale(1f); } + /** + * Starts the SWAP animation by rotating the symbol 360 degrees. + * The symbol will rotate once and then be removed from the parent spatial. + */ public void swap() { if (state != null) throw new RuntimeException("another state is avtive"); spatial.setLocalScale(3); @@ -119,6 +157,10 @@ public void swap() { progress = -0.2f; } + /** + * Starts the TURBO animation by moving the symbol along the Y-axis. + * The symbol will move upwards and then return to its initial position. + */ public void turbo() { if (state != null) throw new RuntimeException("another state is avtive"); spatial.setLocalScale(2); @@ -128,19 +170,45 @@ public void turbo() { progress = 0; } + /** + * Performs linear interpolation between two values. + * + * @param start The starting value. + * @param end The target value. + * @param t The interpolation parameter (0 <= t <= 1). + * @return The interpolated value. + */ private static float lerp(float start, float end, float t) { return (1 - t) * start + t * end; } + /** + * Ease-out function for smoothing the interpolation. + * + * @param t The interpolation parameter (0 <= t <= 1). + * @return The eased value. + */ private static float easeOut(float t) { return (float) Math.sqrt(1 - Math.pow(t - 1, 2)); } + /** + * Ease-in-out function for smoothing the interpolation. + * + * @param t The interpolation parameter (0 <= t <= 1). + * @return The eased value. + */ private float easeInOut(float t) { if (t > 1) t = 1; return (float) -(Math.cos(Math.PI * t) - 1) / 2; } + /** + * Ease-in function for smoothing the interpolation. + * + * @param t The interpolation parameter (0 <= t <= 1). + * @return The eased value. + */ private float easeIn(float t) { return t * t * t * t; } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/ZoomControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/ZoomControl.java index 7b2a06e1..8cf83daf 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/ZoomControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/animation/ZoomControl.java @@ -5,6 +5,13 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.AbstractControl; +/** + * A control that applies a zoom effect to a spatial, smoothly scaling it in and out. + * The zoom effect can be customized with speed and scaling factor. + * + *

The control supports zooming in and out with ease-in and ease-out transitions. + * It starts by zooming in, and once complete, it zooms out, eventually removing the spatial from its parent when the animation ends.

+ */ public class ZoomControl extends InitControl { private boolean zoomingIn = false; private boolean zoomingOut = false; @@ -12,18 +19,35 @@ public class ZoomControl extends InitControl { private float zoomSpeed = 1f; private float zoomFactor = 1f; + /** + * Constructs a new ZoomControl with the default zoom speed. + */ public ZoomControl() { } + /** + * Constructs a new ZoomControl with a specified zoom speed. + * + * @param speed The speed at which the zoom effect occurs. + */ public ZoomControl(float speed) { zoomSpeed = speed; } + /** + * Initializes the spatial for the zoom effect. This method is called when the control is added to the spatial. + * It sets the zooming state to zooming in. + */ @Override protected void initSpatial() { zoomingIn = true; } + /** + * Updates the zoom effect over time, either zooming in or zooming out. + * + * @param tpf Time per frame, the time elapsed since the last frame. + */ @Override protected void controlUpdate(float tpf) { if (zoomingIn) { @@ -45,31 +69,43 @@ protected void controlUpdate(float tpf) { } } + /** + * Ends the zoom animation by removing the spatial from its parent and the control from the spatial. + */ private void end() { spatial.removeFromParent(); spatial.removeControl(this); } - @Override - protected void controlRender(RenderManager rm, ViewPort vp) { - - } - + /** + * Performs linear interpolation between two values. + * + * @param start The starting value. + * @param end The target value. + * @param t The interpolation parameter (0 <= t <= 1). + * @return The interpolated value. + */ private static float lerp(float start, float end, float t) { return (1 - t) * start + t * end; } - // private static float easeOut(float t) { -// return (float) Math.sqrt(1 - Math.pow(t - 1, 2)); -// } + /** + * Ease-out function for smoothing the zoom-in transition. + * + * @param x The interpolation parameter (0 <= x <= 1). + * @return The eased value. + */ private float easeOut(float x) { return x == 1 ? 1 : (float) (1 - Math.pow(2, -10 * x)); } - // private float easeIn(float t) { -// return t * t * t * t; -// } + /** + * Ease-in function for smoothing the zoom-out transition. + * + * @param x The interpolation parameter (0 <= x <= 1). + * @return The eased value. + */ private float easeIn(float x) { return x == 0 ? 0 : (float) Math.pow(2, 10 * x - 10); diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java index 225fdb1d..6f3f6237 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java @@ -597,9 +597,4 @@ private NodeControl getNextWaitingNode(Color color) { throw new IllegalStateException("Keine freien Nodes im Wartebereich für die Farbe " + color); } - - - - - } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineControl.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineControl.java index 7872dbe4..9444e841 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineControl.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/OutlineControl.java @@ -8,7 +8,7 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.AbstractControl; import pp.mdga.client.MdgaApp; -import pp.mdga.client.board.outline.SelectObjectOutliner; +import pp.mdga.client.outline.SelectObjectOutliner; public class OutlineControl extends AbstractControl { private static final int THICKNESS_DEFAULT = 6; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/OutlineFilter.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlineFilter.java similarity index 98% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/OutlineFilter.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlineFilter.java index d9fcaef9..109e2de7 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/OutlineFilter.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlineFilter.java @@ -1,4 +1,4 @@ -package pp.mdga.client.board.outline; +package pp.mdga.client.outline; import com.jme3.asset.AssetManager; import com.jme3.material.Material; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/OutlinePreFilter.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlinePreFilter.java similarity index 97% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/OutlinePreFilter.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlinePreFilter.java index 9a385045..cb2ae654 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/OutlinePreFilter.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlinePreFilter.java @@ -1,4 +1,4 @@ -package pp.mdga.client.board.outline; +package pp.mdga.client.outline; import com.jme3.asset.AssetManager; import com.jme3.material.Material; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/OutlineProFilter.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlineProFilter.java similarity index 98% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/OutlineProFilter.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlineProFilter.java index c40a9435..c49f6158 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/OutlineProFilter.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/outline/OutlineProFilter.java @@ -1,4 +1,4 @@ -package pp.mdga.client.board.outline; +package pp.mdga.client.outline; import com.jme3.asset.AssetManager; import com.jme3.material.Material; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/SelectObjectOutliner.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/outline/SelectObjectOutliner.java similarity index 98% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/SelectObjectOutliner.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/outline/SelectObjectOutliner.java index 3cfbc76c..aa5049a6 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/outline/SelectObjectOutliner.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/outline/SelectObjectOutliner.java @@ -1,4 +1,4 @@ -package pp.mdga.client.board.outline; +package pp.mdga.client.outline; import com.jme3.asset.AssetManager; import com.jme3.math.ColorRGBA;