mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-28 18:59:47 +01:00
add spinning drop
This commit is contained in:
parent
5dff2c271f
commit
a798edf07f
@ -235,8 +235,8 @@ public class ParticleEffectFactory {
|
||||
smokeEmitter.setLocalTranslation(0, 2f, 0);
|
||||
smokeEmitter.setLowLife(1);
|
||||
smokeEmitter.setHighLife(1);
|
||||
smokeEmitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, .5f, 0));
|
||||
smokeEmitter.setImagesX(15); // Assuming the smoke texture is a sprite sheet with 15 frames
|
||||
smokeEmitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
|
||||
smokeEmitter.setImagesX(15);
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||
mat.setTexture("Texture", app.getAssetManager().loadTexture("Effects/Smoke/Smoke.png"));
|
||||
smokeEmitter.setMaterial(mat);
|
||||
|
@ -310,6 +310,7 @@ class SeaSynchronizer extends ShipMapSynchronizer {
|
||||
private Spatial createTransporter(Battleship ship) {
|
||||
final Spatial model = app.getAssetManager().loadModel(TRANSPORTER);
|
||||
float rotationAngle = calculateRotationAngle(ship.getRot())+HALF_PI;
|
||||
|
||||
|
||||
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot())+ PI, 0f);
|
||||
model.scale(0.008f);
|
||||
@ -319,10 +320,10 @@ class SeaSynchronizer extends ShipMapSynchronizer {
|
||||
// Bei 0 oder 180 Grad wird auf der Z-Achse verschoben, bei 90 oder 270 Grad auf der X-Achse
|
||||
if (rotationAngle == 0 || rotationAngle == FastMath.PI) {
|
||||
// Verschiebe auf der Z-Achse und um 2f nach oben
|
||||
translation = translation.add(0,0,1f); // Nach hinten auf der Z-Achse, und um 2f nach oben
|
||||
translation = translation.subtract(0,0,1);
|
||||
} else if (rotationAngle == FastMath.HALF_PI || rotationAngle == 3 * FastMath.HALF_PI) {
|
||||
// Verschiebe auf der X-Achse und um 2f nach oben
|
||||
translation = translation.add(1f,0,0); // Nach hinten auf der X-Achse, und um 2f nach oben
|
||||
translation = translation.add(1,0,0);
|
||||
}
|
||||
|
||||
model.setLocalTranslation(translation);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package pp.battleship.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;
|
||||
@ -11,8 +13,8 @@ import com.jme3.scene.control.AbstractControl;
|
||||
* It will gradually move the ship downwards and then remove it from the scene.
|
||||
*/
|
||||
class SinkingControl extends AbstractControl {
|
||||
private static final float SINK_DURATION = 6f; // Duration of the sinking animation
|
||||
private static final float SINK_SPEED = 0.8f; // Speed at which the ship sinks
|
||||
private static final float SINK_DURATION = 2f; // Duration of the sinking animation
|
||||
private static final float SINK_SPEED = 0.6f; // Speed at which the ship sinks
|
||||
private float elapsedTime = 0;
|
||||
|
||||
private final Node shipNode;
|
||||
@ -24,7 +26,7 @@ class SinkingControl extends AbstractControl {
|
||||
public SinkingControl(Node shipNode) {
|
||||
this.shipNode = shipNode;
|
||||
}
|
||||
|
||||
float tiltAngle= 0;
|
||||
/**
|
||||
* Updated the Map to sink the ship
|
||||
*
|
||||
@ -37,13 +39,18 @@ class SinkingControl extends AbstractControl {
|
||||
|
||||
// Move the ship down over time
|
||||
Vector3f currentPos = shipNode.getLocalTranslation();
|
||||
shipNode.setLocalTranslation(currentPos.x+SINK_SPEED*tpf, currentPos.y - SINK_SPEED * tpf, currentPos.z+SINK_SPEED*tpf);
|
||||
|
||||
shipNode.setLocalTranslation(currentPos.x+SINK_SPEED*tpf, currentPos.y - SINK_SPEED * tpf*2, currentPos.z+SINK_SPEED*tpf*2);
|
||||
|
||||
// Check if sinking duration has passed
|
||||
if (elapsedTime >= SINK_DURATION) {
|
||||
// Remove the ship from the scene
|
||||
shipNode.removeFromParent();
|
||||
}
|
||||
// Apply the tilt angle and rotation during sinking
|
||||
float sinkingTiltAngle = FastMath.DEG_TO_RAD * tiltAngle * tpf;
|
||||
float sinkingRotationAngle = FastMath.DEG_TO_RAD * 45f * tpf; // Additional rotation during sinking
|
||||
Quaternion tiltRotation = new Quaternion().fromAngles(-sinkingTiltAngle, sinkingRotationAngle, 0);
|
||||
spatial.setLocalRotation(tiltRotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +78,9 @@ public class SinkingShip extends AbstractControl {
|
||||
float progress = Math.min((elapsedTime - burnTiltDuration) / sinkDuration, 1f);
|
||||
|
||||
// Apply the tilt angle (remains constant during sinking)
|
||||
Quaternion tiltRotation = new Quaternion().fromAngles(-FastMath.DEG_TO_RAD * tiltAngle, 0, 0);
|
||||
float sinkingTiltAngle = FastMath.DEG_TO_RAD * tiltAngle * progress;
|
||||
float sinkingRotationAngle = FastMath.DEG_TO_RAD * 45f * progress; // Additional rotation during sinking
|
||||
Quaternion tiltRotation = new Quaternion().fromAngles(-sinkingTiltAngle, sinkingRotationAngle, sinkingRotationAngle);
|
||||
spatial.setLocalRotation(tiltRotation);
|
||||
|
||||
// Sink the ship by interpolating the Y position
|
||||
@ -111,6 +113,6 @@ public class SinkingShip extends AbstractControl {
|
||||
* Starts the sinking process for the ship.
|
||||
*/
|
||||
public void startSinking() {
|
||||
// Nothing to do here as the control update handles the timing and sequence
|
||||
// --> sinkingControl
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user