added rotation compability to map.mdga

This commit is contained in:
Cedric Beck
2024-11-15 22:47:23 +01:00
parent 81facb869f
commit d0be65323e
5 changed files with 118 additions and 72 deletions

View File

@@ -1,3 +1,3 @@
package pp.mdga.client.Board; package pp.mdga.client.Board;
public record AssetOnMap(Asset asset, int x, int y){} public record AssetOnMap(Asset asset, int x, int y, float rot){}

View File

@@ -19,13 +19,12 @@ public class BoardView {
private static final int GRID_EXTEND = 5; private static final int GRID_EXTEND = 5;
private static final String MAP_NAME = "map.mdga"; private static final String MAP_NAME = "map.mdga";
private final MdgaApp mdgaApp; private final MdgaApp mdgaApp;
private PileControl drawPile = new PileControl(); private PileControl drawPile = new PileControl();
private PileControl discardPile = new PileControl(); private PileControl discardPile = new PileControl();
private ArrayList<NodeControl> infield = new ArrayList<NodeControl>(40); private ArrayList<NodeControl> infield = new ArrayList<>(40);
private ArrayList<PieceControl> pieces; private ArrayList<PieceControl> pieces;
private Map<Color, List<AssetOnMap>> playerMap; private Map<Color, List<AssetOnMap>> playerMap;
@@ -71,16 +70,16 @@ private Color assetToColor(Asset asset){
case heer -> Color.ARMY; case heer -> Color.ARMY;
case marine -> Color.NAVY; case marine -> Color.NAVY;
case cir -> Color.CYBER; case cir -> Color.CYBER;
default -> null; default -> throw new RuntimeException("invalid asset");
}; };
} }
private Spatial createModel(Asset asset, Vector3f pos){ private Spatial createModel(Asset asset, Vector3f pos, float rot){
String modelName = asset.getModelPath(); String modelName = asset.getModelPath();
String texName = asset.getDiffPath(); String texName = asset.getDiffPath();
Spatial model = mdgaApp.getAssetManager().loadModel(modelName); Spatial model = mdgaApp.getAssetManager().loadModel(modelName);
model.scale(asset.getSize()); model.scale(asset.getSize());
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(90)); model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(90 + rot));
model.setLocalTranslation(pos); model.setLocalTranslation(pos);
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
Material mat = new Material(mdgaApp.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); Material mat = new Material(mdgaApp.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
@@ -109,6 +108,6 @@ public void addPlayer(Color color){
private void displayAsset(AssetOnMap assetOnMap){ private void displayAsset(AssetOnMap assetOnMap){
int x = assetOnMap.x(); int x = assetOnMap.x();
int y = assetOnMap.y(); int y = assetOnMap.y();
Spatial model = createModel(assetOnMap.asset(), gridToWorld(x,y)); Spatial model = createModel(assetOnMap.asset(), gridToWorld(x,y), assetOnMap.rot());
} }
} }

View File

