tried adding shield outline, but there is a bug -> black screen
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import com.jme3.input.MouseInput;
|
||||
import com.jme3.input.controls.*;
|
||||
|
||||
public class InputSyncronizer {
|
||||
public class InputSynchronizer {
|
||||
|
||||
private MdgaApp app;
|
||||
private InputManager inputManager;
|
||||
@@ -14,7 +14,7 @@ public class InputSyncronizer {
|
||||
private float rotationAngle = 0f;
|
||||
private int scrollValue = 50;
|
||||
|
||||
InputSyncronizer(MdgaApp app) {
|
||||
InputSynchronizer(MdgaApp app) {
|
||||
this.app = app;
|
||||
|
||||
this.inputManager = app.getInputManager();
|
||||
@@ -11,11 +11,11 @@ public class MdgaApp extends SimpleApplication {
|
||||
private AnimationHandler animationHandler;
|
||||
private AcousticHandler acousticHandler;
|
||||
private NotificationSynchronizer notificationSynchronizer;
|
||||
private InputSyncronizer inputSyncronizer;
|
||||
private InputSynchronizer inputSynchronizer;
|
||||
private ModelSyncronizer modelSyncronizer;
|
||||
|
||||
MdgaView view = null;
|
||||
private MdgaState state = MdgaState.MAIN;
|
||||
private MdgaState state = MdgaState.GAME;
|
||||
|
||||
private static float resolutionFactor = 1f;
|
||||
|
||||
@@ -43,7 +43,7 @@ public void simpleInitApp() {
|
||||
animationHandler = new AnimationHandler(this);
|
||||
acousticHandler = new AcousticHandler(this);
|
||||
notificationSynchronizer = new NotificationSynchronizer(this);
|
||||
inputSyncronizer = new InputSyncronizer(this);
|
||||
inputSynchronizer = new InputSynchronizer(this);
|
||||
modelSyncronizer = new ModelSyncronizer(this);
|
||||
|
||||
inputManager.deleteMapping("SIMPLEAPP_Exit");
|
||||
@@ -54,7 +54,7 @@ public void simpleInitApp() {
|
||||
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
inputSyncronizer.update();
|
||||
inputSynchronizer.update();
|
||||
view.update();
|
||||
acousticHandler.update();
|
||||
notificationSynchronizer.update();
|
||||
|
||||
@@ -15,11 +15,12 @@ enum MusicAsset {
|
||||
GAME_3("TheSynthRave.wav", 1.0f),
|
||||
GAME_4("LaserParty.wav", 1.0f),
|
||||
GAME_5("RetroNoir.wav", 1.0f),
|
||||
GAME_6("SpaceInvaders.wav", 1.0f);
|
||||
GAME_6("RetroNoir.wav.wav", 1.0f);
|
||||
|
||||
private final String path;
|
||||
private final boolean loop;
|
||||
private final float subVolume;
|
||||
private static final String root = "Music/";
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*/
|
||||
MusicAsset(String name, float subVolume) {
|
||||
this.path = "music/" + name;
|
||||
this.path = root + name;
|
||||
this.loop = false;
|
||||
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).
|
||||
*/
|
||||
MusicAsset(String name, boolean loop, float subVolume) {
|
||||
this.path = "music/" + name;
|
||||
this.path = root + name;
|
||||
this.loop = loop;
|
||||
this.subVolume = subVolume;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ public class BoardHandler {
|
||||
|
||||
private final MdgaApp app;
|
||||
|
||||
private PileControl drawPile = null;
|
||||
private PileControl discardPile = null;
|
||||
private final PileControl drawPile = null;
|
||||
private final PileControl discardPile = null;
|
||||
|
||||
private ArrayList<NodeControl> infield;
|
||||
private Map<UUID, PieceControl> pieces;
|
||||
@@ -34,7 +34,7 @@ public class BoardHandler {
|
||||
|
||||
private Node node;
|
||||
|
||||
private FilterPostProcessor fpp;
|
||||
private final FilterPostProcessor fpp;
|
||||
|
||||
private boolean init;
|
||||
|
||||
@@ -75,7 +75,7 @@ private void initMap() {
|
||||
case cir -> addFigureToPlayerMap(assetToColor(Asset.cir), assetOnMap);
|
||||
case marine -> addFigureToPlayerMap(assetToColor(Asset.marine), assetOnMap);
|
||||
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_blue -> addHomeNode(homeNodesMap, Color.NAVY, assetOnMap);
|
||||
case node_home_green -> addHomeNode(homeNodesMap, Color.ARMY, assetOnMap);
|
||||
@@ -137,7 +137,7 @@ private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl)
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ private float getRotationMove(Vector3f prev, Vector3f next) {
|
||||
private void movePiece_rek(UUID uuid, int curIndex, int moveIndex){
|
||||
if (curIndex == moveIndex) return;
|
||||
|
||||
curIndex = (curIndex + 1) % 40;
|
||||
curIndex = (curIndex + 1) % infield.size();
|
||||
|
||||
PieceControl pieceControl = pieces.get(uuid);
|
||||
NodeControl nodeControl = infield.get(curIndex);
|
||||
@@ -309,15 +309,23 @@ public void shutdown(){
|
||||
|
||||
//List<Pieces>
|
||||
//List<NodesIndexe>
|
||||
public void highlight(UUID uuid, boolean bool){
|
||||
public void outline(UUID uuid, boolean bool){
|
||||
if (!init) throw new RuntimeException("BoardHandler is not initialized");
|
||||
|
||||
pieces.get(uuid).outline(bool);
|
||||
}
|
||||
|
||||
public void unHighlight(UUID uuid){
|
||||
public void deOutline(UUID uuid){
|
||||
if (!init) throw new RuntimeException("BoardHandler is not initialized");
|
||||
|
||||
pieces.get(uuid).deOutline();
|
||||
}
|
||||
|
||||
public void outline(int index){
|
||||
infield.get(index).outline();
|
||||
}
|
||||
|
||||
public void deOutline(int index){
|
||||
infield.get(index).deOutline();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
package pp.mdga.client.board;
|
||||
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.post.FilterPostProcessor;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
|
||||
public class NodeControl extends AbstractControl {
|
||||
public class NodeControl extends OutlineControl {
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float v) {
|
||||
private static final ColorRGBA OUTLINE_COLOR = ColorRGBA.White;
|
||||
|
||||
public NodeControl(MdgaApp app, FilterPostProcessor fpp) {
|
||||
super(app, fpp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlRender(RenderManager renderManager, ViewPort viewPort) {
|
||||
|
||||
public void outline(){
|
||||
super.outline(OUTLINE_COLOR);
|
||||
}
|
||||
|
||||
public Vector3f getLocation(){
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
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 OUTLINE_THICKNESS = 4;
|
||||
public final SelectObjectOutliner outlineOwn;
|
||||
|
||||
public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
|
||||
outlineOwn = new SelectObjectOutliner(OUTLINE_THICKNESS, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera());
|
||||
}
|
||||
|
||||
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
|
||||
outlineOwn = new SelectObjectOutliner(OUTLINE_THICKNESS, fpp, app.getRenderManager(), app.getAssetManager(), cam);
|
||||
}
|
||||
|
||||
|
||||
public void outline(ColorRGBA color){
|
||||
outlineOwn.select(spatial, color);
|
||||
}
|
||||
|
||||
public void deOutline(){
|
||||
outlineOwn.deselect(spatial);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
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 AssetManager assetManager;
|
||||
private Spatial shieldRing;
|
||||
@@ -30,26 +30,20 @@ public class PieceControl extends AbstractControl {
|
||||
private static final ColorRGBA SHIELD_SUPPRESSED_COLOR = new ColorRGBA(1f, 0.5f, 0, SHIELD_TRANSPARENCY);
|
||||
private static final float SHIELD_Z = 0f;
|
||||
|
||||
SelectObjectOutliner outlineOwn;
|
||||
|
||||
private static final ColorRGBA OUTLINE_OWN_COLOR = ColorRGBA.White;
|
||||
private static final ColorRGBA OUTLINE_ENEMY_COLOR = ColorRGBA.Red;
|
||||
private static final int OUTLINE_THICKNESS = 4;
|
||||
|
||||
private final Node parentNode;
|
||||
|
||||
|
||||
public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp){
|
||||
super();
|
||||
super(app, fpp);
|
||||
this.parentNode = new Node();
|
||||
this.initRotation = initRotation;
|
||||
this.assetManager = assetManager;
|
||||
this.shieldRing = null;
|
||||
this.shieldMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
this.shieldMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||
|
||||
|
||||
outlineOwn = new SelectObjectOutliner(OUTLINE_THICKNESS, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera());
|
||||
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
@@ -73,11 +67,6 @@ protected void controlUpdate(float delta) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlRender(RenderManager renderManager, ViewPort viewPort) {
|
||||
|
||||
}
|
||||
|
||||
public void setLocation(Vector3f loc){
|
||||
this.getSpatial().setLocalTranslation(loc);
|
||||
}
|
||||
@@ -140,11 +129,10 @@ public Material getMaterial(){
|
||||
}
|
||||
|
||||
public void outline(boolean enemy) {
|
||||
ColorRGBA color = enemy ? OUTLINE_ENEMY_COLOR : OUTLINE_OWN_COLOR;
|
||||
outlineOwn.select(this.getSpatial(), color);
|
||||
super.outline(enemy ? OUTLINE_ENEMY_COLOR : OUTLINE_OWN_COLOR);
|
||||
}
|
||||
|
||||
public void deOutline() {
|
||||
outlineOwn.deselect(this.getSpatial());
|
||||
super.deOutline();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
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.ViewPort;
|
||||
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.White;
|
||||
|
||||
public CardControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
|
||||
super(app, fpp, cam);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
|
||||
public void outline(){
|
||||
super.outline(OUTLINE_COLOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.post.FilterPostProcessor;
|
||||
import com.jme3.renderer.Camera;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
@@ -21,9 +22,12 @@ public class CardLayer extends AbstractAppState {
|
||||
private boolean init;
|
||||
|
||||
private List<Spatial> cardBuffer;
|
||||
private final FilterPostProcessor fpp;
|
||||
private final Camera overlayCam;
|
||||
|
||||
|
||||
public CardLayer() {
|
||||
public CardLayer(FilterPostProcessor fpp, Camera overlayCam) {
|
||||
this.overlayCam = overlayCam;
|
||||
this.fpp = fpp;
|
||||
this.cardBuffer = new ArrayList<>();
|
||||
init = false;
|
||||
}
|
||||
@@ -33,19 +37,11 @@ public void initialize(AppStateManager stateManager, Application app ) {
|
||||
this.app = app;
|
||||
root = new Node("Under gui viewport Root");
|
||||
|
||||
Camera originalCam = app.getCamera();
|
||||
|
||||
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);
|
||||
ViewPort view = app.getRenderManager().createMainView("Under gui ViewPort", overlayCam);
|
||||
view.setEnabled(true);
|
||||
view.setClearFlags(false, true, false);
|
||||
view.attachScene(root);
|
||||
view.addProcessor(fpp);
|
||||
|
||||
if(!init) init = true;
|
||||
}
|
||||
@@ -81,4 +77,8 @@ public void addCard(Spatial card){
|
||||
public void deleteCard(Spatial spatial){
|
||||
root.detachChild(spatial);
|
||||
}
|
||||
|
||||
public Camera getOverlayCam(){
|
||||
return overlayCam;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
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 pp.mdga.client.Asset;
|
||||
@@ -28,12 +30,15 @@ public class GuiHandler {
|
||||
private static final Vector3f START = new Vector3f(-3,-3,0);
|
||||
private static final Vector3f MARGIN = new Vector3f(2.5f,0,0);
|
||||
|
||||
private final FilterPostProcessor fpp;
|
||||
|
||||
public GuiHandler(MdgaApp app) {
|
||||
this.app = app;
|
||||
this.fpp = new FilterPostProcessor(app.getAssetManager());
|
||||
}
|
||||
|
||||
public void init(){
|
||||
cardLayer = new CardLayer();
|
||||
cardLayer = new CardLayer(fpp, createOverlayCam());
|
||||
app.getStateManager().attach(cardLayer);
|
||||
ownCardsMap = new HashMap<>();
|
||||
playerFont = app.getAssetManager().loadFont("Fonts/Gunplay.fnt");
|
||||
@@ -42,12 +47,10 @@ public void init(){
|
||||
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();
|
||||
@@ -91,7 +94,7 @@ private CardControl createCard(Asset card, Vector3f pos){
|
||||
spatial.setLocalScale(1f);
|
||||
spatial.setLocalTranslation(pos);
|
||||
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);
|
||||
return control;
|
||||
}
|
||||
@@ -146,4 +149,24 @@ public void setActivePlayer(Color color){
|
||||
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());
|
||||
|
||||
ownCardsMap.get(uuid).outline();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
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 pp.mdga.client.board.BoardHandler;
|
||||
import pp.mdga.client.board.CameraHandler;
|
||||
@@ -45,6 +50,31 @@ public void onEnter() {
|
||||
guiHandler.init();
|
||||
continueButton.show();
|
||||
|
||||
List<UUID> test = new ArrayList<>();
|
||||
UUID player0 = UUID.randomUUID();
|
||||
test.add(player0);
|
||||
test.add(UUID.randomUUID());
|
||||
test.add(UUID.randomUUID());
|
||||
test.add(UUID.randomUUID());
|
||||
|
||||
boardHandler.addPlayer(Color.AIRFORCE, test);
|
||||
boardHandler.movePieceStart(player0, 0);
|
||||
boardHandler.outline(player0, true);
|
||||
|
||||
boardHandler.outline(10);
|
||||
|
||||
app.getInputManager().addMapping("Test", new KeyTrigger(KeyInput.KEY_J));
|
||||
app.getInputManager().addListener(new ActionListener() {
|
||||
@Override
|
||||
public void onAction(String name, boolean isPressed, float tpf) {
|
||||
if(name.equals("Test") && isPressed){
|
||||
guiHandler.test();
|
||||
}
|
||||
}
|
||||
}, "Test");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user