added 3d models for the ships
- added different models (see README.txt of the files) - added methods to the SeaSynchronizer class to represent different ships sizes with different models
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.material.RenderState.BlendMode;
|
import com.jme3.material.RenderState.BlendMode;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
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;
|
||||||
@@ -35,6 +36,11 @@
|
|||||||
class SeaSynchronizer extends ShipMapSynchronizer {
|
class SeaSynchronizer extends ShipMapSynchronizer {
|
||||||
private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS
|
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 KING_GEORGE_V_MODEL = "Models/KingGeorgeV/KingGeorgeV.j3o"; //NON-NLS
|
||||||
|
private static final String DESTROYER_MODEL = "Models/Destroyer/Destroyer.j3o"; //NON-NLS
|
||||||
|
private static final String DESTROYER_TEXTURE = "Models/Destroyer/BattleshipC.jpg"; //NON-NLS
|
||||||
|
private static final String TYPE_II_UBOAT_MODEL = "Models/TypeIIUboat/TypeIIUboat.j3o"; //NON-NLS
|
||||||
|
private static final String TYPE_II_UBOAT_TEXTURE = "Models/TypeIIUboat/Type_II_U-boat_diff.jpg"; //NON-NLS
|
||||||
|
private static final String ATLANTICA_MODEL = "Models/Atlantica/Atlantica.j3o"; //NON-NLS
|
||||||
private static final String COLOR = "Color"; //NON-NLS
|
private static final String COLOR = "Color"; //NON-NLS
|
||||||
private static final String SHIP = "ship"; //NON-NLS
|
private static final String SHIP = "ship"; //NON-NLS
|
||||||
private static final String SHOT = "shot"; //NON-NLS
|
private static final String SHOT = "shot"; //NON-NLS
|
||||||
@@ -141,7 +147,13 @@ public Spatial visit(Battleship ship) {
|
|||||||
* @return the spatial representing the battleship
|
* @return the spatial representing the battleship
|
||||||
*/
|
*/
|
||||||
private Spatial createShip(Battleship ship) {
|
private Spatial createShip(Battleship ship) {
|
||||||
return ship.getLength() == 4 ? createBattleship(ship) : createBox(ship);
|
return switch (ship.getLength()) {
|
||||||
|
case 1 -> createVessel(ship);
|
||||||
|
case 2 -> createSubmarine(ship);
|
||||||
|
case 3 -> createDestroyer(ship);
|
||||||
|
case 4 -> createBattleship(ship);
|
||||||
|
default -> createBox(ship);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -196,6 +208,68 @@ private Spatial createBattleship(Battleship ship) {
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a detailed 3D model to represent a destroyer battleship.
|
||||||
|
*
|
||||||
|
* @param ship the battleship to be represented
|
||||||
|
* @return the spatial representing the destroyer battleship
|
||||||
|
*/
|
||||||
|
private Spatial createDestroyer(Battleship ship) {
|
||||||
|
final Spatial model = app.getAssetManager().loadModel(DESTROYER_MODEL);
|
||||||
|
|
||||||
|
Material mat = new Material(app.getAssetManager(), UNSHADED);
|
||||||
|
mat.setTexture("ColorMap", app.getAssetManager().loadTexture(DESTROYER_TEXTURE));
|
||||||
|
mat.getAdditionalRenderState().setBlendMode(BlendMode.Off);
|
||||||
|
model.setMaterial(mat);
|
||||||
|
|
||||||
|
model.setQueueBucket(RenderQueue.Bucket.Opaque);
|
||||||
|
|
||||||
|
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f);
|
||||||
|
model.scale(0.1f);
|
||||||
|
model.setLocalTranslation(0f, 0.25f, 0f);
|
||||||
|
model.setShadowMode(ShadowMode.CastAndReceive);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a detailed 3D model to represent a Type II U-boat submarine.
|
||||||
|
*
|
||||||
|
* @param ship the battleship to be represented
|
||||||
|
* @return the spatial representing the Type II U-boat submarine
|
||||||
|
*/
|
||||||
|
private Spatial createSubmarine(Battleship ship) {
|
||||||
|
final Spatial model = app.getAssetManager().loadModel(TYPE_II_UBOAT_MODEL);
|
||||||
|
|
||||||
|
Material mat = new Material(app.getAssetManager(), UNSHADED);
|
||||||
|
mat.setTexture("ColorMap", app.getAssetManager().loadTexture(TYPE_II_UBOAT_TEXTURE));
|
||||||
|
model.setMaterial(mat);
|
||||||
|
|
||||||
|
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f);
|
||||||
|
model.scale(0.25f);
|
||||||
|
model.getLocalTranslation().addLocal(0f, -0.15f, 0f);
|
||||||
|
model.setShadowMode(ShadowMode.CastAndReceive);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a detailed 3D model to represent a vessel.
|
||||||
|
*
|
||||||
|
* @param ship the battleship to be represented
|
||||||
|
* @return the spatial representing the vessel
|
||||||
|
*/
|
||||||
|
private Spatial createVessel(Battleship ship) {
|
||||||
|
final Spatial model = app.getAssetManager().loadModel(ATLANTICA_MODEL);
|
||||||
|
|
||||||
|
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f);
|
||||||
|
model.scale(0.0003f);
|
||||||
|
model.getLocalTranslation().addLocal(0f, -0.05f, 0f);
|
||||||
|
model.setShadowMode(ShadowMode.CastAndReceive);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the rotation angle for the specified rotation.
|
* Calculates the rotation angle for the specified rotation.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
|
||||||
|
# File Created: 16.12.2011 14:18:52
|
||||||
|
|
||||||
|
newmtl white
|
||||||
|
Ns 53.0000
|
||||||
|
Ni 1.5000
|
||||||
|
d 1.0000
|
||||||
|
Tr 0.0000
|
||||||
|
Tf 1.0000 1.0000 1.0000
|
||||||
|
illum 2
|
||||||
|
Ka 0.6667 0.6667 0.6667
|
||||||
|
Kd 0.6667 0.6667 0.6667
|
||||||
|
Ks 0.1800 0.1800 0.1800
|
||||||
|
Ke 0.0000 0.0000 0.0000
|
||||||
|
|
||||||
|
newmtl boat_elements_black
|
||||||
|
Ns 55.0000
|
||||||
|
Ni 1.5000
|
||||||
|
d 1.0000
|
||||||
|
Tr 0.0000
|
||||||
|
Tf 1.0000 1.0000 1.0000
|
||||||
|
illum 2
|
||||||
|
Ka 0.0000 0.0000 0.0000
|
||||||
|
Kd 0.0000 0.0000 0.0000
|
||||||
|
Ks 0.3600 0.3600 0.3600
|
||||||
|
Ke 0.0000 0.0000 0.0000
|
||||||
|
|
||||||
|
newmtl boat_glass
|
||||||
|
Ns 60.0000
|
||||||
|
Ni 7.0000
|
||||||
|
d 0.4000
|
||||||
|
Tr 0.6000
|
||||||
|
Tf 0.4000 0.4000 0.4000
|
||||||
|
illum 2
|
||||||
|
Ka 0.1059 0.1569 0.1451
|
||||||
|
Kd 0.1059 0.1569 0.1451
|
||||||
|
Ks 0.6750 0.6750 0.6750
|
||||||
|
Ke 0.0000 0.0000 0.0000
|
||||||
|
|
||||||
|
newmtl boat_screw_hooks_bronze
|
||||||
|
Ns 80.0000
|
||||||
|
Ni 1.5000
|
||||||
|
d 1.0000
|
||||||
|
Tr 0.0000
|
||||||
|
Tf 1.0000 1.0000 1.0000
|
||||||
|
illum 2
|
||||||
|
Ka 0.2941 0.2157 0.0510
|
||||||
|
Kd 0.2941 0.2157 0.0510
|
||||||
|
Ks 0.7200 0.7200 0.7200
|
||||||
|
Ke 0.0000 0.0000 0.0000
|
||||||
|
|
||||||
|
newmtl boat_silver
|
||||||
|
Ns 80.0000
|
||||||
|
Ni 1.5000
|
||||||
|
d 1.0000
|
||||||
|
Tr 0.0000
|
||||||
|
Tf 1.0000 1.0000 1.0000
|
||||||
|
illum 2
|
||||||
|
Ka 0.3333 0.3333 0.3333
|
||||||
|
Kd 0.3333 0.3333 0.3333
|
||||||
|
Ks 0.7200 0.7200 0.7200
|
||||||
|
Ke 0.0000 0.0000 0.0000
|
||||||
|
|
||||||
|
newmtl boat_buffer
|
||||||
|
Ns 10.0000
|
||||||
|
Ni 1.5000
|
||||||
|
d 1.0000
|
||||||
|
Tr 0.0000
|
||||||
|
Tf 1.0000 1.0000 1.0000
|
||||||
|
illum 2
|
||||||
|
Ka 1.0000 1.0000 1.0000
|
||||||
|
Kd 1.0000 1.0000 1.0000
|
||||||
|
Ks 0.2700 0.2700 0.2700
|
||||||
|
Ke 0.0000 0.0000 0.0000
|
||||||
|
map_Ka boat_buffer_diffuse.jpg
|
||||||
|
map_Kd boat_buffer_diffuse.jpg
|
||||||
|
|
||||||
|
newmtl boat_roof_accessory
|
||||||
|
Ns 15.0000
|
||||||
|
Ni 1.5000
|
||||||
|
d 1.0000
|
||||||
|
Tr 0.0000
|
||||||
|
Tf 1.0000 1.0000 1.0000
|
||||||
|
illum 2
|
||||||
|
Ka 1.0000 1.0000 1.0000
|
||||||
|
Kd 1.0000 1.0000 1.0000
|
||||||
|
Ks 0.3600 0.3600 0.3600
|
||||||
|
Ke 0.0000 0.0000 0.0000
|
||||||
|
map_Ka boat_roof_accessory_diffuse.jpg
|
||||||
|
map_Kd boat_roof_accessory_diffuse.jpg
|
||||||
|
|
||||||
|
newmtl boat_body
|
||||||
|
Ns 55.0000
|
||||||
|
Ni 1.5000
|
||||||
|
d 1.0000
|
||||||
|
Tr 0.0000
|
||||||
|
Tf 1.0000 1.0000 1.0000
|
||||||
|
illum 2
|
||||||
|
Ka 1.0000 1.0000 1.0000
|
||||||
|
Kd 1.0000 1.0000 1.0000
|
||||||
|
Ks 0.3600 0.3600 0.3600
|
||||||
|
Ke 0.0000 0.0000 0.0000
|
||||||
|
map_Ka boat_body_diffuse.jpg
|
||||||
|
map_Kd boat_body_diffuse.jpg
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,3 @@
|
|||||||
|
based on:
|
||||||
|
https://free3d.com/3d-model/boat-v2--225787.html
|
||||||
|
License: Free Personal Use Only
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 166 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
@@ -0,0 +1,92 @@
|
|||||||
|
# Blender 4.1.0 MTL File: 'None'
|
||||||
|
# www.blender.org
|
||||||
|
|
||||||
|
newmtl Battleship
|
||||||
|
Ns 256.000031
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 1
|
||||||
|
map_Kd BattleshipC.jpg
|
||||||
|
|
||||||
|
newmtl blinn1SG
|
||||||
|
Ns 256.000031
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.500000 0.500000 0.500000
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 1
|
||||||
|
|
||||||
|
newmtl blinn2SG
|
||||||
|
Ns 256.000031
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.500000 0.500000 0.500000
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 1
|
||||||
|
|
||||||
|
newmtl blinn3SG
|
||||||
|
Ns 256.000031
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.500000 0.500000 0.500000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl blinn4SG
|
||||||
|
Ns 256.000031
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.500000 0.500000 0.500000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl blinn5SG
|
||||||
|
Ns 256.000031
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.500000 0.500000 0.500000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl blinn6SG
|
||||||
|
Ns 256.000031
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.500000 0.500000 0.500000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl blinn7SG
|
||||||
|
Ns 256.000031
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.500000 0.500000 0.500000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
|
||||||
|
newmtl blinn8SG
|
||||||
|
Ns 256.000031
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.500000 0.500000 0.500000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 360 KiB |
Binary file not shown.
@@ -0,0 +1,3 @@
|
|||||||
|
based on:
|
||||||
|
https://free3d.com/3d-model/battleship-v1--611736.html
|
||||||
|
License: Free Personal Use Only
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
based on:
|
||||||
|
https://free3d.com/3d-model/wwii-ship-german-type-ii-uboat-v2--700733.html
|
||||||
|
License: Free Personal Use Only
|
||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 168 KiB |
@@ -0,0 +1,16 @@
|
|||||||
|
# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
|
||||||
|
# File Created: 29.03.2012 14:25:39
|
||||||
|
|
||||||
|
newmtl default
|
||||||
|
Ns 35.0000
|
||||||
|
Ni 1.5000
|
||||||
|
d 1.0000
|
||||||
|
Tr 0.0000
|
||||||
|
Tf 1.0000 1.0000 1.0000
|
||||||
|
illum 2
|
||||||
|
Ka 1.0000 1.0000 1.0000
|
||||||
|
Kd 1.0000 1.0000 1.0000
|
||||||
|
Ks 0.5400 0.5400 0.5400
|
||||||
|
Ke 0.0000 0.0000 0.0000
|
||||||
|
map_Ka 14084_WWII_ship_German_Type_II_U-boat_diff.jpg
|
||||||
|
map_Kd 14084_WWII_ship_German_Type_II_U-boat_diff.jpg
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user