Bayblade Mode activated

This commit is contained in:
Luca Puderbach 2024-12-09 19:53:47 +01:00
parent 7cbf000c44
commit 698937e77c
3 changed files with 51 additions and 11 deletions

View File

@ -106,6 +106,26 @@ public class MonopolyAppConfig extends MonopolyClientConfig {
@Property("overlay.top.color") //NON-NLS
private ColorRGBA topColor = ColorRGBA.White;
private ColorRGBA applyGammaCorrection(ColorRGBA color) {
return new ColorRGBA(
correctGamma(color.r),
correctGamma(color.g),
correctGamma(color.b),
color.a // Alpha bleibt unverändert
);
}
private float correctGamma(float channel) {
// Formel: ((RGB / 255)^2.2) * 255
float normalized = channel / 255.0f; // RGB normalisieren (0-1)
float gammaCorrected = (float) Math.pow(normalized, 2.2); // ^2.2
return gammaCorrected * 255.0f; // Zurückskalieren auf 0-255
}
private float correctGamma(float channel, float gamma) {
return (float) Math.pow(channel, gamma);
}
/**
* Creates a default {@code MonopolyAppConfig} with predefined values.
*/

View File

@ -3,6 +3,9 @@ package pp.monopoly.client.gui;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
@ -42,8 +45,10 @@ public class BobTheBuilder extends GameBoardSynchronizer {
// Setze die Position basierend auf der Feld-ID
node.setLocalTranslation(figure.getPos());
// Setze die Rotation basierend auf der Feld-ID
node.setLocalRotation(figure.getRot().toQuaternion());
// Setze die Anfangsrotation auf 90 Grad nach links
Quaternion initialRotation = new Quaternion().fromAngleAxis(FastMath.HALF_PI, Vector3f.UNIT_Y);
node.setLocalRotation(initialRotation);
node.addControl(new FigureControl(node, figure, app));
return node;
}

View File

@ -1,6 +1,7 @@
package pp.monopoly.client.gui;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
@ -50,14 +51,30 @@ public class FigureControl extends AbstractControl implements GameEventListener
return; // Warte, bis die Verzögerung abgeschlossen ist
}
delayTime = 0; // Verzögerung abgeschlossen
LOGGER.log(Level.DEBUG, "Delay completed. Starting animation...");
System.out.println("Delay completed. Starting animation...");
}
if (currentTarget == null && !path.isEmpty()) {
// Hole das nächste Ziel aus dem Pfad
currentTarget = path.poll();
animationTime = 0f;
LOGGER.log(Level.DEBUG, "Next target: {0}", currentTarget);
// Prüfe, ob eine Drehung erforderlich ist (Felder 0, 10, 20, 30)
int currentField = figure.getCurrentFieldID();
int nextField = nextField(currentField);
if ((nextField(currentField) == 10) ||
(nextField(currentField) == 20) ||
(nextField(currentField) == 30) ||
(nextField(currentField) == 0)) {
Quaternion rotation = spatial.getLocalRotation();
Quaternion turnRight = new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y);
spatial.setLocalRotation(rotation.mult(turnRight));
}
System.out.println("Next target: " + currentTarget);
}
if (currentTarget != null) {
@ -71,7 +88,7 @@ public class FigureControl extends AbstractControl implements GameEventListener
// Hüpfeffekt hinzufügen
float hopHeight = 0.5f * FastMath.sin(FastMath.PI * (animationTime / durationPerField));
interpolatedPosition.setY(hopHeight + 1);
interpolatedPosition.setY(hopHeight );
spatial.setLocalTranslation(interpolatedPosition);
// Ziel erreicht
@ -80,17 +97,15 @@ public class FigureControl extends AbstractControl implements GameEventListener
figure.moveTo(currentTarget); // Synchronisiere die interne Position
currentTarget = null; // Setze Ziel zurück
LOGGER.log(Level.DEBUG, "Target reached. Remaining path: {0}", path.size());
System.out.println("Target reached.");
}
}
}
// Beispiel: Berechnung des nächsten Feldes
private int nextField() {
int currentField = figure.getCurrentFieldID();
return (currentField + 1) % 40; // Weiter zum nächsten Feld
private int nextField(int currentField) {
return (currentField + 1) % 40;
}