added message contents to the messages #17

Closed
fkoppe wants to merge 27 commits from dev/client_beck into dev/client_koppe
167 changed files with 51763 additions and 460 deletions

View File

@@ -8,37 +8,38 @@ public enum Asset {
jet, jet,
lw, lw,
marine, marine,
node_home_blue("./node_home/node_home.j3o", "./node_home/node_home_blue_diff.png"), node_home_blue("Models/node_home/node_home.j3o", "Models/node_home/node_home_blue_diff.png"),
node_wait_blue("./node_home/node_home.j3o", "./node_home/node_home_blue_diff.png"), node_wait_blue("Models/node_home/node_home.j3o", "Models/node_home/node_home_blue_diff.png"),
node_home_black("./node_home/node_home.j3o", "./node_home/node_home_black_diff.png"), node_home_black("Models/node_home/node_home.j3o", "Models/node_home/node_home_black_diff.png"),
node_wait_black("./node_home/node_home.j3o", "./node_home/node_home_black_diff.png"), node_wait_black("Models/node_home/node_home.j3o", "Models/node_home/node_home_black_diff.png"),
node_home_green("./node_home/node_home.j3o", "./node_home/node_home_green_diff.png"), node_home_green("Models/node_home/node_home.j3o", "Models/node_home/node_home_green_diff.png"),
node_wait_green("./node_home/node_home.j3o", "./node_home/node_home_green_diff.png"), node_wait_green("Models/node_home/node_home.j3o", "Models/node_home/node_home_green_diff.png"),
node_home_yellow("./node_home/node_home.j3o", "./node_home/node_home_orange_diff.png"), node_home_yellow("Models/node_home/node_home.j3o", "Models/node_home/node_home_orange_diff.png"),
node_wait_yellow("./node_home/node_home.j3o", "./node_home/node_home_orange_diff.png"), node_wait_yellow("Models/node_home/node_home.j3o", "Models/node_home/node_home_orange_diff.png"),
node_normal, node_normal,
node_start("./node_normal/node_normal.j3o", "./node_normal/node_start_diff.png"), node_start("Models/node_normal/node_normal.j3o", "Models/node_normal/node_start_diff.png"),
node_bonus("./node_normal/node_normal.j3o", "./node_normal/node_bonus_diff.png"), node_bonus("Models/node_normal/node_normal.j3o", "Models/node_normal/node_bonus_diff.png"),
radar, radar,
ship(0.8f), ship(0.8f),
smallTent, smallTent,
tank, tank,
// world(1.2f), world("Models/world_new/world_export_new.obj", "Models/world_new/world_new_diff.png", 1.2f),
world("./world_new/world_export_new.obj", "./world_new/world_new_diff.png", 1.2f), shield_ring("Models/shield_ring/shield_ring.obj", null),
shield_ring("./shield_ring/shield_ring.obj", null), tree_small("Models/tree_small/tree_small.obj", "Models/tree_small/tree_small_diff.png"),
tree_small("./tree_small/tree_small.obj", "./tree_small/tree_small_diff.png"), tree_big("Models/tree_big/tree_big.obj", "Models/tree_big/tree_big_diff.png"),
tree_big("./tree_big/tree_big.obj", "./tree_big/tree_big_diff.png"),
turboCard, turboCard,
swapCard, swapCard,
shieldCard shieldCard,
dice("Models/dice/dice.obj", "Models/dice/dice_diff.jpeg")
; ;
private final String modelPath; private final String modelPath;
private final String diffPath; private final String diffPath;
private final float size; private final float size;
private static final String root = "Models/";
Asset() { Asset() {
String folderFileName = "./" + name() + "/" + name(); String folderFileName = "./" + root + name() + "/" + name();
this.modelPath = folderFileName + ".j3o"; this.modelPath = folderFileName + ".j3o";
this.diffPath = folderFileName + "_diff.png"; this.diffPath = folderFileName + "_diff.png";
this.size = 1f; this.size = 1f;
@@ -51,7 +52,7 @@ public enum Asset {
} }
Asset(float size) { Asset(float size) {
String folderFileName = "./" + name() + "/" + name(); String folderFileName = "./" + root + name() + "/" + name();
this.modelPath = folderFileName + ".j3o"; this.modelPath = folderFileName + ".j3o";
this.diffPath = folderFileName + "_diff.png"; this.diffPath = folderFileName + "_diff.png";
this.size = size; this.size = size;

View File

@@ -0,0 +1,192 @@
package pp.mdga.client;
import com.jme3.collision.CollisionResults;
import com.jme3.input.InputManager;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.*;
import com.jme3.math.Ray;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Node;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.control.Control;
import pp.mdga.client.board.NodeControl;
import pp.mdga.client.board.OutlineControl;
import pp.mdga.client.board.PieceControl;
import pp.mdga.client.gui.CardControl;
import pp.mdga.client.view.GameView;
import pp.mdga.game.Piece;
public class InputSynchronizer {
private MdgaApp app;
private InputManager inputManager;
protected boolean rightMousePressed = false;
private float rotationAngle = 180f;
private int scrollValue = 0;
private CardControl hoverCard;
private PieceControl hoverPiece;
InputSynchronizer(MdgaApp app) {
this.app = app;
this.inputManager = app.getInputManager();
hoverCard = null;
hoverPiece = null;
setupInput();
}
private void setupInput() {
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
inputManager.addMapping("MouseRight", new MouseAxisTrigger(MouseInput.AXIS_X, true)); // Right movement
inputManager.addMapping("MouseVertical", new MouseAxisTrigger(MouseInput.AXIS_Y, false), new MouseAxisTrigger(MouseInput.AXIS_Y, true)); //Mouse Up Down movement
inputManager.addMapping("MouseScrollUp", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); // Scroll up
inputManager.addMapping("MouseScrollDown", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); // Scroll down
inputManager.addMapping("Test", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "Settings", "RotateRightMouse", "Click", "Test");
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
}
private boolean test = false;
private final ActionListener actionListener = new ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("Settings") && isPressed) {
app.getView().pressEscape();
}
if (name.equals("RotateRightMouse")) {
rightMousePressed = isPressed;
}
if(name.equals("Click") && isPressed) {
if (app.getView() instanceof GameView gameView) {
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayer().getRootNode(), CardControl.class);
OutlineControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineControl.class);
if(cardLayerSelect != null) {
//cardSelect
cardLayerSelect.outline();
}
if(cardLayerSelect == null && boardSelect != null) {
//boardSelect
if(boardSelect instanceof PieceControl pieceControl){
if(pieceControl.isSelectable()) gameView.getBoardHandler().pieceSelect(pieceControl);
}
if(boardSelect instanceof NodeControl nodeControl){
// nodeControl.outline();
}
}
else {
//both null
}
}
}
if(name.equals("Test") &&isPressed){
test = true;
}
}
};
private final AnalogListener analogListener = new AnalogListener() {
@Override
public void onAnalog(String name, float value, float tpf) {
if (name.equals("MouseLeft") && rightMousePressed) {
rotationAngle -= value * 360f;
}
else if (name.equals("MouseRight") && rightMousePressed) {
rotationAngle += value * 360f;
}
else if (name.equals("MouseScrollUp")) {
scrollValue = Math.max(1, scrollValue - 5);
}
else if (name.equals("MouseScrollDown")) {
scrollValue = Math.min(100, scrollValue + 5);
}
else if (name.equals("MouseLeft") || name.equals("MouseRight") || name.equals("MouseVertical")){
hoverPiece();
}
}
};
private <T extends AbstractControl> T checkHover(Camera cam, Node root, Class<T> controlType) {
CollisionResults results = new CollisionResults();
Ray ray = new Ray(cam.getLocation(), getMousePos(cam).subtract(cam.getLocation()).normalize());
root.collideWith(ray, results);
if (results.size() > 0) {
return results.getClosestCollision().getGeometry().getControl(controlType);
}
return null;
}
private void hoverPiece() {
if (app.getView() instanceof GameView gameView) {
PieceControl control = checkPiece();
if (control != null) {
if(control != hoverPiece){
pieceOff();
hoverPiece = control;
hoverPiece.hover();
}
}
else pieceOff();
}
}
private void hoverCardOutline() {
if (app.getView() instanceof GameView gameView) {
CardControl control = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayer().getRootNode(), CardControl.class);
if (control != null) {
if(control != hoverCard){
pieceOff();
hoverCard = control;
hoverCard.outline();
}
}
else pieceOff();
}
}
private void hoverAction(){
}
private PieceControl checkPiece(){
return checkHover(app.getCamera(), app.getRootNode(), PieceControl.class);
}
private void outlineOff(OutlineControl outline) {
if (outline != null) outline.deOutline();
outline = null;
}
private void pieceOff(){
if(hoverPiece != null) hoverPiece.hoverOff();
hoverPiece = null;
}
private Vector3f getMousePos(Camera cam){
Vector2f mousePositionScreen = inputManager.getCursorPosition();
return cam.getWorldCoordinates(mousePositionScreen, 0);
}
public float getRotation() {
return (rotationAngle / 2) % 360;
}
public int getScroll() {
return scrollValue;
}
}

View File

@@ -1,72 +0,0 @@
package pp.mdga.client;
import com.jme3.input.InputManager;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.*;
public class InputSyncronizer {
private MdgaApp app;
private InputManager inputManager;
protected boolean rightMousePressed = false;
private float rotationAngle = 180f;
private int scrollValue = 0;
InputSyncronizer(MdgaApp app) {
this.app = app;
this.inputManager = app.getInputManager();
setupInput();
}
private void setupInput() {
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
inputManager.addMapping("MouseRight", new MouseAxisTrigger(MouseInput.AXIS_X, true)); // Right movement
inputManager.addMapping("MouseScrollUp", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); // Scroll up
inputManager.addMapping("MouseScrollDown", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); // Scroll down
inputManager.addListener(actionListener, "Settings", "RotateRightMouse");
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
}
private final ActionListener actionListener = new ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("Settings") && isPressed) {
app.getView().pressEscape();
}
if (name.equals("RotateRightMouse")) {
rightMousePressed = isPressed;
}
}
};
private final AnalogListener analogListener = new AnalogListener() {
@Override
public void onAnalog(String name, float value, float tpf) {
if (name.equals("MouseLeft") && rightMousePressed) {
rotationAngle -= value * 360f;
} else if (name.equals("MouseRight") && rightMousePressed) {
rotationAngle += value * 360f;
} else if (name.equals("MouseScrollUp")) {
scrollValue = Math.max(1, scrollValue - 5);
} else if (name.equals("MouseScrollDown")) {
scrollValue = Math.min(100, scrollValue + 5);
}
}
};
public float getRotation() {
return (rotationAngle / 2) % 360;
}
public int getScroll() {
return scrollValue;
}
}

View File

@@ -1,21 +1,28 @@
package pp.mdga.client; package pp.mdga.client;
import com.jme3.app.SimpleApplication; import com.jme3.app.SimpleApplication;
import com.jme3.renderer.RenderManager;
import com.simsilica.lemur.GuiGlobals; import com.simsilica.lemur.GuiGlobals;
import pp.mdga.client.acoustic.AcousticHandler; import pp.mdga.client.acoustic.AcousticHandler;
import pp.mdga.client.animation.AnimationHandler; import pp.mdga.client.animation.AnimationHandler;
import com.jme3.system.AppSettings; import com.jme3.system.AppSettings;
import pp.mdga.client.view.*; import pp.mdga.client.view.*;
import pp.mdga.game.Color;
import pp.mdga.notification.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class MdgaApp extends SimpleApplication { public class MdgaApp extends SimpleApplication {
private AnimationHandler animationHandler; private AnimationHandler animationHandler;
private AcousticHandler acousticHandler; private AcousticHandler acousticHandler;
private NotificationSynchronizer notificationSynchronizer; private NotificationSynchronizer notificationSynchronizer;
private InputSyncronizer inputSyncronizer; private InputSynchronizer inputSynchronizer;
private ModelSyncronizer modelSyncronizer; private ModelSyncronizer modelSyncronizer;
MdgaView view = null; MdgaView view = null;
private MdgaState state = MdgaState.MAIN; private MdgaState state = MdgaState.GAME;
private static float resolutionFactor = 1.8f; private static float resolutionFactor = 1.8f;
@@ -43,7 +50,7 @@ public void simpleInitApp() {
animationHandler = new AnimationHandler(this); animationHandler = new AnimationHandler(this);
acousticHandler = new AcousticHandler(this); acousticHandler = new AcousticHandler(this);
notificationSynchronizer = new NotificationSynchronizer(this); notificationSynchronizer = new NotificationSynchronizer(this);
inputSyncronizer = new InputSyncronizer(this); inputSynchronizer = new InputSynchronizer(this);
modelSyncronizer = new ModelSyncronizer(this); modelSyncronizer = new ModelSyncronizer(this);
inputManager.deleteMapping("SIMPLEAPP_Exit"); inputManager.deleteMapping("SIMPLEAPP_Exit");
@@ -54,6 +61,33 @@ public void simpleInitApp() {
GuiGlobals.initialize(this); GuiGlobals.initialize(this);
enter(state); enter(state);
List<UUID> test = new ArrayList<>();
UUID player0 = UUID.randomUUID();
test.add(player0);
UUID player1 = UUID.randomUUID();
test.add(player1);
test.add(UUID.randomUUID());
test.add(UUID.randomUUID());
List<UUID> test_1 = new ArrayList<>();
UUID player0_1 = UUID.randomUUID();
test_1.add(player0_1);
UUID player1_1 = UUID.randomUUID();
test_1.add(player1_1);
test_1.add(UUID.randomUUID());
test_1.add(UUID.randomUUID());
notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.AIRFORCE, test, "Player 1"));
notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.NAVY, test_1, "Player 2"));
notificationSynchronizer.addTestNotification(new MovePieceNotification(player0, 0, true));
notificationSynchronizer.addTestNotification(new MovePieceNotification(player0_1, 20, true));
notificationSynchronizer.addTestNotification(new MovePieceNotification(player0_1, 20, 21));
notificationSynchronizer.addTestNotification(new MovePieceNotification(player1, 0, true));
notificationSynchronizer.addTestNotification(new MovePieceNotification(player0, 0, 7));
// notificationSynchronizer.addTestNotification(new SelectableMoveNotification(new ArrayList<>(List.of(player0, player1)), new ArrayList<>(List.of(7,3)), new ArrayList<>(List.of(false, false))));
notificationSynchronizer.addTestNotification(new SwapPieceNotification(player0, player0_1));
// notificationSynchronizer.addTestNotification(new SelectableSwapNotification(new ArrayList<>(List.of(player0, player1)), new ArrayList<>(List.of(player0_1))));
} }
@Override @Override
@@ -118,5 +152,5 @@ public ModelSyncronizer getModelSyncronizer() {
return modelSyncronizer; return modelSyncronizer;
} }
public InputSyncronizer getInputSyncronizer() { return inputSyncronizer; } public InputSynchronizer getInputSyncronizer() { return inputSynchronizer; }
} }

