Compare commits
7 Commits
dev/client
...
dev/client
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4430b37581 | ||
|
|
e14b8cb510 | ||
|
|
6d3c733f91 | ||
|
|
1a079dad44 | ||
|
|
32f49a6181 | ||
|
|
29c6b13300 | ||
|
|
2ac2de645b |
@@ -1,18 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
|
|
||||||
<module name="Projekte.mdga.client.main" />
|
|
||||||
<option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties -ea" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
|
|
||||||
<extension name="coverage">
|
|
||||||
<pattern>
|
|
||||||
<option name="PATTERN" value="pp.mdga.client.board.outline.*" />
|
|
||||||
<option name="ENABLED" value="true" />
|
|
||||||
</pattern>
|
|
||||||
</extension>
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
@@ -38,7 +38,12 @@ public enum Asset {
|
|||||||
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"),
|
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"),
|
||||||
shieldCard,
|
shieldCard,
|
||||||
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
|
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
|
||||||
dice
|
dice,
|
||||||
|
tankShoot("Models/tank/tankShoot_bot.j3o", "Models/tank/tank_diff.png"),
|
||||||
|
tankShootTop("Models/tank/tankShoot_top.j3o", "Models/tank/tank_diff.png"),
|
||||||
|
treesSmallBackground("Models/treeSmall/treesSmallBackground.j3o", "Models/treeSmall/treeSmall_diff.png", 1.2f),
|
||||||
|
treesBigBackground("Models/treeBig/treesBigBackground.j3o", "Models/treeBig/treeBig_diff.png", 1.2f),
|
||||||
|
shell
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String modelPath;
|
private final String modelPath;
|
||||||
|
|||||||
@@ -156,9 +156,18 @@ else if(boardSelect != null) {
|
|||||||
p = UUID.randomUUID();
|
p = UUID.randomUUID();
|
||||||
gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
|
gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
|
||||||
gameView.getBoardHandler().movePieceStartAnim(p,0);
|
gameView.getBoardHandler().movePieceStartAnim(p,0);
|
||||||
gameView.getBoardHandler().movePieceAnim(p,0, 8);
|
gameView.getGuiHandler().addCardOwn(BonusCard.SHIELD);
|
||||||
|
gameView.getGuiHandler().setSelectableCards(List.of(BonusCard.SHIELD));
|
||||||
|
|
||||||
|
// gameView.getBoardHandler().movePieceAnim(p,0, 8);
|
||||||
} else {
|
} else {
|
||||||
gameView.getBoardHandler().throwBombAnim(p);
|
// gameView.getBoardHandler().throwBombAnim(p);
|
||||||
|
gameView.getBoardHandler().throwPiece(p,Color.ARMY);
|
||||||
|
// gameView.getBoardHandler().movePieceAnim(p,0,20);
|
||||||
|
// gameView.getBoardHandler().throwPiece(p,Color.CYBER);
|
||||||
|
// gameView.getBoardHandler().throwPiece(p,Color.AIRFORCE);
|
||||||
|
|
||||||
|
|
||||||
//gameView.getBoardHandler().movePieceStartAnim(p,0);
|
//gameView.getBoardHandler().movePieceStartAnim(p,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public void simpleInitApp() {
|
|||||||
gameView = new GameView(this);
|
gameView = new GameView(this);
|
||||||
ceremonyView = new CeremonyView(this);
|
ceremonyView = new CeremonyView(this);
|
||||||
|
|
||||||
enter(MdgaState.GAME);
|
enter(MdgaState.MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,12 +85,13 @@ private void handleGame(Notification notification) {
|
|||||||
GuiHandler guiHandler = gameView.getGuiHandler();
|
GuiHandler guiHandler = gameView.getGuiHandler();
|
||||||
BoardHandler boardHandler = gameView.getBoardHandler();
|
BoardHandler boardHandler = gameView.getBoardHandler();
|
||||||
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
|
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
|
||||||
|
Color ownColor = gameView.getOwnColor();
|
||||||
|
|
||||||
if (notification instanceof AcquireCardNotification n) {
|
if (notification instanceof AcquireCardNotification n) {
|
||||||
guiHandler.addCardOwn(n.getBonusCard());
|
guiHandler.addCardOwn(n.getBonusCard());
|
||||||
} else if (notification instanceof ActivePlayerNotification n) {
|
} else if (notification instanceof ActivePlayerNotification n) {
|
||||||
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
||||||
boardHandler.showDice(n.getColor());
|
if(n.getColor() != ownColor) boardHandler.showDice(n.getColor());
|
||||||
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
|
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
|
||||||
app.enter(MdgaState.CEREMONY);
|
app.enter(MdgaState.CEREMONY);
|
||||||
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
||||||
@@ -138,11 +139,11 @@ private void handleGame(Notification notification) {
|
|||||||
}
|
}
|
||||||
guiHandler.hideText();
|
guiHandler.hideText();
|
||||||
} else if (notification instanceof ThrowPieceNotification n) {
|
} else if (notification instanceof ThrowPieceNotification n) {
|
||||||
boardHandler.throwBombAnim(n.getPieceId());
|
boardHandler.throwPiece(n.getPieceId(), n.getThrowColor());
|
||||||
} else if (notification instanceof NoShieldNotification n) {
|
} else if (notification instanceof NoShieldNotification n) {
|
||||||
boardHandler.unshieldPiece(n.getPieceId());
|
boardHandler.unshieldPiece(n.getPieceId());
|
||||||
} else if (notification instanceof PlayCardNotification n) {
|
} else if (notification instanceof PlayCardNotification n) {
|
||||||
if(n.getColor() == gameView.getOwnColor()) guiHandler.playCardOwn(n.getCard());
|
if(n.getColor() == ownColor) guiHandler.playCardOwn(n.getCard());
|
||||||
else guiHandler.playCardEnemy(n.getColor(), n.getCard());
|
else guiHandler.playCardEnemy(n.getColor(), n.getCard());
|
||||||
} else if (notification instanceof PlayerInGameNotification n) {
|
} else if (notification instanceof PlayerInGameNotification n) {
|
||||||
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
||||||
@@ -151,7 +152,7 @@ private void handleGame(Notification notification) {
|
|||||||
gameView.leaveInterrupt();
|
gameView.leaveInterrupt();
|
||||||
} else if (notification instanceof RollDiceNotification n) {
|
} else if (notification instanceof RollDiceNotification n) {
|
||||||
gameView.getGuiHandler().hideText();
|
gameView.getGuiHandler().hideText();
|
||||||
if(n.getColor() == gameView.getOwnColor()){
|
if(n.getColor() == ownColor){
|
||||||
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
|
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
47
Projekte/mdga/client/src/main/java/pp/mdga/client/Util.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package pp.mdga.client;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
|
||||||
|
public class Util {
|
||||||
|
private Util(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs linear interpolation between two values.
|
||||||
|
*
|
||||||
|
* @param start The starting value.
|
||||||
|
* @param end The ending value.
|
||||||
|
* @param t A parameter between 0 and 1 representing the interpolation progress.
|
||||||
|
* @return The interpolated value.
|
||||||
|
*/
|
||||||
|
public static float linInt(float start, float end, float t) {
|
||||||
|
return start + t * (end - start);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
public static 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;
|
||||||
|
return p1.mult(oneMinusT * oneMinusT)
|
||||||
|
.add(p2.mult(2 * oneMinusT * t))
|
||||||
|
.add(p3.mult(t * t));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
public static float easeInOut(float x){
|
||||||
|
return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,6 +123,15 @@ public void playSound(MdgaSound sound) {
|
|||||||
case BONUS:
|
case BONUS:
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.BONUS, 1.0f, 0.0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.BONUS, 1.0f, 0.0f));
|
||||||
break;
|
break;
|
||||||
|
case TURRET_ROTATE:
|
||||||
|
assets.add(new SoundAssetDelayVolume(SoundAsset.TURRET_ROTATE, 0.7f, 0f));
|
||||||
|
break;
|
||||||
|
case TANK_SHOOT:
|
||||||
|
assets.add(new SoundAssetDelayVolume(SoundAsset.TANK_SHOOT, 0.7f, 0f));
|
||||||
|
break;
|
||||||
|
case TANK_EXPLOSION:
|
||||||
|
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,4 +35,7 @@ public enum MdgaSound {
|
|||||||
EXPLOSION,
|
EXPLOSION,
|
||||||
LOSE,
|
LOSE,
|
||||||
BONUS,
|
BONUS,
|
||||||
|
TURRET_ROTATE,
|
||||||
|
TANK_SHOOT,
|
||||||
|
TANK_EXPLOSION
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,11 @@ enum SoundAsset {
|
|||||||
UI90("ui90.ogg"),
|
UI90("ui90.ogg"),
|
||||||
BONUS("bonus.ogg"),
|
BONUS("bonus.ogg"),
|
||||||
LOSE("lose.ogg"),
|
LOSE("lose.ogg"),
|
||||||
CONNECTED("connected.wav");
|
CONNECTED("connected.wav"),
|
||||||
|
TURRET_ROTATE("turret_rotate.ogg"),
|
||||||
|
TANK_SHOOT("tank_shoot.ogg")
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
private final String path;
|
private final String path;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
|
||||||
|
public class ActionControl extends InitControl {
|
||||||
|
private final Runnable runnable;
|
||||||
|
|
||||||
|
public ActionControl(Runnable runnable){
|
||||||
|
this.runnable = runnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected void action(){
|
||||||
|
if(runnable == null) throw new RuntimeException("runnable is null");
|
||||||
|
else runnable.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
|
import com.jme3.scene.Geometry;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
|
||||||
|
import static pp.mdga.client.Util.linInt;
|
||||||
|
|
||||||
|
public class FadeControl extends ActionControl {
|
||||||
|
private float duration; // Duration of the fade effect
|
||||||
|
private float timeElapsed = 0;
|
||||||
|
private boolean init = false;
|
||||||
|
private float startAlpha;
|
||||||
|
private float endAlpha;
|
||||||
|
|
||||||
|
public FadeControl(float duration, float startAlpha, float endAlpha, Runnable actionAfter) {
|
||||||
|
super(actionAfter);
|
||||||
|
this.duration = duration;
|
||||||
|
this.startAlpha = startAlpha;
|
||||||
|
this.endAlpha = endAlpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FadeControl(float duration, float startAlpha, float endAlpha) {
|
||||||
|
this(duration, startAlpha, endAlpha, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initSpatial() {
|
||||||
|
init = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float tpf) {
|
||||||
|
if (!init) return;
|
||||||
|
|
||||||
|
timeElapsed += tpf;
|
||||||
|
float t = timeElapsed / duration; // Calculate progress (0 to 1)
|
||||||
|
|
||||||
|
if (t >= 1) {
|
||||||
|
// Fade complete
|
||||||
|
t = 1;
|
||||||
|
init = false;
|
||||||
|
spatial.removeControl(this);
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
|
||||||
|
float alpha = linInt(startAlpha, endAlpha, t); // Interpolate alpha
|
||||||
|
|
||||||
|
// Update the material's alpha
|
||||||
|
if (spatial instanceof Geometry geometry) {
|
||||||
|
Material mat = geometry.getMaterial();
|
||||||
|
if (mat != null) {
|
||||||
|
ColorRGBA diffuse = (ColorRGBA) mat.getParam("Diffuse").getValue();
|
||||||
|
mat.setColor("Diffuse", new ColorRGBA(diffuse.r, diffuse.g, diffuse.b, alpha));
|
||||||
|
|
||||||
|
ColorRGBA ambient = (ColorRGBA) mat.getParam("Ambient").getValue();
|
||||||
|
mat.setColor("Ambient", new ColorRGBA(ambient.r, ambient.g, ambient.b, alpha));
|
||||||
|
|
||||||
|
// Disable shadows when the object is nearly invisible
|
||||||
|
if (alpha <= 0.1f) {
|
||||||
|
geometry.setShadowMode(RenderQueue.ShadowMode.Off);
|
||||||
|
} else {
|
||||||
|
geometry.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
|
}
|
||||||
|
} else throw new RuntimeException("Material is null");
|
||||||
|
} else throw new RuntimeException("Spatial is not instance of Geometry");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,7 @@ public class JetAnimation {
|
|||||||
private final float animationDuration; // Dauer der Animation
|
private final float animationDuration; // Dauer der Animation
|
||||||
private Explosion explosion;
|
private Explosion explosion;
|
||||||
private final UUID id;
|
private final UUID id;
|
||||||
|
private Runnable actionAfter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Konstruktor für die ThrowAnimation-Klasse.
|
* Konstruktor für die ThrowAnimation-Klasse.
|
||||||
@@ -40,7 +41,7 @@ public class JetAnimation {
|
|||||||
* @param curveHeight Die maximale Höhe der Flugkurve
|
* @param curveHeight Die maximale Höhe der Flugkurve
|
||||||
* @param animationDuration Die Gesamtdauer der Animation in Sekunden
|
* @param animationDuration Die Gesamtdauer der Animation in Sekunden
|
||||||
*/
|
*/
|
||||||
public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint, float curveHeight, float animationDuration) {
|
public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint, float curveHeight, float animationDuration, Runnable actionAfter) {
|
||||||
Vector3f spawnPoint = targetPoint.add(170, 50, 50);
|
Vector3f spawnPoint = targetPoint.add(170, 50, 50);
|
||||||
|
|
||||||
Vector3f controlPoint = targetPoint.add(new Vector3f(0, 0, -45));
|
Vector3f controlPoint = targetPoint.add(new Vector3f(0, 0, -45));
|
||||||
@@ -58,6 +59,7 @@ public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint,
|
|||||||
id = uuid;
|
id = uuid;
|
||||||
|
|
||||||
explosion = new Explosion(app, rootNode, nodePoint);
|
explosion = new Explosion(app, rootNode, nodePoint);
|
||||||
|
this.actionAfter = actionAfter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,10 +122,7 @@ protected void controlUpdate(float tpf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (elapsedTime > 6.0f) {
|
if (elapsedTime > 6.0f) {
|
||||||
GameView gameView = (GameView) app.getView();
|
endAnim();
|
||||||
BoardHandler boardHandler = gameView.getBoardHandler();
|
|
||||||
|
|
||||||
boardHandler.throwPieceAnim(id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +133,10 @@ protected void controlRender(RenderManager rm, ViewPort vp) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void endAnim(){
|
||||||
|
actionAfter.run();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repräsentiert eine 3D-Bezier-Kurve mit vier Kontrollpunkten.
|
* Repräsentiert eine 3D-Bezier-Kurve mit vier Kontrollpunkten.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,200 @@
|
|||||||
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
|
import com.jme3.effect.ParticleEmitter;
|
||||||
|
import com.jme3.effect.ParticleMesh.Type;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.material.RenderState;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class MatrixAnimation extends ActionControl {
|
||||||
|
private MdgaApp app;
|
||||||
|
private static final Random RANDOM = new Random();
|
||||||
|
private Vector3f radarPos;
|
||||||
|
private Runnable runnable;
|
||||||
|
private boolean init = false;
|
||||||
|
private List<ParticleEmitter> activeEmitter = new ArrayList<>();
|
||||||
|
private ParticleEmitter radarEmitter = null;
|
||||||
|
private float timeElapsed = 0f;
|
||||||
|
|
||||||
|
private enum MatrixState{
|
||||||
|
RADAR_ON,
|
||||||
|
RADAR_OFF,
|
||||||
|
MATRIX_ON,
|
||||||
|
MATRIX_OFF
|
||||||
|
}
|
||||||
|
|
||||||
|
private MatrixState state;
|
||||||
|
public MatrixAnimation(MdgaApp app, Vector3f radarPos, Runnable runnable){
|
||||||
|
super(runnable);
|
||||||
|
this.app = app;
|
||||||
|
this.radarPos = radarPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initSpatial() {
|
||||||
|
state = MatrixState.RADAR_ON;
|
||||||
|
timeElapsed = 0;
|
||||||
|
init = true;
|
||||||
|
radar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float tpf) {
|
||||||
|
if(!init) return;
|
||||||
|
|
||||||
|
timeElapsed += tpf;
|
||||||
|
|
||||||
|
switch(state){
|
||||||
|
case RADAR_ON -> {
|
||||||
|
if(timeElapsed >= 2f){
|
||||||
|
state = MatrixState.RADAR_OFF;
|
||||||
|
timeElapsed = 0;
|
||||||
|
radarEmitter.setParticlesPerSec(0);
|
||||||
|
new Timer().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
app.getRootNode().detachChild(radarEmitter);
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case RADAR_OFF -> {
|
||||||
|
if(timeElapsed >= 0.1f){
|
||||||
|
state = MatrixState.MATRIX_ON;
|
||||||
|
timeElapsed = 0;
|
||||||
|
matrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
case MATRIX_ON -> {
|
||||||
|
if(timeElapsed >= 3f){
|
||||||
|
state = MatrixState.MATRIX_OFF;
|
||||||
|
timeElapsed = 0;
|
||||||
|
turnOff();
|
||||||
|
new Timer().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (ParticleEmitter particleEmitter : activeEmitter){
|
||||||
|
app.getRootNode().detachChild(particleEmitter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case MATRIX_OFF -> {
|
||||||
|
if(timeElapsed >= 0.5f){
|
||||||
|
init = false;
|
||||||
|
spatial.removeControl(this);
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void turnOff(){
|
||||||
|
for (ParticleEmitter particleEmitter : activeEmitter){
|
||||||
|
particleEmitter.setParticlesPerSec(0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void radar(){
|
||||||
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||||
|
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/radar_beam.png"));
|
||||||
|
ParticleEmitter emitter = new ParticleEmitter("Effect", Type.Triangle, 50);
|
||||||
|
emitter.setMaterial(mat);
|
||||||
|
emitter.setImagesX(1); // columns
|
||||||
|
emitter.setImagesY(1); // rows
|
||||||
|
emitter.setSelectRandomImage(true);
|
||||||
|
emitter.setStartColor(ColorRGBA.White);
|
||||||
|
emitter.setEndColor(ColorRGBA.Black);
|
||||||
|
emitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0f, 0f, 2));
|
||||||
|
emitter.getParticleInfluencer().setVelocityVariation(0f);
|
||||||
|
emitter.setStartSize(0.1f);
|
||||||
|
emitter.setEndSize(10);
|
||||||
|
emitter.setGravity(0, 0, 0);
|
||||||
|
float life = 2.6f;
|
||||||
|
emitter.setLowLife(life);
|
||||||
|
emitter.setHighLife(life);
|
||||||
|
emitter.setLocalTranslation(radarPos.add(new Vector3f(0,0,5)));
|
||||||
|
emitter.setParticlesPerSec(1.8f);
|
||||||
|
app.getRootNode().attachChild(emitter);
|
||||||
|
radarEmitter = emitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void matrix(){
|
||||||
|
for(int i = 0; i < 5; i++){
|
||||||
|
particleStream(
|
||||||
|
generateMatrixColor(),
|
||||||
|
generateMatrixColor(),
|
||||||
|
getRandomFloat(0,1f),
|
||||||
|
getRandomPosition(),
|
||||||
|
getRandomFloat(1,2)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void particleStream(ColorRGBA start, ColorRGBA end, float speedVar, Vector3f pos, float spawnVar){
|
||||||
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||||
|
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||||
|
mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/particle_cir.png"));
|
||||||
|
ParticleEmitter matrix = new ParticleEmitter("Effect", Type.Triangle, 50);
|
||||||
|
matrix.setMaterial(mat);
|
||||||
|
matrix.setImagesX(2); // columns
|
||||||
|
matrix.setImagesY(1); // rows
|
||||||
|
matrix.setSelectRandomImage(true);
|
||||||
|
matrix.setStartColor(start);
|
||||||
|
matrix.setEndColor(end);
|
||||||
|
matrix.getParticleInfluencer().setInitialVelocity(new Vector3f(0f, 0f, -6f - speedVar));
|
||||||
|
matrix.getParticleInfluencer().setVelocityVariation(0f);
|
||||||
|
matrix.setStartSize(0.4f);
|
||||||
|
matrix.setEndSize(0.6f);
|
||||||
|
matrix.setGravity(0, 0, 2f);
|
||||||
|
matrix.setLowLife(3f);
|
||||||
|
matrix.setHighLife(3f);
|
||||||
|
matrix.setLocalTranslation(spatial.getLocalTranslation().add(pos).add(new Vector3f(0,0,15)));
|
||||||
|
matrix.setParticlesPerSec(spawnVar);
|
||||||
|
app.getRootNode().attachChild(matrix);
|
||||||
|
activeEmitter.add(matrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3f getRandomPosition() {
|
||||||
|
// Generate a random angle in radians (0 to 2π)
|
||||||
|
float angle = (float) (2 * Math.PI * RANDOM.nextDouble());
|
||||||
|
|
||||||
|
// Generate a random radius with uniform distribution
|
||||||
|
float radius = (float) Math.sqrt(RANDOM.nextDouble());
|
||||||
|
radius *= 1f;
|
||||||
|
|
||||||
|
// Convert polar coordinates to Cartesian
|
||||||
|
float x = radius * (float) Math.cos(angle);
|
||||||
|
float y = radius * (float) Math.sin(angle);
|
||||||
|
|
||||||
|
return new Vector3f(x,y,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getRandomFloat(float start, float end) {
|
||||||
|
if (start > end) {
|
||||||
|
throw new IllegalArgumentException("Start must be less than or equal to end.");
|
||||||
|
}
|
||||||
|
return start + RANDOM.nextFloat() * (end - start);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ColorRGBA generateMatrixColor() {
|
||||||
|
// Red is dominant
|
||||||
|
float red = 0.8f + RANDOM.nextFloat() * 0.2f; // Red channel: 0.8 to 1.0
|
||||||
|
// Green is moderately high
|
||||||
|
float green = 0.4f + RANDOM.nextFloat() * 0.3f; // Green channel: 0.4 to 0.7
|
||||||
|
// Blue is minimal
|
||||||
|
float blue = RANDOM.nextFloat() * 0.2f; // Blue channel: 0.0 to 0.2
|
||||||
|
float alpha = 1.0f; // Fully opaque
|
||||||
|
|
||||||
|
return new ColorRGBA(red, green, blue, alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package pp.mdga.client.animation;
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import pp.mdga.client.InitControl;
|
|
||||||
|
import static pp.mdga.client.Util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A control that smoothly moves a spatial from an initial position to an end position
|
* A control that smoothly moves a spatial from an initial position to an end position
|
||||||
@@ -12,16 +13,16 @@
|
|||||||
* an ease-in-out curve to create a smooth start and stop effect.
|
* an ease-in-out curve to create a smooth start and stop effect.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class MoveControl extends InitControl {
|
public class MoveControl extends ActionControl {
|
||||||
|
|
||||||
private boolean moving;
|
private boolean moving;
|
||||||
private final Vector3f initPos;
|
private final Vector3f initPos;
|
||||||
private final Vector3f endPos;
|
private final Vector3f endPos;
|
||||||
private final Vector3f middlePos;
|
private final Vector3f middlePos;
|
||||||
private final static float HEIGHT = 2;
|
private final float height;
|
||||||
private final static float MOVE_SPEED = 1f;
|
private final float duration;
|
||||||
private float progress = 0;
|
private float timer = 0;
|
||||||
private final Runnable actionAfter;
|
private boolean easing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new MoveControl with specified initial and end positions, and an action to run after the movement.
|
* Creates a new MoveControl with specified initial and end positions, and an action to run after the movement.
|
||||||
@@ -32,15 +33,22 @@ public class MoveControl extends InitControl {
|
|||||||
* @param actionAfter A Runnable that will be executed after the movement finishes.
|
* @param actionAfter A Runnable that will be executed after the movement finishes.
|
||||||
*/
|
*/
|
||||||
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){
|
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){
|
||||||
|
this(initPos, endPos, actionAfter, 2, 1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter, float height, float duration, boolean easing){
|
||||||
|
super(actionAfter);
|
||||||
moving = false;
|
moving = false;
|
||||||
this.initPos = initPos;
|
this.initPos = initPos;
|
||||||
this.endPos = endPos;
|
this.endPos = endPos;
|
||||||
|
this.height = height;
|
||||||
|
this.duration = duration;
|
||||||
|
this.easing = easing;
|
||||||
middlePos = new Vector3f(
|
middlePos = new Vector3f(
|
||||||
(initPos.x + endPos.x) / 2,
|
(initPos.x + endPos.x) / 2,
|
||||||
(initPos.y + endPos.y) / 2,
|
(initPos.y + endPos.y) / 2,
|
||||||
HEIGHT
|
height
|
||||||
);
|
);
|
||||||
this.actionAfter = actionAfter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,7 +58,7 @@ public MoveControl(Vector3f initPos, Vector3f endPos, Runnable actionAfter){
|
|||||||
@Override
|
@Override
|
||||||
protected void initSpatial() {
|
protected void initSpatial() {
|
||||||
moving = true;
|
moving = true;
|
||||||
progress = 0;
|
timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,10 +71,16 @@ protected void initSpatial() {
|
|||||||
@Override
|
@Override
|
||||||
protected void controlUpdate(float tpf) {
|
protected void controlUpdate(float tpf) {
|
||||||
if(!moving) return;
|
if(!moving) return;
|
||||||
progress += tpf * MOVE_SPEED;
|
timer += tpf;
|
||||||
if(progress > 1) progress = 1;
|
|
||||||
spatial.setLocalTranslation(quadInt(initPos,middlePos,endPos, easeInOut(progress)));
|
float t = timer / duration;
|
||||||
if(progress == 1) end();
|
if (t >= 1) t = 1;
|
||||||
|
|
||||||
|
float interpolated = easing ? easeInOut(t) : t;
|
||||||
|
|
||||||
|
spatial.setLocalTranslation(quadInt(initPos,middlePos,endPos, interpolated));
|
||||||
|
|
||||||
|
if(t >= 1) end();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,35 +89,11 @@ protected void controlUpdate(float tpf) {
|
|||||||
*/
|
*/
|
||||||
private void end(){
|
private void end(){
|
||||||
moving = false;
|
moving = false;
|
||||||
actionAfter.run();
|
|
||||||
spatial.removeControl(this);
|
spatial.removeControl(this);
|
||||||
|
action();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
return p1.mult(oneMinusT * oneMinusT)
|
|
||||||
.add(p2.mult(2 * oneMinusT * t))
|
|
||||||
.add(p3.mult(t * t));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
|
import com.jme3.effect.ParticleEmitter;
|
||||||
|
import com.jme3.effect.ParticleMesh;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.material.RenderState;
|
||||||
|
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;
|
||||||
|
import com.jme3.scene.Geometry;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
|
import com.jme3.scene.shape.Box;
|
||||||
|
import pp.mdga.client.Asset;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
|
import pp.mdga.client.board.TankTopControl;
|
||||||
|
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import static com.jme3.material.Materials.LIGHTING;
|
||||||
|
import static com.jme3.material.Materials.UNSHADED;
|
||||||
|
|
||||||
|
public class ShellAnimation extends ActionControl {
|
||||||
|
private static final float FLYING_DURATION = 1.25f;
|
||||||
|
private static final float FLYING_HEIGHT = 12f;
|
||||||
|
private TankTopControl tankTopControl;
|
||||||
|
private MdgaApp app;
|
||||||
|
|
||||||
|
public ShellAnimation(TankTopControl tankTopControl, MdgaApp app, Runnable actionAfter){
|
||||||
|
super(actionAfter);
|
||||||
|
this.tankTopControl = tankTopControl;
|
||||||
|
this.app = app;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initSpatial() {
|
||||||
|
tankTopControl.rotate(spatial.getLocalTranslation(), this::shoot);
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.TURRET_ROTATE);
|
||||||
|
app.getRootNode().attachChild(createShell());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector3f getShootPos(){
|
||||||
|
Vector3f localOffset = new Vector3f(0, -5.4f, 2.9f);
|
||||||
|
Quaternion turretRotation = tankTopControl.getSpatial().getLocalRotation();
|
||||||
|
Vector3f transformedOffset = turretRotation.mult(localOffset);
|
||||||
|
return tankTopControl.getSpatial().getLocalTranslation().add(transformedOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shoot(){
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.TANK_SHOOT);
|
||||||
|
Vector3f shootPos = getShootPos();
|
||||||
|
createEffect(
|
||||||
|
shootPos,
|
||||||
|
"Images/particle/flame.png",
|
||||||
|
2, 2,
|
||||||
|
1, 3,
|
||||||
|
1f,
|
||||||
|
0.3f, 0.7f,
|
||||||
|
new ColorRGBA(1f, 0.8f, 0.4f, 0.5f),
|
||||||
|
new ColorRGBA(1f, 0f, 0f, 0f)
|
||||||
|
);
|
||||||
|
createEffect(
|
||||||
|
shootPos,
|
||||||
|
"Images/particle/vapor_cloud.png",
|
||||||
|
3, 3,
|
||||||
|
0.3f, 0.8f,
|
||||||
|
10,
|
||||||
|
0.1f, 0.35f,
|
||||||
|
new ColorRGBA(0.5f,0.5f,0.5f,0.5f),
|
||||||
|
ColorRGBA.Black
|
||||||
|
);
|
||||||
|
|
||||||
|
Spatial shell = createShell();
|
||||||
|
app.getRootNode().attachChild(shell);
|
||||||
|
shell.addControl(new ShellControl(this::hitExplosion, shootPos, spatial.getLocalTranslation(), FLYING_HEIGHT, FLYING_DURATION, app.getAssetManager()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Spatial createShell(){
|
||||||
|
Spatial model = app.getAssetManager().loadModel(Asset.shell.getModelPath());
|
||||||
|
model.scale(.16f);
|
||||||
|
model.setLocalTranslation(tankTopControl.getSpatial().getLocalTranslation());
|
||||||
|
|
||||||
|
Vector3f shootPos = tankTopControl.getSpatial().getLocalTranslation();
|
||||||
|
Vector3f targetPos = spatial.getLocalTranslation();
|
||||||
|
Vector3f direction = targetPos.subtract(shootPos).normalize();
|
||||||
|
|
||||||
|
Quaternion rotation = new Quaternion();
|
||||||
|
rotation.lookAt(direction, new Vector3f(1,0,0)); // Assuming UNIT_Y is the up vector
|
||||||
|
|
||||||
|
model.setLocalRotation(rotation);
|
||||||
|
model.rotate(FastMath.HALF_PI,0,0);
|
||||||
|
|
||||||
|
Material mat = new Material(app.getAssetManager(), LIGHTING);
|
||||||
|
mat.setBoolean("UseMaterialColors", true);
|
||||||
|
ColorRGBA color = ColorRGBA.fromRGBA255(143,117,0,255);
|
||||||
|
mat.setColor("Diffuse", color);
|
||||||
|
mat.setColor("Ambient", color);
|
||||||
|
model.setMaterial(mat);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hitExplosion(){
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.TANK_EXPLOSION);
|
||||||
|
createEffect(
|
||||||
|
spatial.getLocalTranslation().setZ(1),
|
||||||
|
"Images/particle/flame.png",
|
||||||
|
2, 2,
|
||||||
|
1, 5,
|
||||||
|
2f,
|
||||||
|
0.3f, 0.7f,
|
||||||
|
new ColorRGBA(1f, 0.8f, 0.4f, 0.5f),
|
||||||
|
new ColorRGBA(1f, 0f, 0f, 0f)
|
||||||
|
);
|
||||||
|
new Timer().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
}, 800);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createEffect(Vector3f shootPos,
|
||||||
|
String image,
|
||||||
|
int x, int y,
|
||||||
|
float startSize, float endSize,
|
||||||
|
float velocity,
|
||||||
|
float lowLife, float highLife,
|
||||||
|
ColorRGBA start, ColorRGBA end){
|
||||||
|
// Create a particle emitter for the explosion
|
||||||
|
ParticleEmitter explosionEmitter = new ParticleEmitter("Explosion", ParticleMesh.Type.Triangle, 100);
|
||||||
|
Material explosionMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||||
|
explosionMat.setTexture("Texture", app.getAssetManager().loadTexture(image));
|
||||||
|
explosionEmitter.setMaterial(explosionMat);
|
||||||
|
|
||||||
|
// Particle properties
|
||||||
|
explosionEmitter.setImagesX(x); // Columns in the texture
|
||||||
|
explosionEmitter.setImagesY(y); // Rows in the texture
|
||||||
|
explosionEmitter.setSelectRandomImage(true); // Randomize images for variety
|
||||||
|
|
||||||
|
explosionEmitter.setStartColor(start); // Bright yellowish orange
|
||||||
|
explosionEmitter.setEndColor(end); // Fade to transparent red
|
||||||
|
|
||||||
|
explosionEmitter.setStartSize(startSize); // Initial size
|
||||||
|
explosionEmitter.setEndSize(endSize); // Final size
|
||||||
|
explosionEmitter.setLowLife(lowLife); // Minimum lifetime of particles
|
||||||
|
explosionEmitter.setHighLife(highLife); // Maximum lifetime of particles
|
||||||
|
explosionEmitter.setGravity(0, 0, 1); // Gravity to pull particles down
|
||||||
|
explosionEmitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, velocity));
|
||||||
|
explosionEmitter.getParticleInfluencer().setVelocityVariation(1f); // Adds randomness to the initial velocity
|
||||||
|
explosionEmitter.setFacingVelocity(true); // Particles face their velocity direction
|
||||||
|
explosionEmitter.setLocalTranslation(shootPos);
|
||||||
|
explosionEmitter.setParticlesPerSec(0);
|
||||||
|
explosionEmitter.emitAllParticles();
|
||||||
|
app.getRootNode().attachChild(explosionEmitter);
|
||||||
|
new Timer().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
app.getRootNode().detachChild(explosionEmitter);
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package pp.mdga.client.animation;
|
||||||
|
|
||||||
|
import com.jme3.asset.AssetManager;
|
||||||
|
import com.jme3.effect.ParticleEmitter;
|
||||||
|
import com.jme3.effect.ParticleMesh;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.FastMath;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
|
||||||
|
public class ShellControl extends ActionControl {
|
||||||
|
private final Vector3f shootPos;
|
||||||
|
private final Vector3f endPos;
|
||||||
|
private final float height;
|
||||||
|
private final float duration;
|
||||||
|
private Vector3f oldPos;
|
||||||
|
private ParticleEmitter emitter;
|
||||||
|
private AssetManager assetManager;
|
||||||
|
|
||||||
|
public ShellControl(Runnable runnable, Vector3f shootPos, Vector3f endPos, float height, float duration, AssetManager assetManager){
|
||||||
|
super(runnable);
|
||||||
|
this.shootPos = shootPos;
|
||||||
|
this.endPos = endPos;
|
||||||
|
this.height = height;
|
||||||
|
this.duration = duration;
|
||||||
|
this.assetManager = assetManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initSpatial() {
|
||||||
|
spatial.addControl(new MoveControl(
|
||||||
|
shootPos,
|
||||||
|
endPos,
|
||||||
|
()->{
|
||||||
|
emitter.killAllParticles();
|
||||||
|
emitter.setParticlesPerSec(0);
|
||||||
|
emitter.removeFromParent();
|
||||||
|
spatial.removeControl(this);
|
||||||
|
spatial.removeFromParent();
|
||||||
|
action();
|
||||||
|
},
|
||||||
|
height,
|
||||||
|
duration,
|
||||||
|
false
|
||||||
|
));
|
||||||
|
oldPos = spatial.getLocalTranslation().clone();
|
||||||
|
createEmitter();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createEmitter() {
|
||||||
|
emitter = new ParticleEmitter("ShellTrail", ParticleMesh.Type.Triangle, 200);
|
||||||
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
|
||||||
|
mat.setTexture("Texture", assetManager.loadTexture("Images/particle/line.png")); // Nutze eine schmale, linienartige Textur
|
||||||
|
emitter.setMaterial(mat);
|
||||||
|
|
||||||
|
// Comic-Style Farben
|
||||||
|
emitter.setStartColor(new ColorRGBA(1f, 1f, 1f, 1f)); // Reinweiß
|
||||||
|
emitter.setEndColor(new ColorRGBA(1f, 1f, 1f, 0f)); // Transparent
|
||||||
|
|
||||||
|
// Partikelgröße und Lebensdauer
|
||||||
|
emitter.setStartSize(0.15f); // Startgröße
|
||||||
|
emitter.setEndSize(0.1f); // Endgröße
|
||||||
|
emitter.setLowLife(0.14f); // Sehr kurze Lebensdauer
|
||||||
|
emitter.setHighLife(0.14f);
|
||||||
|
|
||||||
|
emitter.setGravity(0, 0, 0); // Keine Gravitation
|
||||||
|
emitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
|
||||||
|
emitter.getParticleInfluencer().setVelocityVariation(0f); // Kein Variationsspielraum
|
||||||
|
|
||||||
|
// Hohe Dichte für eine glatte Spur
|
||||||
|
emitter.setParticlesPerSec(500);
|
||||||
|
|
||||||
|
// Zur Shell hinzufügen
|
||||||
|
spatial.getParent().attachChild(emitter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float tpf) {
|
||||||
|
Vector3f direction = spatial.getLocalTranslation().subtract(oldPos).normalize();
|
||||||
|
if (direction.lengthSquared() > 0) {
|
||||||
|
spatial.getLocalRotation().lookAt(direction, Vector3f.UNIT_X);
|
||||||
|
spatial.rotate(FastMath.HALF_PI,0,0);
|
||||||
|
}
|
||||||
|
oldPos = spatial.getLocalTranslation().clone();
|
||||||
|
|
||||||
|
emitter.setLocalTranslation(spatial.getLocalTranslation().clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
package pp.mdga.client.board;
|
package pp.mdga.client.board;
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.material.RenderState;
|
||||||
|
import com.jme3.material.RenderState.BlendMode;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import com.jme3.renderer.queue.RenderQueue;
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
@@ -10,8 +13,7 @@
|
|||||||
import pp.mdga.client.Asset;
|
import pp.mdga.client.Asset;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
import pp.mdga.client.animation.MoveControl;
|
import pp.mdga.client.animation.*;
|
||||||
import pp.mdga.client.animation.JetAnimation;
|
|
||||||
import pp.mdga.client.gui.DiceControl;
|
import pp.mdga.client.gui.DiceControl;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
@@ -55,6 +57,10 @@ public class BoardHandler {
|
|||||||
private PieceControl selectedOwnPiece;
|
private PieceControl selectedOwnPiece;
|
||||||
private PieceControl selectedEnemyPiece;
|
private PieceControl selectedEnemyPiece;
|
||||||
private DiceControl diceControl;
|
private DiceControl diceControl;
|
||||||
|
//Radar Position for Matrix animation
|
||||||
|
private Vector3f radarPos;
|
||||||
|
//TankTop for shellAnimation
|
||||||
|
private TankTopControl tankTop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new BoardHandler.
|
* Creates a new BoardHandler.
|
||||||
@@ -147,12 +153,24 @@ private void initMap() {
|
|||||||
case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap);
|
case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap);
|
||||||
case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap);
|
case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap);
|
||||||
case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap);
|
case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap);
|
||||||
|
case radar -> addRadar(assetOnMap);
|
||||||
|
case tankShoot -> addTankShoot(assetOnMap);
|
||||||
|
|
||||||
default -> displayAsset(assetOnMap);
|
default -> displayAsset(assetOnMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addTankShoot(AssetOnMap assetOnMap) {
|
||||||
|
displayAsset(assetOnMap);
|
||||||
|
tankTop = displayAndControl(new AssetOnMap(Asset.tankShootTop, assetOnMap.x(), assetOnMap.y(), assetOnMap.rot()), new TankTopControl());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRadar(AssetOnMap assetOnMap) {
|
||||||
|
radarPos = gridToWorld(assetOnMap.x(), assetOnMap.y());
|
||||||
|
displayAsset(assetOnMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an asset to its corresponding color.
|
* Converts an asset to its corresponding color.
|
||||||
*
|
*
|
||||||
@@ -186,11 +204,16 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
|
|||||||
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot));
|
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot));
|
||||||
model.setLocalTranslation(pos);
|
model.setLocalTranslation(pos);
|
||||||
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||||
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
||||||
|
mat.setBoolean("UseMaterialColors", true); // Required for Material Colors
|
||||||
|
mat.setColor("Diffuse", new ColorRGBA(1, 1, 1, 1)); // White color with full alpha
|
||||||
|
mat.setColor("Ambient", new ColorRGBA(1, 1, 1, 1)); // Ambient color with full alpha
|
||||||
|
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||||
model.setMaterial(mat);
|
model.setMaterial(mat);
|
||||||
rootNodeBoard.attachChild(model);
|
|
||||||
|
|
||||||
|
rootNodeBoard.attachChild(model);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,22 +745,54 @@ public void movePieceStartAnim(UUID uuid, int moveIndex){
|
|||||||
*/
|
*/
|
||||||
public void throwPieceAnim(UUID uuid){
|
public void throwPieceAnim(UUID uuid){
|
||||||
pieces.get(uuid).getSpatial().addControl(new MoveControl(
|
pieces.get(uuid).getSpatial().addControl(new MoveControl(
|
||||||
pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(), ()->throwPiece(uuid))
|
pieces.get(uuid).getLocation(), getNextWaitingNode(pieceColor.get(uuid)).getLocation(),
|
||||||
|
()->throwPiece(uuid))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void throwPiece(UUID uuid, Color throwColor){
|
||||||
|
switch(throwColor){
|
||||||
|
case ARMY -> throwShell(uuid);
|
||||||
|
case NAVY -> throwMissle(uuid);
|
||||||
|
case CYBER -> throwMatrix(uuid);
|
||||||
|
case AIRFORCE -> throwBomb(uuid);
|
||||||
|
default -> throw new RuntimeException("invalid color");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animates the throwing of a piece to the next available waiting node.
|
* Animates the throwing of a piece to the next available waiting node.
|
||||||
*
|
*
|
||||||
* @param uuid the UUID of the piece to animate
|
* @param uuid the UUID of the piece to animate
|
||||||
*/
|
*/
|
||||||
public void throwBombAnim(UUID uuid){
|
private void throwBomb(UUID uuid) {
|
||||||
Vector3f targetPoint = pieces.get(uuid).getLocation();
|
Vector3f targetPoint = pieces.get(uuid).getLocation();
|
||||||
|
|
||||||
JetAnimation anim = new JetAnimation(app, rootNode, uuid, targetPoint, 40, 6);
|
JetAnimation anim = new JetAnimation(app, rootNode, uuid, targetPoint, 40, 6, ()->throwPieceAnim(uuid));
|
||||||
anim.start();
|
anim.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void throwMatrix(UUID uuid) {
|
||||||
|
//app.getAcousticHandler().playSound(MdgaSound.MATRIX);
|
||||||
|
Spatial piece = pieces.get(uuid).getSpatial();
|
||||||
|
piece.addControl(new MatrixAnimation(app, radarPos,()-> {
|
||||||
|
piece.addControl(new FadeControl(1,1,0,
|
||||||
|
() -> {
|
||||||
|
throwPiece(uuid);
|
||||||
|
piece.addControl(new FadeControl(1,0,1));
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void throwMissle(UUID uuid) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void throwShell(UUID uuid) {
|
||||||
|
pieces.get(uuid).getSpatial().addControl(new ShellAnimation(tankTop, app, ()-> throwPieceAnim(uuid)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animates the swapping of two pieces by swapping their positions and rotations.
|
* Animates the swapping of two pieces by swapping their positions and rotations.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -102,15 +102,18 @@ public void init(Color ownColor) {
|
|||||||
* and resets the camera position and rotation to its default state.
|
* and resets the camera position and rotation to its default state.
|
||||||
*/
|
*/
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
app.getRootNode().removeLight(sun);
|
init = false;
|
||||||
app.getRootNode().removeLight(ambient);
|
fpp.removeFilter(fxaaFilter);
|
||||||
|
fpp.removeFilter(ssaoFilter);
|
||||||
|
fpp.removeFilter(dlsf);
|
||||||
app.getRootNode().detachChild(sky);
|
app.getRootNode().detachChild(sky);
|
||||||
|
app.getRootNode().removeLight(ambient);
|
||||||
|
app.getRootNode().removeLight(sun);
|
||||||
|
|
||||||
|
|
||||||
// Reset the camera to its default state
|
// Reset the camera to its default state
|
||||||
app.getCamera().setLocation(defaultCameraPosition);
|
app.getCamera().setLocation(defaultCameraPosition);
|
||||||
app.getCamera().setRotation(defaultCameraRotation);
|
app.getCamera().setRotation(defaultCameraRotation);
|
||||||
|
|
||||||
fpp.removeFilter(dlsf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -109,6 +109,9 @@ private static Asset getLoadedAsset(String assetName) {
|
|||||||
case "tank" -> Asset.tank;
|
case "tank" -> Asset.tank;
|
||||||
case "treeSmall" -> Asset.treeSmall;
|
case "treeSmall" -> Asset.treeSmall;
|
||||||
case "treeBig" -> Asset.treeBig;
|
case "treeBig" -> Asset.treeBig;
|
||||||
|
case "tank_shoot" -> Asset.tankShoot;
|
||||||
|
case "treesBigBackground" -> Asset.treesBigBackground;
|
||||||
|
case "treesSmallBackground" -> Asset.treesSmallBackground;
|
||||||
default -> throw new IllegalStateException("Unexpected value: " + assetName);
|
default -> throw new IllegalStateException("Unexpected value: " + assetName);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public void initSpatial(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void rotateInit() {
|
public void rotateInit() {
|
||||||
// rotate(rotation - initRotation);
|
setRotation(initRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -278,4 +278,5 @@ public boolean isSelectable() {
|
|||||||
public void setHoverable(boolean hoverable) {
|
public void setHoverable(boolean hoverable) {
|
||||||
this.hoverable = hoverable;
|
this.hoverable = hoverable;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package pp.mdga.client.board;
|
||||||
|
|
||||||
|
import com.jme3.math.FastMath;
|
||||||
|
import com.jme3.math.Quaternion;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import pp.mdga.client.InitControl;
|
||||||
|
|
||||||
|
import static pp.mdga.client.Util.linInt;
|
||||||
|
|
||||||
|
public class TankTopControl extends InitControl {
|
||||||
|
|
||||||
|
private float timer = 0; // Time elapsed
|
||||||
|
private final static float DURATION = 1.5f; // Total rotation duration in seconds
|
||||||
|
private boolean rotating = false; // Flag to track if rotation is active
|
||||||
|
private float startAngle = 0;
|
||||||
|
private float endAngle = 0;
|
||||||
|
private Runnable actionAfter = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float tpf) {
|
||||||
|
if (!rotating) return;
|
||||||
|
|
||||||
|
// Update the timer
|
||||||
|
timer += tpf;
|
||||||
|
|
||||||
|
// Calculate interpolation factor (0 to 1)
|
||||||
|
float t = timer / DURATION;
|
||||||
|
|
||||||
|
if (t >= 1) t = 1;
|
||||||
|
|
||||||
|
float curAngle = linInt(startAngle, endAngle, t);
|
||||||
|
|
||||||
|
// Interpolate the rotation
|
||||||
|
Quaternion interpolatedRotation = new Quaternion();
|
||||||
|
interpolatedRotation.fromAngleAxis((float) Math.toRadians(curAngle), Vector3f.UNIT_Z);
|
||||||
|
|
||||||
|
// Apply the interpolated rotation to the spatial
|
||||||
|
spatial.setLocalRotation(interpolatedRotation);
|
||||||
|
|
||||||
|
if(t >= 1){
|
||||||
|
rotating = false;
|
||||||
|
if(actionAfter != null) actionAfter.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rotate(Vector3f enemyPos, Runnable actionAfter) {
|
||||||
|
if (spatial == null) throw new RuntimeException("spatial is null");
|
||||||
|
|
||||||
|
startAngle = getOwnAngle();
|
||||||
|
endAngle = getEnemyAngle(enemyPos);
|
||||||
|
|
||||||
|
// Adjust endAngle to ensure the shortest path
|
||||||
|
float deltaAngle = endAngle - startAngle;
|
||||||
|
if (deltaAngle > 180) {
|
||||||
|
endAngle -= 360; // Rotate counterclockwise
|
||||||
|
} else if (deltaAngle < -180) {
|
||||||
|
endAngle += 360; // Rotate clockwise
|
||||||
|
}
|
||||||
|
|
||||||
|
timer = 0;
|
||||||
|
rotating = true;
|
||||||
|
this.actionAfter = actionAfter; // Store the action to execute after rotation
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getEnemyAngle(Vector3f enemyPos){
|
||||||
|
// Direction to the enemy in the XY plane
|
||||||
|
Vector3f direction = enemyPos.subtract(spatial.getLocalTranslation());
|
||||||
|
direction.z = 0; // Project to XY plane
|
||||||
|
direction.normalizeLocal();
|
||||||
|
|
||||||
|
Vector3f reference = Vector3f.UNIT_Y.mult(-1);
|
||||||
|
|
||||||
|
// Calculate the angle between the direction vector and the reference vector
|
||||||
|
float angle = FastMath.acos(reference.dot(direction));
|
||||||
|
|
||||||
|
// Determine rotation direction using the cross product
|
||||||
|
Vector3f cross = reference.cross(direction);
|
||||||
|
if (cross.z < 0) {
|
||||||
|
angle = -angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float) Math.toDegrees(angle); // Return the absolute angle in degrees
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getOwnAngle() {
|
||||||
|
// Tank's forward direction in the XY plane
|
||||||
|
Vector3f forward = spatial.getLocalRotation().mult(Vector3f.UNIT_Y);
|
||||||
|
forward.z = 0; // Project to XY plane
|
||||||
|
forward.normalizeLocal();
|
||||||
|
|
||||||
|
// Reference vector: Positive X-axis
|
||||||
|
Vector3f reference = Vector3f.UNIT_Y;
|
||||||
|
|
||||||
|
// Calculate the angle between the forward vector and the reference vector
|
||||||
|
float angle = FastMath.acos(reference.dot(forward));
|
||||||
|
|
||||||
|
// Determine rotation direction using the cross product
|
||||||
|
Vector3f cross = reference.cross(forward);
|
||||||
|
if (cross.z < 0) { // For Z-up, check the Z component of the cross product
|
||||||
|
angle = -angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float) Math.toDegrees(angle); // Return the absolute angle in radians
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -152,5 +152,4 @@ void rollRankingResultOwn(Color color, int eye){
|
|||||||
void diceNow(){
|
void diceNow(){
|
||||||
createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0);
|
createTopText("Klicke zum Würfeln", 5, 80, ColorRGBA.White, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import com.jme3.post.filters.ComposeFilter;
|
import com.jme3.post.filters.ComposeFilter;
|
||||||
|
import com.jme3.post.filters.FXAAFilter;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.renderer.RenderManager;
|
import com.jme3.renderer.RenderManager;
|
||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
@@ -31,35 +32,46 @@ public class CardLayer extends AbstractAppState {
|
|||||||
private List<Spatial> cardBuffer;
|
private List<Spatial> cardBuffer;
|
||||||
private final FilterPostProcessor fpp;
|
private final FilterPostProcessor fpp;
|
||||||
private final Camera overlayCam;
|
private final Camera overlayCam;
|
||||||
Texture2D backTexture;
|
private Texture2D backTexture;
|
||||||
|
private FXAAFilter fxaaFilter;
|
||||||
|
private ViewPort view;
|
||||||
|
private DirectionalLightShadowFilter dlsf;
|
||||||
|
DirectionalLight sun;
|
||||||
|
ComposeFilter compose;
|
||||||
|
|
||||||
|
|
||||||
public CardLayer(FilterPostProcessor fpp, Camera overlayCam, Texture2D backTexture) {
|
public CardLayer(FilterPostProcessor fpp, Camera overlayCam, Texture2D backTexture) {
|
||||||
this.overlayCam = overlayCam;
|
this.overlayCam = overlayCam;
|
||||||
this.fpp = fpp;
|
this.fpp = fpp;
|
||||||
this.cardBuffer = new ArrayList<>();
|
|
||||||
init = false;
|
|
||||||
this.backTexture = backTexture;
|
this.backTexture = backTexture;
|
||||||
|
cardBuffer = new ArrayList<>();
|
||||||
|
init = false;
|
||||||
|
fxaaFilter = new FXAAFilter();
|
||||||
|
view = null;
|
||||||
|
dlsf = null;
|
||||||
|
|
||||||
|
sun = new DirectionalLight();
|
||||||
|
sun.setColor(ColorRGBA.White);
|
||||||
|
sun.setDirection(new Vector3f(.5f, -.5f, -1));
|
||||||
|
compose = new ComposeFilter(backTexture);
|
||||||
|
root = new Node("Under gui viewport Root");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(AppStateManager stateManager, Application app) {
|
public void initialize(AppStateManager stateManager, Application app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
root = new Node("Under gui viewport Root");
|
|
||||||
|
|
||||||
ViewPort view = app.getRenderManager().createMainView("Under gui ViewPort", overlayCam);
|
view = app.getRenderManager().createMainView("Under gui ViewPort", overlayCam);
|
||||||
view.setEnabled(true);
|
view.setEnabled(true);
|
||||||
view.setClearFlags(true, true, true);
|
view.setClearFlags(true, true, true);
|
||||||
view.attachScene(root);
|
view.attachScene(root);
|
||||||
fpp.setFrameBufferFormat(Image.Format.RGBA8);
|
fpp.setFrameBufferFormat(Image.Format.RGBA8);
|
||||||
fpp.addFilter(new ComposeFilter(backTexture));
|
fpp.addFilter(compose);
|
||||||
|
fpp.addFilter(fxaaFilter);
|
||||||
|
|
||||||
|
|
||||||
DirectionalLight sun = new DirectionalLight();
|
|
||||||
sun.setColor(ColorRGBA.White);
|
|
||||||
sun.setDirection(new Vector3f(.5f, -.5f, -1));
|
|
||||||
root.addLight(sun);
|
root.addLight(sun);
|
||||||
|
|
||||||
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3);
|
dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3);
|
||||||
dlsf.setLight(sun);
|
dlsf.setLight(sun);
|
||||||
dlsf.setEnabled(true);
|
dlsf.setEnabled(true);
|
||||||
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
||||||
@@ -72,6 +84,15 @@ public void initialize(AppStateManager stateManager, Application app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
view.clearProcessors();
|
||||||
|
fpp.removeFilter(dlsf);
|
||||||
|
dlsf = null;
|
||||||
|
root.removeLight(sun);
|
||||||
|
fpp.removeFilter(fxaaFilter);
|
||||||
|
fpp.removeFilter(compose);
|
||||||
|
view.detachScene(root);
|
||||||
|
app.getRenderManager().removeMainView(view);
|
||||||
|
|
||||||
cardBuffer.clear();
|
cardBuffer.clear();
|
||||||
root.detachAllChildren();
|
root.detachAllChildren();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,14 +39,15 @@ public DiceControl(AssetManager assetManager){
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void controlUpdate(float tpf) {
|
protected void controlUpdate(float tpf) {
|
||||||
|
float clampedTpf = Math.min(tpf, 0.05f); // Max 50 ms per frame
|
||||||
if (isRolling) {
|
if (isRolling) {
|
||||||
if(!slerp) {
|
if(!slerp) {
|
||||||
// Apply rotational velocity to the dice
|
// Apply rotational velocity to the dice
|
||||||
spinWithAngularVelocity(tpf);
|
spinWithAngularVelocity(clampedTpf);
|
||||||
|
|
||||||
// Gradually reduce rotational velocity (simulate deceleration)
|
// Gradually reduce rotational velocity (simulate deceleration)
|
||||||
angularVelocity.subtractLocal(
|
angularVelocity.subtractLocal(
|
||||||
angularVelocity.mult(deceleration * tpf)
|
angularVelocity.mult(deceleration * clampedTpf)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Stop rolling when angular velocity is close to zero
|
// Stop rolling when angular velocity is close to zero
|
||||||
@@ -55,7 +56,7 @@ protected void controlUpdate(float tpf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
timeElapsed += tpf * rollDuration;
|
timeElapsed += clampedTpf * rollDuration;
|
||||||
|
|
||||||
|
|
||||||
if (timeElapsed > 1.0f) timeElapsed = 1.0f;
|
if (timeElapsed > 1.0f) timeElapsed = 1.0f;
|
||||||
@@ -71,7 +72,7 @@ protected void controlUpdate(float tpf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(spin){
|
}else if(spin){
|
||||||
spinWithAngularVelocity(tpf);
|
spinWithAngularVelocity(clampedTpf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
|
import com.jme3.post.filters.FXAAFilter;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.renderer.RenderManager;
|
import com.jme3.renderer.RenderManager;
|
||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
@@ -54,7 +55,6 @@ public void select(Spatial model, ColorRGBA color, int width) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void hideOutlineFilterEffect(Spatial model) {
|
private void hideOutlineFilterEffect(Spatial model) {
|
||||||
// app.enqueue(() -> {
|
|
||||||
outlineFilter.setEnabled(false);
|
outlineFilter.setEnabled(false);
|
||||||
outlineFilter.getOutlinePreFilter().setEnabled(false);
|
outlineFilter.getOutlinePreFilter().setEnabled(false);
|
||||||
fpp.removeFilter(outlineFilter);
|
fpp.removeFilter(outlineFilter);
|
||||||
@@ -62,18 +62,14 @@ private void hideOutlineFilterEffect(Spatial model) {
|
|||||||
outlineViewport.clearProcessors();
|
outlineViewport.clearProcessors();
|
||||||
renderManager.removePreView(outlineViewport);
|
renderManager.removePreView(outlineViewport);
|
||||||
outlineViewport = null;
|
outlineViewport = null;
|
||||||
// return null;
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
|
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
|
||||||
// app.enqueue(() -> {
|
|
||||||
outlineViewport = renderManager.createPreView("outlineViewport", cam);
|
outlineViewport = renderManager.createPreView("outlineViewport", cam);
|
||||||
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
|
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
|
||||||
|
|
||||||
OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
|
OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
|
||||||
outlineFpp.addFilter(outlinePreFilter);
|
outlineFpp.addFilter(outlinePreFilter);
|
||||||
|
|
||||||
outlineViewport.attachScene(model);
|
outlineViewport.attachScene(model);
|
||||||
outlineViewport.addProcessor(outlineFpp);
|
outlineViewport.addProcessor(outlineFpp);
|
||||||
|
|
||||||
@@ -82,7 +78,5 @@ private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color)
|
|||||||
outlineFilter.setOutlineWidth(width);
|
outlineFilter.setOutlineWidth(width);
|
||||||
|
|
||||||
fpp.addFilter(outlineFilter);
|
fpp.addFilter(outlineFilter);
|
||||||
// return null;
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 46 KiB |
BIN
Projekte/mdga/client/src/main/resources/Images/particle/line.png
Normal file
|
After Width: | Height: | Size: 140 B |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 18 KiB |
@@ -1,4 +1,6 @@
|
|||||||
world 0,0 90
|
world 0,0 90
|
||||||
|
treesBigBackground 0,0 90
|
||||||
|
treesSmallBackground 0,0 90
|
||||||
|
|
||||||
|
|
||||||
#Marine Pos
|
#Marine Pos
|
||||||
@@ -56,7 +58,8 @@ big_tent -10,-9 130
|
|||||||
big_tent 9,-10 225
|
big_tent 9,-10 225
|
||||||
radar 0,10 -20
|
radar 0,10 -20
|
||||||
tank -1,-10 135
|
tank -1,-10 135
|
||||||
tank 0,-18 180
|
#tank 0,-18 180
|
||||||
|
tank_shoot 0,-18 180
|
||||||
tank 3,-18 180
|
tank 3,-18 180
|
||||||
tank -3,-18 180
|
tank -3,-18 180
|
||||||
|
|
||||||
@@ -270,3 +273,4 @@ treeBig 12,22 360
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
Projekte/mdga/client/src/main/resources/Models/shell/shell.j3o
Normal file
|
Before Width: | Height: | Size: 10 MiB After Width: | Height: | Size: 13 MiB |
|
After Width: | Height: | Size: 10 MiB |
BIN
Projekte/mdga/client/src/main/resources/Sounds/matrix.wav
Normal file
BIN
Projekte/mdga/client/src/main/resources/Sounds/tank_shoot.ogg
Normal file
BIN
Projekte/mdga/client/src/main/resources/Sounds/turret_rotate.ogg
Normal file
@@ -42,7 +42,7 @@ protected void handlePowerCard(PlayCardMessage msg){
|
|||||||
protected void throwPiece(Piece piece){
|
protected void throwPiece(Piece piece){
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||||
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).addWaitingPiece(piece);
|
logic.getGame().getBoard().getPlayerData().get(piece.getColor()).addWaitingPiece(piece);
|
||||||
logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
|
// logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
|
||||||
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
|
logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
|
||||||
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
logic.getGame().getGameStatistics().increasePiecesBeingThrown();
|
||||||
piece.setState(PieceState.WAITING);
|
piece.setState(PieceState.WAITING);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package pp.mdga.notification;
|
package pp.mdga.notification;
|
||||||
|
|
||||||
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,12 +12,14 @@ public class ThrowPieceNotification extends Notification {
|
|||||||
* The id of the piece that was thrown.
|
* The id of the piece that was thrown.
|
||||||
*/
|
*/
|
||||||
private final UUID pieceId;
|
private final UUID pieceId;
|
||||||
|
private final Color throwColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor is used to create a new ThrowPieceNotification
|
* This constructor is used to create a new ThrowPieceNotification
|
||||||
*/
|
*/
|
||||||
public ThrowPieceNotification(UUID pieceId) {
|
public ThrowPieceNotification(UUID pieceId, Color throwColor) {
|
||||||
this.pieceId = pieceId;
|
this.pieceId = pieceId;
|
||||||
|
this.throwColor = throwColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,4 +30,8 @@ public ThrowPieceNotification(UUID pieceId) {
|
|||||||
public UUID getPieceId() {
|
public UUID getPieceId() {
|
||||||
return pieceId;
|
return pieceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color getThrowColor() {
|
||||||
|
return throwColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||