merge dev/client into dev/client_koppe

This commit is contained in:
Cedric Beck
2024-11-24 10:30:37 +01:00
20 changed files with 22891 additions and 3645 deletions

View File

@@ -6,7 +6,7 @@
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="pp.mdga.client.board.*" />
<option name="PATTERN" value="pp.mdga.client.board.Outline.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>

View File

@@ -9,6 +9,12 @@ implementation project(":jme-common")
implementation project(":mdga:model")
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.plugins

View File

@@ -104,7 +104,7 @@ public void playState(MdgaState state) {
addGameTracks();
playGame = true;
assert (!gameTracks.isEmpty()) : "no more game music available";
asset = gameTracks.removeFirst();
asset = gameTracks.remove(0);
break;
case CEREMONY:
playGame = false;

View File

@@ -14,8 +14,8 @@ enum BoardAsset {
node_wait_black("./node_home/node_home.j3o", "./node_home/node_home_black_diff.png"),
node_home_green("./node_home/node_home.j3o", "./node_home/node_home_green_diff.png"),
node_wait_green("./node_home/node_home.j3o", "./node_home/node_home_green_diff.png"),
node_home_yellow("./node_home/node_home.j3o", "./node_home/node_home_yellow_diff.png"),
node_wait_yellow("./node_home/node_home.j3o", "./node_home/node_home_yellow_diff.png"),
node_home_yellow("./node_home/node_home.j3o", "./node_home/node_home_orange_diff.png"),
node_wait_yellow("./node_home/node_home.j3o", "./node_home/node_home_orange_diff.png"),
node_normal,
node_start("./node_normal/node_normal.j3o", "./node_normal/node_start_diff.png"),
node_bonus("./node_normal/node_normal.j3o", "./node_normal/node_bonus_diff.png"),
@@ -27,7 +27,7 @@ enum BoardAsset {
tank,
turboCard,
// world(1.2f),
world("./world_new/world_new.obj", "./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("./shield_ring/shield_ring.obj", null),
tree_small("./tree_small/tree_small.obj", "./tree_small/tree_small_diff.png"),
tree_big("./tree_big/tree_big.obj", "./tree_big/tree_big_diff.png");

View File

@@ -1,7 +1,9 @@
package pp.mdga.client.board;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
@@ -30,12 +32,31 @@ public class BoardHandler {
private Map<Color, List<PieceControl>> waitingPiecesMap;
private Map<UUID, Color> pieceColor;
private Node node = new Node();
private Node node;
public BoardHandler(MdgaApp app) {
assert (app != null) : "app is null";
private FilterPostProcessor fpp;
private boolean init;
public BoardHandler(MdgaApp app, FilterPostProcessor fpp) {
if(app == null) throw new RuntimeException("app is null");
this.init = false;
this.app = app;
this.fpp = fpp;
}
private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
List<AssetOnMap> inMap = addItemToMapList(colorAssetsMap, col, assetOnMap);
if (inMap.size() > 4) throw new RuntimeException("to many assets for " + col);
}
private void initMap() {
if (init) return;
this.init = true;
this.node = new Node("Asset Node");
app.getRootNode().attachChild(node);
this.pieces = new HashMap<>();
this.colorAssetsMap = new HashMap<>();
@@ -45,23 +66,6 @@ public BoardHandler(MdgaApp app) {
this.waitingPiecesMap = new HashMap<>();
this.pieceColor = new HashMap<>();
initMap();
}
public void init() {
app.getRootNode().attachChild(node);
}
public void shutdown() {
app.getRootNode().detachChild(node);
}
private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
List<AssetOnMap> inMap = addItemToMapList(colorAssetsMap, col, assetOnMap);
assert (inMap.size() <= 4) : "BoardView: to many assets for " + col;
}
private void initMap() {
List<AssetOnMap> assetOnMaps = MapLoader.loadMap(MAP_NAME);
for (AssetOnMap assetOnMap : assetOnMaps) {
@@ -108,6 +112,7 @@ private Spatial createModel(BoardAsset asset, Vector3f pos, float rot) {
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
model.setMaterial(mat);
node.attachChild(model);
// app.getRootNode().attachChild(model);
return model;
}
@@ -133,7 +138,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()));
assert(homeNodes.size() <= 4) : "BoardView: too many homeNodes for " + color;
if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color);
}
private float getRotationMove(Vector3f prev, Vector3f next) {
@@ -173,17 +178,19 @@ private <T, E> List<T> removeItemFromMapList(Map<E,List<T>> map, E key, T item){
//public methods****************************************************************************************************
public void addPlayer(Color color, List<UUID> uuid) {
if (!init) throw new RuntimeException("BoardHandler is not initialized");
List<AssetOnMap> playerAssets = colorAssetsMap.get(color);
assert (playerAssets != null) : "Assets for Player color are not defined";
assert (uuid.size() == playerAssets.size()) : "UUID array and playerAssets are not the same size";
if (playerAssets == null) throw new RuntimeException("Assets for Player color are not defined");
if (uuid.size() != playerAssets.size()) throw new RuntimeException("UUID array and playerAssets are not the same size");
List<NodeControl> waitNodes = waitingNodesMap.get(color);
assert(waitNodes.size() == playerAssets.size()) : "BoardHandler: waitNodes size does not match playerAssets size";
if (waitNodes.size() != playerAssets.size()) throw new RuntimeException("waitNodes size does not match playerAssets size");
for (int i = 0; i < playerAssets.size(); 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, fpp));
movePieceToNode(pieceControl, waitNodes.get(i));
pieces.put(uuid.get(i), pieceControl);
@@ -195,13 +202,14 @@ public void addPlayer(Color color, List<UUID> uuid) {
}
public void moveHomePiece(UUID uuid, int index){
Color color = pieceColor.get(uuid);
assert(color != null) : "BoardHandler: uuid is not mapped to a color";
if (!init) throw new RuntimeException("BoardHandler is not initialized");
Color color = pieceColor.get(uuid);
if(color == null) throw new RuntimeException("uuid is not mapped to a color");
List<NodeControl> homeNodes = homeNodesMap.get(color);
assert(homeNodesMap.size() == 4) : "BoardView: HomeNodes for " + color + " are not defined";
if(homeNodesMap.size() != 4) throw new RuntimeException("HomeNodes for" + color + " are not properly defined");
PieceControl pieceControl = pieces.get(uuid);
NodeControl nodeControl = homeNodes.get(index);
@@ -215,8 +223,10 @@ public void moveHomePiece(UUID uuid, int index){
}
public void movePieceStart(UUID uuid, int nodeIndex){
if (!init) throw new RuntimeException("BoardHandler is not initialized");
Color color = pieceColor.get(uuid);
assert(color != null) : "BoardHandler: uuid is not mapped to a color";
if(color == null) throw new RuntimeException("uuid is not mapped to a color");
PieceControl pieceControl = pieces.get(uuid);
movePieceToNode(pieceControl, infield.get(nodeIndex));
@@ -225,12 +235,17 @@ public void movePieceStart(UUID uuid, int nodeIndex){
}
public void movePiece(UUID uuid, int curIndex, int moveIndex){
if (!init) throw new RuntimeException("BoardHandler is not initialized");
movePiece_rek(uuid, curIndex, moveIndex);
}
public void throwPiece(UUID uuid){
if (!init) throw new RuntimeException("BoardHandler is not initialized");
Color color = pieceColor.get(uuid);
assert(color != null) : "BoardHandler: uuid is not mapped to a color";
if(color == null) throw new RuntimeException("uuid is not mapped to a color");
PieceControl pieceControl = pieces.get(uuid);
List<NodeControl> waitNodes = waitingNodesMap.get(color);
@@ -241,23 +256,31 @@ public void throwPiece(UUID uuid){
}
public void shieldPiece(UUID uuid){
if (!init) throw new RuntimeException("BoardHandler is not initialized");
pieces.get(uuid).activateShield();
}
public void unshieldPiece(UUID uuid){
if (!init) throw new RuntimeException("BoardHandler is not initialized");
pieces.get(uuid).deactivateShield();
}
public void suppressShield(UUID uuid){
if (!init) throw new RuntimeException("BoardHandler is not initialized");
pieces.get(uuid).suppressShield();
}
public void swapPieces(UUID piece1, UUID piece2){
if (!init) throw new RuntimeException("BoardHandler is not initialized");
PieceControl piece1_control = pieces.get(piece1);
PieceControl piece2_control = pieces.get(piece2);
assert(piece1_control != null) : "BoardHandler: swap: piece1 UUID is not valid";
assert(piece2_control != null) : "BoardHandler: swap: piece2 UUID is not valid";
if(piece1_control == null) throw new RuntimeException("piece1 UUID is not valid");
if(piece2_control == null) throw new RuntimeException("piece2 UUID is not valid");
float rot1 = piece1_control.getRotation();
float rot2 = piece2_control.getRotation();
@@ -265,27 +288,36 @@ public void swapPieces(UUID piece1, UUID piece2){
piece1_control.setRotation(rot2);
piece2_control.setRotation(rot1);
Vector3f pos1 = piece1_control.getLocation();
Vector3f pos2 = piece2_control.getLocation();
Vector3f pos1 = piece1_control.getLocation().clone();
Vector3f pos2 = piece2_control.getLocation().clone();
piece1_control.setLocation(pos2);
piece2_control.setLocation(pos1);
}
public void test(UUID uuid){
System.out.println((float) Math.toDegrees(Math.atan2(1,0)));
System.out.println((float) Math.toDegrees(Math.atan2(-1,0)));
System.out.println((float) Math.toDegrees(Math.atan2(0,1)));
System.out.println((float) Math.toDegrees(Math.atan2(0,-1)));
public void init(){
initMap();
}
public void shutdown(){
if (!init) return;
init = false;
app.getRootNode().detachChild(node);
}
//List<Pieces>
//List<NodesIndexe>
public void highlight(UUID uuid, boolean bool){
if (!init) throw new RuntimeException("BoardHandler is not initialized");
pieces.get(uuid).outline(bool);
}
System.out.println(pieces.get(uuid).getRotation());
pieces.get(uuid).setRotation(-90);
System.out.println(pieces.get(uuid).getRotation());
public void unHighlight(UUID uuid){
if (!init) throw new RuntimeException("BoardHandler is not initialized");
pieces.get(uuid).deOutline();
}
}

View File

@@ -4,8 +4,8 @@
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.shadow.DirectionalLightShadowRenderer;
import com.jme3.post.FilterPostProcessor;
import com.jme3.shadow.DirectionalLightShadowFilter;
import pp.mdga.client.MdgaApp;
public class CameraHandler {
@@ -16,8 +16,7 @@ public class CameraHandler {
private static final int SHADOWMAP_SIZE = 1024 * 8;
public CameraHandler(MdgaApp app){
public CameraHandler(MdgaApp app, FilterPostProcessor fpp){
this.app = app;
sun = new DirectionalLight();
@@ -26,6 +25,10 @@ public CameraHandler(MdgaApp app){
ambient = new AmbientLight();
ambient.setColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1));
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 4);
dlsf.setLight(sun);
fpp.addFilter(dlsf);
}
public void init() {
@@ -34,10 +37,6 @@ public void init() {
app.getCamera().setLocation(new Vector3f(-zoom, 0, zoom));
app.getCamera().lookAt(new Vector3f(0, 0, 0), new Vector3f(0, 0, 1));
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(app.getAssetManager(), SHADOWMAP_SIZE, 4);
dlsr.setLight(sun);
app.getViewPort().addProcessor(dlsr);
app.getRootNode().addLight(sun);
app.getRootNode().addLight(ambient);
}

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 OutlineFilter extends Filter {
private OutlinePreFilter outlinePreFilter;
private ColorRGBA outlineColor = new ColorRGBA(0, 1, 0, 1);
private float outlineWidth = 1;
public OutlineFilter(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/Outline.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

@@ -0,0 +1,67 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
public class OutlinePreFilter extends Filter {
private Pass normalPass;
private RenderManager renderManager;
/**
* Creates a OutlinePreFilter
*/
public OutlinePreFilter() {
super("OutlinePreFilter");
}
@Override
protected boolean isRequiresDepthTexture() {
return true;
}
@Override
protected void postQueue(RenderQueue queue) {
Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, false);
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
}
@Override
protected Material getMaterial() {
return material;
}
public Texture getOutlineTexture() {
return normalPass.getRenderedTexture();
}
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
normalPass = new Pass();
normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
material = new Material(manager, "MatDefs/SelectObjectOutliner/OutlinePre.j3md");
}
@Override
protected void cleanUpFilter(Renderer r) {
normalPass.cleanup(r);
}
}

View File

@@ -0,0 +1,77 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.material.RenderState;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import pp.mdga.game.Color;
public class SelectObjectOutliner {
private final FilterPostProcessor fpp;
private final RenderManager renderManager;
private final AssetManager assetManager;
private final Camera cam;
private final int width;
private boolean selected;
private ViewPort outlineViewport = null;
private OutlineFilter outlineFilter = null;
public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam) {
this.selected = false;
this.fpp = fpp;
this.renderManager = renderManager;
this.assetManager = assetManager;
this.cam = cam;
this.width = width;
}
public void deselect(Spatial model) {
if(selected){
selected = false;
hideOutlineFilterEffect(model);
}
}
public void select(Spatial model, ColorRGBA color) {
if(!selected){
selected = true;
showOutlineFilterEffect(model, width, color);
}
}
private void hideOutlineFilterEffect(Spatial model) {
outlineFilter.setEnabled(false);
outlineFilter.getOutlinePreFilter().setEnabled(false);
fpp.removeFilter(outlineFilter);
outlineViewport.detachScene(model);
renderManager.removePreView(outlineViewport);
outlineViewport = null;
}
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
outlineViewport = renderManager.createPreView("outlineViewport", cam);
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
outlineFpp.addFilter(outlinePreFilter);
outlineViewport.attachScene(model);
outlineViewport.addProcessor(outlineFpp);
outlineFilter = new OutlineFilter(outlinePreFilter);
outlineFilter.setOutlineColor(color);
outlineFilter.setOutlineWidth(width);
fpp.addFilter(outlineFilter);
}
}

View File

@@ -6,20 +6,22 @@
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.board.Outline.SelectObjectOutliner;
public class PieceControl extends AbstractControl {
private float rotation;
private final float initRotation;
private AssetManager assetManager;
private final AssetManager assetManager;
private Spatial shieldRing;
private Node rootNode;
private Material shield_mat;
private final Material shieldMat;
private static final float SHIELD_SPEED = 1f;
private static final float SHIELD_TRANSPARENCY = 0.6f;
@@ -27,32 +29,36 @@ 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;
public PieceControl(float initRotation, AssetManager assetManager, Node rootNode){
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();
this.parentNode = new Node();
this.initRotation = initRotation;
this.assetManager = assetManager;
this.shieldRing = null;
this.rootNode = rootNode;
this.shieldMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
this.shieldMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
this.shield_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
this.shield_mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
outlineOwn = new SelectObjectOutliner(OUTLINE_THICKNESS, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera());
}
public float getRotation() {
return (float) Math.toDegrees(this.spatial.getLocalRotation().toAngleAxis(new Vector3f(0,0,1)));
// return rotation;
}
public void setRotation(float rot){
Quaternion quaternion = new Quaternion();
quaternion.fromAngleAxis((float) Math.toRadians(rot), new Vector3f(0,0,1));
this.spatial.setLocalRotation(quaternion);
// this.getSpatial().rotate(0, 0, (float) Math.toRadians(rot));
}
public Vector3f getLocation(){
@@ -77,10 +83,23 @@ public void setLocation(Vector3f loc){
@Override
public void setSpatial(Spatial spatial){
super.setSpatial(spatial);
if(spatial != null){
setRotation(this.initRotation);
if(this.getSpatial() == null && spatial != null){
super.setSpatial(spatial);
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() {
@@ -95,19 +114,36 @@ public void activateShield(){
shieldRing.setQueueBucket(RenderQueue.Bucket.Transparent); // Render in the transparent bucket
shield_mat.setColor("Color", SHIELD_COLOR);
shieldRing.setMaterial(shield_mat);
shieldMat.setColor("Color", SHIELD_COLOR);
shieldRing.setMaterial(shieldMat);
rootNode.attachChild(shieldRing);
parentNode.attachChild(shieldRing);
}
public void deactivateShield(){
rootNode.detachChild(shieldRing);
parentNode.detachChild(shieldRing);
shieldRing = null;
}
public void suppressShield(){
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){
this.spatial.setMaterial(mat);
}
public Material getMaterial(){
return ((Geometry) this.spatial).getMaterial();
}
public void outline(boolean enemy) {
ColorRGBA color = enemy ? OUTLINE_ENEMY_COLOR : OUTLINE_OWN_COLOR;
outlineOwn.select(this.getSpatial(), color);
}
public void deOutline() {
outlineOwn.deselect(this.getSpatial());
}
}

View File

@@ -1,5 +1,5 @@
package pp.mdga.client.gui;
public class GuiView {
public class GuiHandler {
}

View File

@@ -1,5 +1,6 @@
package pp.mdga.client.view;
import com.jme3.post.FilterPostProcessor;
import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.board.CameraHandler;
import pp.mdga.client.dialog.SingleButtonLeftDialog;
@@ -17,8 +18,11 @@ public class GameView extends MdgaView {
public GameView(MdgaApp app) {
super(app);
this.boardHandler = new BoardHandler(app);
this.camera = new CameraHandler(app);
//Filter für Outline: Reihenfolge CameraHandler(dlsf) -> BoardHandler -> viewPort.addProcessor einhalten!
FilterPostProcessor fpp = new FilterPostProcessor(app.getAssetManager());
this.camera = new CameraHandler(app, fpp);
this.boardHandler = new BoardHandler(app, fpp);
app.getViewPort().addProcessor(fpp);
leaveButton = new SingleButtonLeftDialog(app, settingsNode, "Verlassen", () -> leaveGame());
@@ -27,8 +31,8 @@ public GameView(MdgaApp app) {
@Override
public void onEnter() {
boardHandler.init();
camera.init();
boardHandler.init();
continueButton.show();
}

View File

@@ -0,0 +1,29 @@
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);
//如果是背景
if(depth==vec4(0.) && (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth||depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)){
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/Outline.frag
WorldParameters {
}
}
}

View File

@@ -0,0 +1,10 @@
varying vec2 texCoord;
uniform sampler2D m_Texture;
uniform sampler2D m_NormalsTexture;
uniform sampler2D m_DepthTexture;
void main(){
vec4 color = texture2D(m_Texture, texCoord);
gl_FragColor=color;
}

View File

@@ -0,0 +1,19 @@
MaterialDef Cartoon Edge {
MaterialParameters {
Int NumSamples
Int NumSamplesDepth
Texture2D Texture
Texture2D NormalsTexture
Texture2D DepthTexture
}
Technique {
VertexShader GLSL150: MatDefs/SelectObjectOutliner/Post15.vert
FragmentShader GLSL150: MatDefs/SelectObjectOutliner/OutlinePre.frag
WorldParameters {
}
}
}

View File

@@ -0,0 +1,10 @@
in vec4 inPosition;
in vec2 inTexCoord;
out vec2 texCoord;
void main() {
vec2 pos = inPosition.xy * 2.0 - 1.0;
gl_Position = vec4(pos, 0.0, 1.0);
texCoord = inTexCoord;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff