tried fixing outline problem
This commit is contained in:
@@ -9,6 +9,12 @@ implementation project(":jme-common")
|
|||||||
implementation project(":mdga:model")
|
implementation project(":mdga:model")
|
||||||
|
|
||||||
implementation libs.jme3.desktop
|
implementation libs.jme3.desktop
|
||||||
|
implementation libs.jme3.core
|
||||||
|
implementation libs.jme3.lwjgl3
|
||||||
|
implementation libs.jme3.lwjgl
|
||||||
|
implementation libs.jme3.desktop
|
||||||
|
implementation libs.jme3.effects
|
||||||
|
|
||||||
|
|
||||||
runtimeOnly libs.jme3.awt.dialogs
|
runtimeOnly libs.jme3.awt.dialogs
|
||||||
runtimeOnly libs.jme3.plugins
|
runtimeOnly libs.jme3.plugins
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
|
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.renderer.lwjgl.LwjglRender;
|
||||||
import com.jme3.system.NanoTimer;
|
import com.jme3.system.NanoTimer;
|
||||||
import pp.mdga.client.acoustic.AcousticHandler;
|
import pp.mdga.client.acoustic.AcousticHandler;
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
@@ -15,6 +21,7 @@
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
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;
|
||||||
@@ -31,7 +38,7 @@ public static void main(String[] args) {
|
|||||||
settings.setWidth(1280);
|
settings.setWidth(1280);
|
||||||
settings.setHeight(720);
|
settings.setHeight(720);
|
||||||
settings.setVSync(false);
|
settings.setVSync(false);
|
||||||
|
settings.setRenderer(AppSettings.LWJGL_OPENGL45);
|
||||||
MdgaApp app = new MdgaApp();
|
MdgaApp app = new MdgaApp();
|
||||||
app.setSettings(settings);
|
app.setSettings(settings);
|
||||||
app.setShowSettings(false);
|
app.setShowSettings(false);
|
||||||
@@ -49,8 +56,10 @@ public void simpleInitApp() {
|
|||||||
//dialogView.mainMenu();
|
//dialogView.mainMenu();
|
||||||
//acousticHandler.playState(MdgaState.GAME);
|
//acousticHandler.playState(MdgaState.GAME);
|
||||||
|
|
||||||
acousticHandler.playSound(MdgaSound.LOST);
|
// acousticHandler.playSound(MdgaSound.LOST);
|
||||||
acousticHandler.playSound(MdgaSound.VICTORY);
|
// acousticHandler.playSound(MdgaSound.VICTORY);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UUID test0 = UUID.randomUUID();
|
UUID test0 = UUID.randomUUID();
|
||||||
UUID test1 = UUID.randomUUID();
|
UUID test1 = UUID.randomUUID();
|
||||||
@@ -60,34 +69,35 @@ public void simpleInitApp() {
|
|||||||
testList.add(test1);
|
testList.add(test1);
|
||||||
testList.add(test0);
|
testList.add(test0);
|
||||||
|
|
||||||
UUID test0_1 = UUID.randomUUID();
|
// UUID test0_1 = UUID.randomUUID();
|
||||||
UUID test1_1 = UUID.randomUUID();
|
// UUID test1_1 = UUID.randomUUID();
|
||||||
List<UUID> testList_1 = new ArrayList<>();
|
// List<UUID> testList_1 = new ArrayList<>();
|
||||||
testList_1.add(UUID.randomUUID());
|
// testList_1.add(UUID.randomUUID());
|
||||||
testList_1.add(UUID.randomUUID());
|
// testList_1.add(UUID.randomUUID());
|
||||||
testList_1.add(test1_1);
|
// testList_1.add(test1_1);
|
||||||
testList_1.add(test0_1);
|
// testList_1.add(test0_1);
|
||||||
|
|
||||||
boardView.init();
|
boardView.init();
|
||||||
|
|
||||||
|
inputManager.addMapping("h", new KeyTrigger(KeyInput.KEY_H));
|
||||||
|
inputManager.addMapping("j", new KeyTrigger(KeyInput.KEY_J));
|
||||||
|
inputManager.addListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void onAction(String name, boolean isPressed, float tpf) {
|
||||||
|
if (name.equals("h") && isPressed) {
|
||||||
|
boardView.highlight(test0);
|
||||||
|
}
|
||||||
|
if(name.equals("j") && isPressed){
|
||||||
|
boardView.unHighlight(test0);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "h", "j");
|
||||||
|
|
||||||
|
|
||||||
boardView.addPlayer(Color.AIRFORCE, testList);
|
boardView.addPlayer(Color.AIRFORCE, testList);
|
||||||
// boardView.movePieceStart(test0, 0);
|
|
||||||
// boardView.movePiece(test0, 0, 1);
|
|
||||||
// boardView.movePiece(test0, 1, 6);
|
|
||||||
// boardView.throwPiece(test0);
|
|
||||||
// boardView.shieldPiece(test0);
|
|
||||||
|
|
||||||
// boardView.addPlayer(Color.CYBER, testList_1);
|
|
||||||
// boardView.movePieceStart(test0_1, 10);
|
|
||||||
// boardView.movePiece(test0_1, 10,14);
|
|
||||||
// boardView.movePiece(test0_1, 14,15);
|
|
||||||
|
|
||||||
boardView.highlight(test0);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// boardView.moveHomePiece(test0, 0);
|
|
||||||
// boardView.moveHomePiece(test0, Color.AIRFORCE,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ public BoardHandler(MdgaApp app) {
|
|||||||
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.node = new Node();
|
this.node = new Node("Asset Node");
|
||||||
this.outlineHandler = new OutlineHandler(app, app.getRootNode());
|
this.outlineHandler = new OutlineHandler(app, app.getRootNode());
|
||||||
|
|
||||||
// app.getRootNode().attachChild(node);
|
app.getRootNode().attachChild(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
|
private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
|
||||||
@@ -103,8 +103,8 @@ private Spatial createModel(BoardAsset asset, Vector3f pos, float rot) {
|
|||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||||
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);
|
// app.getRootNode().attachChild(model);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +180,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.getRootNode()));
|
PieceControl pieceControl = displayAndControl(assetOnMap, new PieceControl(assetOnMap.rot(), app.getAssetManager(), app));
|
||||||
movePieceToNode(pieceControl, waitNodes.get(i));
|
movePieceToNode(pieceControl, waitNodes.get(i));
|
||||||
|
|
||||||
pieces.put(uuid.get(i), pieceControl);
|
pieces.put(uuid.get(i), pieceControl);
|
||||||
@@ -289,10 +289,10 @@ public void shutdown(){
|
|||||||
//List<Pieces>
|
//List<Pieces>
|
||||||
//List<NodesIndexe>
|
//List<NodesIndexe>
|
||||||
public void highlight(UUID uuid){
|
public void highlight(UUID uuid){
|
||||||
outlineHandler.outlineOwn(pieces.get(uuid).getSpatial());
|
pieces.get(uuid).outline();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unHighlight(UUID uuid){
|
public void unHighlight(UUID uuid){
|
||||||
outlineHandler.deOutline(pieces.get(uuid).getSpatial());
|
pieces.get(uuid).deOutline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ public class OutlineHandler {
|
|||||||
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 int OUTLINE_THICKNESS = 4;
|
||||||
|
|
||||||
|
private Node outlineNode;
|
||||||
|
|
||||||
public OutlineHandler(MdgaApp app, Node rootNode){
|
public OutlineHandler(MdgaApp app, Node rootNode){
|
||||||
FilterPostProcessor fpp = new FilterPostProcessor(app.getAssetManager());
|
FilterPostProcessor fpp = new FilterPostProcessor(app.getAssetManager());
|
||||||
app.getViewPort().addProcessor(fpp);
|
app.getViewPort().addProcessor(fpp);
|
||||||
|
|||||||
@@ -17,31 +17,37 @@
|
|||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
public class PieceControl extends AbstractControl {
|
public class PieceControl extends AbstractControl {
|
||||||
private float rotation;
|
|
||||||
private final float initRotation;
|
private final float initRotation;
|
||||||
private AssetManager assetManager;
|
private final AssetManager assetManager;
|
||||||
private Spatial shieldRing;
|
private Spatial shieldRing;
|
||||||
private Node rootNode;
|
private final Material shieldMat;
|
||||||
private Material shield_mat;
|
|
||||||
private MdgaApp app;
|
|
||||||
|
|
||||||
private static final float SHIELD_SPEED = 1f;
|
private static final float SHIELD_SPEED = 1f;
|
||||||
private static final float SHIELD_TRANSPARENCY = 0.6f;
|
private static final float SHIELD_TRANSPARENCY = 0.6f;
|
||||||
private static final ColorRGBA SHIELD_COLOR = new ColorRGBA(0, 0.9f, 1, SHIELD_TRANSPARENCY);
|
private static final ColorRGBA SHIELD_COLOR = new ColorRGBA(0, 0.9f, 1, SHIELD_TRANSPARENCY);
|
||||||
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;
|
||||||
private static final ColorRGBA OUTLINE_COLOR = ColorRGBA.White;
|
|
||||||
private static final int OUTLINE_THICKNESS = 4;
|
|
||||||
|
|
||||||
public PieceControl(float initRotation, AssetManager assetManager, Node rootNode){
|
SelectObjectOutliner outlineOwn;
|
||||||
|
|
||||||
|
private static final ColorRGBA OUTLINE_OWN_COLOR = ColorRGBA.White;
|
||||||
|
private static final int OUTLINE_THICKNESS = 4;
|
||||||
|
private final Node parentNode;
|
||||||
|
|
||||||
|
public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app){
|
||||||
super();
|
super();
|
||||||
|
this.parentNode = new Node();
|
||||||
this.initRotation = initRotation;
|
this.initRotation = initRotation;
|
||||||
this.assetManager = assetManager;
|
this.assetManager = assetManager;
|
||||||
this.shieldRing = null;
|
this.shieldRing = null;
|
||||||
this.rootNode = rootNode;
|
this.shieldMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
this.shieldMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||||
|
|
||||||
|
FilterPostProcessor fpp = new FilterPostProcessor(app.getAssetManager());
|
||||||
|
app.getViewPort().addProcessor(fpp);
|
||||||
|
outlineOwn = new SelectObjectOutliner();
|
||||||
|
outlineOwn.initOutliner(SelectObjectOutliner.OUTLINER_TYPE_FILTER, OUTLINE_THICKNESS, OUTLINE_OWN_COLOR, parentNode, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera());
|
||||||
|
|
||||||
this.shield_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
|
||||||
this.shield_mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRotation() {
|
public float getRotation() {
|
||||||
@@ -76,10 +82,23 @@ public void setLocation(Vector3f loc){
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSpatial(Spatial spatial){
|
public void setSpatial(Spatial spatial){
|
||||||
super.setSpatial(spatial);
|
if(this.getSpatial() == null && spatial != null){
|
||||||
if(spatial != null){
|
super.setSpatial(spatial);
|
||||||
setRotation(this.initRotation);
|
initSpatial();
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
super.setSpatial(spatial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initSpatial(){
|
||||||
|
setRotation(this.initRotation);
|
||||||
|
|
||||||
|
Node oldParent = this.spatial.getParent();
|
||||||
|
this.parentNode.setName(this.spatial.getName() + " Parent");
|
||||||
|
oldParent.detachChild(this.getSpatial());
|
||||||
|
this.parentNode.attachChild(this.getSpatial());
|
||||||
|
oldParent.attachChild(this.parentNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotateInit() {
|
public void rotateInit() {
|
||||||
@@ -94,20 +113,20 @@ public void activateShield(){
|
|||||||
|
|
||||||
|
|
||||||
shieldRing.setQueueBucket(RenderQueue.Bucket.Transparent); // Render in the transparent bucket
|
shieldRing.setQueueBucket(RenderQueue.Bucket.Transparent); // Render in the transparent bucket
|
||||||
shield_mat.setColor("Color", SHIELD_COLOR);
|
shieldMat.setColor("Color", SHIELD_COLOR);
|
||||||
shieldRing.setMaterial(shield_mat);
|
shieldRing.setMaterial(shieldMat);
|
||||||
|
|
||||||
rootNode.attachChild(shieldRing);
|
parentNode.attachChild(shieldRing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivateShield(){
|
public void deactivateShield(){
|
||||||
rootNode.detachChild(shieldRing);
|
parentNode.detachChild(shieldRing);
|
||||||
shieldRing = null;
|
shieldRing = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void suppressShield(){
|
public void suppressShield(){
|
||||||
assert(shieldRing != null) : "PieceControl: shieldRing is not set";
|
assert(shieldRing != null) : "PieceControl: shieldRing is not set";
|
||||||
shield_mat.setColor("Color", SHIELD_SUPPRESSED_COLOR);
|
shieldMat.setColor("Color", SHIELD_SUPPRESSED_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaterial(Material mat){
|
public void setMaterial(Material mat){
|
||||||
@@ -117,4 +136,12 @@ public void setMaterial(Material mat){
|
|||||||
public Material getMaterial(){
|
public Material getMaterial(){
|
||||||
return ((Geometry) this.spatial).getMaterial();
|
return ((Geometry) this.spatial).getMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void outline() {
|
||||||
|
outlineOwn.select(this.getSpatial());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deOutline() {
|
||||||
|
outlineOwn.deselect(this.getSpatial());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,9 @@ private void hideOutlineFilterEffect(Spatial model) {
|
|||||||
OutlineFilter outlineFilter = model.getUserData("OutlineFilter");
|
OutlineFilter outlineFilter = model.getUserData("OutlineFilter");
|
||||||
if (outlineFilter != null) {
|
if (outlineFilter != null) {
|
||||||
outlineFilter.setEnabled(false);
|
outlineFilter.setEnabled(false);
|
||||||
outlineFilter.getOutlinePreFilter().setEnabled(false);
|
outlineFilter.getOutlinePreFilter().setEnabled(false);
|
||||||
|
fpp.removeFilter(outlineFilter);
|
||||||
|
model.setUserData("OutlineFilter", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,16 +161,16 @@ 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)outlineFilter).setOutlineColor(color);
|
((OutlineFilter)outlineFilter).setOutlineColor(color);
|
||||||
((OutlineFilter)outlineFilter).setOutlineWidth(width);
|
((OutlineFilter)outlineFilter).setOutlineWidth(width);
|
||||||
model.setUserData("OutlineFilter", outlineFilter);
|
model.setUserData("OutlineFilter", outlineFilter);
|
||||||
|
|
||||||
fpp.addFilter(outlineFilter);
|
fpp.addFilter(outlineFilter);
|
||||||
} else {
|
} else {
|
||||||
outlineFilter.setEnabled(true);
|
outlineFilter.setEnabled(true);
|
||||||
//
|
//
|
||||||
((OutlineFilter)outlineFilter).getOutlinePreFilter().setEnabled(true);
|
((OutlineFilter)outlineFilter).getOutlinePreFilter().setEnabled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ MaterialDef Cartoon Edge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Technique {
|
Technique {
|
||||||
VertexShader GLSL100: MatDefs/SelectObjectOutliner/Post15.vert
|
VertexShader GLSL150: MatDefs/SelectObjectOutliner/Post15.vert
|
||||||
FragmentShader GLSL100: MatDefs/SelectObjectOutliner/Outline.frag
|
FragmentShader GLSL150: MatDefs/SelectObjectOutliner/Outline.frag
|
||||||
|
|
||||||
WorldParameters {
|
WorldParameters {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,4 @@ MaterialDef Cartoon Edge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Technique {
|
|
||||||
VertexShader GLSL100: Common/MatDefs/Post/Post.vert
|
|
||||||
FragmentShader GLSL100: Shaders/outline/OutlinePre.frag
|
|
||||||
|
|
||||||
WorldParameters {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user