Development #35
@@ -38,7 +38,8 @@ public enum Asset {
|
||||
swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"),
|
||||
shieldCard,
|
||||
shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
|
||||
dice
|
||||
dice,
|
||||
missile("Models/missile/AVMT300.obj", "Models/missile/texture.jpg", 0.1f),
|
||||
;
|
||||
|
||||
private final String modelPath;
|
||||
|
||||
@@ -149,16 +149,16 @@ else if(boardSelect != null) {
|
||||
if (name.equals("Right")) {
|
||||
isRotateRight = !isRotateRight;
|
||||
}
|
||||
if(name.equals("Test2") &&isPressed){
|
||||
if(name.equals("Test") &&isPressed){
|
||||
if(app.getView() instanceof GameView gameView){
|
||||
|
||||
if(p == null) {
|
||||
p = UUID.randomUUID();
|
||||
gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
|
||||
gameView.getBoardHandler().movePieceStartAnim(p,0);
|
||||
gameView.getBoardHandler().movePieceAnim(p,0, 8);
|
||||
//gameView.getBoardHandler().movePieceAnim(p,0, 8);
|
||||
} else {
|
||||
gameView.getBoardHandler().throwBombAnim(p);
|
||||
gameView.getBoardHandler().throwMissileAnim(p);
|
||||
//gameView.getBoardHandler().movePieceStartAnim(p,0);
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ public void simpleInitApp() {
|
||||
gameView = new GameView(this);
|
||||
ceremonyView = new CeremonyView(this);
|
||||
|
||||
enter(MdgaState.MAIN);
|
||||
enter(MdgaState.GAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -113,9 +113,9 @@ public void playSound(MdgaSound sound) {
|
||||
assets.add(new SoundAssetDelayVolume(SoundAsset.JET, 1.0f, 0.0f));
|
||||
break;
|
||||
case EXPLOSION:
|
||||
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 4f));
|
||||
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_2, 1.0f, 4f));
|
||||
assets.add(new SoundAssetDelayVolume(SoundAsset.THUNDER, 1.0f, 4f));
|
||||
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
|
||||
assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_2, 1.0f, 0f));
|
||||
assets.add(new SoundAssetDelayVolume(SoundAsset.THUNDER, 1.0f, 0f));
|
||||
break;
|
||||
case LOSE:
|
||||
assets.add(new SoundAssetDelayVolume(SoundAsset.LOSE, 1.0f, 0.0f));
|
||||
@@ -126,6 +126,9 @@ public void playSound(MdgaSound sound) {
|
||||
case UI90:
|
||||
assets.add(new SoundAssetDelayVolume(SoundAsset.UI90, 1.0f, 0.0f));
|
||||
break;
|
||||
case MISSILE:
|
||||
assets.add(new SoundAssetDelayVolume(SoundAsset.MISSILE, 1.0f, 0.0f));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -36,4 +36,6 @@ public enum MdgaSound {
|
||||
LOSE,
|
||||
BONUS,
|
||||
UI90,
|
||||
MISSILE,
|
||||
MATRIX,
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ enum SoundAsset {
|
||||
UI90("ui90.ogg"),
|
||||
BONUS("bonus.ogg"),
|
||||
LOSE("lose.ogg"),
|
||||
MISSILE("missile.ogg"),
|
||||
CONNECTED("connected.wav");
|
||||
|
||||
private final String path;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.client.acoustic.MdgaSound;
|
||||
|
||||
public class Explosion {
|
||||
|
||||
@@ -34,8 +35,6 @@ public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
|
||||
this.location = location;
|
||||
|
||||
this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||
mat.getAdditionalRenderState().setDepthWrite(false);
|
||||
mat.getAdditionalRenderState().setDepthTest(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +55,6 @@ private void initializeEmitter() {
|
||||
fire.setParticlesPerSec(0);
|
||||
|
||||
fire.setLocalTranslation(location);
|
||||
fire.move(0, 0, 45);
|
||||
|
||||
smoke = new ParticleEmitter("Effect2", Type.Triangle,40);
|
||||
smoke.setMaterial(mat);
|
||||
@@ -74,7 +72,8 @@ private void initializeEmitter() {
|
||||
smoke.setParticlesPerSec(0);
|
||||
|
||||
smoke.setLocalTranslation(location);
|
||||
smoke.move(0, 0, 45);
|
||||
|
||||
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,7 +57,7 @@ public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint,
|
||||
|
||||
id = uuid;
|
||||
|
||||
explosion = new Explosion(app, rootNode, nodePoint);
|
||||
explosion = new Explosion(app, rootNode, targetPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,8 +83,6 @@ private void spawnJet() {
|
||||
jetModel.setMaterial(mat);
|
||||
|
||||
rootNode.attachChild(jetModel);
|
||||
|
||||
app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
package pp.mdga.client.animation;
|
||||
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import pp.mdga.client.Asset;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.client.acoustic.MdgaSound;
|
||||
import pp.mdga.client.board.BoardHandler;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class MissileAnimation {
|
||||
|
||||
private final Node rootNode; // Root-Knoten, an den die Animation gehängt wird
|
||||
private final MdgaApp app; // Referenz auf die Hauptanwendung
|
||||
private final Vector3f start; // Startpunkt der Rakete
|
||||
private final Vector3f target; // Zielpunkt der Rakete
|
||||
private final float flightTime; // Gesamtdauer des Flugs
|
||||
private Explosion explosion;
|
||||
private Spatial missileModel; // 3D-Modell der Rakete
|
||||
|
||||
private UUID id;
|
||||
|
||||
/**
|
||||
* Konstruktor für die MissileAnimation.
|
||||
*
|
||||
* @param app Die Hauptanwendung.
|
||||
* @param rootNode Der Root-Knoten, an den die Animation gehängt wird.
|
||||
* @param target Der Zielpunkt der Rakete.
|
||||
* @param flightTime Die Zeit, die die Rakete für den gesamten Flug benötigt.
|
||||
*/
|
||||
public MissileAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f target, float flightTime) {
|
||||
this.app = app;
|
||||
this.rootNode = rootNode;
|
||||
this.flightTime = flightTime;
|
||||
|
||||
explosion = new Explosion(app, rootNode, target);
|
||||
id = uuid;
|
||||
|
||||
this.target = target.add(new Vector3f(1.5f, -1, 0));
|
||||
|
||||
|
||||
start = BoardHandler.gridToWorld(12, 0);
|
||||
start.add(new Vector3f(0, 0, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Startet die Raketenanimation.
|
||||
*/
|
||||
public void start() {
|
||||
loadMissile();
|
||||
animateMissile();
|
||||
|
||||
app.getAcousticHandler().playSound(MdgaSound.MISSILE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt das Raketenmodell und setzt es auf den Startpunkt.
|
||||
*/
|
||||
private void loadMissile() {
|
||||
missileModel = app.getAssetManager().loadModel(Asset.missile.getModelPath()); // Lade das Missile-Modell
|
||||
missileModel.scale(Asset.missile.getSize());
|
||||
missileModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.missile.getDiffPath()));
|
||||
missileModel.setMaterial(mat);
|
||||
missileModel.setLocalTranslation(start); // Setze Startposition
|
||||
rootNode.attachChild(missileModel); // Füge das Modell zur Szene hinzu
|
||||
}
|
||||
|
||||
/**
|
||||
* Animiert die Rakete entlang einer Parabel.
|
||||
*/
|
||||
private void animateMissile() {
|
||||
missileModel.addControl(new AbstractControl() {
|
||||
private float elapsedTime = 0;
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
elapsedTime += tpf;
|
||||
float progress = elapsedTime / flightTime;
|
||||
|
||||
if (progress >= 0.95f) {
|
||||
explosion.trigger();
|
||||
}
|
||||
|
||||
if (progress >= 1) {
|
||||
explosion.trigger();
|
||||
|
||||
// Flug abgeschlossen
|
||||
rootNode.detachChild(missileModel); // Entferne Rakete nach dem Ziel
|
||||
this.spatial.removeControl(this); // Entferne die Steuerung
|
||||
return;
|
||||
}
|
||||
|
||||
// Berechne die aktuelle Position entlang der Parabel
|
||||
Vector3f currentPosition = computeParabolicPath(start, target, progress);
|
||||
missileModel.setLocalTranslation(currentPosition);
|
||||
|
||||
// Passe die Ausrichtung an (Nase der Rakete zeigt in Flugrichtung)
|
||||
Vector3f direction = computeParabolicPath(start, target, progress + 0.01f)
|
||||
.subtract(currentPosition)
|
||||
.normalizeLocal();
|
||||
missileModel.lookAt(currentPosition.add(direction), Vector3f.UNIT_Y); // Z ist oben, Y ist "Up"
|
||||
missileModel.rotate(0, FastMath.HALF_PI, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
// Keine Render-Logik benötigt
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechnet eine Parabelbewegung von `start` zu `target`.
|
||||
*
|
||||
* @param start Der Startpunkt der Rakete.
|
||||
* @param target Der Zielpunkt der Rakete.
|
||||
* @param t Der Fortschritt des Flugs (0 bis 1).
|
||||
* @return Die Position der Rakete entlang der Parabel.
|
||||
*/
|
||||
private Vector3f computeParabolicPath(Vector3f start, Vector3f target, float t) {
|
||||
Vector3f midPoint = start.add(target).multLocal(0.5f); // Berechne die Mitte zwischen Start und Ziel
|
||||
midPoint.addLocal(0, 0, 20); // Erhöhe den Scheitelpunkt der Parabel entlang der Z-Achse
|
||||
|
||||
// Quadratische Interpolation (Parabel)
|
||||
Vector3f startToMid = FastMath.interpolateLinear(t, start, midPoint);
|
||||
Vector3f midToTarget = FastMath.interpolateLinear(t, midPoint, target);
|
||||
return FastMath.interpolateLinear(t, startToMid, midToTarget);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
import pp.mdga.client.Asset;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.client.acoustic.MdgaSound;
|
||||
import pp.mdga.client.animation.MissileAnimation;
|
||||
import pp.mdga.client.animation.MoveControl;
|
||||
import pp.mdga.client.animation.JetAnimation;
|
||||
import pp.mdga.client.gui.DiceControl;
|
||||
@@ -201,7 +202,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
|
||||
* @param y The y-coordinate on the grid
|
||||
* @return The corresponding world position
|
||||
*/
|
||||
private static Vector3f gridToWorld(int x, int y) {
|
||||
public static Vector3f gridToWorld(int x, int y) {
|
||||
return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
|
||||
}
|
||||
|
||||
@@ -727,7 +728,7 @@ public void throwPieceAnim(UUID uuid){
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the throwing of a piece to the next available waiting node.
|
||||
* Animates the throwing of a piece to the next available waiting node and plays jet animation.
|
||||
*
|
||||
* @param uuid the UUID of the piece to animate
|
||||
*/
|
||||
@@ -738,6 +739,18 @@ public void throwBombAnim(UUID uuid){
|
||||
anim.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the throwing of a piece to the next available waiting node and plays ship animation.
|
||||
*
|
||||
* @param uuid the UUID of the piece to animate
|
||||
*/
|
||||
public void throwMissileAnim(UUID uuid){
|
||||
Vector3f targetPoint = pieces.get(uuid).getLocation();
|
||||
|
||||
MissileAnimation anim = new MissileAnimation(app, rootNode, uuid, targetPoint, 2);
|
||||
anim.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the swapping of two pieces by swapping their positions and rotations.
|
||||
*
|
||||
|
||||
@@ -31,6 +31,7 @@ public class GameView extends MdgaView {
|
||||
public GameView(MdgaApp app) {
|
||||
super(app);
|
||||
|
||||
setOwnColor(Color.AIRFORCE);
|
||||
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
|
||||
|
||||
confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 0 B |
Binary file not shown.
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 0 B |
Binary file not shown.
File diff suppressed because one or more lines are too long
3052
Projekte/mdga/client/src/main/resources/Models/missile/AVMT300.fbx
Normal file
3052
Projekte/mdga/client/src/main/resources/Models/missile/AVMT300.fbx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
# Blender MTL File: 'untitled.blend'
|
||||
# Material Count: 3
|
||||
|
||||
newmtl Material.001
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd untiffftled.jpg
|
||||
|
||||
newmtl Material.002
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd untiffftled.jpg
|
||||
|
||||
newmtl Material.004
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd untiffftled.jpg
|
||||
2523
Projekte/mdga/client/src/main/resources/Models/missile/AVMT300.obj
Normal file
2523
Projekte/mdga/client/src/main/resources/Models/missile/AVMT300.obj
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Projekte/mdga/client/src/main/resources/Sounds/missile.ogg
Normal file
BIN
Projekte/mdga/client/src/main/resources/Sounds/missile.ogg
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Projekte/mdga/client/src/main/resources/Sounds/thunder.wav
Normal file
BIN
Projekte/mdga/client/src/main/resources/Sounds/thunder.wav
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user