Compare commits

..

No commits in common. "1e20a2ac6efe49af58fccd2daaccf8e307d679d0" and "1db2d9ebaceb567f3ed2f5dd35e3daee35d23992" have entirely different histories.

11 changed files with 152 additions and 115 deletions

View File

@ -8,22 +8,24 @@ import com.jme3.effect.ParticleMesh;
import com.jme3.effect.shapes.EmitterSphereShape; import com.jme3.effect.shapes.EmitterSphereShape;
import com.jme3.light.AmbientLight; import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight; import com.jme3.light.DirectionalLight;
import com.jme3.light.PointLight;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.material.RenderState.FaceCullMode;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath; import com.jme3.math.FastMath;
import com.jme3.math.Quaternion; import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue; import com.jme3.renderer.Camera;
import com.jme3.renderer.queue.RenderQueue.ShadowMode; import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box; import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Cylinder; import com.jme3.scene.shape.Cylinder;
import com.jme3.scene.shape.Sphere;
import com.jme3.shadow.DirectionalLightShadowRenderer; import com.jme3.shadow.DirectionalLightShadowRenderer;
import com.jme3.shadow.EdgeFilteringMode; import com.jme3.shadow.EdgeFilteringMode;
import com.jme3.texture.Texture; import com.jme3.texture.Texture;
import com.jme3.util.SkyFactory;
import com.jme3.util.TangentBinormalGenerator; import com.jme3.util.TangentBinormalGenerator;
import pp.monopoly.client.gui.BobTheBuilder; import pp.monopoly.client.gui.BobTheBuilder;
@ -31,7 +33,13 @@ import pp.monopoly.client.gui.CameraController;
import pp.monopoly.client.gui.CameraInputHandler; import pp.monopoly.client.gui.CameraInputHandler;
import pp.monopoly.client.gui.Toolbar; import pp.monopoly.client.gui.Toolbar;
import pp.monopoly.model.Board; import pp.monopoly.model.Board;
import pp.monopoly.client.gui.FigureControl;
import static java.lang.Math.divideExact;
import static pp.util.FloatMath.TWO_PI;
import static pp.util.FloatMath.cos;
import static pp.util.FloatMath.sin;
import static pp.util.FloatMath.sqrt;
/** /**
* Manages the rendering and visual aspects of the sea and sky in the Battleship game. * Manages the rendering and visual aspects of the sea and sky in the Battleship game.
@ -67,14 +75,15 @@ public class BoardAppState extends MonopolyAppState {
/** /**
* The pop-up manager for displaying messages and notifications. * The pop-up manager for displaying messages and notifications.
*/ */
private PopUpManager popUpManager; private PopUpManager popUpManager;;
private Vector3f currentTarget;
private Vector3f currentTarget = new Vector3f(-10f,0,-10f);
private float modelHeight = -5f;
private final float targetHeight = 0f;
private final float animationSpeed = 0.01389f;
private Node modelNode; private Node modelNode;
private boolean startAnimation = false;
private CameraController cameraController; private CameraController cameraController;
private CameraInputHandler cameraInputHandler; private CameraInputHandler cameraInputHandler;
@ -168,79 +177,17 @@ public class BoardAppState extends MonopolyAppState {
*/ */
private void setupSky() { private void setupSky() {
final AssetManager assetManager = getApp().getAssetManager(); final AssetManager assetManager = getApp().getAssetManager();
final Texture west = assetManager.loadTexture("Pictures/Backdrop/wall.jpg"); //NON-NLS
// Create a cylinder for the sky final Texture east = assetManager.loadTexture("Pictures/Backdrop/door.jpg"); //NON-NLS
float radius = 500f; // Adjust radius as needed final Texture north = assetManager.loadTexture("Pictures/Backdrop/board.jpg"); //NON-NLS
float height = 200f; // Height of the cylinder final Texture south = assetManager.loadTexture("Pictures/Backdrop/wall.jpg"); //NON-NLS
int radialSamples = 64; // Number of radial segments for smoothness final Texture up = assetManager.loadTexture("Pictures/Backdrop/wall.jpg"); //NON-NLS
int axisSamples = 2; // No vertical divisions (flat vertical surface) final Texture down = assetManager.loadTexture("Pictures/Backdrop/floor1.jpg"); //NON-NLS
final Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
Cylinder skyCylinder = new Cylinder(axisSamples, radialSamples, radius, height, true); // sky.rotate(0, PI, 0);
viewNode.attachChild(sky);
// Create a geometry for the cylinder
Geometry skyGeometry = new Geometry("CylinderSky", skyCylinder);
// Load the cylindrical texture
Texture cylinderTexture = assetManager.loadTexture("Textures/CylinderMap.jpg");
// Create a material and apply the texture
Material skyMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
skyMaterial.setTexture("ColorMap", cylinderTexture);
skyMaterial.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); // Render inside of the cylinder
// Assign material to the geometry
skyGeometry.setMaterial(skyMaterial);
skyGeometry.rotate(-FastMath.HALF_PI, 0, 0); // Rotate 90° along the Y-axis
// Position and attach the cylinder to the scene
skyGeometry.setQueueBucket(RenderQueue.Bucket.Sky); // Ensure it's rendered in the background
skyGeometry.setCullHint(Spatial.CullHint.Never); // Always render the sky
viewNode.attachChild(skyGeometry);
addCylinderCaps();
} }
/**
* Adds top and bottom caps to the cylinder sky.
*/
private void addCylinderCaps() {
final AssetManager assetManager = getApp().getAssetManager();
float radius = 500f; // Match the cylinder's radius
float height = 225f; // Match the cylinder's height
int radialSamples = 64; // Match the cylinder's radial samples
// Bottom Cap
Cylinder bottomCap = new Cylinder(2, radialSamples, radius, 0.01f, true, false); // Thin bottom cap
Geometry bottomGeometry = new Geometry("BottomCap", bottomCap);
bottomGeometry.setLocalTranslation(0, -height / 2, 0); // Position at the bottom
bottomGeometry.rotate(FastMath.HALF_PI, 0, 0); // Rotate to make it horizontal
Material bottomMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
bottomMaterial.setTexture("ColorMap", assetManager.loadTexture("Textures/grass.jpg")); // Bottom texture
bottomMaterial.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); // Render both sides
bottomGeometry.setMaterial(bottomMaterial);
bottomGeometry.setQueueBucket(RenderQueue.Bucket.Sky);
bottomGeometry.setCullHint(Spatial.CullHint.Never);
// Top Cap
Cylinder topCap = new Cylinder(2, radialSamples, radius, 0.01f, true, false); // Thin top cap
Geometry topGeometry = new Geometry("TopCap", topCap);
topGeometry.setLocalTranslation(0, height / 2, 0); // Position at the top
topGeometry.rotate(FastMath.HALF_PI, 0, 0); // Rotate to make it horizontal
Material topMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
topMaterial.setTexture("ColorMap", assetManager.loadTexture("Textures/Top.png")); // Top texture
topMaterial.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); // Render both sides
topGeometry.setMaterial(topMaterial);
topGeometry.setQueueBucket(RenderQueue.Bucket.Sky);
topGeometry.setCullHint(Spatial.CullHint.Never);
// Attach caps to the view node
viewNode.attachChild(bottomGeometry);
viewNode.attachChild(topGeometry);
}
/** /**
* Sets up the sea surface in the scene. This includes creating the sea mesh, * Sets up the sea surface in the scene. This includes creating the sea mesh,
* applying textures, and enabling shadows. * applying textures, and enabling shadows.
@ -265,49 +212,30 @@ private void addCylinderCaps() {
sceneNode.attachChild(createCardDeck()); sceneNode.attachChild(createCardDeck());
sceneNode.attachChild(seaGeo); sceneNode.attachChild(seaGeo);
addModelToCenter(sceneNode);
// Schneefall hinzufügen // Schneefall hinzufügen
addSnowEffect(sceneNode); addSnowEffect(sceneNode);
} }
private Node createCardDeck() { private Node createCardDeck() {
Node cardDeck = new Node("cardDeck"); Node cardDeck = new Node("cardDeck");
Spatial card = getApp().getAssetManager().loadModel("models/Kartendecks/Ereigniskarten.j3o");
card.setLocalTranslation(5.5f, 0, 2.7f);
card.setLocalScale(4.1f);
card.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Y));
// Ereigniskarten Spatial card2 = getApp().getAssetManager().loadModel("models/Kartendecks/Gemeinschaftskarten.j3o");
Vector3f basePosition1 = new Vector3f(3.1f, 0.4f, 3.8f); // Basisposition für Ereigniskarten card2.setLocalTranslation(-1.4f, 0, -3.8f);
float baseRotation1 = -60; // Basisrotation in Grad card2.setLocalScale(4.1f);
for (int i = 0; i < 6; i++) { card2.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI , Vector3f.UNIT_Y));
Box box = new Box(1.2f, 0.05f, 1.8f); // Sehr flaches Rechteck
Geometry flatCard = new Geometry("Ereigniskarten_" + i, box);
Material mat = new Material(getApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", getApp().getAssetManager().loadTexture("Textures/Ereigniskarten.png"));
flatCard.setMaterial(mat);
// Position und Rotation für die Karte
flatCard.setLocalTranslation(basePosition1.x, basePosition1.y - (i * 0.08f), basePosition1.z);
flatCard.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.DEG_TO_RAD * (baseRotation1 - (i * 5)), Vector3f.UNIT_Y));
cardDeck.attachChild(flatCard);
}
// Gemeinschaftskarten
Vector3f basePosition2 = new Vector3f(-3.3f, 0.4f, -3.8f); // Basisposition für Gemeinschaftskarten
float baseRotation2 = -220; // Basisrotation in Grad
for (int i = 0; i < 6; i++) {
Box box = new Box(1.2f, 0.04f, 1.8f); // Sehr flaches Rechteck
Geometry flatCard = new Geometry("Gemeinschaftskarten_" + i, box);
Material mat = new Material(getApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", getApp().getAssetManager().loadTexture("Textures/Gemeinschaftskarten.png"));
flatCard.setMaterial(mat);
// Position und Rotation für die Karte
flatCard.setLocalTranslation(basePosition2.x, basePosition2.y - (i * 0.08f), basePosition2.z);
flatCard.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.DEG_TO_RAD * (baseRotation2 - (i * 5)), Vector3f.UNIT_Y));
cardDeck.attachChild(flatCard);
}
//TODO insert card deck
// cardDeck.attachChild(card);
// cardDeck.attachChild(card2);
return cardDeck; return cardDeck;
} }
public Vector3f getCurrentTarget(){ public Vector3f getCurrentTarget(){
return currentTarget; return currentTarget;
} }
@ -341,4 +269,86 @@ private void addCylinderCaps() {
parentNode.attachChild(snowEmitter); parentNode.attachChild(snowEmitter);
} }
private void addModelToCenter(Node parentNode) {
AssetManager assetManager = getApp().getAssetManager();
Material material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
material.setColor("Diffuse", ColorRGBA.White);
material.setBoolean("UseMaterialColors", true);
Sphere lowerSphereLeft = new Sphere(32, 32, 0.5f);
Geometry lowerSphereLeftGeom = new Geometry("LowerSphereLeft", lowerSphereLeft);
lowerSphereLeftGeom.setMaterial(material);
lowerSphereLeftGeom.setLocalTranslation(-0.6f - 4f, 0.5f, 0.3f - 5f);
Sphere lowerSphereRight = new Sphere(32, 32, 0.5f);
Geometry lowerSphereRightGeom = new Geometry("LowerSphereRight", lowerSphereRight);
lowerSphereRightGeom.setMaterial(material);
lowerSphereRightGeom.setLocalTranslation(0.6f - 4f, 0.5f, 0.3f - 5f);
Cylinder cylinder = new Cylinder(16, 16, 0.4f, 2f, true);
Geometry cylinderGeom = new Geometry("Cylinder", cylinder);
cylinderGeom.setMaterial(material);
cylinderGeom.setLocalTranslation(0f - 4f, 1.5f, 0f - 5f);
cylinderGeom.rotate(FastMath.HALF_PI, 0, 0);
Sphere upperSphere = new Sphere(32, 32, 0.4f);
Geometry upperSphereGeom = new Geometry("UpperSphere", upperSphere);
upperSphereGeom.setMaterial(material);
upperSphereGeom.setLocalTranslation(0f - 4f, 2.5f, 0f - 5f);
this.modelNode = new Node("3DModel");
this.modelNode.attachChild(lowerSphereLeftGeom);
this.modelNode.attachChild(lowerSphereRightGeom);
this.modelNode.attachChild(cylinderGeom);
this.modelNode.attachChild(upperSphereGeom);
this.modelNode.setLocalTranslation(0, modelHeight, 0);
parentNode.attachChild(this.modelNode);
PointLight lightLeft = new PointLight();
lightLeft.setColor(ColorRGBA.Blue);
lightLeft.setPosition(new Vector3f(-0.6f - 4f, 0f, 0.3f - 5f));
lightLeft.setRadius(2f);
parentNode.addLight(lightLeft);
PointLight lightRight = new PointLight();
lightRight.setColor(ColorRGBA.Blue);
lightRight.setPosition(new Vector3f(0.6f - 4f, 0f, 0.3f - 5f));
lightRight.setRadius(2f);
parentNode.addLight(lightRight);
}
@Override
public void update(float tpf) {
super.update(tpf);
if (startAnimation && modelHeight < targetHeight) {
modelHeight += animationSpeed * tpf; // Geschwindigkeit basierend auf Zeit pro Frame
if (modelHeight > targetHeight) {
modelHeight = targetHeight; // Zielhöhe nicht überschreiten
startAnimation = false; // Animation beenden
}
updateModelHeight(); // Aktualisiere die Position des Modells
}
}
private void updateModelHeight() {
if (modelNode == null) {
modelNode = (Node) sceneNode.getChild("3DModel");
}
if (modelNode != null) {
modelNode.setLocalTranslation(0, modelHeight, 0); // Aktualisiere die Y-Position
}
}
public void onRollDicePressed() {
System.out.println("onRollDicePressed called");
if (!startAnimation) {
startAnimation = true;
modelHeight = -5f; // Reset der Höhe
updateModelHeight(); // Stelle sicher, dass das Modell an der Startposition ist
System.out.println("Animation started, startAnimation set to: " + startAnimation);
}
}
} }

View File

@ -293,8 +293,6 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
stateManager.attach(stats); stateManager.attach(stats);
} }
flyCam.setEnabled(true); flyCam.setEnabled(true);
flyCam.setMoveSpeed(4f); // Setzt die Bewegungsgeschwindigkeit der Kamera (Standardwert ist 1f)
stateManager.detach(stateManager.getState(StatsAppState.class)); stateManager.detach(stateManager.getState(StatsAppState.class));
stateManager.detach(stateManager.getState(DebugKeysAppState.class)); stateManager.detach(stateManager.getState(DebugKeysAppState.class));

View File

@ -20,6 +20,7 @@ import com.simsilica.lemur.event.MouseEventControl;
import com.simsilica.lemur.event.MouseListener; import com.simsilica.lemur.event.MouseListener;
import com.simsilica.lemur.style.ElementId; import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog; import pp.dialog.Dialog;
import pp.monopoly.client.BoardAppState;
import pp.monopoly.client.MonopolyApp; import pp.monopoly.client.MonopolyApp;
import pp.monopoly.client.gui.popups.Bankrupt; import pp.monopoly.client.gui.popups.Bankrupt;
import pp.monopoly.game.server.Player; import pp.monopoly.game.server.Player;
@ -196,6 +197,16 @@ public class Toolbar extends Dialog implements GameEventListener {
menuContainer.setBackground(null); menuContainer.setBackground(null);
} }
/**
* Returns the color of the current player.
*
* @return The color of the current player.
*/
private ColorRGBA getCurrentPlayerColor() {
Player currentPlayer = playerHandler.getPlayerById(app.getId());
return Player.getColor(currentPlayer.getId()).getColor();
}
/** /**
* Creates the dice display section of the toolbar interface. * Creates the dice display section of the toolbar interface.
* *
@ -280,6 +291,12 @@ public class Toolbar extends Dialog implements GameEventListener {
startDiceAnimation(); startDiceAnimation();
app.getGameLogic().send(new RollDice()); app.getGameLogic().send(new RollDice());
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
// Animation in BoardAppState starten
BoardAppState boardAppState = app.getStateManager().getState(BoardAppState.class);
if (boardAppState != null) {
boardAppState.onRollDicePressed(); // Animation starten
}
}); });
} }
@ -344,6 +361,18 @@ public class Toolbar extends Dialog implements GameEventListener {
return endTurnButton; return endTurnButton;
} }
/**
* Creates a background with the specified color.
*
* @param color The color of the background.
* @return The background component.
*/
private QuadBackgroundComponent createButtonBackground(ColorRGBA color) {
QuadBackgroundComponent background = new QuadBackgroundComponent(color);
Texture gradient = app.getAssetManager().loadTexture("Textures/gradient.png");
if (gradient != null) background.setTexture(gradient);
return background;
}
/** /**
* Handles the end turn event. * Handles the end turn event.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 707 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB