Compare commits
19 Commits
b_koppe_fe
...
b_Beck_Ced
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5035aa5a96 | ||
|
|
67b99317d2 | ||
|
|
bb1e3858bb | ||
|
|
9b85030050 | ||
|
|
4492843ca1 | ||
|
|
5edd4ebe0b | ||
|
|
216bd60d84 | ||
|
|
8275778d66 | ||
|
|
1d114c8d24 | ||
|
|
8b6a787115 | ||
|
|
8a5afe0b18 | ||
|
|
6496a5a6b7 | ||
|
|
af221ad693 | ||
|
|
ae61e8061c | ||
|
|
5f596d5797 | ||
|
|
82d86a378a | ||
|
|
02f7a6542e | ||
|
|
1afa621bec | ||
|
|
546872dd83 |
@@ -2,7 +2,7 @@
|
||||
<configuration default="false" name="Projekte [test]" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/Projekte" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="--continue" />
|
||||
<option name="taskDescriptions">
|
||||
|
||||
@@ -9,7 +9,6 @@ implementation project(":jme-common")
|
||||
implementation project(":battleship:model")
|
||||
|
||||
implementation libs.jme3.desktop
|
||||
implementation libs.jme3.effects
|
||||
|
||||
runtimeOnly libs.jme3.awt.dialogs
|
||||
runtimeOnly libs.jme3.plugins
|
||||
|
||||
@@ -26,10 +26,13 @@ map.own=maps/map1.json
|
||||
robot.targets=2, 0,\
|
||||
2, 1,\
|
||||
2, 2,\
|
||||
2, 3
|
||||
2, 3,\
|
||||
2, 4,\
|
||||
2, 5,\
|
||||
2, 6
|
||||
#
|
||||
# Delay in milliseconds between each shot fired by the RobotClient.
|
||||
robot.delay=500
|
||||
robot.delay=4000
|
||||
#
|
||||
# The dimensions of the game map used in single mode.
|
||||
# 'map.width' defines the number of columns, and 'map.height' defines the number of rows.
|
||||
|
||||
@@ -122,10 +122,7 @@ public class BattleshipApp extends SimpleApplication implements BattleshipClient
|
||||
*/
|
||||
private final ActionListener escapeListener = (name, isPressed, tpf) -> escape(isPressed);
|
||||
|
||||
/**
|
||||
* Listener for handling actions triggered by the Escape key.
|
||||
*/
|
||||
private GameMusic music;
|
||||
private EffectHandler effectHandler;
|
||||
|
||||
static {
|
||||
// Configure logging
|
||||
@@ -160,6 +157,7 @@ private BattleshipApp() {
|
||||
logic.addListener(this);
|
||||
setShowSettings(config.getShowSettings());
|
||||
setSettings(makeSettings());
|
||||
effectHandler = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,15 +196,6 @@ DialogManager getDialogManager() {
|
||||
return dialogManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the GameMusic responsible for playing music.
|
||||
*
|
||||
* @return The {@link GameMusic} instance.
|
||||
*/
|
||||
GameMusic getGameMusic() {
|
||||
return music;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the game logic handler for the client.
|
||||
*
|
||||
@@ -238,9 +227,8 @@ public void simpleInitApp() {
|
||||
setupInput();
|
||||
setupStates();
|
||||
setupGui();
|
||||
effectHandler = new EffectHandler(this);
|
||||
serverConnection.connect();
|
||||
|
||||
music = new GameMusic(this, "Sound/Music/battleship.ogg");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,11 +269,20 @@ private void setupStates() {
|
||||
flyCam.setEnabled(false);
|
||||
stateManager.detach(stateManager.getState(StatsAppState.class));
|
||||
stateManager.detach(stateManager.getState(DebugKeysAppState.class));
|
||||
|
||||
attachGameMusic();
|
||||
attachGameSound();
|
||||
stateManager.attachAll(new EditorAppState(), new BattleAppState(), new SeaAppState());
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the game sound state and sets its initial enabled state.
|
||||
*/
|
||||
private void attachGameMusic() {
|
||||
final GameMusic gameMusic = new GameMusic();
|
||||
gameMusic.setEnabled(GameMusic.enabledInPreferences());
|
||||
stateManager.attach(gameMusic);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the game sound state and sets its initial enabled state.
|
||||
*/
|
||||
@@ -442,4 +439,8 @@ void errorDialog(String errorMessage) {
|
||||
.build()
|
||||
.open();
|
||||
}
|
||||
|
||||
public EffectHandler getEffectHandler() {
|
||||
return effectHandler;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
package pp.battleship.client;
|
||||
|
||||
import com.jme3.effect.ParticleEmitter;
|
||||
import com.jme3.effect.ParticleMesh;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import pp.battleship.model.Battleship;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* EffectHandler manages the creation and manipulation of particle effects in the Battleship application.
|
||||
*/
|
||||
public class EffectHandler {
|
||||
private final BattleshipApp app;
|
||||
private final Map<Battleship, List<ParticleEmitter>> effects;
|
||||
|
||||
/**
|
||||
* Constructs an EffectHandler with the specified BattleshipApp instance.
|
||||
*
|
||||
* @param app the BattleshipApp instance
|
||||
*/
|
||||
public EffectHandler(BattleshipApp app) {
|
||||
this.app = app;
|
||||
effects = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a fire effect at the specified position for the given Battleship.
|
||||
*
|
||||
* @param point the position where the fire effect will be created
|
||||
* @param ship the Battleship associated with the fire effect
|
||||
* @return a Node containing the fire effect
|
||||
*/
|
||||
public Node createFire(Vector3f point, Battleship ship) {
|
||||
Node parent = new Node();
|
||||
parent.setLocalTranslation(point);
|
||||
|
||||
ParticleEmitter fire = initializeParticleEmitter(
|
||||
"Effects/Explosion/flame.png",
|
||||
2,2,
|
||||
new ColorRGBA(1f, 0f, 0f, 1f),
|
||||
new ColorRGBA(1f, 1f, 0f, 0.5f),
|
||||
new Vector3f(0, 1.5f, 0),
|
||||
50,
|
||||
.4f,
|
||||
0.05f,
|
||||
1f,
|
||||
2f,
|
||||
0.2f,
|
||||
new Vector3f(0, 0, 0)
|
||||
);
|
||||
|
||||
ParticleEmitter smoke = initializeParticleEmitter(
|
||||
"Effects/Smoke/Smoke.png",
|
||||
15,
|
||||
1,
|
||||
new ColorRGBA(1f, 1f, 1f, 0f),
|
||||
new ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f),
|
||||
new Vector3f(0, 1f, 0),
|
||||
600,
|
||||
.2f,
|
||||
0.1f,
|
||||
1f,
|
||||
5f,
|
||||
0.25f,
|
||||
new Vector3f(0, 0, 0)
|
||||
);
|
||||
|
||||
parent.attachChild(fire);
|
||||
parent.attachChild(smoke);
|
||||
|
||||
List<ParticleEmitter> oldEffects = new ArrayList<>(effects.getOrDefault(ship, new ArrayList<>()));
|
||||
oldEffects.add(fire);
|
||||
oldEffects.add(smoke);
|
||||
effects.put(ship, oldEffects);
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a water splash effect at the specified position.
|
||||
*
|
||||
* @param pos the position where the water splash effect will be created
|
||||
* @return a Geometry representing the water splash effect
|
||||
*/
|
||||
public Geometry waterSplash(Vector3f pos) {
|
||||
ParticleEmitter water = initializeParticleEmitter(
|
||||
"Effects/Explosion/flash.png",
|
||||
2,2,
|
||||
new ColorRGBA(0.3f, 0.8f, 1f, 0f),
|
||||
new ColorRGBA(0f, 0f, 1f, 1f),
|
||||
new Vector3f(0, 3, 0),
|
||||
100,
|
||||
.6f,
|
||||
0.05f,
|
||||
1f,
|
||||
1.5f,
|
||||
0.3f,
|
||||
new Vector3f(0, 4f, 0)
|
||||
);
|
||||
|
||||
water.setLocalTranslation(pos);
|
||||
water.emitAllParticles();
|
||||
water.setParticlesPerSec(0);
|
||||
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
deleteSplash(water);
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
return water;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a debris splash effect at the specified position.
|
||||
*
|
||||
* @param pos the position where the debris splash effect will be created
|
||||
* @return a Geometry representing the debris splash effect
|
||||
*/
|
||||
public Geometry debrisSplash(Vector3f pos) {
|
||||
ParticleEmitter debris = initializeParticleEmitter(
|
||||
"Effects/Explosion/Debris.png",
|
||||
3,3,
|
||||
new ColorRGBA(0.1f, 0.1f, 0.1f, 0f),
|
||||
new ColorRGBA(0.5f, 0.5f, 0.5f, .8f),
|
||||
new Vector3f(0, 2f, 0),
|
||||
50,
|
||||
0.1f,
|
||||
0.5f,
|
||||
1f,
|
||||
1.5f,
|
||||
0.5f,
|
||||
new Vector3f(0, 0, 0)
|
||||
);
|
||||
debris.setLocalTranslation(pos);
|
||||
|
||||
debris.emitAllParticles();
|
||||
debris.setParticlesPerSec(0);
|
||||
|
||||
return debris;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the specified splash effect from the scene.
|
||||
*
|
||||
* @param splash the Geometry representing the splash effect to be deleted
|
||||
*/
|
||||
private void deleteSplash(Geometry splash) {
|
||||
splash.getParent().detachChild(splash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops all particle effects associated with the specified Battleship.
|
||||
*
|
||||
* @param ship the Battleship whose effects are to be destroyed
|
||||
*/
|
||||
public void destroyShip(Battleship ship) {
|
||||
for (ParticleEmitter emitter : effects.get(ship)) {
|
||||
emitter.setParticlesPerSec(0);
|
||||
}
|
||||
}
|
||||
|
||||
private ParticleEmitter initializeParticleEmitter(
|
||||
String texturePath, int imagesX, int imagesY, ColorRGBA endColor, ColorRGBA startColor, Vector3f initialVelocity,
|
||||
int particleCount, float startSize, float endSize, float lowLife, float highLife,
|
||||
float velocityVariation, Vector3f gravity
|
||||
) {
|
||||
ParticleEmitter emitter = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, particleCount);
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||
mat.setTexture("Texture", app.getAssetManager().loadTexture(texturePath));
|
||||
emitter.setMaterial(mat);
|
||||
emitter.setImagesX(imagesX);
|
||||
emitter.setImagesY(imagesY);
|
||||
emitter.setEndColor(endColor);
|
||||
emitter.setStartColor(startColor);
|
||||
emitter.getParticleInfluencer().setInitialVelocity(initialVelocity);
|
||||
emitter.setStartSize(startSize);
|
||||
emitter.setEndSize(endSize);
|
||||
emitter.setLowLife(lowLife);
|
||||
emitter.setHighLife(highLife);
|
||||
emitter.getParticleInfluencer().setVelocityVariation(velocityVariation);
|
||||
emitter.setGravity(gravity);
|
||||
|
||||
return emitter;
|
||||
}
|
||||
}
|
||||
@@ -1,170 +1,114 @@
|
||||
////////////////////////////////////////
|
||||
// Programming project code
|
||||
// UniBw M, 2022, 2023, 2024
|
||||
// www.unibw.de/inf2
|
||||
// (c) Mark Minas (mark.minas@unibw.de)
|
||||
////////////////////////////////////////
|
||||
|
||||
package pp.battleship.client;
|
||||
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import com.jme3.asset.AssetLoadException;
|
||||
import com.jme3.asset.AssetNotFoundException;
|
||||
import com.jme3.audio.AudioData;
|
||||
import com.jme3.audio.AudioNode;
|
||||
import com.jme3.audio.AudioSource;
|
||||
import pp.battleship.notification.GameEventListener;
|
||||
import pp.battleship.notification.SoundEvent;
|
||||
|
||||
import java.lang.System.Logger;
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import static pp.JmeUtil.loadSound;
|
||||
import static pp.util.PreferencesUtils.getPreferences;
|
||||
|
||||
/**
|
||||
* An application state that plays music.
|
||||
* An application state that plays sounds.
|
||||
*/
|
||||
public class GameMusic extends AbstractAppState implements GameEventListener {
|
||||
private static final Logger LOGGER = System.getLogger(GameMusic.class.getName());
|
||||
|
||||
public class GameMusic extends AbstractAppState {
|
||||
private static final Preferences PREFERENCES = getPreferences(GameMusic.class);
|
||||
private static final String ENABLED_PREF = "toggle"; //NON-NLS
|
||||
private static final String SLIDER_PREF = "slider"; //NON-NLS
|
||||
private static final String ENABLED_PREF = "enabled";
|
||||
private static final String VOLUME_PREF = "volume";
|
||||
|
||||
private AudioNode music;
|
||||
private boolean enabled;
|
||||
private static final String MUSIC_PATH = "Sound/background.wav";
|
||||
|
||||
private AudioNode backgroundMusic;
|
||||
private float volume;
|
||||
|
||||
public GameMusic(Application app, String musicFilePath) {
|
||||
this.enabled = PREFERENCES.getBoolean(ENABLED_PREF, true);
|
||||
this.volume = PREFERENCES.getFloat(SLIDER_PREF, 2.0f);
|
||||
|
||||
music = new AudioNode(app.getAssetManager(), musicFilePath, AudioData.DataType.Stream);
|
||||
music.setLooping(true);
|
||||
music.setPositional(false);
|
||||
music.setVolume(1.0f);
|
||||
|
||||
if(enabled) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if music is enabled in the preferences.
|
||||
* Returns whether the music is enabled in the user preferences.
|
||||
*
|
||||
* @return {@code true} if music is enabled, {@code false} otherwise.
|
||||
* @return true if music is enabled, false otherwise
|
||||
*/
|
||||
public static boolean enabledInPreferences() {
|
||||
return PREFERENCES.getBoolean(ENABLED_PREF, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the volume value that is set in the preferences.
|
||||
* Returns the music volume level stored in the user preferences.
|
||||
*
|
||||
* @return {@code true} if sound is enabled, {@code false} otherwise.
|
||||
* @return the volume level as a float (default is 0.5f)
|
||||
*/
|
||||
public static float volumeInPreferences() {
|
||||
return PREFERENCES.getFloat(SLIDER_PREF, 2.0f);
|
||||
return PREFERENCES.getFloat(VOLUME_PREF, 0.5f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the game music on or off.
|
||||
* Initializes the game music system
|
||||
*
|
||||
* @param stateManager the state manager of the game
|
||||
* @param app the main application
|
||||
*/
|
||||
public void toggleMusic() {
|
||||
setEnabled(!isEnabled());
|
||||
@Override
|
||||
public void initialize(AppStateManager stateManager, Application app) {
|
||||
super.initialize(stateManager, app);
|
||||
backgroundMusic = loadSound(app, MUSIC_PATH);
|
||||
setMusicVolume(volumeInPreferences());
|
||||
if (isEnabled()) playMusic();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled state of this AppState.
|
||||
* Overrides {@link AbstractAppState#setEnabled(boolean)}
|
||||
* Overrides {@link com.jme3.app.state.AbstractAppState#setEnabled(boolean)}
|
||||
*
|
||||
* @param enabled {@code true} to enable the AppState, {@code false} to disable it.
|
||||
*/
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
super.setEnabled(enabled);
|
||||
|
||||
if(enabled) {
|
||||
start();
|
||||
} else {
|
||||
stop();
|
||||
if (enabled && !isEnabled()) {
|
||||
playMusic();
|
||||
}
|
||||
|
||||
LOGGER.log(Level.INFO, "Music enabled: {0}", enabled); //NON-NLS
|
||||
else if (!enabled && isEnabled()) {
|
||||
stopMusic();
|
||||
}
|
||||
super.setEnabled(enabled);
|
||||
PREFERENCES.putBoolean(ENABLED_PREF, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the volume for the music
|
||||
*
|
||||
* @param volume the new volume to be set
|
||||
* Plays the background music.
|
||||
*/
|
||||
public void setVolume(float volume) {
|
||||
public void playMusic() {
|
||||
if (backgroundMusic != null) {
|
||||
backgroundMusic.play();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops background music.
|
||||
*/
|
||||
public void stopMusic() {
|
||||
if (backgroundMusic != null) {
|
||||
backgroundMusic.stop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the volume of the background music and saves the volume setting in user preferences.
|
||||
*
|
||||
* @param volume the volume level to set (0.0f to 1.0f)
|
||||
*/
|
||||
public void setMusicVolume(float volume) {
|
||||
if (backgroundMusic != null) {
|
||||
backgroundMusic.setVolume(volume);
|
||||
this.volume = volume;
|
||||
music.setVolume(volume);
|
||||
|
||||
LOGGER.log(Level.INFO, "Volume set to: {0}", volume); //NON-NLS
|
||||
PREFERENCES.putFloat(SLIDER_PREF, volume);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a music from the specified file.
|
||||
*
|
||||
* @param app The application
|
||||
* @param name The name of the sound file.
|
||||
* @return The loaded AudioNode.
|
||||
*/
|
||||
private AudioNode loadSound(Application app, String name) {
|
||||
try {
|
||||
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
|
||||
sound.setLooping(false);
|
||||
sound.setPositional(false);
|
||||
return sound;
|
||||
}
|
||||
catch (AssetLoadException | AssetNotFoundException ex) {
|
||||
LOGGER.log(Level.ERROR, ex.getMessage(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the music.
|
||||
*/
|
||||
public void start() {
|
||||
if (enabled && (music.getStatus() == AudioSource.Status.Stopped || music.getStatus() == AudioSource.Status.Paused)) {
|
||||
music.play();
|
||||
PREFERENCES.putFloat(VOLUME_PREF, volume);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the music.
|
||||
*/
|
||||
public void stop() {
|
||||
if (music.getStatus() == AudioSource.Status.Playing) {
|
||||
music.stop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the volume
|
||||
*
|
||||
* @return float the current volume
|
||||
* Returns volume stored in class
|
||||
* @return volume
|
||||
*/
|
||||
public float getVolume() {
|
||||
return volume;
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if music should be played or not
|
||||
*
|
||||
* @return boolean value if music is enabled
|
||||
*/
|
||||
public boolean isMusicEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import com.jme3.asset.AssetLoadException;
|
||||
import com.jme3.asset.AssetNotFoundException;
|
||||
import com.jme3.audio.AudioData;
|
||||
import com.jme3.audio.AudioNode;
|
||||
import pp.battleship.notification.GameEventListener;
|
||||
import pp.battleship.notification.SoundEvent;
|
||||
@@ -21,6 +18,7 @@
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import static pp.JmeUtil.loadSound;
|
||||
import static pp.util.PreferencesUtils.getPreferences;
|
||||
|
||||
/**
|
||||
@@ -34,7 +32,7 @@ public class GameSound extends AbstractAppState implements GameEventListener {
|
||||
private AudioNode splashSound;
|
||||
private AudioNode shipDestroyedSound;
|
||||
private AudioNode explosionSound;
|
||||
private AudioNode missleSound;
|
||||
private AudioNode shellFlyingSound;
|
||||
|
||||
/**
|
||||
* Checks if sound is enabled in the preferences.
|
||||
@@ -79,27 +77,16 @@ public void initialize(AppStateManager stateManager, Application app) {
|
||||
shipDestroyedSound = loadSound(app, "Sound/Effects/sunken.wav"); //NON-NLS
|
||||
splashSound = loadSound(app, "Sound/Effects/splash.wav"); //NON-NLS
|
||||
explosionSound = loadSound(app, "Sound/Effects/explosion.wav"); //NON-NLS
|
||||
missleSound = loadSound(app, "Sound/Effects/missle.wav");
|
||||
shellFlyingSound = loadSound(app, "Sound/Effects/shell_flying.wav");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a sound from the specified file.
|
||||
*
|
||||
* @param app The application
|
||||
* @param name The name of the sound file.
|
||||
* @return The loaded AudioNode.
|
||||
* Plays the shell flying sound effect.
|
||||
*/
|
||||
private AudioNode loadSound(Application app, String name) {
|
||||
try {
|
||||
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
|
||||
sound.setLooping(false);
|
||||
sound.setPositional(false);
|
||||
return sound;
|
||||
public void shellFly() {
|
||||
if (isEnabled() && shellFlyingSound != null) {
|
||||
shellFlyingSound.playInstance();
|
||||
}
|
||||
catch (AssetLoadException | AssetNotFoundException ex) {
|
||||
LOGGER.log(Level.ERROR, ex.getMessage(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,14 +97,6 @@ public void splash() {
|
||||
splashSound.playInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays the missle flyby sound effect.
|
||||
*/
|
||||
public void flyBy() {
|
||||
if (isEnabled() && missleSound != null)
|
||||
missleSound.playInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays the explosion sound effect.
|
||||
*/
|
||||
@@ -140,7 +119,7 @@ public void receivedEvent(SoundEvent event) {
|
||||
case EXPLOSION -> explosion();
|
||||
case SPLASH -> splash();
|
||||
case DESTROYED_SHIP -> shipDestroyed();
|
||||
case MISSLE_FLYBY -> flyBy();
|
||||
case SHELL_FLYING -> shellFly();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
|
||||
package pp.battleship.client;
|
||||
|
||||
import com.simsilica.lemur.*;
|
||||
import com.simsilica.lemur.core.VersionedReference;
|
||||
import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Checkbox;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.dialog.StateCheckboxModel;
|
||||
@@ -32,8 +33,7 @@ class Menu extends Dialog {
|
||||
private final BattleshipApp app;
|
||||
private final Button loadButton = new Button(lookup("menu.map.load"));
|
||||
private final Button saveButton = new Button(lookup("menu.map.save"));
|
||||
|
||||
private final VersionedReference<Double> volumeRef;
|
||||
private final VolumeSlider volumeSlider;
|
||||
|
||||
/**
|
||||
* Constructs the Menu dialog for the Battleship application.
|
||||
@@ -43,27 +43,18 @@ class Menu extends Dialog {
|
||||
public Menu(BattleshipApp app) {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
volumeSlider = new VolumeSlider(app.getStateManager().getState(GameMusic.class));
|
||||
|
||||
addChild(new Label(lookup("battleship.name"), new ElementId("header"))); //NON-NLS
|
||||
addChild(new Checkbox(lookup("menu.sound-enabled"),
|
||||
new StateCheckboxModel(app, GameSound.class)));
|
||||
addChild(new Checkbox(lookup("menu.music-enabled"), new StateCheckboxModel(app, GameMusic.class)));
|
||||
addChild(volumeSlider);
|
||||
|
||||
addChild(loadButton)
|
||||
.addClickCommands(s -> ifTopDialog(this::loadDialog));
|
||||
addChild(saveButton)
|
||||
.addClickCommands(s -> ifTopDialog(this::saveDialog));
|
||||
|
||||
Checkbox musicToggle = new Checkbox(lookup("menu.music.toggle"));
|
||||
musicToggle.setChecked(app.getGameMusic().isMusicEnabled());
|
||||
musicToggle.addClickCommands(s -> toggleMusic());
|
||||
|
||||
addChild(musicToggle);
|
||||
|
||||
Slider volumeSlider = new Slider(lookup("menu.music.slider"));
|
||||
volumeSlider.setModel(new DefaultRangedValueModel(0.0 , 4.0, app.getGameMusic().getVolume()));
|
||||
volumeSlider.setDelta(0.4);
|
||||
addChild(volumeSlider);
|
||||
|
||||
volumeRef = volumeSlider.getModel().createReference();
|
||||
|
||||
addChild(new Button(lookup("menu.return-to-game")))
|
||||
.addClickCommands(s -> ifTopDialog(this::close));
|
||||
addChild(new Button(lookup("menu.quit")))
|
||||
@@ -72,33 +63,17 @@ public Menu(BattleshipApp app) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the state of the load/save buttons and volume based on the game logic.
|
||||
* Updates the state of the load and save buttons based on the game logic.
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
loadButton.setEnabled(app.getGameLogic().mayLoadMap());
|
||||
saveButton.setEnabled(app.getGameLogic().maySaveMap());
|
||||
|
||||
if(volumeRef.update()){
|
||||
double newVolume = volumeRef.get();
|
||||
adjustVolume(newVolume);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* this method adjust the volume for the background music
|
||||
*
|
||||
* @param volume is the double value of the volume
|
||||
*/
|
||||
private void adjustVolume(double volume) {
|
||||
app.getGameMusic().setVolume((float) volume);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method toggles the background music on and off
|
||||
*/
|
||||
private void toggleMusic() {
|
||||
app.getGameMusic().toggleMusic();
|
||||
@Override
|
||||
public void update(float delta) {
|
||||
volumeSlider.update();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.TextField;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
import pp.battleship.client.clienthost.BattleshipServerClient;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.dialog.DialogBuilder;
|
||||
import pp.dialog.SimpleDialog;
|
||||
@@ -37,8 +38,10 @@ class NetworkDialog extends SimpleDialog {
|
||||
private String hostname;
|
||||
private int portNumber;
|
||||
private Future<Object> connectionFuture;
|
||||
private Future<Object> serverFuture;
|
||||
private Dialog progressDialog;
|
||||
private boolean hostServer = false;
|
||||
private BattleshipServerClient server;
|
||||
private final Checkbox clientHostCheckbox;
|
||||
|
||||
/**
|
||||
* Constructs a new NetworkDialog.
|
||||
@@ -52,22 +55,18 @@ class NetworkDialog extends SimpleDialog {
|
||||
host.setPreferredWidth(400f);
|
||||
port.setSingleLine(true);
|
||||
|
||||
Checkbox serverHost = new Checkbox(lookup("menu.host"));
|
||||
serverHost.setChecked(false);
|
||||
serverHost.addClickCommands(s -> toggleServerHost());
|
||||
addChild(serverHost);
|
||||
|
||||
final BattleshipApp app = network.getApp();
|
||||
final Container input = new Container(new SpringGridLayout());
|
||||
input.addChild(new Label(lookup("host.name") + ": "));
|
||||
input.addChild(host, 1);
|
||||
input.addChild(new Label(lookup("port.number") + ": "));
|
||||
input.addChild(port, 1);
|
||||
|
||||
clientHostCheckbox = new Checkbox("Host Server");
|
||||
input.addChild(clientHostCheckbox);
|
||||
DialogBuilder.simple(app.getDialogManager())
|
||||
.setTitle(lookup("server.dialog"))
|
||||
.setExtension(d -> d.addChild(input))
|
||||
.setOkButton(lookup("button.connect"), d -> connectLocally())
|
||||
.setOkButton(lookup("button.connect"), d -> connect())
|
||||
.setNoButton(lookup("button.cancel"), app::closeApp)
|
||||
.setOkClose(false)
|
||||
.setNoClose(false)
|
||||
@@ -84,48 +83,22 @@ private void connect() {
|
||||
hostname = host.getText().trim().isEmpty() ? LOCALHOST : host.getText();
|
||||
portNumber = Integer.parseInt(port.getText());
|
||||
openProgressDialog();
|
||||
|
||||
if (clientHostCheckbox.isChecked()) {
|
||||
serverFuture = network.getApp().getExecutor().submit(this::initServer);
|
||||
|
||||
while (server == null || !server.isReady()) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
connectionFuture = network.getApp().getExecutor().submit(this::initNetwork);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
network.getApp().errorDialog(lookup("port.must.be.integer"));
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a server or if not host connects to one
|
||||
*/
|
||||
private void connectLocally() {
|
||||
if(hostServer){
|
||||
startServer();
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a host server in a new thread
|
||||
*/
|
||||
private void startServer() {
|
||||
new Thread(() -> {
|
||||
try{
|
||||
BattleshipServer battleshipServer = new BattleshipServer();
|
||||
battleshipServer.run();
|
||||
} catch (Exception e) {
|
||||
LOGGER.log(Level.ERROR,e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles client/host mode
|
||||
*/
|
||||
private void toggleServerHost(){
|
||||
hostServer = !hostServer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,6 +126,23 @@ private Object initNetwork() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to initialize the server hosted by the client.
|
||||
*
|
||||
* @throws RuntimeException If an error occurs when starting the server.
|
||||
*/
|
||||
private Object initServer() {
|
||||
try {
|
||||
server = new BattleshipServerClient();
|
||||
server.run(Integer.parseInt(port.getText()));
|
||||
return null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOGGER.log(Level.ERROR, "Error while starting server", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by {@linkplain pp.dialog.DialogManager#update(float)} for periodically
|
||||
* updating this dialog. T
|
||||
@@ -171,6 +161,19 @@ public void update(float delta) {
|
||||
LOGGER.log(Level.WARNING, "Interrupted!", e); //NON-NLS
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
if (serverFuture != null && serverFuture.isDone()) {
|
||||
try {
|
||||
serverFuture.get();
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
LOGGER.log(Level.ERROR, "Failed to start server", e.getCause());
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
LOGGER.log(Level.WARNING, "Server thread was interrupted", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package pp.battleship.client;
|
||||
|
||||
import com.simsilica.lemur.Slider;
|
||||
|
||||
/**
|
||||
* Represents a volume slider for controlling the background music volume in the Battleship game.
|
||||
* This class extends the {@link Slider} class and interfaces with the {@link GameMusic} instance
|
||||
* to adjust the volume settings based on user input.
|
||||
*/
|
||||
public class VolumeSlider extends Slider {
|
||||
private final GameMusic gameMusic;
|
||||
private float volume;
|
||||
|
||||
/**
|
||||
* Constructs a new VolumeSlider instance and initializes it with the current volume level
|
||||
* from the game music preferences.
|
||||
*
|
||||
* @param gameMusic the instance of {@link GameMusic} to control music volume
|
||||
*/
|
||||
public VolumeSlider(GameMusic gameMusic) {
|
||||
super();
|
||||
this.gameMusic = gameMusic;
|
||||
volume = gameMusic.getVolume();
|
||||
getModel().setPercent(volume);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the volume setting based on the current slider position.
|
||||
* If the slider's percent value has changed, it updates the music volume
|
||||
* in the associated {@link GameMusic} instance.
|
||||
*/
|
||||
public void update() {
|
||||
if (getModel().getPercent() != volume) {
|
||||
this.volume = (float) getModel().getPercent();
|
||||
gameMusic.setMusicVolume(volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,19 +5,27 @@
|
||||
// (c) Mark Minas (mark.minas@unibw.de)
|
||||
////////////////////////////////////////
|
||||
|
||||
package pp.battleship.client;
|
||||
package pp.battleship.client.clienthost;
|
||||
|
||||
import com.jme3.network.*;
|
||||
import com.jme3.network.ConnectionListener;
|
||||
import com.jme3.network.HostedConnection;
|
||||
import com.jme3.network.Message;
|
||||
import com.jme3.network.MessageListener;
|
||||
import com.jme3.network.Network;
|
||||
import com.jme3.network.Server;
|
||||
import com.jme3.network.serializing.Serializer;
|
||||
import pp.battleship.BattleshipConfig;
|
||||
import pp.battleship.game.server.Player;
|
||||
import pp.battleship.game.server.ServerGameLogic;
|
||||
import pp.battleship.game.server.ServerSender;
|
||||
import pp.battleship.message.client.AnimationEndMessage;
|
||||
import pp.battleship.message.client.AnimationFinishedMessage;
|
||||
import pp.battleship.message.client.ClientMessage;
|
||||
import pp.battleship.message.client.MapMessage;
|
||||
import pp.battleship.message.client.ShootMessage;
|
||||
import pp.battleship.message.server.*;
|
||||
import pp.battleship.message.server.EffectMessage;
|
||||
import pp.battleship.message.server.GameDetails;
|
||||
import pp.battleship.message.server.ServerMessage;
|
||||
import pp.battleship.message.server.StartBattleMessage;
|
||||
import pp.battleship.model.Battleship;
|
||||
import pp.battleship.model.IntPoint;
|
||||
import pp.battleship.model.Shot;
|
||||
@@ -34,14 +42,14 @@
|
||||
/**
|
||||
* Server implementing the visitor pattern as MessageReceiver for ClientMessages
|
||||
*/
|
||||
public class BattleshipServer implements MessageListener<HostedConnection>, ConnectionListener, ServerSender {
|
||||
private static final Logger LOGGER = System.getLogger(BattleshipServer.class.getName());
|
||||
public class BattleshipServerClient implements MessageListener<HostedConnection>, ConnectionListener, ServerSender {
|
||||
private static final Logger LOGGER = System.getLogger(BattleshipServerClient.class.getName());
|
||||
private static final File CONFIG_FILE = new File("server.properties");
|
||||
|
||||
private final BattleshipConfig config = new BattleshipConfig();
|
||||
private Server myServer;
|
||||
private final ServerGameLogic logic;
|
||||
private final BlockingQueue<ReceivedMessage> pendingMessages = new LinkedBlockingQueue<>();
|
||||
private final BlockingQueue<ReceivedMessageClient> pendingMessages = new LinkedBlockingQueue<>();
|
||||
|
||||
static {
|
||||
// Configure logging
|
||||
@@ -56,31 +64,40 @@ public class BattleshipServer implements MessageListener<HostedConnection>, Conn
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Battleships server.
|
||||
* Creates the server and reads the configuration from the specified file.
|
||||
* Initializes the game logic and sets up logging.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new BattleshipServer().run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the server.
|
||||
*/
|
||||
BattleshipServer() {
|
||||
public BattleshipServerClient() {
|
||||
config.readFromIfExists(CONFIG_FILE);
|
||||
LOGGER.log(Level.INFO, "Configuration: {0}", config); //NON-NLS
|
||||
logic = new ServerGameLogic(this, config);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
startServer();
|
||||
/**
|
||||
* Checks if the server is ready.
|
||||
*
|
||||
* @return true if the server is running, false otherwise
|
||||
*/
|
||||
public boolean isReady() {
|
||||
return myServer != null && myServer.isRunning();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the server and continuously processes incoming messages.
|
||||
*/
|
||||
public void run(int port) {
|
||||
startServer(port);
|
||||
while (true)
|
||||
processNextMessage();
|
||||
}
|
||||
|
||||
private void startServer() {
|
||||
/**
|
||||
* Starts the server by creating a network server on the specified port.
|
||||
*/
|
||||
private void startServer(int port) {
|
||||
try {
|
||||
LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS
|
||||
myServer = Network.createServer(config.getPort());
|
||||
myServer = Network.createServer(port);
|
||||
initializeSerializables();
|
||||
myServer.start();
|
||||
registerListeners();
|
||||
@@ -92,6 +109,9 @@ private void startServer() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the next message in the queue.
|
||||
*/
|
||||
private void processNextMessage() {
|
||||
try {
|
||||
pendingMessages.take().process(logic);
|
||||
@@ -102,24 +122,28 @@ private void processNextMessage() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all serializable message classes for network transmission.
|
||||
*/
|
||||
private void initializeSerializables() {
|
||||
Serializer.registerClass(AnimationEndMessage.class);
|
||||
Serializer.registerClass(AnimationStartMessage.class);
|
||||
Serializer.registerClass(SwitchBattleState.class);
|
||||
Serializer.registerClass(GameDetails.class);
|
||||
Serializer.registerClass(StartBattleMessage.class);
|
||||
Serializer.registerClass(MapMessage.class);
|
||||
Serializer.registerClass(ShootMessage.class);
|
||||
Serializer.registerClass(EffectMessage.class);
|
||||
Serializer.registerClass(AnimationFinishedMessage.class);
|
||||
Serializer.registerClass(Battleship.class);
|
||||
Serializer.registerClass(IntPoint.class);
|
||||
Serializer.registerClass(Shot.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the message and connection listeners for the server.
|
||||
*/
|
||||
private void registerListeners() {
|
||||
myServer.addMessageListener(this, AnimationEndMessage.class);
|
||||
myServer.addMessageListener(this, MapMessage.class);
|
||||
myServer.addMessageListener(this, ShootMessage.class);
|
||||
myServer.addMessageListener(this, AnimationFinishedMessage.class);
|
||||
myServer.addConnectionListener(this);
|
||||
}
|
||||
|
||||
@@ -127,7 +151,7 @@ private void registerListeners() {
|
||||
public void messageReceived(HostedConnection source, Message message) {
|
||||
LOGGER.log(Level.INFO, "message received from {0}: {1}", source.getId(), message); //NON-NLS
|
||||
if (message instanceof ClientMessage clientMessage)
|
||||
pendingMessages.add(new ReceivedMessage(clientMessage, source.getId()));
|
||||
pendingMessages.add(new ReceivedMessageClient(clientMessage, source.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,6 +172,11 @@ public void connectionRemoved(Server server, HostedConnection hostedConnection)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the server and closes all active connections.
|
||||
*
|
||||
* @param exitValue the exit code to terminate the program with
|
||||
*/
|
||||
private void exit(int exitValue) { //NON-NLS
|
||||
LOGGER.log(Level.INFO, "close request"); //NON-NLS
|
||||
if (myServer != null)
|
||||
@@ -5,12 +5,12 @@
|
||||
// (c) Mark Minas (mark.minas@unibw.de)
|
||||
////////////////////////////////////////
|
||||
|
||||
package pp.battleship.client;
|
||||
package pp.battleship.client.clienthost;
|
||||
|
||||
import pp.battleship.message.client.ClientInterpreter;
|
||||
import pp.battleship.message.client.ClientMessage;
|
||||
|
||||
record ReceivedMessage(ClientMessage message, int from) {
|
||||
record ReceivedMessageClient(ClientMessage message, int from) {
|
||||
void process(ClientInterpreter interpreter) {
|
||||
message.accept(interpreter, from);
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
* and interaction between the model and the view.
|
||||
*/
|
||||
class MapView {
|
||||
private static final float FIELD_SIZE = 40f;
|
||||
public static final float FIELD_SIZE = 40f;
|
||||
private static final float GRID_LINE_WIDTH = 2f;
|
||||
private static final float BACKGROUND_DEPTH = -4f;
|
||||
private static final float GRID_DEPTH = -1f;
|
||||
|
||||
@@ -7,17 +7,21 @@
|
||||
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
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.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Sphere;
|
||||
import pp.battleship.model.Battleship;
|
||||
import pp.battleship.model.IntPoint;
|
||||
import pp.battleship.model.Shell;
|
||||
import pp.battleship.model.Shot;
|
||||
import pp.util.Position;
|
||||
|
||||
import static com.jme3.material.Materials.UNSHADED;
|
||||
|
||||
/**
|
||||
* Synchronizes the visual representation of the ship map with the game model.
|
||||
* It handles the rendering of ships and shots on the map view, updating the view
|
||||
@@ -28,11 +32,8 @@ class MapViewSynchronizer extends ShipMapSynchronizer {
|
||||
private static final float SHIP_LINE_WIDTH = 6f;
|
||||
private static final float SHOT_DEPTH = -2f;
|
||||
private static final float SHIP_DEPTH = 0f;
|
||||
private static final float SHELL_DEPTH = 1f;
|
||||
private static final float INDENT = 4f;
|
||||
private static final float SHELL_DEPTH = 8f;
|
||||
private static final float SHELL_SIZE = 0.75f;
|
||||
private static final float SHELL_CENTERED_IN_MAP_GRID = 0.0625f;
|
||||
|
||||
|
||||
// Colors used for different visual elements
|
||||
private static final ColorRGBA HIT_COLOR = ColorRGBA.Red;
|
||||
@@ -117,28 +118,25 @@ public Spatial visit(Battleship ship) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a visual representation of a shell on the map.
|
||||
* Creates and returns a Spatial representation of the given {@code Shell} object
|
||||
* for 2D visualization in the game. The shell is represented as a circle.
|
||||
*
|
||||
* @param shell the Shell object representing the shell in the model
|
||||
* @return a Spatial representing the shell
|
||||
* @param shell The {@code Shell} object to be visualized.
|
||||
* @return A {@code Spatial} object representing the shell on the map.
|
||||
*/
|
||||
@Override
|
||||
public Spatial visit(Shell shell) {
|
||||
final Node shellNode = new Node("shell");
|
||||
|
||||
final Position p1 = view.modelToView(shell.getX(), shell.getY());
|
||||
final Position p2 = view.modelToView(shell.getX() + SHELL_SIZE, shell.getY() + SHELL_SIZE);
|
||||
|
||||
final Position startPosition = view.modelToView(SHELL_CENTERED_IN_MAP_GRID, SHELL_CENTERED_IN_MAP_GRID);
|
||||
|
||||
shellNode.attachChild(view.getApp().getDraw().makeRectangle(startPosition.getX(), startPosition.getY(), SHELL_DEPTH, p2.getX() - p1.getX(), p2.getY() - p1.getY(), ColorRGBA.Magenta));
|
||||
shellNode.setLocalTranslation(startPosition.getX(), startPosition.getY(), SHELL_DEPTH);
|
||||
shellNode.addControl(new ShellControlMap(p1, view.getApp(), new IntPoint(shell.getX(), shell.getY())));
|
||||
return shellNode;
|
||||
|
||||
final ColorRGBA color = ColorRGBA.Black;
|
||||
Geometry ellipse = new Geometry("ellipse", new Sphere(50, 50, MapView.FIELD_SIZE / 2 * 0.8f));
|
||||
Material mat = new Material(view.getApp().getAssetManager(), UNSHADED); //NON-NLS
|
||||
mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
||||
mat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
|
||||
mat.setColor("Color", color);
|
||||
ellipse.setMaterial(mat);
|
||||
ellipse.addControl(new Shell2DControl(view, shell));
|
||||
return ellipse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a line geometry representing part of the ship's border.
|
||||
*
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
import com.jme3.effect.ParticleEmitter;
|
||||
import com.jme3.effect.ParticleMesh;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import com.jme3.scene.control.Control;
|
||||
import pp.battleship.client.BattleshipApp;
|
||||
import pp.battleship.model.Shot;
|
||||
|
||||
public class ParticleHandler {
|
||||
private final BattleshipApp app;
|
||||
static final System.Logger LOGGER = System.getLogger(ParticleHandler.class.getName());
|
||||
|
||||
private Material material;
|
||||
|
||||
/**
|
||||
* Constructs a new ParticleHandler
|
||||
*
|
||||
* @param app the main battleship application
|
||||
*/
|
||||
public ParticleHandler(BattleshipApp app) {
|
||||
this.app = app;
|
||||
material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is used to create a hit effect at the position of a node
|
||||
*
|
||||
* @param node the node of the battleship where the effect should be attached to
|
||||
* @param shot the shot that hit a target
|
||||
*/
|
||||
public void createHitParticles(Node node, Shot shot) {
|
||||
ParticleEmitter smokeParticles = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,1000);
|
||||
smokeParticles.setMaterial(material);
|
||||
smokeParticles.setImagesX(2);
|
||||
smokeParticles.setImagesY(2);
|
||||
smokeParticles.setStartColor(ColorRGBA.Orange);
|
||||
smokeParticles.setEndColor(ColorRGBA.Black);
|
||||
smokeParticles.getParticleInfluencer().setInitialVelocity(new Vector3f(0,0.8f,0));
|
||||
smokeParticles.setStartSize(0.5f);
|
||||
smokeParticles.setEndSize(0.04f);
|
||||
smokeParticles.setGravity(0, -0.1f, 0);
|
||||
smokeParticles.setLowLife(1f);
|
||||
smokeParticles.setHighLife(4f);
|
||||
smokeParticles.setParticlesPerSec(0);
|
||||
smokeParticles.setLocalTranslation(shot.getY() + 0.5f, 0 , shot.getX() + 0.5f);
|
||||
smokeParticles.emitAllParticles();
|
||||
|
||||
ParticleEmitter particles2 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,300);
|
||||
particles2.setMaterial(material);
|
||||
particles2.setImagesX(2);
|
||||
particles2.setImagesY(2);
|
||||
particles2.setStartColor(ColorRGBA.Orange);
|
||||
particles2.setEndColor(ColorRGBA.Yellow);
|
||||
particles2.getParticleInfluencer().setInitialVelocity(new Vector3f(0,2,0));
|
||||
particles2.setStartSize(0.7f);
|
||||
particles2.setEndSize(0.1f);
|
||||
particles2.setGravity(0, 0, 0);
|
||||
particles2.setLowLife(0.5f);
|
||||
particles2.setHighLife(1.5f);
|
||||
particles2.setParticlesPerSec(0);
|
||||
particles2.setLocalTranslation(shot.getY() + 1f, 0 , shot.getX() + 1f);
|
||||
particles2.emitAllParticles();
|
||||
|
||||
ParticleEmitter particles3 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,300);
|
||||
particles3.setMaterial(material);
|
||||
particles3.setImagesX(1);
|
||||
particles3.setImagesY(1);
|
||||
particles3.setStartColor(ColorRGBA.Red);
|
||||
particles3.setEndColor(ColorRGBA.Gray);
|
||||
particles3.getParticleInfluencer().setInitialVelocity(new Vector3f(0,0.5f,0));
|
||||
particles3.setStartSize(0.8f);
|
||||
particles3.setEndSize(0.1f);
|
||||
particles3.setGravity(0, 0, 0);
|
||||
particles3.setLowLife(0.5f);
|
||||
particles3.setHighLife(0.8f);
|
||||
particles3.setParticlesPerSec(0);
|
||||
particles3.setLocalTranslation(shot.getY() + 1f, 0 , shot.getX() + 1f);
|
||||
particles3.emitAllParticles();
|
||||
|
||||
ParticleEmitter flames = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,300);
|
||||
flames.setMaterial(material);
|
||||
flames.setImagesX(1);
|
||||
flames.setImagesY(1);
|
||||
flames.setStartColor(ColorRGBA.Red);
|
||||
flames.setEndColor(ColorRGBA.Orange);
|
||||
flames.getParticleInfluencer().setInitialVelocity(new Vector3f(0,1.0f,0));
|
||||
flames.setStartSize(0.4f);
|
||||
flames.setEndSize(0.1f);
|
||||
flames.setGravity(0, -0.2f, 0);
|
||||
flames.setLowLife(0.7f);
|
||||
flames.setHighLife(1.5f);
|
||||
flames.setLocalTranslation(shot.getY(), 0 , shot.getX());
|
||||
flames.setLocalTranslation(flames.getLocalTranslation().subtract(node.getLocalTranslation()));
|
||||
flames.setParticlesPerSec(70);
|
||||
|
||||
node.attachChild(smokeParticles);
|
||||
smokeParticles.addControl((Control) new ParticleControl(smokeParticles, node));
|
||||
|
||||
node.attachChild(particles2);
|
||||
particles2.addControl((Control) new ParticleControl(particles2, node));
|
||||
|
||||
node.attachChild(particles3);
|
||||
particles3.addControl((Control) new ParticleControl(particles3, node));
|
||||
|
||||
//node.attachChild(flames);
|
||||
//flames.addControl((Control) new ParticleControl(flames, node));
|
||||
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Hit-particles at {0}", smokeParticles.getLocalTranslation().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a miss effect at a certain location
|
||||
* @param shot the shot that missed
|
||||
* @return A ParticleEmitter
|
||||
*/
|
||||
public ParticleEmitter createMissParticles(Shot shot) {
|
||||
ParticleEmitter particles = new ParticleEmitter("MissEffect", ParticleMesh.Type.Triangle, 200);
|
||||
particles.setMaterial(material);
|
||||
particles.setImagesX(2);
|
||||
particles.setImagesY(2);
|
||||
particles.setStartColor(ColorRGBA.Blue);
|
||||
particles.setEndColor(ColorRGBA.White);
|
||||
particles.getParticleInfluencer().setInitialVelocity(new Vector3f(0.01f, 3f, 0.01f));
|
||||
particles.setStartSize(0.05f);
|
||||
particles.setEndSize(0.4f);
|
||||
particles.setGravity(0, 2f, 0);
|
||||
particles.setLowLife(1.0f);
|
||||
particles.setHighLife(2.2f);
|
||||
particles.setParticlesPerSec(0);
|
||||
particles.setLocalTranslation(shot.getY(), -0.5f , shot.getX());
|
||||
particles.emitAllParticles();
|
||||
|
||||
LOGGER.log(System.Logger.Level.DEBUG, "Miss-particles at {0}", particles.getLocalTranslation().toString());
|
||||
|
||||
return particles;
|
||||
}
|
||||
|
||||
/**
|
||||
* This inner class is used to control the effects
|
||||
*/
|
||||
private static class ParticleControl extends AbstractControl {
|
||||
private final ParticleEmitter emitter;
|
||||
private final Node parentNode;
|
||||
|
||||
/**
|
||||
* this constructor is used to when the particle should be attached to a specific node
|
||||
*
|
||||
* @param emitter the Particle emitter to be controlled
|
||||
* @param parentNode the node to be attached
|
||||
*/
|
||||
public ParticleControl(ParticleEmitter emitter, Node parentNode) {
|
||||
this.emitter = emitter;
|
||||
this.parentNode = parentNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is used when the particle shouldn't be attached to
|
||||
* a specific node
|
||||
*
|
||||
* @param emitter the Particle emitter to be controlled
|
||||
*/
|
||||
public ParticleControl(ParticleEmitter emitter) {
|
||||
this.emitter = emitter;
|
||||
this.parentNode = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method which checks if the particle is not rendered anymore so it can be removed
|
||||
*
|
||||
* @param tpf time per frame (in seconds)
|
||||
*/
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
if (emitter.getParticlesPerSec() == 0 && emitter.getNumVisibleParticles() == 0) {
|
||||
if (parentNode != null)
|
||||
parentNode.detachChild(emitter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rm the RenderManager rendering the controlled Spatial (not null)
|
||||
* @param vp the ViewPort being rendered (not null)
|
||||
*/
|
||||
@Override
|
||||
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,6 @@
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.material.RenderState.BlendMode;
|
||||
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.ShadowMode;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
@@ -20,9 +17,17 @@
|
||||
import com.jme3.scene.shape.Box;
|
||||
import com.jme3.scene.shape.Cylinder;
|
||||
import pp.battleship.client.BattleshipApp;
|
||||
import pp.battleship.model.*;
|
||||
import pp.battleship.model.Battleship;
|
||||
import pp.battleship.model.Rotation;
|
||||
import pp.battleship.model.Shell;
|
||||
import pp.battleship.model.ShipMap;
|
||||
import pp.battleship.model.Shot;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static pp.JmeUtil.mapToWorldCord;
|
||||
import static pp.util.FloatMath.HALF_PI;
|
||||
import static pp.util.FloatMath.PI;
|
||||
|
||||
@@ -34,18 +39,16 @@
|
||||
*/
|
||||
class SeaSynchronizer extends ShipMapSynchronizer {
|
||||
private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS
|
||||
private static final String KING_GEORGE_V_MODEL = "Models/KingGeorgeV/KingGeorgeV.j3o"; //NON-NLS
|
||||
private static final String LIGHTING = "Common/MatDefs/Light/Lighting.j3md";
|
||||
private static final String COLOR = "Color"; //NON-NLS
|
||||
private static final String SHIP = "ship"; //NON-NLS
|
||||
private static final String SHOT = "shot"; //NON-NLS
|
||||
private static final ColorRGBA BOX_COLOR = ColorRGBA.Gray;
|
||||
private static final ColorRGBA SPLASH_COLOR = new ColorRGBA(0f, 0f, 1f, 0.4f);
|
||||
private static final ColorRGBA HIT_COLOR = new ColorRGBA(1f, 0f, 0f, 0.4f);
|
||||
private static final String BOMB = "Models/Bomb/Files/Bomb GBU-43B(MOAB).obj";
|
||||
|
||||
private final ShipMap map;
|
||||
private final BattleshipApp app;
|
||||
private final ParticleHandler handler;
|
||||
|
||||
/**
|
||||
* Constructs a {@code SeaSynchronizer} object with the specified application, root node, and ship map.
|
||||
@@ -58,41 +61,9 @@ public SeaSynchronizer(BattleshipApp app, Node root, ShipMap map) {
|
||||
super(app.getGameLogic().getOwnMap(), root);
|
||||
this.app = app;
|
||||
this.map = map;
|
||||
|
||||
handler = new ParticleHandler(app);
|
||||
|
||||
addExisting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@link Shell} and creates a graphical representation of it.
|
||||
*
|
||||
* @param shell the shell to be represented
|
||||
* @return the graphical representation of the shell
|
||||
*/
|
||||
@Override
|
||||
public Spatial visit(Shell shell) {
|
||||
final Node node = new Node("shell");
|
||||
|
||||
final Spatial model = app.getAssetManager().loadModel(BOMB);
|
||||
|
||||
model.rotate(-PI/2, 0, 0);
|
||||
model.scale(0.09f);
|
||||
model.setShadowMode(ShadowMode.CastAndReceive);
|
||||
model.move(0, 0, 0);
|
||||
|
||||
node.attachChild(model);
|
||||
|
||||
final float x = shell.getY();
|
||||
final float z = shell.getX();
|
||||
|
||||
node.setLocalTranslation(x, 8f, z);
|
||||
ShellControll control = new ShellControll(shell, app);
|
||||
node.addControl(control);
|
||||
return node;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@link Shot} and creates a graphical representation of it.
|
||||
* If the shot is a hit, it attaches the representation to the ship node.
|
||||
@@ -103,7 +74,11 @@ public Spatial visit(Shell shell) {
|
||||
*/
|
||||
@Override
|
||||
public Spatial visit(Shot shot) {
|
||||
return shot.isHit() ? handleHit(shot) : handler.createMissParticles(shot);
|
||||
return shot.isHit() ? handleHit(shot) : handleMiss(shot);
|
||||
}
|
||||
|
||||
private Spatial handleMiss(Shot shot) {
|
||||
return app.getEffectHandler().waterSplash(mapToWorldCord(shot.getX(), shot.getY()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,18 +86,30 @@ public Spatial visit(Shot shot) {
|
||||
* contains the ship model as a child so that it moves with the ship.
|
||||
*
|
||||
* @param shot a hit
|
||||
* @return always null to prevent the representation from being sattached
|
||||
* @return always null to prevent the representation from being attached
|
||||
* to the items node as well
|
||||
*/
|
||||
private Spatial handleHit(Shot shot) {
|
||||
final Battleship ship = requireNonNull(map.findShipAt(shot), "Missing ship");
|
||||
final Node shipNode = requireNonNull((Node) getSpatial(ship), "Missing ship node");
|
||||
shipNode.getControl(ShipControl.class).hit(shot);
|
||||
if (ship.isDestroyed()) {
|
||||
shipNode.getControl(ShipControl.class).destroyed();
|
||||
|
||||
handler.createHitParticles(shipNode, shot);
|
||||
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
handleShipDestroy(shipNode);
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handleShipDestroy(Node shipNode) {
|
||||
shipNode.getParent().detachChild(shipNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a cylinder geometry representing the specified shot.
|
||||
* The appearance of the cylinder depends on whether the shot is a hit or a miss.
|
||||
@@ -161,10 +148,31 @@ public Spatial visit(Battleship ship) {
|
||||
final float x = 0.5f * (ship.getMinY() + ship.getMaxY() + 1f);
|
||||
final float z = 0.5f * (ship.getMinX() + ship.getMaxX() + 1f);
|
||||
node.setLocalTranslation(x, 0f, z);
|
||||
node.addControl(new ShipControl(ship));
|
||||
node.addControl(new ShipControl(ship, node, app.getEffectHandler()));
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a 3D model representation of the given {@code Shell} object
|
||||
* for visualization in the game.
|
||||
*
|
||||
* @param shell The {@code Shell} object to be visualized.
|
||||
* @return A {@code Spatial} object representing the 3D model of the shell.
|
||||
*/
|
||||
@Override
|
||||
public Spatial visit(Shell shell) {
|
||||
final Spatial model = app.getAssetManager().loadModel("Models/Shell/shell.j3o");
|
||||
model.setLocalScale(.05f);
|
||||
model.setShadowMode(ShadowMode.CastAndReceive);
|
||||
Material mat = new Material(app.getAssetManager(), LIGHTING);
|
||||
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture("Models/Shell/shell_color.png"));
|
||||
mat.setReceivesShadows(true);
|
||||
model.setMaterial(mat);
|
||||
|
||||
model.addControl(new ShellControl(shell));
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the appropriate graphical representation of the specified battleship.
|
||||
* The representation is either a detailed model or a simple box based on the length of the ship.
|
||||
@@ -173,33 +181,13 @@ public Spatial visit(Battleship ship) {
|
||||
* @return the spatial representing the battleship
|
||||
*/
|
||||
private Spatial createShip(Battleship ship) {
|
||||
final int len = ship.getLength();
|
||||
|
||||
Quaternion q0 = new Quaternion();
|
||||
|
||||
Quaternion q1 = new Quaternion();
|
||||
q1.fromAngleAxis(PI/2, new Vector3f(1, 0, 0));
|
||||
|
||||
Quaternion q2 = new Quaternion();
|
||||
q2.fromAngleAxis(PI/2, new Vector3f(1, 0, 0));
|
||||
|
||||
switch (len) {
|
||||
case 1 -> {
|
||||
return createBattleship(ship, "Models/Uboat/uboat.j3o", 0.2f, new Vector3f(0.0f, -0.1f, 0.0f), q0);
|
||||
}
|
||||
case 2 -> {
|
||||
return createBattleship(ship, "Models/KingGeorgeV/KingGeorgeV.j3o", 1.0f, new Vector3f(0.0f, 0.0f, 0.0f), q0);
|
||||
}
|
||||
case 3 -> {
|
||||
return createBattleship(ship, "Models/EssexClass/essex.j3o", 0.8f, new Vector3f(0.0f, 0.3f, 0.0f), q2);
|
||||
}
|
||||
case 4 -> {
|
||||
return createBattleship(ship, "Models/Container/container.j3o", 0.05f, new Vector3f(0.0f, 0.0f, 0.0f), q1);
|
||||
}
|
||||
default -> {
|
||||
return createBox(ship);
|
||||
}
|
||||
}
|
||||
return switch (ship.getLength()) {
|
||||
case 1 -> createBattleship(ship, ShipModel.SHIP1);
|
||||
case 2 -> createBattleship(ship, ShipModel.SHIP2);
|
||||
case 3 -> createBattleship(ship, ShipModel.SHIP3);
|
||||
case 4 -> createBattleship(ship, ShipModel.SHIP4);
|
||||
default -> createBox(ship);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,24 +227,28 @@ private Material createColoredMaterial(ColorRGBA color) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a 3D model to represent a "battleship".
|
||||
* Creates a detailed 3D model to represent a "King George V" battleship.
|
||||
*
|
||||
* @param ship the battleship to be represented
|
||||
* @param path the battleship to be represented
|
||||
* @param scale the battleship to be represented
|
||||
* @param translation the battleship to be represented
|
||||
* @param rotation the battleship to be represented
|
||||
* @return the spatial representing the battleship
|
||||
* @return the spatial representing the "King George V" battleship
|
||||
*/
|
||||
private Spatial createBattleship(Battleship ship, String path, float scale, Vector3f translation, Quaternion rotation) {
|
||||
final Spatial model = app.getAssetManager().loadModel(path);
|
||||
private Spatial createBattleship(Battleship ship, ShipModel shipModel) {
|
||||
final Spatial model = app.getAssetManager().loadModel(shipModel.getPath());
|
||||
|
||||
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f);
|
||||
model.rotate(rotation);
|
||||
model.scale(scale);
|
||||
model.setLocalTranslation(translation);
|
||||
model.scale(shipModel.getScale());
|
||||
model.setLocalTranslation(shipModel.getTranslation());
|
||||
model.setShadowMode(ShadowMode.CastAndReceive);
|
||||
|
||||
Material mat = new Material(app.getAssetManager(), LIGHTING);
|
||||
|
||||
String colorPath = shipModel.getColorPath();
|
||||
String bumpPath = shipModel.getBumpPath();
|
||||
if (colorPath != null) mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(colorPath));
|
||||
if (bumpPath != null) mat.setTexture("NormalMap", app.getAssetManager().loadTexture(bumpPath));
|
||||
|
||||
mat.setReceivesShadows(true);
|
||||
model.setMaterial(mat);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import pp.battleship.model.Shell;
|
||||
import pp.util.Position;
|
||||
|
||||
/**
|
||||
* Controls the 2D representation of a {@code Shell} in the game, updating its position
|
||||
* based on the shell's current state in the game model. The {@code Shell2DControl} class
|
||||
* is responsible for translating the shell's 3D position to a 2D view position within
|
||||
* the game's map view.
|
||||
*/
|
||||
public class Shell2DControl extends AbstractControl {
|
||||
private final Shell shell;
|
||||
private final MapView view;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code Shell2DControl} to manage the 2D visualization of the given {@code Shell}.
|
||||
*
|
||||
* @param view The {@code MapView} used to get information about the map to display.
|
||||
* @param shell The {@code Shell} being visualized.
|
||||
*/
|
||||
public Shell2DControl(MapView view, Shell shell){
|
||||
this.shell = shell;
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the position of the shell's 2D representation based on the shell's current
|
||||
* 3D position in the game model. The position is mapped from model space to view space
|
||||
* coordinates and translated to the appropriate location within the {@code MapView}.
|
||||
*
|
||||
* @param tpf Time per frame, representing the time elapsed since the last frame.
|
||||
*/
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
Vector3f shellPos = shell.getPosition();
|
||||
Position viewPos = view.modelToView(shellPos.x, shellPos.z);
|
||||
spatial.setLocalTranslation(viewPos.getX() + MapView.FIELD_SIZE / 2, viewPos.getY() + MapView.FIELD_SIZE / 2, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
// No rendering-specific behavior required for this control
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import pp.battleship.model.Shell;
|
||||
|
||||
import static pp.JmeUtil.mapToWorldCord;
|
||||
import static pp.util.FloatMath.PI;
|
||||
|
||||
/**
|
||||
* Controls the 3D representation of a {@code Shell} in the game, updating its position
|
||||
* and rotation based on the shell's current state in the game model. The {@code ShellControl}
|
||||
* class ensures that the spatial associated with the shell is positioned and oriented correctly
|
||||
* within the world.
|
||||
*/
|
||||
public class ShellControl extends AbstractControl {
|
||||
private final Shell shell;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code ShellControl} to manage the 3D visualization of the given {@code Shell}.
|
||||
*
|
||||
* @param shell The {@code Shell} being visualized and controlled.
|
||||
*/
|
||||
public ShellControl(Shell shell){
|
||||
super();
|
||||
this.shell = shell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the 3D position and rotation of the shell based on its current state.
|
||||
* Converts map coordinates to world coordinates and applies the shell's orientation.
|
||||
*
|
||||
* @param tpf Time per frame, representing the elapsed time since the last update.
|
||||
*/
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
Vector3f pos = shell.getPosition();
|
||||
Vector3f fixed = mapToWorldCord(pos.x, pos.z);
|
||||
fixed.setY(pos.y);
|
||||
spatial.setLocalTranslation(fixed);
|
||||
spatial.setLocalRotation(shell.getRotation());
|
||||
spatial.rotate(PI/2,0,0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
// No rendering-specific behavior required for this control
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import pp.battleship.client.BattleshipApp;
|
||||
import pp.battleship.message.client.AnimationEndMessage;
|
||||
import pp.battleship.model.IntPoint;
|
||||
import pp.util.Position;
|
||||
|
||||
/**
|
||||
* Controls the movement of a shell in a specified position on the battlefield.
|
||||
* This control updates the shell's position and sends a message when it reaches
|
||||
* its target location.
|
||||
*/
|
||||
public class ShellControlMap extends AbstractControl {
|
||||
private final Position position; // Target position for the shell
|
||||
private final IntPoint pos; // Target coordinates as an IntPoint
|
||||
private static final Vector3f vector = new Vector3f(); // Movement vector
|
||||
private final BattleshipApp app; // Reference to the main application
|
||||
|
||||
/**
|
||||
* Constructs a ShellControlMap object with the specified target position,
|
||||
* application instance, and target coordinates.
|
||||
*
|
||||
* @param position The target Position for the shell.
|
||||
* @param app The BattleshipApp instance managing the game logic.
|
||||
* @param pos The IntPoint representing the target coordinates of the shell.
|
||||
*/
|
||||
public ShellControlMap(Position position, BattleshipApp app, IntPoint pos) {
|
||||
super();
|
||||
this.position = position;
|
||||
this.pos = pos;
|
||||
this.app = app;
|
||||
vector.set(new Vector3f(position.getX(), position.getY(), 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the shell's position based on the time per frame.
|
||||
* If the shell reaches or exceeds the target position, it detaches
|
||||
* the shell from the scene and sends an animation end message.
|
||||
*
|
||||
* @param tpf Time per frame, used to calculate movement.
|
||||
*/
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
spatial.move(vector.mult(tpf));
|
||||
if (spatial.getLocalTranslation().getX() >= position.getX() &&
|
||||
spatial.getLocalTranslation().getY() >= position.getY()) {
|
||||
spatial.getParent().detachChild(spatial);
|
||||
app.getGameLogic().send(new AnimationEndMessage(pos));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the shell control. This method can be overridden to implement
|
||||
* custom rendering behavior, but it is currently empty.
|
||||
*
|
||||
* @param rm The RenderManager for rendering the control.
|
||||
* @param vp The ViewPort where the control is rendered.
|
||||
*/
|
||||
@Override
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
// No rendering logic implemented for ShellControlMap
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import pp.battleship.client.BattleshipApp;
|
||||
import pp.battleship.message.client.AnimationEndMessage;
|
||||
import pp.battleship.model.IntPoint;
|
||||
import pp.battleship.model.Shell;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Controls the movement and behavior of a shell in the battleship game.
|
||||
* This control updates the position of the shell and sends a message
|
||||
* when the shell reaches the ground.
|
||||
*/
|
||||
public class ShellControll extends AbstractControl {
|
||||
private final Shell shell;
|
||||
private final BattleshipApp app;
|
||||
|
||||
private static final float MOVE_SPEED = 20.0f; // Speed at which the shell moves
|
||||
|
||||
/**
|
||||
* Constructs a ShellControll object with the specified shell and application instance.
|
||||
*
|
||||
* @param shell The Shell instance to control.
|
||||
* @param app The BattleshipApp instance managing the game logic.
|
||||
*/
|
||||
public ShellControll(Shell shell, BattleshipApp app) {
|
||||
this.shell = shell;
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the shell's position based on the time per frame.
|
||||
* If the shell's position falls below a certain threshold,
|
||||
* it detaches the shell from the scene and sends an animation end message.
|
||||
*
|
||||
* @param tpf Time per frame, used to calculate movement.
|
||||
*/
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
spatial.move(0, -MOVE_SPEED * tpf, 0);
|
||||
if (spatial.getLocalTranslation().getY() <= 0.1f) {
|
||||
spatial.getParent().detachChild(spatial);
|
||||
app.getGameLogic().send(new AnimationEndMessage(new IntPoint(shell.getX(), shell.getY())));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the shell control. This method can be overridden to implement
|
||||
* custom rendering behavior, but it is currently empty.
|
||||
*
|
||||
* @param rm The RenderManager for rendering the control.
|
||||
* @param vp The ViewPort where the control is rendered.
|
||||
*/
|
||||
@Override
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
// No rendering logic implemented for ShellControll
|
||||
}
|
||||
}
|
||||
@@ -11,116 +11,157 @@
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import pp.battleship.client.EffectHandler;
|
||||
import pp.battleship.model.Battleship;
|
||||
import pp.battleship.model.Rotation;
|
||||
import pp.battleship.model.Shot;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import static pp.JmeUtil.mapToWorldCord;
|
||||
import static pp.util.FloatMath.DEG_TO_RAD;
|
||||
import static pp.util.FloatMath.TWO_PI;
|
||||
import static pp.util.FloatMath.sin;
|
||||
|
||||
/**
|
||||
* Controls the oscillating pitch motion of a battleship model in the game.
|
||||
* The ship oscillates to simulate a realistic movement on water, based on its orientation and length.
|
||||
* Controls the pitch oscillation and sinking behavior of a {@code Battleship} model in the game.
|
||||
* The ship tilts back and forth to simulate movement on water, and can also be animated to sink
|
||||
* when destroyed.
|
||||
*/
|
||||
class ShipControl extends AbstractControl {
|
||||
/**
|
||||
* The sinking height, after wich the ship will get removed
|
||||
*/
|
||||
private static final Float SINKING_HEIGHT = -0.6f;
|
||||
private static final float SINK_SPEED = 0.04f;
|
||||
private static final float SINK_ROT_SPEED = 0.1f;
|
||||
|
||||
|
||||
/**
|
||||
* The axis of rotation for the ship's pitch (tilting forward and backward).
|
||||
*/
|
||||
// The axis of rotation for the ship's pitch (tilting).
|
||||
private final Vector3f axis;
|
||||
|
||||
/**
|
||||
* The duration of one complete oscillation cycle in seconds.
|
||||
*/
|
||||
// The duration of one oscillation cycle in seconds.
|
||||
private final float cycle;
|
||||
|
||||
/**
|
||||
* The amplitude of the pitch oscillation in radians, determining how much the ship tilts.
|
||||
*/
|
||||
// The amplitude of the pitch oscillation in radians.
|
||||
private final float amplitude;
|
||||
|
||||
/**
|
||||
* A quaternion representing the ship's current pitch rotation.
|
||||
*/
|
||||
// Quaternion representing the ship's pitch rotation.
|
||||
private final Quaternion pitch = new Quaternion();
|
||||
|
||||
/**
|
||||
* The current time within the oscillation cycle, used to calculate the ship's pitch angle.
|
||||
*/
|
||||
// The current time within the oscillation cycle.
|
||||
private float time;
|
||||
|
||||
/**
|
||||
* The ship, that the ShipControl controls
|
||||
*/
|
||||
private final Battleship ship;
|
||||
// Flag indicating if the ship is sinking.
|
||||
private boolean sinking;
|
||||
|
||||
// The battleship being controlled.
|
||||
private final Battleship battleship;
|
||||
|
||||
// Node representing the ship in the scene graph.
|
||||
private final Node shipNode;
|
||||
|
||||
// Handles visual effects for the ship.
|
||||
private final EffectHandler effectHandler;
|
||||
|
||||
/**
|
||||
* Constructs a new ShipControl instance for the specified Battleship.
|
||||
* The ship's orientation determines the axis of rotation, while its length influences
|
||||
* the cycle duration and amplitude of the oscillation.
|
||||
* Constructs a new {@code ShipControl} instance to manage the effects for a specified {@code Battleship}.
|
||||
* The ship's orientation determines the axis of rotation, and its length affects the oscillation cycle
|
||||
* and amplitude.
|
||||
*
|
||||
* @param ship the Battleship object to control
|
||||
* @param battleship The {@code Battleship} being controlled.
|
||||
* @param shipNode The scene graph node representing the ship.
|
||||
* @param effectHandler The {@code EffectHandler} for creating visual effects.
|
||||
*/
|
||||
public ShipControl(Battleship ship) {
|
||||
this.ship = ship;
|
||||
public ShipControl(Battleship battleship, Node shipNode, EffectHandler effectHandler) {
|
||||
this.battleship = battleship;
|
||||
this.shipNode = shipNode;
|
||||
this.effectHandler = effectHandler;
|
||||
|
||||
// Determine the axis of rotation based on the ship's orientation
|
||||
axis = switch (ship.getRot()) {
|
||||
sinking = false;
|
||||
// Determine the axis of rotation based on the ship's orientation.
|
||||
axis = switch (battleship.getRot()) {
|
||||
case LEFT, RIGHT -> Vector3f.UNIT_X;
|
||||
case UP, DOWN -> Vector3f.UNIT_Z;
|
||||
};
|
||||
|
||||
// Set the cycle duration and amplitude based on the ship's length
|
||||
cycle = ship.getLength() * 2f;
|
||||
amplitude = 5f * DEG_TO_RAD / ship.getLength();
|
||||
// Set the cycle duration and amplitude based on the ship's length.
|
||||
cycle = battleship.getLength() * 2f;
|
||||
amplitude = 5f * DEG_TO_RAD / battleship.getLength();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the ship's pitch oscillation each frame. The ship's pitch is adjusted
|
||||
* to create a continuous tilting motion, simulating the effect of waves.
|
||||
* Updates the ship's motion. If the ship is sinking, it animates the sinking process.
|
||||
* Otherwise, it oscillates the ship to simulate wave motion.
|
||||
*
|
||||
* @param tpf time per frame (in seconds), used to calculate the new pitch angle
|
||||
* @param tpf Time per frame, used to update the ship's motion.
|
||||
*/
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
// If spatial is null, do nothing
|
||||
if (sinking) {
|
||||
handleSinking(tpf);
|
||||
}
|
||||
else {
|
||||
handlePitch(tpf);
|
||||
}
|
||||
}
|
||||
|
||||
// Handles the sinking animation.
|
||||
private void handleSinking(float tpf) {
|
||||
if (spatial == null) return;
|
||||
|
||||
if (ship.isDestroyed() && spatial.getLocalTranslation().getY() < SINKING_HEIGHT) { // removes the ship, if it is completely sunk
|
||||
spatial.getParent().detachChild(spatial);
|
||||
spatial.setLocalTranslation(spatial.getLocalTranslation().add(new Vector3f(0, -1, 0).mult(tpf * SINK_SPEED)));
|
||||
if (battleship.getRot() == Rotation.UP || battleship.getRot() == Rotation.DOWN) {
|
||||
spatial.rotate(tpf * SINK_ROT_SPEED, 0, 0);
|
||||
}
|
||||
else {
|
||||
spatial.rotate(0, 0, tpf * SINK_ROT_SPEED);
|
||||
}
|
||||
else if (ship.isDestroyed() && spatial.getLocalTranslation().getY() >= SINKING_HEIGHT) { // sink the ship, if it's not completely sunk
|
||||
spatial.move(0, tpf * -0.03f, 0);
|
||||
}
|
||||
|
||||
// Update the time within the oscillation cycle
|
||||
// Handles the pitch oscillation to simulate wave movement.
|
||||
private void handlePitch(float tpf) {
|
||||
if (spatial == null) return;
|
||||
|
||||
// Update time in the oscillation cycle.
|
||||
time = (time + tpf) % cycle;
|
||||
|
||||
// Calculate the current angle of the oscillation
|
||||
final float angle = amplitude * sin(time * TWO_PI / cycle);
|
||||
// Calculate the pitch angle.
|
||||
float angle = amplitude * sin(time * TWO_PI / cycle);
|
||||
|
||||
// Update the pitch Quaternion with the new angle
|
||||
// Update pitch rotation.
|
||||
pitch.fromAngleAxis(angle, axis);
|
||||
|
||||
// Apply the pitch rotation to the spatial
|
||||
// Apply rotation to the spatial.
|
||||
spatial.setLocalRotation(pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called during the rendering phase, but it does not perform any
|
||||
* operations in this implementation as the control only influences the spatial's
|
||||
* transformation, not its rendering process.
|
||||
*
|
||||
* @param rm the RenderManager rendering the controlled Spatial (not null)
|
||||
* @param vp the ViewPort being rendered (not null)
|
||||
*/
|
||||
@Override
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
// No rendering logic is needed for this control
|
||||
// No rendering-specific behavior required.
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates the ship's sinking animation and schedules its destruction.
|
||||
*/
|
||||
public void destroyed() {
|
||||
sinking = true;
|
||||
shipNode.attachChild(effectHandler.debrisSplash(shipNode.getLocalTranslation()));
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
effectHandler.destroyShip(battleship);
|
||||
}
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers an effect when the ship is hit by a shot, creating a fire effect at the impact location.
|
||||
*
|
||||
* @param shot The shot that hit the ship.
|
||||
*/
|
||||
public void hit(Shot shot) {
|
||||
Vector3f shipNodePos = shipNode.getLocalTranslation();
|
||||
Vector3f shotWorld = mapToWorldCord(shot.getX(), shot.getY());
|
||||
Vector3f firePos = shotWorld.subtract(shipNodePos);
|
||||
shipNode.attachChild(effectHandler.createFire(firePos, battleship));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package pp.battleship.client.gui;
|
||||
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
/**
|
||||
* Enum representing different ship models for the Battleship game.
|
||||
* Each ship model has a corresponding 3D model path, scale, translation, color texture, and optional bump texture.
|
||||
*/
|
||||
public enum ShipModel {
|
||||
SHIP1("Models/Ships/1/ship1.j3o", 0.15f, new Vector3f(0f, 0f, 0f), "Models/Ships/1/ship1_color.png", null),
|
||||
SHIP2("Models/Ships/2/ship2.j3o", 0.03f, new Vector3f(0f, 0.2f, 0f), "Models/Ships/2/ship2.jpg", null),
|
||||
SHIP3("Models/Ships/3/ship3.j3o", 0.47f, new Vector3f(0f, -0.2f, 0f), "Models/Ships/3/ship3_color.jpg", null),
|
||||
SHIP4("Models/Ships/4/ship4.j3o", 1.48f, new Vector3f(0f, 0f, 0f), "Models/Ships/4/ship4_color.jpg", "Models/Ships/4/ship4_bump.jpg");
|
||||
|
||||
private final String modelPath;
|
||||
private final float modelScale;
|
||||
private final Vector3f translation;
|
||||
private final String colorPath;
|
||||
private final String bumpPath;
|
||||
|
||||
/**
|
||||
* Constructs a new ShipModel with the specified parameters.
|
||||
*
|
||||
* @param modelPath the path to the 3D model of the ship
|
||||
* @param modelScale the scale factor to be applied to the model
|
||||
* @param translation the translation to be applied to the model
|
||||
* @param colorPath the path to the color texture of the model
|
||||
* @param bumpPath the optional path to the bump texture of the model (may be null)
|
||||
*/
|
||||
ShipModel(String modelPath, float modelScale, Vector3f translation, String colorPath, String bumpPath) {
|
||||
this.modelPath = modelPath;
|
||||
this.modelScale = modelScale;
|
||||
this.translation = translation;
|
||||
this.colorPath = colorPath;
|
||||
this.bumpPath = bumpPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the bump texture of the ship model.
|
||||
*
|
||||
* @return the bump texture path, or null if no bump texture is defined
|
||||
*/
|
||||
public String getBumpPath() {
|
||||
return bumpPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the color texture of the ship model.
|
||||
*
|
||||
* @return the color texture path
|
||||
*/
|
||||
public String getColorPath() {
|
||||
return colorPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scale factor of the ship model.
|
||||
*
|
||||
* @return the scale factor
|
||||
*/
|
||||
public float getScale() {
|
||||
return modelScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the 3D model of the ship.
|
||||
*
|
||||
* @return the model path
|
||||
*/
|
||||
public String getPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the translation to be applied to the ship model.
|
||||
*
|
||||
* @return the translation vector
|
||||
*/
|
||||
public Vector3f getTranslation() {
|
||||
return translation;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 31 KiB |
@@ -1,11 +0,0 @@
|
||||
# Blender MTL File: 'untitletttd.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl None
|
||||
Ns 0
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.8 0.8 0.8
|
||||
Ks 0.8 0.8 0.8
|
||||
d 1
|
||||
illum 2
|
||||
map_Kd C:\Users\Convidado.Cliente-JMF-PC\Desktop\ghftht.png
|
||||
|
Before Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 332 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 629 KiB |
|
Before Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 122 KiB |
@@ -1,35 +0,0 @@
|
||||
# Blender 4.2.1 LTS MTL File: 'untitled.blend'
|
||||
# www.blender.org
|
||||
|
||||
newmtl Bridge
|
||||
Ns 250.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.500000
|
||||
illum 2
|
||||
map_Kd Bridge_baseColor.png
|
||||
map_Ke Bridge_emissive.jpg
|
||||
map_d Bridge_baseColor.png
|
||||
map_Bump -bm 1.000000 Bridge_normal.jpg
|
||||
|
||||
newmtl Containers
|
||||
Ns 250.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.500000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd Containers_baseColor.jpg
|
||||
map_Bump -bm 1.000000 Containers_normal.jpg
|
||||
|
||||
newmtl Hull
|
||||
Ns 250.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.500000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd Hull_baseColor.jpg
|
||||
map_Bump -bm 1.000000 Hull_normal.jpg
|
||||
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 98 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 78 B |