View File

@@ -21,7 +21,6 @@ public void addTestNotification(Notification n) {
public void update() { public void update() {
//TODO fetch model notifications //TODO fetch model notifications
for (Notification n : notifications) { for (Notification n : notifications) {
switch (app.getState()) { switch (app.getState()) {
case MAIN: case MAIN:
@@ -40,6 +39,7 @@ public void update() {
throw new RuntimeException("no notification expected: " + n.toString()); throw new RuntimeException("no notification expected: " + n.toString());
} }
} }
notifications.clear();
} }
private void handleMain(Notification notification) { private void handleMain(Notification notification) {
@@ -71,8 +71,8 @@ private void handleGame(Notification notification) {
if (notification instanceof AcquireCardNotification) { if (notification instanceof AcquireCardNotification) {
// Handle AcquireCardNotification // Handle AcquireCardNotification
} else if (notification instanceof ActivePlayerNotification) { } else if (notification instanceof ActivePlayerNotification n) {
// Handle ActivePlayerNotification gameView.getGuiHandler().setActivePlayer(n.getColor());
} else if (notification instanceof CeremonyNotification) { } else if (notification instanceof CeremonyNotification) {
app.enter(MdgaState.CEREMONY); app.enter(MdgaState.CEREMONY);
} else if (notification instanceof DiceNowNotification) { } else if (notification instanceof DiceNowNotification) {
@@ -81,14 +81,19 @@ private void handleGame(Notification notification) {
// Handle DicingNotification // Handle DicingNotification
} else if (notification instanceof DrawCardNotification) { } else if (notification instanceof DrawCardNotification) {
// Handle DrawCardNotification // Handle DrawCardNotification
} else if (notification instanceof HomeMoveNotification) { } else if (notification instanceof HomeMoveNotification home) {
HomeMoveNotification n = (HomeMoveNotification)notification; gameView.getBoardHandler().moveHomePiece(home.getPieceId(), home.getHomeIndex());
gameView.getBoardHandler().moveHomePiece(n.getPieceId(), n.getHomeIndex());
} else if (notification instanceof InterruptNotification) { } else if (notification instanceof InterruptNotification) {
// Handle InterruptNotification // Handle InterruptNotification
} else if (notification instanceof MovePieceNotification) { } else if (notification instanceof MovePieceNotification n) {
MovePieceNotification n = (MovePieceNotification)notification; if(n.isMoveStart()) {
//gameView.getBoardHandler().movePiece(n.get); //TODO //StartMove
gameView.getBoardHandler().movePieceStart(n.getPiece(), n.getMoveIndex());
}
else {
//InfieldMove
gameView.getBoardHandler().movePiece(n.getPiece(), n.getStartIndex(), n.getMoveIndex());
}
} else if (notification instanceof MoveThrowPieceNotification) { } else if (notification instanceof MoveThrowPieceNotification) {
MoveThrowPieceNotification n = (MoveThrowPieceNotification)notification; MoveThrowPieceNotification n = (MoveThrowPieceNotification)notification;
//gameView.getBoardHandler().throwPiece(n.); //TODO //gameView.getBoardHandler().throwPiece(n.); //TODO
@@ -99,16 +104,16 @@ private void handleGame(Notification notification) {
// Handle PieceInGameNotification // Handle PieceInGameNotification
} else if (notification instanceof PlayCardNotification) { } else if (notification instanceof PlayCardNotification) {
// Handle PlayCardNotification // Handle PlayCardNotification
} else if (notification instanceof PlayerInGameNotification) { } else if (notification instanceof PlayerInGameNotification n) {
// Handle PlayerInGameNotification // Handle PlayerInGameNotification
gameView.getBoardHandler().addPlayer(n.getColor(),n.getPiecesList());
gameView.getGuiHandler().addPlayer(n.getColor(),n.getName());
} else if (notification instanceof ResumeNotification) { } else if (notification instanceof ResumeNotification) {
// Handle ResumeNotification // Handle ResumeNotification
} else if (notification instanceof RollDiceNotification) { } else if (notification instanceof RollDiceNotification) {
// Handle RollDiceNotification // Handle RollDiceNotification
} else if (notification instanceof SelectableCardsNotification) { } else if (notification instanceof SelectableCardsNotification) {
// Handle SelectableCardsNotification // Handle SelectableCardsNotification
} else if (notification instanceof SelectablePiecesNotification) {
// Handle SelectablePiecesNotification
} else if (notification instanceof ShieldActiveNotification) { } else if (notification instanceof ShieldActiveNotification) {
ShieldActiveNotification n = (ShieldActiveNotification)notification; ShieldActiveNotification n = (ShieldActiveNotification)notification;
gameView.getBoardHandler().shieldPiece(n.getPieceId()); gameView.getBoardHandler().shieldPiece(n.getPieceId());
@@ -117,10 +122,14 @@ private void handleGame(Notification notification) {
gameView.getBoardHandler().suppressShield(n.getPieceId()); gameView.getBoardHandler().suppressShield(n.getPieceId());
} else if (notification instanceof StartDialogNotification) { } else if (notification instanceof StartDialogNotification) {
app.enter(MdgaState.MAIN); app.enter(MdgaState.MAIN);
} else if (notification instanceof SwapPieceNotification) { } else if (notification instanceof SwapPieceNotification n) {
// Handle SwapPieceNotification gameView.getBoardHandler().swapPieces(n.getFirstPiece(), n.getSecondPiece());
} else if (notification instanceof WaitMoveNotification) { } else if (notification instanceof WaitMoveNotification) {
// Handle WaitMoveNotification // Handle WaitMoveNotification
} else if (notification instanceof SelectableMoveNotification n) {
gameView.getBoardHandler().outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves());
} else if (notification instanceof SelectableSwapNotification n) {
gameView.getBoardHandler().outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
} else { } else {
throw new RuntimeException("notification not expected: " + notification.toString()); throw new RuntimeException("notification not expected: " + notification.toString());
} }

View File

@@ -20,6 +20,7 @@ enum MusicAsset {
private final String path; private final String path;
private final boolean loop; private final boolean loop;
private final float subVolume; private final float subVolume;
private static final String root = "Music/";
/** /**
* Constructs a new MusicAsset object with the specified name and sub-volume. * Constructs a new MusicAsset object with the specified name and sub-volume.
@@ -29,7 +30,7 @@ enum MusicAsset {
* @param subVolume A relative volume that modifies the base volume of the track (typically a percentage). * @param subVolume A relative volume that modifies the base volume of the track (typically a percentage).
*/ */
MusicAsset(String name, float subVolume) { MusicAsset(String name, float subVolume) {
this.path = "music/" + name; this.path = root + name;
this.loop = false; this.loop = false;
this.subVolume = subVolume; this.subVolume = subVolume;
} }
@@ -42,7 +43,7 @@ enum MusicAsset {
* @param subVolume A relative volume that modifies the base volume of the track (typically a percentage). * @param subVolume A relative volume that modifies the base volume of the track (typically a percentage).
*/ */
MusicAsset(String name, boolean loop, float subVolume) { MusicAsset(String name, boolean loop, float subVolume) {
this.path = "music/" + name; this.path = root + name;
this.loop = loop; this.loop = loop;
this.subVolume = subVolume; this.subVolume = subVolume;
} }

View File

@@ -27,7 +27,7 @@ enum SoundAsset {
* @param name The name of the sound file. * @param name The name of the sound file.
*/ */
SoundAsset(String name) { SoundAsset(String name) {
this.path = "sound/" + name; this.path = "Sounds/" + name;
} }
/** /**

View File

@@ -16,12 +16,12 @@
public class BoardHandler { public class BoardHandler {
private static final float GRID_SIZE = 1.72f; private static final float GRID_SIZE = 1.72f;
private static final float GRID_ELEVATION = 0.0f; private static final float GRID_ELEVATION = 0.0f;
private static final String MAP_NAME = "map.mdga"; private static final String MAP_NAME = "Maps/map.mdga";
private final MdgaApp app; private final MdgaApp app;
private PileControl drawPile = null; private final PileControl drawPile = null;
private PileControl discardPile = null; private final PileControl discardPile = null;
private ArrayList<NodeControl> infield; private ArrayList<NodeControl> infield;
private Map<UUID, PieceControl> pieces; private Map<UUID, PieceControl> pieces;
@@ -31,19 +31,31 @@ public class BoardHandler {
private Map<Color, List<NodeControl>> waitingNodesMap; private Map<Color, List<NodeControl>> waitingNodesMap;
private Map<Color, List<PieceControl>> waitingPiecesMap; private Map<Color, List<PieceControl>> waitingPiecesMap;
private Map<UUID, Color> pieceColor; private Map<UUID, Color> pieceColor;
private Set<OutlineControl> outlineControls;
private Node node; private Node node;
private FilterPostProcessor fpp; private final FilterPostProcessor fpp;
private boolean init; private boolean isInitialised;
private boolean scheduleInit = false;
private boolean scheduleShutdown = false;
private List<PieceControl> selectableOwnPieces = new ArrayList<>();
private List<PieceControl> selectableEnemyPieces = new ArrayList<>();
private PieceControl selectedOwnPiece;
private PieceControl selectedEnemyPiece;
public BoardHandler(MdgaApp app, FilterPostProcessor fpp) { public BoardHandler(MdgaApp app, FilterPostProcessor fpp) {
if(app == null) throw new RuntimeException("app is null"); if(app == null) throw new RuntimeException("app is null");
this.init = false; this.isInitialised = false;
this.app = app; this.app = app;
this.fpp = fpp; this.fpp = fpp;
selectedEnemyPiece = null;
selectedOwnPiece = null;
initMap();
} }
private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) { private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
@@ -52,11 +64,10 @@ private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
} }
private void initMap() { private void initMap() {
if (init) return; if (isInitialised) return;
this.init = true; this.isInitialised = true;
this.node = new Node("Asset Node"); this.node = new Node("Asset Node");
app.getRootNode().attachChild(node);
this.pieces = new HashMap<>(); this.pieces = new HashMap<>();
this.colorAssetsMap = new HashMap<>(); this.colorAssetsMap = new HashMap<>();
@@ -65,6 +76,10 @@ private void initMap() {
this.waitingNodesMap = new HashMap<>(); this.waitingNodesMap = new HashMap<>();
this.waitingPiecesMap = new HashMap<>(); this.waitingPiecesMap = new HashMap<>();
this.pieceColor = new HashMap<>(); this.pieceColor = new HashMap<>();
this.outlineControls = new HashSet<>();
List<AssetOnMap> assetOnMaps = MapLoader.loadMap(MAP_NAME); List<AssetOnMap> assetOnMaps = MapLoader.loadMap(MAP_NAME);
@@ -75,7 +90,7 @@ private void initMap() {
case cir -> addFigureToPlayerMap(assetToColor(Asset.cir), assetOnMap); case cir -> addFigureToPlayerMap(assetToColor(Asset.cir), assetOnMap);
case marine -> addFigureToPlayerMap(assetToColor(Asset.marine), assetOnMap); case marine -> addFigureToPlayerMap(assetToColor(Asset.marine), assetOnMap);
case node_normal, node_bonus, node_start -> case node_normal, node_bonus, node_start ->
infield.add(displayAndControl(assetOnMap, new NodeControl())); infield.add(displayAndControl(assetOnMap, new NodeControl(app, fpp)));
case node_home_black -> addHomeNode(homeNodesMap, Color.AIRFORCE, assetOnMap); case node_home_black -> addHomeNode(homeNodesMap, Color.AIRFORCE, assetOnMap);
case node_home_blue -> addHomeNode(homeNodesMap, Color.NAVY, assetOnMap); case node_home_blue -> addHomeNode(homeNodesMap, Color.NAVY, assetOnMap);
case node_home_green -> addHomeNode(homeNodesMap, Color.ARMY, assetOnMap); case node_home_green -> addHomeNode(homeNodesMap, Color.ARMY, assetOnMap);
@@ -112,7 +127,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName)); mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
model.setMaterial(mat); model.setMaterial(mat);
node.attachChild(model); node.attachChild(model);
// app.getRootNode().attachChild(model);
return model; return model;
} }
@@ -137,20 +152,22 @@ private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl)
} }
private void addHomeNode(Map<Color, List<NodeControl>> map, Color color, AssetOnMap assetOnMap){ private void addHomeNode(Map<Color, List<NodeControl>> map, Color color, AssetOnMap assetOnMap){
List<NodeControl> homeNodes = addItemToMapList(map, color, displayAndControl(assetOnMap, new NodeControl())); List<NodeControl> homeNodes = addItemToMapList(map, color, displayAndControl(assetOnMap, new NodeControl(app, fpp)));
if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color); if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color);
} }
private float getRotationMove(Vector3f prev, Vector3f next) { private float getRotationMove(Vector3f prev, Vector3f next) {
Vector3f direction = next.subtract(prev).normalizeLocal(); Vector3f direction = next.subtract(prev).normalizeLocal();
//I had to reverse dir.y, because then it worked. //I had to reverse dir.y, because then it worked.
return (float) Math.toDegrees(Math.atan2(direction.x, -direction.y)); float newRot = (float) Math.toDegrees(Math.atan2(direction.x, -direction.y));
if(newRot < 0) newRot += 360;
return newRot;
} }
private void movePiece_rek(UUID uuid, int curIndex, int moveIndex){ private void movePiece_rek(UUID uuid, int curIndex, int moveIndex){
if (curIndex == moveIndex) return; if (curIndex == moveIndex) return;
curIndex = (curIndex + 1) % 40; curIndex = (curIndex + 1) % infield.size();
PieceControl pieceControl = pieces.get(uuid); PieceControl pieceControl = pieces.get(uuid);
NodeControl nodeControl = infield.get(curIndex); NodeControl nodeControl = infield.get(curIndex);
@@ -178,7 +195,7 @@ private <T, E> List<T> removeItemFromMapList(Map<E,List<T>> map, E key, T item){
//public methods**************************************************************************************************** //public methods****************************************************************************************************
public void addPlayer(Color color, List<UUID> uuid) { public void addPlayer(Color color, List<UUID> uuid) {
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
List<AssetOnMap> playerAssets = colorAssetsMap.get(color); List<AssetOnMap> playerAssets = colorAssetsMap.get(color);
if (playerAssets == null) throw new RuntimeException("Assets for Player color are not defined"); if (playerAssets == null) throw new RuntimeException("Assets for Player color are not defined");
@@ -191,6 +208,7 @@ public void addPlayer(Color color, List<UUID> uuid) {
for (int i = 0; i < playerAssets.size(); i++){ for (int i = 0; i < playerAssets.size(); i++){
AssetOnMap assetOnMap = playerAssets.get(i); AssetOnMap assetOnMap = playerAssets.get(i);
PieceControl pieceControl = displayAndControl(assetOnMap, new PieceControl(assetOnMap.rot(), app.getAssetManager(), app, fpp)); PieceControl pieceControl = displayAndControl(assetOnMap, new PieceControl(assetOnMap.rot(), app.getAssetManager(), app, fpp));
pieceControl.setRotation(assetOnMap.rot());
movePieceToNode(pieceControl, waitNodes.get(i)); movePieceToNode(pieceControl, waitNodes.get(i));
pieces.put(uuid.get(i), pieceControl); pieces.put(uuid.get(i), pieceControl);
@@ -202,7 +220,7 @@ public void addPlayer(Color color, List<UUID> uuid) {
} }
public void moveHomePiece(UUID uuid, int index){ public void moveHomePiece(UUID uuid, int index){
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
Color color = pieceColor.get(uuid); Color color = pieceColor.get(uuid);
if(color == null) throw new RuntimeException("uuid is not mapped to a color"); if(color == null) throw new RuntimeException("uuid is not mapped to a color");
@@ -223,7 +241,7 @@ public void moveHomePiece(UUID uuid, int index){
} }
public void movePieceStart(UUID uuid, int nodeIndex){ public void movePieceStart(UUID uuid, int nodeIndex){
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
Color color = pieceColor.get(uuid); Color color = pieceColor.get(uuid);
if(color == null) throw new RuntimeException("uuid is not mapped to a color"); if(color == null) throw new RuntimeException("uuid is not mapped to a color");
@@ -235,13 +253,13 @@ public void movePieceStart(UUID uuid, int nodeIndex){
} }
public void movePiece(UUID uuid, int curIndex, int moveIndex){ public void movePiece(UUID uuid, int curIndex, int moveIndex){
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
movePiece_rek(uuid, curIndex, moveIndex); movePiece_rek(uuid, curIndex, moveIndex);
} }
public void throwPiece(UUID uuid){ public void throwPiece(UUID uuid){
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
Color color = pieceColor.get(uuid); Color color = pieceColor.get(uuid);
if(color == null) throw new RuntimeException("uuid is not mapped to a color"); if(color == null) throw new RuntimeException("uuid is not mapped to a color");
@@ -256,25 +274,25 @@ public void throwPiece(UUID uuid){
} }
public void shieldPiece(UUID uuid){ public void shieldPiece(UUID uuid){
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
pieces.get(uuid).activateShield(); pieces.get(uuid).activateShield();
} }
public void unshieldPiece(UUID uuid){ public void unshieldPiece(UUID uuid){
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
pieces.get(uuid).deactivateShield(); pieces.get(uuid).deactivateShield();
} }
public void suppressShield(UUID uuid){ public void suppressShield(UUID uuid){
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
pieces.get(uuid).suppressShield(); pieces.get(uuid).suppressShield();
} }
public void swapPieces(UUID piece1, UUID piece2){ public void swapPieces(UUID piece1, UUID piece2){
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
PieceControl piece1_control = pieces.get(piece1); PieceControl piece1_control = pieces.get(piece1);
PieceControl piece2_control = pieces.get(piece2); PieceControl piece2_control = pieces.get(piece2);
@@ -295,29 +313,165 @@ public void swapPieces(UUID piece1, UUID piece2){
piece2_control.setLocation(pos1); piece2_control.setLocation(pos1);
} }
public void init(){ public void init() {
initMap(); // outlineControls.forEach((outlineControl) -> {
// outlineControl.outline(outlineControl.getColor());
// });
isInitialised = true;
scheduleInit = false;
app.getRootNode().attachChild(node);
} }
public void shutdown(){ public void shutdown(){
if (!init) return; outlineControls.forEach((outlineControl) -> {
outlineControl.deOutline();
});
init = false; isInitialised = false;
scheduleShutdown = false;
app.getRootNode().detachChild(node); app.getRootNode().detachChild(node);
} }
//List<Pieces> //List<Pieces>
//List<NodesIndexe> //List<NodesIndexe>
public void highlight(UUID uuid, boolean bool){ public void highlight(UUID uuid, boolean bool){
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
pieces.get(uuid).highlight(bool);
pieces.get(uuid).setSelectable(bool);
pieces.get(uuid).outline(bool);
} }
public void unHighlight(UUID uuid){ public void deOutline(UUID uuid){
if (!init) throw new RuntimeException("BoardHandler is not initialized"); if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
pieces.get(uuid).deOutline(); pieces.get(uuid).deOutline();
outlineControls.remove(pieces.get(uuid));
} }
public void outline(int index){
// infield.get(index).outline();
outlineControls.add(infield.get(index));
}
//called when (dice) moveNum is received from server to display the movable pieces and corresponding moveNodes
public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolean> homeMoves) {
if(pieces.size() != moveIndexe.size() || pieces.size() != homeMoves.size()) throw new RuntimeException("arrays are not the same size");
selectableEnemyPieces.clear();
selectableOwnPieces.clear();
selectedOwnPiece = null;
selectedEnemyPiece = null;
for (int i = 0; i < pieces.size(); i++) {
UUID uuid = pieces.get(i);
PieceControl pieceControl = this.pieces.get(uuid);
NodeControl nodeControl;
if (homeMoves.get(i)) {
Color color = pieceColor.get(uuid);
nodeControl = homeNodesMap.get(color).get(moveIndexe.get(i));
}
else {
nodeControl = infield.get(moveIndexe.get(i));
}
nodeControl.highlight();
pieceControl.highlight(false);
pieceControl.setHoverable(true);
pieceControl.setSelectable(true);
selectableOwnPieces.add(pieceControl);
}
}
//called when swap notification is received to highlight and select own/enemy pieces
public void outlineSwap(List<UUID> ownPieces, List<UUID> enemyPieces){
selectableEnemyPieces.clear();
selectableOwnPieces.clear();
selectedOwnPiece = null;
selectedEnemyPiece = null;
for(UUID uuid : ownPieces) {
PieceControl p = pieces.get(uuid);
p.highlight(false);
p.setHoverable(true);
p.setSelectable(true);
selectableOwnPieces.add(p);
}
for(UUID uuid : enemyPieces) {
PieceControl p = pieces.get(uuid);
p.highlight(true);
p.setHoverable(true);
p.setSelectable(true);
selectableEnemyPieces.add(p);
}
}
//called from inputSynchronizer when a piece is selectable
public void pieceSelect(PieceControl pieceSelected) {
boolean isSelected = pieceSelected.isSelected();
if(selectableOwnPieces.contains(pieceSelected)){
for(PieceControl p : selectableOwnPieces) {
p.unSelect();
}
if (!isSelected) {
pieceSelected.select();
selectedOwnPiece = pieceSelected;
}
else {
pieceSelected.unSelect();
selectedOwnPiece = null;
}
}
else if(selectableEnemyPieces.contains(pieceSelected)) {
for(PieceControl p : selectableEnemyPieces) {
p.unSelect();
}
if (!isSelected) {
pieceSelected.select();
selectedEnemyPiece = pieceSelected;
}
else {
pieceSelected.unSelect();
selectedEnemyPiece = null;
}
}
else throw new RuntimeException("pieceSelected is not in own/enemySelectablePieces");
}
//called when view is no longer needed to select pieces
public void clearSelectable(){
for(PieceControl p : selectableEnemyPieces) {
p.unSelect();
p.setSelectable(false);
}
for(PieceControl p : selectableOwnPieces) {
p.unSelect();
p.setSelectable(false);
}
selectableEnemyPieces.clear();
selectableOwnPieces.clear();
selectedEnemyPiece = null;
selectedOwnPiece = null;
}
public void deOutline(int index){
infield.get(index).deOutline();
outlineControls.remove(infield.get(index));
}
public void enableHover(UUID uuid){
pieces.get(uuid).setHoverable(true);
}
} }

View File

@@ -1,22 +1,27 @@
package pp.mdga.client.board; package pp.mdga.client.board;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl; import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp;
public class NodeControl extends AbstractControl { public class NodeControl extends OutlineControl {
@Override private static final ColorRGBA OUTLINE_HIGHLIGHT_COLOR = ColorRGBA.White;
protected void controlUpdate(float v) { private static final int OUTLINE_HIGHLIGHT_WIDTH = 6;
}
@Override
protected void controlRender(RenderManager renderManager, ViewPort viewPort) {
public NodeControl(MdgaApp app, FilterPostProcessor fpp) {
super(app, fpp);
} }
public Vector3f getLocation(){ public Vector3f getLocation(){
return this.getSpatial().getLocalTranslation(); return this.getSpatial().getLocalTranslation();
} }
public void highlight() {
super.outline(OUTLINE_HIGHLIGHT_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
}
} }

View File

@@ -0,0 +1,79 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.material.MaterialDef;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.texture.FrameBuffer;
public class OutlineProFilter extends Filter {
private OutlinePreFilter outlinePreFilter;
private ColorRGBA outlineColor = new ColorRGBA(0, 1, 0, 1);
private float outlineWidth = 1;
public OutlineProFilter(OutlinePreFilter outlinePreFilter) {
super("OutlineFilter");
this.outlinePreFilter = outlinePreFilter;
}
@Override
protected void initFilter(AssetManager assetManager, RenderManager renderManager, ViewPort vp, int w, int h) {
MaterialDef matDef = (MaterialDef) assetManager.loadAsset("MatDefs/SelectObjectOutliner/OutlinePro.j3md");
material = new Material(matDef);
material.setVector2("Resolution", new Vector2f(w, h));
material.setColor("OutlineColor", outlineColor);
material.setFloat("OutlineWidth", outlineWidth);
}
@Override
protected void preFrame(float tpf) {
super.preFrame(tpf);
material.setTexture("OutlineDepthTexture", outlinePreFilter.getOutlineTexture());
// System.out.println("OutlineFilter.preFrame()");
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
// material.setTexture("OutlineDepthTexture", outlinePreFilter.getDefaultPassDepthTexture());
// System.out.println("OutlineFilter.postFrame()");
}
@Override
protected Material getMaterial() {
return material;
}
public ColorRGBA getOutlineColor() {
return outlineColor;
}
public void setOutlineColor(ColorRGBA outlineColor) {
this.outlineColor = outlineColor;
if (material != null) {
material.setColor("OutlineColor", outlineColor);
}
}
public float getOutlineWidth() {
return outlineWidth;
}
public void setOutlineWidth(float outlineWidth) {
this.outlineWidth = outlineWidth;
if (material != null) {
material.setFloat("OutlineWidth", outlineWidth);
}
}
public OutlinePreFilter getOutlinePreFilter() {
return outlinePreFilter;
}
}

View File

@@ -23,8 +23,8 @@ public class SelectObjectOutliner {
private final int width; private final int width;
private boolean selected; private boolean selected;
private ViewPort outlineViewport = null; private ViewPort outlineViewport = null;
private OutlineFilter outlineFilter = null; // private OutlineFilter outlineFilter = null;
private OutlineProFilter outlineFilter = null;
public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam) { public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam) {
this.selected = false; this.selected = false;
@@ -49,11 +49,19 @@ public void select(Spatial model, ColorRGBA color) {
} }
} }
public void select(Spatial model, ColorRGBA color, int width) {
if(!selected){
selected = true;
showOutlineFilterEffect(model, width, color);
}
}
private void hideOutlineFilterEffect(Spatial model) { private void hideOutlineFilterEffect(Spatial model) {
outlineFilter.setEnabled(false); outlineFilter.setEnabled(false);
outlineFilter.getOutlinePreFilter().setEnabled(false); outlineFilter.getOutlinePreFilter().setEnabled(false);
fpp.removeFilter(outlineFilter); fpp.removeFilter(outlineFilter);
outlineViewport.detachScene(model); outlineViewport.detachScene(model);
outlineViewport.clearProcessors();
renderManager.removePreView(outlineViewport); renderManager.removePreView(outlineViewport);
outlineViewport = null; outlineViewport = null;
} }
@@ -68,7 +76,8 @@ private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color)
outlineViewport.attachScene(model); outlineViewport.attachScene(model);
outlineViewport.addProcessor(outlineFpp); outlineViewport.addProcessor(outlineFpp);
outlineFilter = new OutlineFilter(outlinePreFilter); // outlineFilter = new OutlineFilter(outlinePreFilter);
outlineFilter = new OutlineProFilter(outlinePreFilter);
outlineFilter.setOutlineColor(color); outlineFilter.setOutlineColor(color);
outlineFilter.setOutlineWidth(width); outlineFilter.setOutlineWidth(width);

View File

@@ -0,0 +1,51 @@
package pp.mdga.client.board;
import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.board.Outline.SelectObjectOutliner;
public class OutlineControl extends AbstractControl {
private static final int THICKNESS_DEFAULT = 6;
private final SelectObjectOutliner outlineOwn;
public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera());
}
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam);
}
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness){
outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam);
}
public void outline(ColorRGBA color){
outlineOwn.select(spatial, color);
}
public void outline(ColorRGBA color, int width){
deOutline();
outlineOwn.select(spatial, color, width);
}
public void deOutline(){
outlineOwn.deselect(spatial);
}
@Override
protected void controlUpdate(float tpf) {
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
}

View File

@@ -7,18 +7,14 @@
import com.jme3.math.Quaternion; import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue; import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.Asset; import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.board.Outline.SelectObjectOutliner;
public class PieceControl extends AbstractControl { public class PieceControl extends OutlineControl {
private final float initRotation; private final float initRotation;
private final AssetManager assetManager; private final AssetManager assetManager;
private Spatial shieldRing; private Spatial shieldRing;
@@ -30,40 +26,53 @@ public class PieceControl extends AbstractControl {
private static final ColorRGBA SHIELD_SUPPRESSED_COLOR = new ColorRGBA(1f, 0.5f, 0, SHIELD_TRANSPARENCY); private static final ColorRGBA SHIELD_SUPPRESSED_COLOR = new ColorRGBA(1f, 0.5f, 0, SHIELD_TRANSPARENCY);
private static final float SHIELD_Z = 0f; private static final float SHIELD_Z = 0f;
SelectObjectOutliner outlineOwn;
private static final ColorRGBA OUTLINE_OWN_COLOR = ColorRGBA.White; private static final ColorRGBA OUTLINE_OWN_COLOR = ColorRGBA.White;
private static final ColorRGBA OUTLINE_ENEMY_COLOR = ColorRGBA.Red; private static final ColorRGBA OUTLINE_ENEMY_COLOR = ColorRGBA.Red;
private static final int OUTLINE_THICKNESS = 4; private static final ColorRGBA OUTLINE_OWN_HOVER_COLOR = ColorRGBA.Yellow;
private static final ColorRGBA OUTLINE_ENEMY_HOVER_COLOR = ColorRGBA.Green;
private static final ColorRGBA OUTLINE_OWN_SELECT_COLOR = ColorRGBA.Cyan;
private static final ColorRGBA OUTLINE_ENEMY_SELECT_COLOR = ColorRGBA.Orange;
private static final int OUTLINE_HIGHLIGHT_WIDTH = 6;
private static final int OUTLINE_HOVER_WIDTH = 6;
private static final int OUTLINE_SELECT_WIDTH = 8;
private final Node parentNode; private final Node parentNode;
private boolean enemy;
private boolean hoverable;
private boolean highlight;
private boolean selectable;
private boolean select;
public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp){ public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp){
super(); super(app, fpp);
this.parentNode = new Node(); this.parentNode = new Node();
this.initRotation = initRotation; this.initRotation = initRotation;
this.assetManager = assetManager; this.assetManager = assetManager;
this.shieldRing = null; this.shieldRing = null;
this.shieldMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); this.shieldMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
this.shieldMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha); this.shieldMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
enemy = false;
hoverable = false;
outlineOwn = new SelectObjectOutliner(OUTLINE_THICKNESS, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera()); highlight = false;
selectable = false;
select = false;
} }
public float getRotation() { public float getRotation() {
return (float) Math.toDegrees(this.spatial.getLocalRotation().toAngleAxis(new Vector3f(0,0,1))); return (float) Math.toDegrees(spatial.getLocalRotation().toAngleAxis(new Vector3f(0,0,1)));
} }
public void setRotation(float rot){ public void setRotation(float rot){
if(rot < 0) rot =- 360;
Quaternion quaternion = new Quaternion(); Quaternion quaternion = new Quaternion();
quaternion.fromAngleAxis((float) Math.toRadians(rot), new Vector3f(0,0,1)); quaternion.fromAngleAxis((float) Math.toRadians(rot), new Vector3f(0,0,1));
this.spatial.setLocalRotation(quaternion); spatial.setLocalRotation(quaternion);
} }
public Vector3f getLocation(){ public Vector3f getLocation(){
return this.getSpatial().getLocalTranslation(); return spatial.getLocalTranslation();
} }
@Override @Override
@@ -73,18 +82,13 @@ protected void controlUpdate(float delta) {
} }
} }
@Override
protected void controlRender(RenderManager renderManager, ViewPort viewPort) {
}
public void setLocation(Vector3f loc){ public void setLocation(Vector3f loc){
this.getSpatial().setLocalTranslation(loc); this.spatial.setLocalTranslation(loc);
} }
@Override @Override
public void setSpatial(Spatial spatial){ public void setSpatial(Spatial spatial){
if(this.getSpatial() == null && spatial != null){ if(this.spatial == null && spatial != null){
super.setSpatial(spatial); super.setSpatial(spatial);
initSpatial(); initSpatial();
} }
@@ -96,8 +100,8 @@ public void setSpatial(Spatial spatial){
public void initSpatial(){ public void initSpatial(){
setRotation(this.initRotation); setRotation(this.initRotation);
Node oldParent = this.spatial.getParent(); Node oldParent = spatial.getParent();
this.parentNode.setName(this.spatial.getName() + " Parent"); this.parentNode.setName(spatial.getName() + " Parent");
oldParent.detachChild(this.getSpatial()); oldParent.detachChild(this.getSpatial());
this.parentNode.attachChild(this.getSpatial()); this.parentNode.attachChild(this.getSpatial());
oldParent.attachChild(this.parentNode); oldParent.attachChild(this.parentNode);
@@ -132,19 +136,66 @@ public void suppressShield(){
} }
public void setMaterial(Material mat){ public void setMaterial(Material mat){
this.spatial.setMaterial(mat); spatial.setMaterial(mat);
} }
public Material getMaterial(){ public Material getMaterial(){
return ((Geometry) this.spatial).getMaterial(); return ((Geometry) getSpatial()).getMaterial();
} }
public void outline(boolean enemy) {
ColorRGBA color = enemy ? OUTLINE_ENEMY_COLOR : OUTLINE_OWN_COLOR; //highlight own/enemy figure to select
outlineOwn.select(this.getSpatial(), color); public void highlight(boolean enemy) {
this.enemy = enemy;
highlight = true;
super.outline(enemy ? OUTLINE_ENEMY_COLOR : OUTLINE_OWN_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
}
public void unHighlight(){
highlight = false;
}
public void hover(){
if(!hoverable) return;
super.outline(enemy ? OUTLINE_ENEMY_HOVER_COLOR : OUTLINE_OWN_HOVER_COLOR, OUTLINE_HOVER_WIDTH);
}
public void hoverOff(){
if(!hoverable) return;
if(select) select();
else if(highlight) highlight(enemy);
else deOutline();
}
public void unSelect(){
select = false;
if(highlight) highlight(enemy);
else deOutline();
}
public void select(){
if(!selectable) return;
select = true;
super.outline(enemy ? OUTLINE_ENEMY_SELECT_COLOR : OUTLINE_OWN_SELECT_COLOR, OUTLINE_SELECT_WIDTH);
}
public void setSelectable(boolean selectable){
this.selectable = selectable;
}
public boolean isSelected() { return select; }
public boolean isSelectable() {
return selectable;
}
public void setHoverable(boolean hoverable) {
this.hoverable = hoverable;
} }
public void deOutline() { public void deOutline() {
outlineOwn.deselect(this.getSpatial()); super.deOutline();
} }
} }

View File

@@ -19,7 +19,7 @@ public HostDialog(MdgaApp app, Node node, Runnable backAction) {
quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor()); quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
container.setBackground(quad1); container.setBackground(quad1);
Texture texture = app.getAssetManager().loadTexture("mdga_logo.png"); Texture texture = app.getAssetManager().loadTexture("Images/mdga_logo.png");
QuadBackgroundComponent b = new QuadBackgroundComponent(texture); QuadBackgroundComponent b = new QuadBackgroundComponent(texture);

View File

@@ -22,7 +22,7 @@ public JoinDialog(MdgaApp app, Node node, Runnable backAction) {
quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor()); quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
container.setBackground(quad1); container.setBackground(quad1);
Texture texture = app.getAssetManager().loadTexture("mdga_logo.png"); Texture texture = app.getAssetManager().loadTexture("Images/mdga_logo.png");
QuadBackgroundComponent b = new QuadBackgroundComponent(texture); QuadBackgroundComponent b = new QuadBackgroundComponent(texture);

View File

@@ -18,7 +18,7 @@ public class SettingsButtonDialog extends Dialog {
public SettingsButtonDialog(MdgaApp app, Node node, String label, Runnable action) { public SettingsButtonDialog(MdgaApp app, Node node, String label, Runnable action) {
super(app, node); super(app, node);
icon = new IconComponent("zahnrad.png"); icon = new IconComponent("Images/zahnrad.png");
icon.setIconScale(0.1f * app.getResolutionFactor()); icon.setIconScale(0.1f * app.getResolutionFactor());
createButton(label, action, new Vector3f(60 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0)); createButton(label, action, new Vector3f(60 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));

View File

@@ -0,0 +1,66 @@
package pp.mdga.client.dialog;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.HAlignment;
import com.simsilica.lemur.VAlignment;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import pp.mdga.client.MdgaApp;
public class SingleButtonTopRight extends Dialog {
public SingleButtonTopRight(MdgaApp app, Node node, String label, Runnable action) {
super(app, node);
createButton(label, action, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
}
@Override
public void show() {
super.show();
float x = (14 * horitontal_step) - container.getPreferredSize().x;
float y = 8.5f * vertical_step;
container.setLocalTranslation(x, y, 0);
}
@Override
public void hide() {
super.hide();
}
protected void createButton(String label, Runnable action, Vector3f size) {
Button button = new Button(label);
button.addClickCommands(source -> action.run());
button.setFontSize(fontSize);
button.setHighlightColor(ColorRGBA.White);
button.setColor(ColorRGBA.Black);
button.setPreferredSize(size);
button.setTextHAlignment(HAlignment.Center);
button.setTextVAlignment(VAlignment.Center);
QuadBackgroundComponent background = new QuadBackgroundComponent(ColorRGBA.Red);
background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
button.setBackground(background);
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(ColorRGBA.Yellow);
hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
source.setBackground(hoverBackground);
button.setHighlightColor(ColorRGBA.White);
button.setColor(ColorRGBA.Black);
});
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOff, (source) -> {
QuadBackgroundComponent normalBackground = new QuadBackgroundComponent(ColorRGBA.Red);
normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
source.setBackground(normalBackground);
button.setHighlightColor(ColorRGBA.White);
button.setColor(ColorRGBA.Black);
});
container.addChild(button);
}
}

View File

@@ -19,7 +19,7 @@ public StartDialog(MdgaApp app, Node node) {
quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor()); quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
container.setBackground(quad1); container.setBackground(quad1);
Texture texture = app.getAssetManager().loadTexture("mdga_logo.png"); Texture texture = app.getAssetManager().loadTexture("Images/mdga_logo.png");
QuadBackgroundComponent b = new QuadBackgroundComponent(texture); QuadBackgroundComponent b = new QuadBackgroundComponent(texture);

View File

@@ -1,23 +1,24 @@
package pp.mdga.client.gui; package pp.mdga.client.gui;
import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl; import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.board.OutlineControl;
public class CardControl extends AbstractControl { public class CardControl extends OutlineControl {
public CardControl(){ private static final ColorRGBA OUTLINE_COLOR = ColorRGBA.Yellow;
private static final int OUTLINE_THICKNESS = 9;
public CardControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
super(app, fpp, cam, OUTLINE_THICKNESS);
} }
public void outline(){
@Override super.outline(OUTLINE_COLOR);
protected void controlUpdate(float tpf) {
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
} }
} }

View File

@@ -5,11 +5,15 @@
import com.jme3.app.state.AppStateManager; import com.jme3.app.state.AppStateManager;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.ComposeFilter;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.texture.Image;
import com.jme3.texture.Texture2D;
import pp.mdga.client.Asset; import pp.mdga.client.Asset;
import java.util.*; import java.util.*;
@@ -21,11 +25,16 @@ public class CardLayer extends AbstractAppState {
private boolean init; private boolean init;
private List<Spatial> cardBuffer; private List<Spatial> cardBuffer;
private final FilterPostProcessor fpp;
private final Camera overlayCam;
Texture2D backTexture;
public CardLayer(FilterPostProcessor fpp, Camera overlayCam, Texture2D backTexture) {
public CardLayer() { this.overlayCam = overlayCam;
this.fpp = fpp;
this.cardBuffer = new ArrayList<>(); this.cardBuffer = new ArrayList<>();
init = false; init = false;
this.backTexture = backTexture;
} }
@Override @Override
@@ -33,23 +42,20 @@ public void initialize(AppStateManager stateManager, Application app ) {
this.app = app; this.app = app;
root = new Node("Under gui viewport Root"); root = new Node("Under gui viewport Root");
Camera originalCam = app.getCamera(); ViewPort view = app.getRenderManager().createMainView("Under gui ViewPort", overlayCam);
Camera cam = new Camera(originalCam.getWidth(), originalCam.getHeight());
cam.setParallelProjection(false);
cam.setFrustum(originalCam.getFrustumNear(), originalCam.getFrustumFar(), originalCam.getFrustumLeft(), originalCam.getFrustumRight(),originalCam.getFrustumTop(), originalCam.getFrustumBottom());
cam.setFov(originalCam.getFov());
cam.setLocation(new Vector3f(0, 0, 10));
cam.lookAt(new Vector3f(0,0,0), Vector3f.UNIT_Y);
ViewPort view = app.getRenderManager().createMainView("Under gui ViewPort", cam);
view.setEnabled(true); view.setEnabled(true);
view.setClearFlags(false, true, false); view.setClearFlags(true, true, true);
view.attachScene(root); view.attachScene(root);
fpp.setFrameBufferFormat(Image.Format.RGBA8);
fpp.addFilter(new ComposeFilter(backTexture));
view.addProcessor(fpp);
if(!init) init = true; if(!init) init = true;
}
public void shutdown(){
cardBuffer.clear();
root.detachAllChildren();
} }
@@ -61,7 +67,7 @@ public void render(RenderManager rm) {
@Override @Override
public void update( float tpf ) { public void update( float tpf ) {
root.updateLogicalState(tpf);
if (init && !cardBuffer.isEmpty()) { if (init && !cardBuffer.isEmpty()) {
for(Spatial spatial : cardBuffer){ for(Spatial spatial : cardBuffer){
@@ -69,9 +75,22 @@ public void update( float tpf ) {
} }
cardBuffer.clear(); cardBuffer.clear();
} }
root.updateLogicalState(tpf);
} }
public void addCard(Spatial card){ public void addSpatial(Spatial card){
cardBuffer.add(card); cardBuffer.add(card);
} }
public void deleteSpatial(Spatial spatial){
root.detachChild(spatial);
}
public Camera getOverlayCam(){
return overlayCam;
}
public Node getRootNode(){
return root;
}
} }

View File

@@ -0,0 +1,105 @@
package pp.mdga.client.gui;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl;
import java.util.Random;
public class DiceControl extends AbstractControl {
private final Random random = new Random();
private Quaternion targetRotation; // Final rotation of the dice
private final Vector3f angularVelocity = new Vector3f(); // Rotational velocity (radians/sec)
private float deceleration = 0.5f; // Friction-like deceleration
private boolean isRolling = false;
private boolean slerp = false;
private float timeElapsed = 0.0f;
private float rollDuration = 0.0001f;
@Override
protected void controlUpdate(float tpf) {
if (isRolling) {
if(!slerp) {
// Apply rotational velocity to the dice
Quaternion currentRotation = spatial.getLocalRotation();
Quaternion deltaRotation = new Quaternion();
deltaRotation.fromAngles(
angularVelocity.x * tpf,
angularVelocity.y * tpf,
angularVelocity.z * tpf
);
spatial.setLocalRotation(currentRotation.mult(deltaRotation));
// Gradually reduce rotational velocity (simulate deceleration)
angularVelocity.subtractLocal(
angularVelocity.mult(deceleration * tpf)
);
// Stop rolling when angular velocity is close to zero
if (angularVelocity.lengthSquared() < 3f) {
slerp = true;
}
}
else {
timeElapsed += tpf * rollDuration;
if (timeElapsed > 1.0f) timeElapsed = 1.0f;
// Quaternion interpolated = new Quaternion();
// interpolated.slerp(spatial.getLocalRotation(), targetRotation, progress);
// spatial.setLocalRotation(interpolated);
Quaternion interpolated = spatial.getLocalRotation().clone();
interpolated.nlerp(targetRotation, lerp(timeElapsed));
spatial.setLocalRotation(interpolated);
// Stop rolling once duration is complete
if (timeElapsed >= 1.0f) {
isRolling = false;
slerp = false;
}
}
}
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
// No custom rendering needed
}
public void rollDice(int diceNum) {
if (isRolling) return; // Prevent re-rolling during animation
// Set high initial rotational velocity
angularVelocity.set(
random.nextFloat() * 1000f + 200f, // X-axis speed
random.nextFloat() * 1000f + 200f, // Y-axis speed
random.nextFloat() * 1000f + 200f // Z-axis speed
);
// Set final target rotation for the diceNum
targetRotation = getRotationForDiceNum(diceNum);
isRolling = true;
}
private Quaternion getRotationForDiceNum(int diceNum) {
// Define specific rotations for each dice face (adjust based on your dice model)
return switch (diceNum) {
case 1 -> new Quaternion().fromAngleAxis((float) (1 * (Math.PI / 2)), Vector3f.UNIT_X); //
case 2 -> new Quaternion().fromAngleAxis((float) (1 * (Math.PI / 2)), Vector3f.UNIT_Y); //
case 3 -> new Quaternion().fromAngleAxis((float) (0 * (Math.PI / 2)), Vector3f.UNIT_X); //
case 4 -> new Quaternion().fromAngleAxis((float) (2 * (Math.PI / 2)), Vector3f.UNIT_Y); //
case 5 -> new Quaternion().fromAngleAxis((float) (3 * (Math.PI / 2)), Vector3f.UNIT_Y); //
case 6 -> new Quaternion().fromAngleAxis((float) (3 * (Math.PI / 2)), Vector3f.UNIT_X); //
default -> throw new IllegalArgumentException("Invalid dice number: " + diceNum);
};
}
public static float lerp(float t) {
return (float) Math.sqrt(1 - Math.pow(t - 1, 2));
}
}

View File

@@ -1,15 +1,21 @@
package pp.mdga.client.gui; package pp.mdga.client.gui;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.texture.Texture2D;
import pp.mdga.client.Asset; import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.game.BonusCard; import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import java.util.UUID;
public class GuiHandler { public class GuiHandler {
@@ -17,23 +23,44 @@ public class GuiHandler {
private MdgaApp app; private MdgaApp app;
private CardLayer cardLayer; private CardLayer cardLayer;
private Map<UUID, CardControl> ownCardsMap; private Map<UUID, CardControl> ownCardsMap;
private BitmapFont playerFont;
private Node playerNameNode;
private List<Color> playerOrder;
Map<Color, String> colorNameMap;
private static final Vector3f START = new Vector3f(-3,-3,0); private static final Vector3f START = new Vector3f(-3,-3,0);
private static final Vector3f MARGIN = new Vector3f(2.5f,0,0); private static final Vector3f MARGIN = new Vector3f(2.5f,0,0);
public GuiHandler(MdgaApp app) { private final FilterPostProcessor fpp;
Texture2D backTexture;
private Camera cardLayerCamera;
public GuiHandler(MdgaApp app, Texture2D backTexture) {
this.app = app; this.app = app;
this.fpp = new FilterPostProcessor(app.getAssetManager());
this.backTexture = backTexture;
cardLayerCamera = createOverlayCam();
} }
public void init(){ public void init(){
cardLayer = new CardLayer(); cardLayer = new CardLayer(fpp, cardLayerCamera, backTexture);
app.getStateManager().attach(cardLayer); app.getStateManager().attach(cardLayer);
ownCardsMap = new HashMap<>(); ownCardsMap = new HashMap<>();
playerFont = app.getAssetManager().loadFont("Fonts/Gunplay.fnt");
playerNameNode = new Node("player name node");
app.getGuiNode().attachChild(playerNameNode);
playerOrder = new ArrayList<>();
colorNameMap = new HashMap<>();
}
addCard(BonusCard.SHIELD, UUID.randomUUID());
addCard(BonusCard.TURBO, UUID.randomUUID());
addCard(BonusCard.SWAP, UUID.randomUUID());
public void shutdown(){
if(cardLayer != null){
cardLayer.shutdown();
}
cardLayer = null;
ownCardsMap = null;
} }
private Asset bonusToAsset(BonusCard card){ private Asset bonusToAsset(BonusCard card){
@@ -48,7 +75,33 @@ private Asset bonusToAsset(BonusCard card){
public void addCard(BonusCard card, UUID uuid) { public void addCard(BonusCard card, UUID uuid) {
CardControl control = createCard(bonusToAsset(card), nextPos()); CardControl control = createCard(bonusToAsset(card), nextPos());
ownCardsMap.put(uuid, control); ownCardsMap.put(uuid, control);
cardLayer.addCard(control.getSpatial()); cardLayer.addSpatial(control.getSpatial());
}
public void showDice(){
DiceControl control = createDice();
cardLayer.addSpatial(control.getSpatial());
control.rollDice(1);
}
private DiceControl createDice() {
Spatial spatial = app.getAssetManager().loadModel(Asset.dice.getModelPath());
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", app.getAssetManager().loadTexture(Asset.dice.getDiffPath()));
spatial.setMaterial(mat);
spatial.setLocalScale(1f);
spatial.setLocalTranslation(new Vector3f(0,0,0));
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180));
DiceControl control = new DiceControl();
spatial.addControl(control);
return control;
}
public void deleteCard(UUID uuid){
if(!ownCardsMap.containsKey(uuid)) throw new RuntimeException("uuid dont exist in ownCardsmap");
cardLayer.deleteSpatial(ownCardsMap.get(uuid).getSpatial());
ownCardsMap.remove(uuid);
} }
private Vector3f nextPos() { private Vector3f nextPos() {
@@ -63,8 +116,92 @@ private CardControl createCard(Asset card, Vector3f pos){
spatial.setLocalScale(1f); spatial.setLocalScale(1f);
spatial.setLocalTranslation(pos); spatial.setLocalTranslation(pos);
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180)); spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180));
CardControl control = new CardControl(); CardControl control = new CardControl(app, fpp, cardLayer.getOverlayCam());
spatial.addControl(control); spatial.addControl(control);
return control; return control;
} }
private void drawPlayers(){
playerNameNode.detachAllChildren();
float paddingTop = 10;
float paddingLeft = 15;
float margin = 35;
for(int i = 0; i < playerOrder.size(); i++) {
Color color = playerOrder.get(i);
if(!colorNameMap.containsKey(color)) throw new RuntimeException(color + " isn't mapped to a name");
String name = colorNameMap.get(color);
renderName(name, paddingTop + margin * i, paddingLeft, i == 0);
}
}
private void renderName(String name, float paddingTop, float paddingLeft, boolean first){
BitmapText hudText = new BitmapText(playerFont);
//renderedSize = 45
hudText.setSize(28);
hudText.setColor(first ? ColorRGBA.Blue : ColorRGBA.White);
hudText.setText(name);
int screenHeight = app.getContext().getSettings().getHeight();
hudText.setLocalTranslation(paddingLeft, screenHeight - paddingTop, 0);
playerNameNode.attachChild(hudText);
}
public void setPlayers(List<String> names, List<Color> colors){
if(names.size() != colors.size()) throw new RuntimeException("names and colors are not the same size");
for(int i = 0; i < names.size(); i++){
colorNameMap.put(colors.get(i), names.get(i));
}
this.playerOrder = new ArrayList<>(colors);
drawPlayers();
}
public void addPlayer(Color color, String name){
colorNameMap.put(color, name);
playerOrder.add(color);
drawPlayers();
}
public void setActivePlayer(Color color){
Color lastFirst = playerOrder.remove(0);
playerOrder.remove(color);
playerOrder.add(0,color);
playerOrder.add(lastFirst);
drawPlayers();
}
private Camera createOverlayCam(){
Camera originalCam = app.getCamera();
Camera overlayCam = new Camera(originalCam.getWidth(), originalCam.getHeight());
overlayCam.setParallelProjection(false);
overlayCam.setFrustum(originalCam.getFrustumNear(), originalCam.getFrustumFar(), originalCam.getFrustumLeft(), originalCam.getFrustumRight(),originalCam.getFrustumTop(), originalCam.getFrustumBottom());
overlayCam.setFov(originalCam.getFov());
overlayCam.setLocation(new Vector3f(0, 0, 10));
overlayCam.lookAt(new Vector3f(0,0,0), Vector3f.UNIT_Y);
return overlayCam;
}
public void test(){
UUID uuid = UUID.randomUUID();
addCard(BonusCard.SHIELD, uuid);
addCard(BonusCard.TURBO, UUID.randomUUID());
addCard(BonusCard.SWAP, UUID.randomUUID());
showDice();
}
public Camera getCardLayerCamera() {
return cardLayerCamera;
}
public CardLayer getCardLayer(){
return cardLayer;
}
} }

View File

@@ -39,7 +39,7 @@ public void onLeave() {
} }
private void awardCeremony() { private void awardCeremony() {
background = createBackground("b1.png"); background = createBackground("Images/b1.png");
node.attachChild(background); node.attachChild(background);
continueButton.show(); continueButton.show();
@@ -47,7 +47,7 @@ private void awardCeremony() {
} }
private void statistics() { private void statistics() {
background = createBackground("b2.png"); background = createBackground("Images/b2.png");
node.attachChild(background); node.attachChild(background);
continueButton.show(); continueButton.show();

View File

@@ -1,6 +1,15 @@
package pp.mdga.client.view; package pp.mdga.client.view;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.ComposeFilter;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image;
import com.jme3.texture.Texture2D;
import pp.mdga.client.board.BoardHandler; import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.board.CameraHandler; import pp.mdga.client.board.CameraHandler;
import pp.mdga.client.dialog.SingleButtonLeftDialog; import pp.mdga.client.dialog.SingleButtonLeftDialog;
@@ -31,7 +40,13 @@ public GameView(MdgaApp app) {
this.boardHandler = new BoardHandler(app, fpp); this.boardHandler = new BoardHandler(app, fpp);
app.getViewPort().addProcessor(fpp); app.getViewPort().addProcessor(fpp);
this.guiHandler = new GuiHandler(app); FrameBuffer backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1);
Texture2D backTexture = new Texture2D(app.getCamera().getWidth(), app.getCamera().getHeight(), Image.Format.RGBA8);
backFrameBuffer.setDepthTarget(FrameBuffer.FrameBufferTarget.newTarget(Image.Format.Depth));
backFrameBuffer.addColorTarget(FrameBuffer.FrameBufferTarget.newTarget(backTexture));
app.getViewPort().setOutputFrameBuffer(backFrameBuffer);
this.guiHandler = new GuiHandler(app, backTexture);
leaveButton = new SingleButtonLeftDialog(app, settingsNode, "Verlassen", () -> leaveGame()); leaveButton = new SingleButtonLeftDialog(app, settingsNode, "Verlassen", () -> leaveGame());
@@ -45,6 +60,21 @@ public void onEnter() {
guiHandler.init(); guiHandler.init();
continueButton.show(); continueButton.show();
// boardHandler.addPlayer(Color.AIRFORCE, test);
// boardHandler.movePieceStart(player0, 0);
// boardHandler.enableHover(player0);
// boardHandler.enableHover(player1);
// boardHandler.highlight(player0, true);
// boardHandler.outline(player0, true);
// boardHandler.outline(10);
guiHandler.test();
} }
@Override @Override
@@ -81,4 +111,8 @@ private void leaveGame() {
public BoardHandler getBoardHandler() { public BoardHandler getBoardHandler() {
return boardHandler; return boardHandler;
} }
public GuiHandler getGuiHandler() {
return guiHandler;
}
} }

View File

@@ -21,7 +21,7 @@ public class LobbyView extends MdgaView {
public LobbyView(MdgaApp app) { public LobbyView(MdgaApp app) {
super(app); super(app);
background = createBackground("lobby.png"); background = createBackground("Images/lobby.png");
node.attachChild(background); node.attachChild(background);
readyButton = new SingleButtonRightDialog(app, node, "Fertig", () -> app.getModelSyncronizer().setReady()); readyButton = new SingleButtonRightDialog(app, node, "Fertig", () -> app.getModelSyncronizer().setReady());

View File

@@ -18,7 +18,7 @@ public class MainView extends MdgaView {
public MainView(MdgaApp app) { public MainView(MdgaApp app) {
super(app); super(app);
background = createBackground("powercards.png"); background = createBackground("Images/powercards.png");
node.attachChild(background); node.attachChild(background);
Vector3f size = new Vector3f(280, 60, 0); Vector3f size = new Vector3f(280, 60, 0);

View File

@@ -35,6 +35,8 @@ public abstract class MdgaView {
private SettingsDialog audio; private SettingsDialog audio;
private SettingsDialog video; private SettingsDialog video;
private static final String IMAGE_ROOT = "Images/";
public MdgaView(MdgaApp app) { public MdgaView(MdgaApp app) {
this.app = app; this.app = app;
this.node = new Node(); this.node = new Node();
@@ -45,29 +47,29 @@ public MdgaView(MdgaApp app) {
this.settingsButton = new SettingsButtonDialog(app, node, "", () -> enterSettings(false)); this.settingsButton = new SettingsButtonDialog(app, node, "", () -> enterSettings(false));
this.settingsBackground = createBackground("background/zahnräder.png"); this.settingsBackground = createBackground(IMAGE_ROOT + "background/zahnräder.png");
settingsNode.attachChild(settingsBackground); settingsNode.attachChild(settingsBackground);
this.audioBackground = createBackground("background/lautsprecher.png"); this.audioBackground = createBackground(IMAGE_ROOT + "background/lautsprecher.png");
audioSettingsNode.attachChild(audioBackground); audioSettingsNode.attachChild(audioBackground);
this.videoBackground = createBackground("background/monitors.png"); this.videoBackground = createBackground(IMAGE_ROOT + "background/monitors.png");
videoSettingsNode.attachChild(videoBackground); videoSettingsNode.attachChild(videoBackground);
Vector3f size = new Vector3f(280, 60, 0); Vector3f size = new Vector3f(280, 60, 0);
this.settings = new SettingsDialog(app, settingsNode, "zahnrad.png"); this.settings = new SettingsDialog(app, settingsNode, IMAGE_ROOT + "zahnrad.png");
this.settings.addButton("Video", () -> enterVideo(), size); this.settings.addButton("Video", () -> enterVideo(), size);
this.settings.addButton("Audio", () -> enterAudio(), size); this.settings.addButton("Audio", () -> enterAudio(), size);
this.settings.addButton("Zurück", () -> leaveSettings(false), size); this.settings.addButton("Zurück", () -> leaveSettings(false), size);
this.audio = new SettingsDialog(app, audioSettingsNode, "audio_icon.png"); this.audio = new SettingsDialog(app, audioSettingsNode, IMAGE_ROOT + "audio_icon.png");
this.audio.addSlider("Lautstärke", new PercentRunnable(app.getAcousticHandler()::setMainVolume), new GetPercentRunnable(app.getAcousticHandler()::getMainVolume), size, (int) app.getAcousticHandler().getMainVolume() * 100); this.audio.addSlider("Lautstärke", new PercentRunnable(app.getAcousticHandler()::setMainVolume), new GetPercentRunnable(app.getAcousticHandler()::getMainVolume), size, (int) app.getAcousticHandler().getMainVolume() * 100);
this.audio.addSlider("Musik", new PercentRunnable(app.getAcousticHandler()::setMusicVolume), new GetPercentRunnable(app.getAcousticHandler()::getMusicVolume), size, (int) app.getAcousticHandler().getMusicVolume() * 100); this.audio.addSlider("Musik", new PercentRunnable(app.getAcousticHandler()::setMusicVolume), new GetPercentRunnable(app.getAcousticHandler()::getMusicVolume), size, (int) app.getAcousticHandler().getMusicVolume() * 100);
this.audio.addSlider("Sound", new PercentRunnable(app.getAcousticHandler()::setSoundVolume), new GetPercentRunnable(app.getAcousticHandler()::getSoundVolume), size, (int) app.getAcousticHandler().getSoundVolume() * 100); this.audio.addSlider("Sound", new PercentRunnable(app.getAcousticHandler()::setSoundVolume), new GetPercentRunnable(app.getAcousticHandler()::getSoundVolume), size, (int) app.getAcousticHandler().getSoundVolume() * 100);
this.audio.addButton("Zurück", () -> leaveAudio(), size); this.audio.addButton("Zurück", () -> leaveAudio(), size);
this.video = new SettingsDialog(app, videoSettingsNode, "monitor.png"); this.video = new SettingsDialog(app, videoSettingsNode, IMAGE_ROOT + "monitor.png");
this.video.addButton("A", () -> System.out.println("A"), size); this.video.addButton("A", () -> System.out.println("A"), size);
this.video.addButton("B", () -> System.out.println("B"), size); this.video.addButton("B", () -> System.out.println("B"), size);
this.video.addButton("Zurück", () -> leaveVideo(), size); this.video.addButton("Zurück", () -> leaveVideo(), size);

View File

@@ -0,0 +1,195 @@
info face=null size=45 bold=0 italic=0 charset=ASCII unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
common lineHeight=55 base=26 scaleW=512 scaleH=512 pages=1 packed=0
page id=0 file="Gunplay.png"
chars count=255
char id=9 x=0 y=11 width=0 height=55 xoffset=0 yoffset=0 xadvance=-1 page=0 chnl=0
char id=10 x=0 y=11 width=0 height=55 xoffset=0 yoffset=0 xadvance=-1 page=0 chnl=0
char id=13 x=0 y=11 width=0 height=55 xoffset=0 yoffset=0 xadvance=-1 page=0 chnl=0
char id=32 x=0 y=11 width=0 height=55 xoffset=0 yoffset=0 xadvance=14 page=0 chnl=0
char id=33 x=0 y=11 width=9 height=55 xoffset=2 yoffset=0 xadvance=12 page=0 chnl=0
char id=34 x=9 y=11 width=15 height=55 xoffset=2 yoffset=0 xadvance=17 page=0 chnl=0
char id=35 x=24 y=11 width=24 height=55 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=0
char id=36 x=48 y=11 width=20 height=55 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=0
char id=37 x=68 y=11 width=37 height=55 xoffset=1 yoffset=0 xadvance=38 page=0 chnl=0
char id=38 x=105 y=11 width=32 height=55 xoffset=1 yoffset=0 xadvance=32 page=0 chnl=0
char id=39 x=137 y=11 width=7 height=55 xoffset=2 yoffset=0 xadvance=9 page=0 chnl=0
char id=40 x=144 y=11 width=10 height=55 xoffset=1 yoffset=0 xadvance=10 page=0 chnl=0
char id=41 x=154 y=11 width=10 height=55 xoffset=1 yoffset=0 xadvance=10 page=0 chnl=0
char id=42 x=164 y=11 width=17 height=55 xoffset=1 yoffset=0 xadvance=17 page=0 chnl=0
char id=43 x=181 y=11 width=21 height=55 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=0
char id=44 x=202 y=11 width=9 height=55 xoffset=1 yoffset=0 xadvance=10 page=0 chnl=0
char id=45 x=211 y=11 width=15 height=55 xoffset=2 yoffset=0 xadvance=18 page=0 chnl=0
char id=46 x=226 y=11 width=9 height=55 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=0
char id=47 x=235 y=11 width=25 height=55 xoffset=0 yoffset=0 xadvance=24 page=0 chnl=0
char id=48 x=260 y=11 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=49 x=286 y=11 width=15 height=55 xoffset=0 yoffset=0 xadvance=15 page=0 chnl=0
char id=50 x=301 y=11 width=26 height=55 xoffset=1 yoffset=0 xadvance=27 page=0 chnl=0
char id=51 x=327 y=11 width=25 height=55 xoffset=1 yoffset=0 xadvance=26 page=0 chnl=0
char id=52 x=352 y=11 width=28 height=55 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0
char id=53 x=380 y=11 width=24 height=55 xoffset=1 yoffset=0 xadvance=26 page=0 chnl=0
char id=54 x=404 y=11 width=25 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=55 x=429 y=11 width=23 height=55 xoffset=1 yoffset=0 xadvance=23 page=0 chnl=0
char id=56 x=452 y=11 width=25 height=55 xoffset=1 yoffset=0 xadvance=26 page=0 chnl=0
char id=57 x=477 y=11 width=26 height=55 xoffset=1 yoffset=0 xadvance=28 page=0 chnl=0
char id=58 x=503 y=11 width=8 height=55 xoffset=2 yoffset=0 xadvance=10 page=0 chnl=0
char id=59 x=0 y=66 width=9 height=55 xoffset=1 yoffset=0 xadvance=10 page=0 chnl=0
char id=60 x=9 y=66 width=14 height=55 xoffset=0 yoffset=0 xadvance=14 page=0 chnl=0
char id=61 x=23 y=66 width=22 height=55 xoffset=2 yoffset=0 xadvance=24 page=0 chnl=0
char id=62 x=45 y=66 width=14 height=55 xoffset=2 yoffset=0 xadvance=15 page=0 chnl=0
char id=63 x=59 y=66 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=64 x=82 y=66 width=32 height=55 xoffset=1 yoffset=0 xadvance=34 page=0 chnl=0
char id=65 x=114 y=66 width=29 height=55 xoffset=0 yoffset=0 xadvance=28 page=0 chnl=0
char id=66 x=143 y=66 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=67 x=169 y=66 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=68 x=195 y=66 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=69 x=221 y=66 width=21 height=55 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=0
char id=70 x=242 y=66 width=21 height=55 xoffset=2 yoffset=0 xadvance=22 page=0 chnl=0
char id=71 x=263 y=66 width=25 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=72 x=288 y=66 width=25 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=73 x=313 y=66 width=9 height=55 xoffset=2 yoffset=0 xadvance=12 page=0 chnl=0
char id=74 x=322 y=66 width=16 height=55 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=0
char id=75 x=338 y=66 width=28 height=55 xoffset=2 yoffset=0 xadvance=29 page=0 chnl=0
char id=76 x=366 y=66 width=20 height=55 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=0
char id=77 x=386 y=66 width=35 height=55 xoffset=2 yoffset=0 xadvance=38 page=0 chnl=0
char id=78 x=421 y=66 width=27 height=55 xoffset=2 yoffset=0 xadvance=30 page=0 chnl=0
char id=79 x=448 y=66 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=80 x=474 y=66 width=25 height=55 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=0
char id=81 x=0 y=121 width=26 height=55 xoffset=1 yoffset=0 xadvance=28 page=0 chnl=0
char id=82 x=26 y=121 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=83 x=52 y=121 width=28 height=55 xoffset=1 yoffset=0 xadvance=29 page=0 chnl=0
char id=84 x=80 y=121 width=27 height=55 xoffset=0 yoffset=0 xadvance=26 page=0 chnl=0
char id=85 x=107 y=121 width=26 height=55 xoffset=2 yoffset=0 xadvance=29 page=0 chnl=0
char id=86 x=133 y=121 width=29 height=55 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0
char id=87 x=162 y=121 width=42 height=55 xoffset=0 yoffset=0 xadvance=41 page=0 chnl=0
char id=88 x=204 y=121 width=31 height=55 xoffset=0 yoffset=0 xadvance=31 page=0 chnl=0
char id=89 x=235 y=121 width=29 height=55 xoffset=0 yoffset=0 xadvance=28 page=0 chnl=0
char id=90 x=264 y=121 width=25 height=55 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=0
char id=91 x=289 y=121 width=8 height=55 xoffset=2 yoffset=0 xadvance=10 page=0 chnl=0
char id=92 x=297 y=121 width=25 height=55 xoffset=0 yoffset=0 xadvance=24 page=0 chnl=0
char id=93 x=322 y=121 width=8 height=55 xoffset=2 yoffset=0 xadvance=10 page=0 chnl=0
char id=94 x=330 y=121 width=23 height=55 xoffset=1 yoffset=0 xadvance=23 page=0 chnl=0
char id=95 x=353 y=121 width=31 height=55 xoffset=-1 yoffset=0 xadvance=28 page=0 chnl=0
char id=96 x=384 y=121 width=14 height=55 xoffset=-1 yoffset=0 xadvance=13 page=0 chnl=0
char id=97 x=398 y=121 width=24 height=55 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=0
char id=98 x=422 y=121 width=22 height=55 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=0
char id=99 x=444 y=121 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=100 x=467 y=121 width=22 height=55 xoffset=1 yoffset=0 xadvance=23 page=0 chnl=0
char id=101 x=489 y=121 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=102 x=0 y=176 width=17 height=55 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=0
char id=103 x=17 y=176 width=22 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=104 x=39 y=176 width=22 height=55 xoffset=2 yoffset=0 xadvance=24 page=0 chnl=0
char id=105 x=61 y=176 width=8 height=55 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=0
char id=106 x=69 y=176 width=14 height=55 xoffset=-4 yoffset=0 xadvance=10 page=0 chnl=0
char id=107 x=83 y=176 width=24 height=55 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=0
char id=108 x=107 y=176 width=8 height=55 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=0
char id=109 x=115 y=176 width=34 height=55 xoffset=2 yoffset=0 xadvance=36 page=0 chnl=0
char id=110 x=149 y=176 width=22 height=55 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=0
char id=111 x=171 y=176 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=112 x=194 y=176 width=22 height=55 xoffset=2 yoffset=0 xadvance=24 page=0 chnl=0
char id=113 x=216 y=176 width=22 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=114 x=238 y=176 width=15 height=55 xoffset=2 yoffset=0 xadvance=17 page=0 chnl=0
char id=115 x=253 y=176 width=22 height=55 xoffset=1 yoffset=0 xadvance=23 page=0 chnl=0
char id=116 x=275 y=176 width=17 height=55 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=0
char id=117 x=292 y=176 width=22 height=55 xoffset=2 yoffset=0 xadvance=24 page=0 chnl=0
char id=118 x=314 y=176 width=24 height=55 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=0
char id=119 x=338 y=176 width=36 height=55 xoffset=0 yoffset=0 xadvance=36 page=0 chnl=0
char id=120 x=374 y=176 width=25 height=55 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=0
char id=121 x=399 y=176 width=24 height=55 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=0
char id=122 x=423 y=176 width=20 height=55 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=0
char id=123 x=443 y=176 width=17 height=55 xoffset=0 yoffset=0 xadvance=17 page=0 chnl=0
char id=124 x=460 y=176 width=6 height=55 xoffset=2 yoffset=0 xadvance=8 page=0 chnl=0
char id=125 x=466 y=176 width=16 height=55 xoffset=1 yoffset=0 xadvance=17 page=0 chnl=0
char id=126 x=482 y=176 width=22 height=55 xoffset=3 yoffset=0 xadvance=27 page=0 chnl=0
char id=161 x=0 y=231 width=9 height=55 xoffset=2 yoffset=0 xadvance=12 page=0 chnl=0
char id=162 x=9 y=231 width=20 height=55 xoffset=2 yoffset=0 xadvance=22 page=0 chnl=0
char id=163 x=29 y=231 width=23 height=55 xoffset=1 yoffset=0 xadvance=23 page=0 chnl=0
char id=164 x=52 y=231 width=19 height=55 xoffset=3 yoffset=0 xadvance=24 page=0 chnl=0
char id=165 x=71 y=231 width=29 height=55 xoffset=1 yoffset=0 xadvance=30 page=0 chnl=0
char id=166 x=100 y=231 width=6 height=55 xoffset=2 yoffset=0 xadvance=8 page=0 chnl=0
char id=167 x=106 y=231 width=23 height=55 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=0
char id=168 x=129 y=231 width=16 height=55 xoffset=2 yoffset=0 xadvance=19 page=0 chnl=0
char id=169 x=145 y=231 width=38 height=55 xoffset=1 yoffset=0 xadvance=39 page=0 chnl=0
char id=170 x=183 y=231 width=17 height=55 xoffset=1 yoffset=0 xadvance=18 page=0 chnl=0
char id=171 x=200 y=231 width=18 height=55 xoffset=2 yoffset=0 xadvance=22 page=0 chnl=0
char id=172 x=218 y=231 width=25 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=174 x=243 y=231 width=23 height=55 xoffset=1 yoffset=0 xadvance=23 page=0 chnl=0
char id=175 x=266 y=231 width=15 height=55 xoffset=2 yoffset=0 xadvance=18 page=0 chnl=0
char id=176 x=281 y=231 width=17 height=55 xoffset=1 yoffset=0 xadvance=18 page=0 chnl=0
char id=177 x=298 y=231 width=22 height=55 xoffset=3 yoffset=0 xadvance=27 page=0 chnl=0
char id=178 x=320 y=231 width=13 height=55 xoffset=2 yoffset=0 xadvance=15 page=0 chnl=0
char id=179 x=333 y=231 width=12 height=55 xoffset=2 yoffset=0 xadvance=14 page=0 chnl=0
char id=180 x=345 y=231 width=14 height=55 xoffset=2 yoffset=0 xadvance=15 page=0 chnl=0
char id=182 x=359 y=231 width=18 height=55 xoffset=3 yoffset=0 xadvance=22 page=0 chnl=0
char id=183 x=377 y=231 width=9 height=55 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=0
char id=184 x=386 y=231 width=10 height=55 xoffset=2 yoffset=0 xadvance=12 page=0 chnl=0
char id=185 x=396 y=231 width=8 height=55 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=0
char id=186 x=404 y=231 width=17 height=55 xoffset=1 yoffset=0 xadvance=19 page=0 chnl=0
char id=187 x=421 y=231 width=18 height=55 xoffset=2 yoffset=0 xadvance=22 page=0 chnl=0
char id=188 x=439 y=231 width=32 height=55 xoffset=2 yoffset=0 xadvance=34 page=0 chnl=0
char id=189 x=471 y=231 width=31 height=55 xoffset=2 yoffset=0 xadvance=35 page=0 chnl=0
char id=190 x=0 y=286 width=34 height=55 xoffset=0 yoffset=0 xadvance=34 page=0 chnl=0
char id=191 x=34 y=286 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=192 x=57 y=286 width=29 height=55 xoffset=0 yoffset=0 xadvance=28 page=0 chnl=0
char id=193 x=86 y=286 width=29 height=55 xoffset=0 yoffset=0 xadvance=28 page=0 chnl=0
char id=194 x=115 y=286 width=29 height=55 xoffset=0 yoffset=0 xadvance=28 page=0 chnl=0
char id=195 x=144 y=286 width=29 height=55 xoffset=0 yoffset=0 xadvance=28 page=0 chnl=0
char id=196 x=173 y=286 width=29 height=55 xoffset=0 yoffset=0 xadvance=28 page=0 chnl=0
char id=197 x=202 y=286 width=29 height=55 xoffset=0 yoffset=0 xadvance=28 page=0 chnl=0
char id=198 x=231 y=286 width=32 height=55 xoffset=0 yoffset=0 xadvance=33 page=0 chnl=0
char id=199 x=263 y=286 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=200 x=289 y=286 width=21 height=55 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=0
char id=201 x=310 y=286 width=21 height=55 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=0
char id=202 x=331 y=286 width=21 height=55 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=0
char id=203 x=352 y=286 width=21 height=55 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=0
char id=204 x=373 y=286 width=13 height=55 xoffset=-1 yoffset=0 xadvance=12 page=0 chnl=0
char id=205 x=386 y=286 width=15 height=55 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=0
char id=206 x=401 y=286 width=17 height=55 xoffset=-2 yoffset=0 xadvance=12 page=0 chnl=0
char id=207 x=418 y=286 width=17 height=55 xoffset=-2 yoffset=0 xadvance=12 page=0 chnl=0
char id=208 x=435 y=286 width=29 height=55 xoffset=1 yoffset=0 xadvance=30 page=0 chnl=0
char id=209 x=464 y=286 width=27 height=55 xoffset=2 yoffset=0 xadvance=30 page=0 chnl=0
char id=210 x=0 y=341 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=211 x=26 y=341 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=212 x=52 y=341 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=213 x=78 y=341 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=214 x=104 y=341 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=215 x=130 y=341 width=18 height=55 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=0
char id=216 x=148 y=341 width=26 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=217 x=174 y=341 width=26 height=55 xoffset=2 yoffset=0 xadvance=29 page=0 chnl=0
char id=218 x=200 y=341 width=26 height=55 xoffset=2 yoffset=0 xadvance=29 page=0 chnl=0
char id=219 x=226 y=341 width=26 height=55 xoffset=2 yoffset=0 xadvance=29 page=0 chnl=0
char id=220 x=252 y=341 width=26 height=55 xoffset=2 yoffset=0 xadvance=29 page=0 chnl=0
char id=221 x=278 y=341 width=29 height=55 xoffset=0 yoffset=0 xadvance=28 page=0 chnl=0
char id=222 x=307 y=341 width=20 height=55 xoffset=2 yoffset=0 xadvance=22 page=0 chnl=0
char id=223 x=327 y=341 width=25 height=55 xoffset=1 yoffset=0 xadvance=26 page=0 chnl=0
char id=224 x=352 y=341 width=24 height=55 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=0
char id=225 x=376 y=341 width=24 height=55 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=0
char id=226 x=400 y=341 width=24 height=55 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=0
char id=227 x=424 y=341 width=24 height=55 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=0
char id=228 x=448 y=341 width=24 height=55 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=0
char id=229 x=472 y=341 width=24 height=55 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=0
char id=230 x=0 y=396 width=37 height=55 xoffset=1 yoffset=0 xadvance=38 page=0 chnl=0
char id=231 x=37 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=232 x=60 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=233 x=83 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=234 x=106 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=235 x=129 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=236 x=152 y=396 width=14 height=55 xoffset=-2 yoffset=0 xadvance=11 page=0 chnl=0
char id=237 x=166 y=396 width=14 height=55 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=0
char id=238 x=180 y=396 width=16 height=55 xoffset=-2 yoffset=0 xadvance=11 page=0 chnl=0
char id=239 x=196 y=396 width=16 height=55 xoffset=-2 yoffset=0 xadvance=11 page=0 chnl=0
char id=240 x=212 y=396 width=25 height=55 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=0
char id=241 x=237 y=396 width=22 height=55 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=0
char id=242 x=259 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=243 x=282 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=244 x=305 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=245 x=328 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=246 x=351 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=247 x=374 y=396 width=15 height=55 xoffset=2 yoffset=0 xadvance=18 page=0 chnl=0
char id=248 x=389 y=396 width=23 height=55 xoffset=1 yoffset=0 xadvance=24 page=0 chnl=0
char id=249 x=412 y=396 width=22 height=55 xoffset=2 yoffset=0 xadvance=24 page=0 chnl=0
char id=250 x=434 y=396 width=22 height=55 xoffset=2 yoffset=0 xadvance=24 page=0 chnl=0
char id=251 x=456 y=396 width=22 height=55 xoffset=2 yoffset=0 xadvance=24 page=0 chnl=0
char id=252 x=478 y=396 width=22 height=55 xoffset=2 yoffset=0 xadvance=24 page=0 chnl=0
char id=253 x=0 y=451 width=24 height=55 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=0
char id=254 x=24 y=451 width=22 height=55 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=0
char id=255 x=46 y=451 width=24 height=55 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 216 KiB

After

Width:  |  Height:  |  Size: 216 KiB

View File

Before

Width:  |  Height:  |  Size: 274 KiB

After

Width:  |  Height:  |  Size: 274 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 150 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

@@ -4,10 +4,10 @@ world 0,0 90
#tree_big 0,0 0 #tree_big 0,0 0
#Marine Pos #Marine Pos
marine 4,-5 -90 marine 4,-5 270
marine 4,-4 -90 marine 4,-4 270
marine 5,-4 -90 marine 5,-4 270
marine 5,-5 -90 marine 5,-5 270
#Blue (Marine) wait Node #Blue (Marine) wait Node
node_wait_blue 4,-5 0 node_wait_blue 4,-5 0

View File

@@ -1,29 +1,40 @@
// Samplers for textures
uniform sampler2D m_Texture; uniform sampler2D m_Texture;
uniform sampler2D m_OutlineDepthTexture; uniform sampler2D m_OutlineDepthTexture;
uniform sampler2D m_DepthTexture; uniform sampler2D m_DepthTexture;
varying vec2 texCoord;
// Input texture coordinates from the vertex shader
in vec2 texCoord;
// Resolution of the screen and outline settings
uniform vec2 m_Resolution; uniform vec2 m_Resolution;
uniform vec4 m_OutlineColor; uniform vec4 m_OutlineColor;
uniform float m_OutlineWidth; uniform float m_OutlineWidth;
// Output color of the fragment
out vec4 fragColor;
void main() { void main() {
vec4 depth = texture2D(m_OutlineDepthTexture, texCoord); // Sample depth textures
vec4 depth1 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,m_OutlineWidth))/m_Resolution); vec4 depth = texture(m_OutlineDepthTexture, texCoord);
vec4 depth2 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,-m_OutlineWidth))/m_Resolution); vec4 depth1 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
vec4 depth3 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,m_OutlineWidth))/m_Resolution); vec4 depth2 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
vec4 depth4 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,-m_OutlineWidth))/m_Resolution); vec4 depth3 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
vec4 depth5 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,m_OutlineWidth))/m_Resolution); vec4 depth4 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
vec4 depth6 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-m_OutlineWidth))/m_Resolution); vec4 depth5 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(0.0, m_OutlineWidth)) / m_Resolution);
vec4 depth7 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,0.))/m_Resolution); vec4 depth6 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(0.0, -m_OutlineWidth)) / m_Resolution);
vec4 depth8 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,0.))/m_Resolution); vec4 depth7 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, 0.0)) / m_Resolution);
vec4 color = texture2D(m_Texture, texCoord); vec4 depth8 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, 0.0)) / m_Resolution);
//如果是背景
if(depth==vec4(0.) && (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth||depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)){ // Sample the main texture
gl_FragColor = m_OutlineColor; vec4 color = texture(m_Texture, texCoord);
}else{
gl_FragColor = color; // Determine whether to apply the outline color
} if (depth == vec4(0.0) &&
//debug (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth ||
//gl_FragColor = vec4(0.,(1.-ratio),0.,1.); depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)) {
} fragColor = m_OutlineColor; // Apply outline color
} else {
fragColor = color; // Use the original texture color
}
}

View File

@@ -1,10 +1,18 @@
varying vec2 texCoord;
// Use 'in' instead of 'varying' for inputs from the vertex shader
in vec2 texCoord;
// Declare a custom output variable for the fragment color
out vec4 fragColor;
// Uniform samplers
uniform sampler2D m_Texture; uniform sampler2D m_Texture;
uniform sampler2D m_NormalsTexture; uniform sampler2D m_NormalsTexture;
uniform sampler2D m_DepthTexture; uniform sampler2D m_DepthTexture;
void main(){ void main() {
vec4 color = texture2D(m_Texture, texCoord); // Sample the texture at the given texture coordinates
gl_FragColor=color; vec4 color = texture(m_Texture, texCoord);
} // Assign the color to the output variable
fragColor = color;
}

View File

@@ -0,0 +1,109 @@
uniform sampler2D m_Texture;
uniform sampler2D m_OutlineDepthTexture;
uniform sampler2D m_DepthTexture;
varying vec2 texCoord;
uniform vec2 m_Resolution;
uniform vec4 m_OutlineColor;
uniform float m_OutlineWidth;
void main() {
vec4 depth = texture2D(m_OutlineDepthTexture, texCoord);
vec4 depth1 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,m_OutlineWidth))/m_Resolution);
vec4 depth2 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,-m_OutlineWidth))/m_Resolution);
vec4 depth3 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,m_OutlineWidth))/m_Resolution);
vec4 depth4 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,-m_OutlineWidth))/m_Resolution);
vec4 depth5 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,m_OutlineWidth))/m_Resolution);
vec4 depth6 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-m_OutlineWidth))/m_Resolution);
vec4 depth7 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,0.))/m_Resolution);
vec4 depth8 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,0.))/m_Resolution);
vec4 color = texture2D(m_Texture, texCoord);
//如果是背景
float ratio=0.;
if(depth==vec4(0.) && (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth||depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)){
float dist=m_OutlineWidth;
//距离边的像素
vec4 nearDepth;
if(depth1 != depth){
for(float i=0.;i<m_OutlineWidth;i++){
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,i))/m_Resolution);
if(nearDepth != depth){
dist = i;
break;
}
}
}else
if(depth2 != depth){
for(float i=0.;i<m_OutlineWidth;i++){
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,-i))/m_Resolution);
if(nearDepth != depth){
dist = i;
break;
}
}
}else
if(depth3 != depth){
for(float i=0.;i<m_OutlineWidth;i++){
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,i))/m_Resolution);
if(nearDepth != depth){
dist = i;
break;
}
}
}else
if(depth4 != depth){
for(float i=0.;i<m_OutlineWidth;i++){
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,-i))/m_Resolution);
if(nearDepth != depth){
dist = i;
break;
}
}
}else
if(depth5 != depth){
for(float i=0.;i<m_OutlineWidth;i++){
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,i))/m_Resolution);
if(nearDepth != depth){
dist = i;
break;
}
}
}else
if(depth6 != depth){
for(float i=0.;i<m_OutlineWidth;i++){
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-i))/m_Resolution);
if(nearDepth != depth){
dist = i;
break;
}
}
}else
if(depth7 != depth){
for(float i=0.;i<m_OutlineWidth;i++){
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,0.))/m_Resolution);
if(nearDepth != depth){
dist = i;
break;
}
}
}else
if(depth8 != depth){
for(float i=0.;i<m_OutlineWidth;i++){
nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,0.))/m_Resolution);
if(nearDepth != depth){
dist = i;
break;
}
}
}
//0:场景颜色 1:outline颜色
ratio = clamp(1.- dist/m_OutlineWidth,0.,1.);
//float off = (1.-ratio*ratio)*(1.-ratio*ratio);
gl_FragColor = color*(1.-ratio) +m_OutlineColor*ratio;
//gl_FragColor = m_OutlineColor;
}else{
gl_FragColor = color;
}
//debug
//gl_FragColor = vec4(0.,(1.-ratio),0.,1.);
}

View File

@@ -0,0 +1,21 @@
MaterialDef Cartoon Edge {
MaterialParameters {
Int NumSamples
Int NumSamplesDepth
Texture2D Texture
Texture2D OutlineDepthTexture
Texture2D DepthTexture
Vector2 Resolution
Color OutlineColor
Float OutlineWidth
}
Technique {
VertexShader GLSL150: MatDefs/SelectObjectOutliner/Post15.vert
FragmentShader GLSL150: MatDefs/SelectObjectOutliner/OutlinePro.frag
WorldParameters {
}
}
}

View File

@@ -1,10 +1,15 @@
// Use 'in' for vertex attributes
in vec4 inPosition; in vec4 inPosition;
in vec2 inTexCoord; in vec2 inTexCoord;
// Use 'out' for passing data to the fragment shader
out vec2 texCoord; out vec2 texCoord;
void main() { void main() {
// Transform position to clip space
vec2 pos = inPosition.xy * 2.0 - 1.0; vec2 pos = inPosition.xy * 2.0 - 1.0;
gl_Position = vec4(pos, 0.0, 1.0); gl_Position = vec4(pos, 0.0, 1.0);
// Pass texture coordinates to the fragment shader
texCoord = inTexCoord; texCoord = inTexCoord;
} }

View File

Before

Width:  |  Height:  |  Size: 316 KiB

After

Width:  |  Height:  |  Size: 316 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

View File

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 210 KiB

View File

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 186 KiB

View File

Before

Width:  |  Height:  |  Size: 298 KiB

After

Width:  |  Height:  |  Size: 298 KiB

View File

Before

Width:  |  Height:  |  Size: 274 KiB

After

Width:  |  Height:  |  Size: 274 KiB

View File

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

Before

Width:  |  Height:  |  Size: 12 MiB

After

Width:  |  Height:  |  Size: 12 MiB

Some files were not shown because too many files have changed in this diff Show More