@@ -27,7 +27,7 @@ public static List<AssetOnMap> loadMap(String mapName) {
if(entry.charAt(0) == '#') continue; if(entry.charAt(0) == '#') continue;
String[] parts = entry.trim().split(" "); String[] parts = entry.trim().split(" ");
assert(parts.length == 2); assert(parts.length == 3);
String assetName = parts[0]; String assetName = parts[0];
String[] coordinates = parts[1].split(","); String[] coordinates = parts[1].split(",");
@@ -37,8 +37,10 @@ public static List<AssetOnMap> loadMap(String mapName) {
int x = Integer.parseInt(coordinates[0]); int x = Integer.parseInt(coordinates[0]);
int y = Integer.parseInt(coordinates[1]); int y = Integer.parseInt(coordinates[1]);
float rot = Float.parseFloat(parts[2]);
Asset asset = getLoadedAsset(assetName); Asset asset = getLoadedAsset(assetName);
assetsOnMap.add(new AssetOnMap(asset, x, y)); assetsOnMap.add(new AssetOnMap(asset, x, y, rot));
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -39,7 +39,10 @@ public static void main(String[] args) {
public void simpleInitApp() { public void simpleInitApp() {
animationHandler = new AnimationHandler(this); animationHandler = new AnimationHandler(this);
boardView = new BoardView(4,this); boardView = new BoardView(4,this);
// boardView.addPlayer(Color.NAVY); boardView.addPlayer(Color.NAVY);
boardView.addPlayer(Color.AIRFORCE);
boardView.addPlayer(Color.ARMY);
boardView.addPlayer(Color.CYBER);
flyCam.setEnabled(true); flyCam.setEnabled(true);
int zoom = 20; int zoom = 20;
cam.setLocation(new Vector3f(zoom,0,zoom)); cam.setLocation(new Vector3f(zoom,0,zoom));

View File

@@ -1,70 +1,112 @@
world 0,0 world 0,0 0
#Marine Pos #Marine Pos
marine 4,-3 marine 4,-5 180
marine 4,-4 marine 4,-4 180
marine 5,-4 marine 5,-4 180
marine 5,-3 marine 5,-5 180
#Nodes für Map #Blue (Marine) Home Node
node_start -1,-5 node_home_blue 4,-5 0
node -1,-4 node_home_blue 4,-4 0
node -1,-3 node_home_blue 5,-4 0
node -1,-2 node_home_blue 5,-5 0
node_bonus -1,-1
node -2,-1 #Lw Pos
node -3,-1 lw -5,4 0
node -4,-1 lw -4,4 0
node -5,-1 lw -4,5 0
node -5,0 lw -5,5 0
node_start -5,1
node -4,1 #Black (Lw) Home Node
node -3,1 node_home_black -5,4 0
node -2,1 node_home_black -4,4 0
node_bonus -1,1 node_home_black -4,5 0
node -1,2 node_home_black -5,5 0
node -1,3
node -1,4 #Heer Pos
node -1,5 heer -4,-5 90
node 0,5 heer -4,-4 90
node_start 1,5 heer -5,-4 90
node 1,4 heer -5,-5 90
node 1,3
node 1,2 #Green (Heer) Home Node
node_bonus 1,1 node_home_green -4,-5 0
node 2,1 node_home_green -4,-4 0
node 3,1 node_home_green -5,-4 0
node 4,1 node_home_green -5,-5 0
node 5,1
node 5,0 #CIR Pos
node_start 5,-1 cir 4,5 -90
node 4,-1 cir 4,4 -90
node 3,-1 cir 5,4 -90
node 2,-1 cir 5,5 -90
node_bonus 1,-1
node 1,-2 #Yellow (CIR) Home Node
node 1,-3 node_home_yellow 4,5 0
node 1,-4 node_home_yellow 4,4 0
node 1,-5 node_home_yellow 5,4 0
node 0,-5 node_home_yellow 5,5 0
#Nodes für Map 0
node_start -1,-5 0
node -1,-4 0 0
node -1,-3 0 0
node -1,-2 0 0
node_bonus -1,-1 0
node -2,-1 0
node -3,-1 0
node -4,-1 0
node -5,-1 0
node -5,0 0
node_start -5,1 0
node -4,1 0
node -3,1 0
node -2,1 0
node_bonus -1,1 0
node -1,2 0
node -1,3 0
node -1,4 0
node -1,5 0
node 0,5 0
node_start 1,5 0
node 1,4 0
node 1,3 0
node 1,2 0
node_bonus 1,1 0
node 2,1 0
node 3,1 0
node 4,1 0
node 5,1 0
node 5,0 0
node_start 5,-1 0
node 4,-1 0
node 3,-1 0
node 2,-1 0
node_bonus 1,-1 0
node 1,-2 0
node 1,-3 0
node 1,-4 0
node 1,-5 0
node 0,-5 0
#Node Home #Node Home
node_home_blue 0,-1 node_home_green 0,-1 0
node_home_blue 0,-2 node_home_green 0,-2 0
node_home_blue 0,-3 node_home_green 0,-3 0
node_home_blue 0,-4 node_home_green 0,-4 0
node_home_black 0,1 node_home_yellow 0,1 0
node_home_black 0,2 node_home_yellow 0,2 0
node_home_black 0,3 node_home_yellow 0,3 0
node_home_black 0,4 node_home_yellow 0,4 0
node_home_yellow 1,0 node_home_blue 1,0 0
node_home_yellow 2,0 node_home_blue 2,0 0
node_home_yellow 3,0 node_home_blue 3,0 0
node_home_yellow 4,0 node_home_blue 4,0 0
node_home_green -1,0 node_home_black -1,0 0
node_home_green -2,0 node_home_black -2,0 0
node_home_green -3,0 node_home_black -3,0 0
node_home_green -4,0 node_home_black -4,0 0