Merge commit
This commit is contained in:
63
Projekte/mdga/client/src/main/java/pp/mdga/client/Asset.java
Normal file
63
Projekte/mdga/client/src/main/java/pp/mdga/client/Asset.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package pp.mdga.client;
|
||||
|
||||
public enum Asset {
|
||||
bigTent,
|
||||
cardStack,
|
||||
cir,
|
||||
heer,
|
||||
jet,
|
||||
lw,
|
||||
marine,
|
||||
node_home_blue("./node_home/node_home.j3o", "./node_home/node_home_blue.png"),
|
||||
node_home_black("./node_home/node_home.j3o", "./node_home/node_home_black.png"),
|
||||
node_home_green("./node_home/node_home.j3o", "./node_home/node_home_green.png"),
|
||||
node_home_yellow("./node_home/node_home.j3o", "./node_home/node_home_yellow.png"),
|
||||
node_normal,
|
||||
node_start("./node_normal/node_normal.j3o", "./node_normal/node_normal_start.png"),
|
||||
node_bonus("./node_normal/node_normal.j3o", "./node_normal/node_normal_bonus.png"),
|
||||
radar,
|
||||
shieldCard,
|
||||
ship,
|
||||
smallTent,
|
||||
swapCard,
|
||||
tank,
|
||||
turboCard,
|
||||
world(1.1f);
|
||||
|
||||
private final String modelPath;
|
||||
private final String diffPath;
|
||||
private final float size;
|
||||
|
||||
Asset(){
|
||||
String folderFileName = "./" + name() + "/" + name();
|
||||
this.modelPath = folderFileName + ".j3o";
|
||||
this.diffPath = folderFileName + "_diff.png";
|
||||
this.size = 1f;
|
||||
}
|
||||
|
||||
Asset(String modelPath, String diffPath){
|
||||
this.modelPath = modelPath;
|
||||
this.diffPath = diffPath;
|
||||
this.size = 1f;
|
||||
}
|
||||
|
||||
Asset(float size){
|
||||
String folderFileName = "./" + name() + "/" + name();
|
||||
this.modelPath = folderFileName + ".j3o";
|
||||
this.diffPath = folderFileName + "_diff.png";
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
public String getDiffPath() {
|
||||
return diffPath;
|
||||
}
|
||||
|
||||
public float getSize(){
|
||||
return size;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,27 +3,91 @@
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import pp.mdga.client.Animation.AnimationHandler;
|
||||
import com.jme3.light.AmbientLight;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.shadow.DirectionalLightShadowRenderer;
|
||||
import com.jme3.system.AppSettings;
|
||||
|
||||
public class MdgaApp extends SimpleApplication {
|
||||
private AnimationHandler animationHandler;
|
||||
|
||||
public static void main(String[] args) {
|
||||
MdgaApp app = new MdgaApp();
|
||||
AppSettings settings = new AppSettings(true);
|
||||
settings.setSamples(128);
|
||||
settings.setCenterWindow(true);
|
||||
settings.setWidth(1300);
|
||||
settings.setHeight(1000);
|
||||
app.setSettings(settings);
|
||||
app.setShowSettings(false);
|
||||
app.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleInitApp() {
|
||||
animationHandler = new AnimationHandler(this);
|
||||
|
||||
flyCam.setEnabled(true);
|
||||
int zoom = 20;
|
||||
cam.setLocation(new Vector3f(zoom,0,zoom));
|
||||
cam.lookAt(new Vector3f(0,0,0), new Vector3f(0,0,1));
|
||||
|
||||
DirectionalLight sun = new DirectionalLight();
|
||||
sun.setColor(ColorRGBA.White);
|
||||
sun.setDirection(new Vector3f(-1,0,-1));
|
||||
rootNode.addLight(sun);
|
||||
AmbientLight ambient = new AmbientLight();
|
||||
ambient.setColor(new ColorRGBA(0.3f,0.3f,0.3f,1));
|
||||
rootNode.addLight(ambient);
|
||||
|
||||
final int SHADOWMAP_SIZE=1024*8;
|
||||
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 4);
|
||||
dlsr.setLight(sun);
|
||||
viewPort.addProcessor(dlsr);
|
||||
|
||||
createModel(Asset.lw).setLocalTranslation(new Vector3f(0,-10,0));
|
||||
createModel(Asset.cir).setLocalTranslation(new Vector3f(0,-8,0));
|
||||
createModel(Asset.marine).setLocalTranslation(new Vector3f(0,-6,0));
|
||||
createModel(Asset.heer).setLocalTranslation(new Vector3f(0,-4,0));
|
||||
createModel(Asset.node_normal).setLocalTranslation(new Vector3f(0,-2.5f,0));
|
||||
createModel(Asset.node_home_blue).setLocalTranslation(new Vector3f(0,-1,0));
|
||||
createModel(Asset.smallTent).setLocalTranslation(new Vector3f(0,1,0));
|
||||
createModel(Asset.tank).setLocalTranslation(new Vector3f(0,5,0));
|
||||
createModel(Asset.jet).setLocalTranslation(new Vector3f(0,12,0));
|
||||
createModel(Asset.ship).setLocalTranslation(new Vector3f(0,17,0));
|
||||
createModel(Asset.radar).setLocalTranslation(new Vector3f(0,20,0));
|
||||
|
||||
createModel(Asset.world);
|
||||
|
||||
System.out.println(Asset.node_normal.getModelPath());
|
||||
System.out.println(Asset.node_normal.getDiffPath());
|
||||
}
|
||||
|
||||
|
||||
private Spatial createModel(Asset asset){
|
||||
String modelName = asset.getModelPath();
|
||||
String texName = asset.getDiffPath();
|
||||
Spatial model = assetManager.loadModel(modelName);
|
||||
model.scale(asset.getSize());
|
||||
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(90));
|
||||
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
|
||||
mat.setTexture("DiffuseMap", assetManager.loadTexture(texName));
|
||||
model.setMaterial(mat);
|
||||
rootNode.attachChild(model);
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
|
||||
//this method will be called every game tick and can be used to make updates
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleRender(RenderManager rm) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
libs {
|
||||
version('jme', '3.6.1-stable')
|
||||
version('jme', '3.7.0-stable')
|
||||
|
||||
library('jme3-core', 'org.jmonkeyengine', 'jme3-core').versionRef('jme')
|
||||
library('jme3-desktop', 'org.jmonkeyengine', 'jme3-desktop').versionRef('jme')
|
||||
|
||||
Reference in New Issue
Block a user