diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java index 4f1ea7a..d1fafdb 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java @@ -10,11 +10,13 @@ import com.jme3.light.AmbientLight; import com.jme3.light.DirectionalLight; import com.jme3.light.PointLight; import com.jme3.material.Material; +import com.jme3.material.RenderState.FaceCullMode; import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; +import com.jme3.renderer.queue.RenderQueue; import com.jme3.renderer.queue.RenderQueue.ShadowMode; import com.jme3.scene.Geometry; import com.jme3.scene.Node; @@ -177,17 +179,79 @@ public class BoardAppState extends MonopolyAppState { */ private void setupSky() { final AssetManager assetManager = getApp().getAssetManager(); - final Texture west = assetManager.loadTexture("Pictures/Backdrop/wall.jpg"); //NON-NLS - final Texture east = assetManager.loadTexture("Pictures/Backdrop/door.jpg"); //NON-NLS - final Texture north = assetManager.loadTexture("Pictures/Backdrop/board.jpg"); //NON-NLS - final Texture south = assetManager.loadTexture("Pictures/Backdrop/wall.jpg"); //NON-NLS - final Texture up = assetManager.loadTexture("Pictures/Backdrop/wall.jpg"); //NON-NLS - final Texture down = assetManager.loadTexture("Pictures/Backdrop/floor1.jpg"); //NON-NLS - final Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down); - // sky.rotate(0, PI, 0); - viewNode.attachChild(sky); + + // Create a cylinder for the sky + float radius = 500f; // Adjust radius as needed + float height = 200f; // Height of the cylinder + int radialSamples = 64; // Number of radial segments for smoothness + int axisSamples = 2; // No vertical divisions (flat vertical surface) + + Cylinder skyCylinder = new Cylinder(axisSamples, radialSamples, radius, height, true); + + // 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, * applying textures, and enabling shadows. diff --git a/Projekte/monopoly/client/src/main/resources/Textures/Bot.jpg b/Projekte/monopoly/client/src/main/resources/Textures/Bot.jpg new file mode 100644 index 0000000..60ae967 Binary files /dev/null and b/Projekte/monopoly/client/src/main/resources/Textures/Bot.jpg differ diff --git a/Projekte/monopoly/client/src/main/resources/Textures/CylinderMap.jpg b/Projekte/monopoly/client/src/main/resources/Textures/CylinderMap.jpg new file mode 100644 index 0000000..d2967c8 Binary files /dev/null and b/Projekte/monopoly/client/src/main/resources/Textures/CylinderMap.jpg differ diff --git a/Projekte/monopoly/client/src/main/resources/Textures/Top.png b/Projekte/monopoly/client/src/main/resources/Textures/Top.png new file mode 100644 index 0000000..5fdf163 Binary files /dev/null and b/Projekte/monopoly/client/src/main/resources/Textures/Top.png differ diff --git a/Projekte/monopoly/client/src/main/resources/Textures/grass.jpg b/Projekte/monopoly/client/src/main/resources/Textures/grass.jpg new file mode 100644 index 0000000..e3b0133 Binary files /dev/null and b/Projekte/monopoly/client/src/main/resources/Textures/grass.jpg differ