Add game source, converter pipeline, and web port
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.animation.AnimChannel
|
||||
* com.jme3.animation.AnimControl
|
||||
* com.jme3.animation.AnimEventListener
|
||||
* com.jme3.animation.LoopMode
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.KeyTrigger
|
||||
* com.jme3.input.controls.MouseButtonTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.light.DirectionalLight
|
||||
* com.jme3.light.Light
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Node
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.debug.SkeletonDebugger
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.animation.AnimChannel;
|
||||
import com.jme3.animation.AnimControl;
|
||||
import com.jme3.animation.AnimEventListener;
|
||||
import com.jme3.animation.LoopMode;
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.debug.SkeletonDebugger;
|
||||
|
||||
public class HelloAnimation
|
||||
extends SimpleApplication
|
||||
implements AnimEventListener {
|
||||
private AnimChannel channel;
|
||||
private AnimControl control;
|
||||
Node player;
|
||||
private ActionListener actionListener = new ActionListener(){
|
||||
|
||||
public void onAction(String name, boolean keyPressed, float tpf) {
|
||||
if (name.equals("Walk") && !keyPressed && !HelloAnimation.this.channel.getAnimationName().equals("Walk")) {
|
||||
HelloAnimation.this.channel.setAnim("Walk", 0.5f);
|
||||
HelloAnimation.this.channel.setLoopMode(LoopMode.Loop);
|
||||
}
|
||||
if (name.equals("Dodge") && !keyPressed && !HelloAnimation.this.channel.getAnimationName().equals("Push")) {
|
||||
HelloAnimation.this.channel.setAnim("push", 1.0f);
|
||||
HelloAnimation.this.channel.setLoopMode(LoopMode.DontLoop);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void main(String[] agrs) {
|
||||
HelloAnimation app = new HelloAnimation();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
this.viewPort.setBackgroundColor(ColorRGBA.LightGray);
|
||||
this.initKeys();
|
||||
DirectionalLight dl = new DirectionalLight();
|
||||
dl.setDirection(new Vector3f(-0.1f, -1.0f, -1.0f).normalizeLocal());
|
||||
this.rootNode.addLight((Light)dl);
|
||||
this.player = (Node)this.assetManager.loadModel("Models/Oto/Oto.mesh.xml");
|
||||
this.player.setLocalScale(0.5f);
|
||||
this.rootNode.attachChild((Spatial)this.player);
|
||||
this.control = (AnimControl)this.player.getControl(AnimControl.class);
|
||||
this.control.addListener((AnimEventListener)this);
|
||||
this.channel = this.control.createChannel();
|
||||
this.channel.setAnim("stand");
|
||||
SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", this.control.getSkeleton());
|
||||
Material mat = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setColor("Color", ColorRGBA.Green);
|
||||
mat.getAdditionalRenderState().setDepthTest(false);
|
||||
skeletonDebug.setMaterial(mat);
|
||||
this.player.attachChild((Spatial)skeletonDebug);
|
||||
}
|
||||
|
||||
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
|
||||
if (animName.equals("Walk")) {
|
||||
channel.setAnim("stand", 0.5f);
|
||||
channel.setLoopMode(LoopMode.DontLoop);
|
||||
channel.setSpeed(1.0f);
|
||||
}
|
||||
if (animName.equals("push")) {
|
||||
channel.setAnim("stand", 1.0f);
|
||||
channel.setLoopMode(LoopMode.DontLoop);
|
||||
channel.setSpeed(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
|
||||
}
|
||||
|
||||
private void initKeys() {
|
||||
this.inputManager.addMapping("Walk", new Trigger[]{new KeyTrigger(57)});
|
||||
this.inputManager.addMapping("Dodge", new Trigger[]{new MouseButtonTrigger(0)});
|
||||
this.inputManager.addListener((InputListener)this.actionListener, new String[]{"Walk", "Dodge"});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.font.BitmapText
|
||||
* com.jme3.light.DirectionalLight
|
||||
* com.jme3.light.Light
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.shape.Box
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.font.BitmapText;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Box;
|
||||
|
||||
public class HelloAssets
|
||||
extends SimpleApplication {
|
||||
public static void main(String[] args) {
|
||||
HelloAssets app = new HelloAssets();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
Spatial teapot = this.assetManager.loadModel("Models/Teapot/Teapot.obj");
|
||||
Material mat_default = new Material(this.assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
|
||||
teapot.setMaterial(mat_default);
|
||||
this.rootNode.attachChild(teapot);
|
||||
Box box = new Box(Vector3f.ZERO, 2.5f, 2.5f, 1.0f);
|
||||
Geometry wall = new Geometry("Box", (Mesh)box);
|
||||
Material mat_brick = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat_brick.setTexture("ColorMap", this.assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
|
||||
wall.setMaterial(mat_brick);
|
||||
wall.setLocalTranslation(2.0f, -2.5f, 0.0f);
|
||||
this.rootNode.attachChild((Spatial)wall);
|
||||
this.guiNode.detachAllChildren();
|
||||
this.guiFont = this.assetManager.loadFont("Interface/Fonts/Default.fnt");
|
||||
BitmapText helloText = new BitmapText(this.guiFont, false);
|
||||
helloText.setSize((float)this.guiFont.getCharSet().getRenderedSize());
|
||||
helloText.setText("Hello World");
|
||||
helloText.setLocalTranslation(300.0f, helloText.getLineHeight(), 0.0f);
|
||||
this.guiNode.attachChild((Spatial)helloText);
|
||||
Spatial ninja = this.assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
|
||||
ninja.scale(0.05f, 0.05f, 0.05f);
|
||||
ninja.rotate(0.0f, -3.0f, 0.0f);
|
||||
ninja.setLocalTranslation(0.0f, -5.0f, -2.0f);
|
||||
this.rootNode.attachChild(ninja);
|
||||
DirectionalLight sun = new DirectionalLight();
|
||||
sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
|
||||
this.rootNode.addLight((Light)sun);
|
||||
Spatial gameLevel = this.assetManager.loadModel("Scenes/main.j3o");
|
||||
gameLevel.setLocalTranslation(0.0f, -5.2f, 0.0f);
|
||||
gameLevel.setLocalScale(2.0f);
|
||||
this.rootNode.attachChild(gameLevel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.audio.AudioNode
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.MouseButtonTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.shape.Box
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.audio.AudioNode;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Box;
|
||||
|
||||
public class HelloAudio
|
||||
extends SimpleApplication {
|
||||
private AudioNode audio_gun;
|
||||
private AudioNode audio_nature;
|
||||
private Geometry player;
|
||||
private ActionListener actionListener = new ActionListener(){
|
||||
|
||||
public void onAction(String name, boolean keyPressed, float tpf) {
|
||||
if (name.equals("Shoot") && !keyPressed) {
|
||||
HelloAudio.this.audio_gun.playInstance();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
HelloAudio app = new HelloAudio();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
this.flyCam.setMoveSpeed(40.0f);
|
||||
Box box1 = new Box(Vector3f.ZERO, 1.0f, 1.0f, 1.0f);
|
||||
this.player = new Geometry("Player", (Mesh)box1);
|
||||
Material mat1 = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat1.setColor("Color", ColorRGBA.Blue);
|
||||
this.player.setMaterial(mat1);
|
||||
this.rootNode.attachChild((Spatial)this.player);
|
||||
this.initKeys();
|
||||
this.initAudio();
|
||||
}
|
||||
|
||||
public void initAudio() {
|
||||
this.audio_gun = new AudioNode(this.assetManager, "Sound/Effects/Gun.wav", false);
|
||||
this.audio_gun.setLooping(false);
|
||||
this.audio_gun.setVolume(2.0f);
|
||||
this.rootNode.attachChild((Spatial)this.audio_gun);
|
||||
this.audio_nature = new AudioNode(this.assetManager, "Sound/Environment/Nature.ogg", false);
|
||||
this.audio_nature.setLooping(true);
|
||||
this.audio_nature.setPositional(false);
|
||||
this.audio_nature.setLocalTranslation(Vector3f.ZERO.clone());
|
||||
this.audio_nature.setVolume(3.0f);
|
||||
this.rootNode.attachChild((Spatial)this.audio_nature);
|
||||
this.audio_nature.play();
|
||||
}
|
||||
|
||||
private void initKeys() {
|
||||
this.inputManager.addMapping("Shoot", new Trigger[]{new MouseButtonTrigger(0)});
|
||||
this.inputManager.addListener((InputListener)this.actionListener, new String[]{"Shoot"});
|
||||
}
|
||||
|
||||
public void simpleUpdate(float tpf) {
|
||||
this.listener.setLocation(this.cam.getLocation());
|
||||
this.listener.setRotation(this.cam.getRotation());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.app.state.AppState
|
||||
* com.jme3.asset.plugins.ZipLocator
|
||||
* com.jme3.bullet.BulletAppState
|
||||
* com.jme3.bullet.collision.shapes.CapsuleCollisionShape
|
||||
* com.jme3.bullet.collision.shapes.CollisionShape
|
||||
* com.jme3.bullet.control.CharacterControl
|
||||
* com.jme3.bullet.control.RigidBodyControl
|
||||
* com.jme3.bullet.util.CollisionShapeFactory
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.KeyTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.light.AmbientLight
|
||||
* com.jme3.light.DirectionalLight
|
||||
* com.jme3.light.Light
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Node
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.control.Control
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.state.AppState;
|
||||
import com.jme3.asset.plugins.ZipLocator;
|
||||
import com.jme3.bullet.BulletAppState;
|
||||
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
|
||||
import com.jme3.bullet.collision.shapes.CollisionShape;
|
||||
import com.jme3.bullet.control.CharacterControl;
|
||||
import com.jme3.bullet.control.RigidBodyControl;
|
||||
import com.jme3.bullet.util.CollisionShapeFactory;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.light.AmbientLight;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
|
||||
public class HelloCollision
|
||||
extends SimpleApplication
|
||||
implements ActionListener {
|
||||
private Spatial sceneModel;
|
||||
private BulletAppState bulletAppState;
|
||||
private RigidBodyControl landscape;
|
||||
private CharacterControl player;
|
||||
private Vector3f walkDirection = new Vector3f();
|
||||
private boolean left = false;
|
||||
private boolean right = false;
|
||||
private boolean up = false;
|
||||
private boolean down = false;
|
||||
|
||||
public static void main(String[] args) {
|
||||
HelloCollision app = new HelloCollision();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
this.bulletAppState = new BulletAppState();
|
||||
this.stateManager.attach((AppState)this.bulletAppState);
|
||||
this.bulletAppState.getPhysicsSpace().enableDebug(this.assetManager);
|
||||
this.viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1.0f, 1.0f));
|
||||
this.flyCam.setMoveSpeed(100.0f);
|
||||
this.setUpKeys();
|
||||
this.setUpLight();
|
||||
this.assetManager.registerLocator("town.zip", ZipLocator.class);
|
||||
this.sceneModel = this.assetManager.loadModel("main.scene");
|
||||
this.sceneModel.setLocalScale(2.0f);
|
||||
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Spatial)((Node)this.sceneModel));
|
||||
this.landscape = new RigidBodyControl(sceneShape, 0.0f);
|
||||
this.sceneModel.addControl((Control)this.landscape);
|
||||
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6.0f, 1);
|
||||
this.player = new CharacterControl((CollisionShape)capsuleShape, 0.5f);
|
||||
this.player.setJumpSpeed(20.0f);
|
||||
this.player.setFallSpeed(30.0f);
|
||||
this.player.setGravity(30.0f);
|
||||
this.player.setPhysicsLocation(new Vector3f(0.0f, 10.0f, 0.0f));
|
||||
this.rootNode.attachChild(this.sceneModel);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)this.landscape);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)this.player);
|
||||
}
|
||||
|
||||
private void setUpLight() {
|
||||
AmbientLight al = new AmbientLight();
|
||||
al.setColor(ColorRGBA.White.mult(1.3f));
|
||||
this.rootNode.addLight((Light)al);
|
||||
DirectionalLight dl = new DirectionalLight();
|
||||
dl.setColor(ColorRGBA.White);
|
||||
dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());
|
||||
this.rootNode.addLight((Light)dl);
|
||||
}
|
||||
|
||||
private void setUpKeys() {
|
||||
this.inputManager.addMapping("Left", new Trigger[]{new KeyTrigger(30)});
|
||||
this.inputManager.addMapping("Right", new Trigger[]{new KeyTrigger(32)});
|
||||
this.inputManager.addMapping("Up", new Trigger[]{new KeyTrigger(17)});
|
||||
this.inputManager.addMapping("Down", new Trigger[]{new KeyTrigger(31)});
|
||||
this.inputManager.addMapping("Jump", new Trigger[]{new KeyTrigger(57)});
|
||||
this.inputManager.addListener((InputListener)this, new String[]{"Left"});
|
||||
this.inputManager.addListener((InputListener)this, new String[]{"Right"});
|
||||
this.inputManager.addListener((InputListener)this, new String[]{"Up"});
|
||||
this.inputManager.addListener((InputListener)this, new String[]{"Down"});
|
||||
this.inputManager.addListener((InputListener)this, new String[]{"Jump"});
|
||||
}
|
||||
|
||||
public void onAction(String binding, boolean value, float tpf) {
|
||||
if (binding.equals("Left")) {
|
||||
this.left = value;
|
||||
} else if (binding.equals("Right")) {
|
||||
this.right = value;
|
||||
} else if (binding.equals("Up")) {
|
||||
this.up = value;
|
||||
} else if (binding.equals("Down")) {
|
||||
this.down = value;
|
||||
} else if (binding.equals("Jump")) {
|
||||
this.player.jump();
|
||||
}
|
||||
}
|
||||
|
||||
public void simpleUpdate(float tpf) {
|
||||
Vector3f camDir = this.cam.getDirection().clone().multLocal(0.6f);
|
||||
Vector3f camLeft = this.cam.getLeft().clone().multLocal(0.4f);
|
||||
this.walkDirection.set(0.0f, 0.0f, 0.0f);
|
||||
if (this.left) {
|
||||
this.walkDirection.addLocal(camLeft);
|
||||
}
|
||||
if (this.right) {
|
||||
this.walkDirection.addLocal(camLeft.negate());
|
||||
}
|
||||
if (this.up) {
|
||||
this.walkDirection.addLocal(camDir);
|
||||
}
|
||||
if (this.down) {
|
||||
this.walkDirection.addLocal(camDir.negate());
|
||||
}
|
||||
this.player.setWalkDirection(this.walkDirection);
|
||||
this.cam.setLocation(this.player.getPhysicsLocation());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.effect.ParticleEmitter
|
||||
* com.jme3.effect.ParticleMesh$Type
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Spatial
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.effect.ParticleEmitter;
|
||||
import com.jme3.effect.ParticleMesh;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Spatial;
|
||||
|
||||
public class HelloEffects
|
||||
extends SimpleApplication {
|
||||
public static void main(String[] args) {
|
||||
HelloEffects app = new HelloEffects();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30);
|
||||
Material mat_red = new Material(this.assetManager, "Common/MatDefs/Misc/Particle.j3md");
|
||||
mat_red.setTexture("Texture", this.assetManager.loadTexture("Effects/Explosion/flame.png"));
|
||||
fire.setMaterial(mat_red);
|
||||
fire.setImagesX(2);
|
||||
fire.setImagesY(2);
|
||||
fire.setEndColor(ColorRGBA.Cyan);
|
||||
fire.setStartColor(ColorRGBA.Blue);
|
||||
fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, -2.0f, 0.0f));
|
||||
fire.setStartSize(0.1f);
|
||||
fire.setEndSize(1.5f);
|
||||
fire.setGravity(0.0f, 1.0f, 0.0f);
|
||||
fire.setLowLife(1.0f);
|
||||
fire.setHighLife(3.0f);
|
||||
fire.getParticleInfluencer().setVelocityVariation(0.3f);
|
||||
this.rootNode.attachChild((Spatial)fire);
|
||||
ParticleEmitter debris = new ParticleEmitter("Debris", ParticleMesh.Type.Triangle, 10);
|
||||
Material debris_mat = new Material(this.assetManager, "Common/MatDefs/Misc/Particle.j3md");
|
||||
debris_mat.setTexture("Texture", this.assetManager.loadTexture("Effects/Explosion/Debris.png"));
|
||||
debris.setMaterial(debris_mat);
|
||||
debris.setImagesX(3);
|
||||
debris.setImagesY(3);
|
||||
debris.setRotateSpeed(4.0f);
|
||||
debris.setSelectRandomImage(true);
|
||||
debris.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 4.0f, 0.0f));
|
||||
debris.setStartColor(ColorRGBA.White);
|
||||
debris.setGravity(0.0f, 6.0f, 0.0f);
|
||||
debris.getParticleInfluencer().setVelocityVariation(0.6f);
|
||||
this.rootNode.attachChild((Spatial)debris);
|
||||
debris.emitAllParticles();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.AnalogListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.KeyTrigger
|
||||
* com.jme3.input.controls.MouseAxisTrigger
|
||||
* com.jme3.input.controls.MouseButtonTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.light.DirectionalLight
|
||||
* com.jme3.light.Light
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.shape.Box
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.AnalogListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseAxisTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Box;
|
||||
|
||||
public class HelloInput
|
||||
extends SimpleApplication {
|
||||
protected Geometry player;
|
||||
boolean isRunning = true;
|
||||
private ActionListener actionListener = new ActionListener(){
|
||||
|
||||
public void onAction(String name, boolean keyPressed, float tpf) {
|
||||
if (name.equals("Pause") && !keyPressed) {
|
||||
HelloInput.this.isRunning = !HelloInput.this.isRunning;
|
||||
}
|
||||
}
|
||||
};
|
||||
private AnalogListener analogListener = new AnalogListener(){
|
||||
|
||||
public void onAnalog(String name, float value, float tpf) {
|
||||
if (HelloInput.this.isRunning) {
|
||||
Vector3f v;
|
||||
if (name.equals("RotateLeft")) {
|
||||
HelloInput.this.player.rotate(0.0f, value * HelloInput.this.speed, 0.0f);
|
||||
}
|
||||
if (name.equals("RotateRight")) {
|
||||
HelloInput.this.player.rotate(0.0f, value * -HelloInput.this.speed, 0.0f);
|
||||
}
|
||||
if (name.equals("Right")) {
|
||||
v = HelloInput.this.player.getLocalTranslation();
|
||||
HelloInput.this.player.setLocalTranslation(v.x + value * HelloInput.this.speed, v.y, v.z);
|
||||
}
|
||||
if (name.equals("Left")) {
|
||||
v = HelloInput.this.player.getLocalTranslation();
|
||||
HelloInput.this.player.setLocalTranslation(v.x - value * HelloInput.this.speed, v.y, v.z);
|
||||
}
|
||||
if (name.equals("Up")) {
|
||||
v = HelloInput.this.player.getLocalTranslation();
|
||||
HelloInput.this.player.setLocalTranslation(v.x, v.y + value * HelloInput.this.speed, v.z);
|
||||
}
|
||||
if (name.equals("Down")) {
|
||||
v = HelloInput.this.player.getLocalTranslation();
|
||||
HelloInput.this.player.setLocalTranslation(v.x, v.y - value * HelloInput.this.speed, v.z);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Press P to unpause.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
HelloInput app = new HelloInput();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
Box b = new Box(Vector3f.ZERO, 1.0f, 1.0f, 1.0f);
|
||||
this.player = new Geometry("Player", (Mesh)b);
|
||||
Material mat = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setColor("Color", ColorRGBA.randomColor());
|
||||
this.player.setMaterial(mat);
|
||||
this.rootNode.attachChild((Spatial)this.player);
|
||||
this.initKeys();
|
||||
Spatial gameLevel = this.assetManager.loadModel("Scenes/main.j3o");
|
||||
gameLevel.setLocalTranslation(0.0f, -5.2f, 0.0f);
|
||||
gameLevel.setLocalScale(2.0f);
|
||||
this.rootNode.attachChild(gameLevel);
|
||||
DirectionalLight sun = new DirectionalLight();
|
||||
sun.setColor(ColorRGBA.White);
|
||||
sun.setDirection(new Vector3f(-0.5f, -0.5f, -0.5f).normalizeLocal());
|
||||
this.rootNode.addLight((Light)sun);
|
||||
}
|
||||
|
||||
private void initKeys() {
|
||||
this.inputManager.addMapping("Pause", new Trigger[]{new KeyTrigger(25)});
|
||||
this.inputManager.addMapping("Left", new Trigger[]{new KeyTrigger(36)});
|
||||
this.inputManager.addMapping("Right", new Trigger[]{new KeyTrigger(38)});
|
||||
this.inputManager.addMapping("Up", new Trigger[]{new KeyTrigger(23), new MouseAxisTrigger(2, true)});
|
||||
this.inputManager.addMapping("Down", new Trigger[]{new KeyTrigger(37), new MouseAxisTrigger(2, false)});
|
||||
this.inputManager.addMapping("RotateLeft", new Trigger[]{new KeyTrigger(57), new MouseButtonTrigger(0)});
|
||||
this.inputManager.addMapping("RotateRight", new Trigger[]{new MouseButtonTrigger(1)});
|
||||
this.inputManager.addListener((InputListener)this.actionListener, new String[]{"Pause"});
|
||||
this.inputManager.addListener((InputListener)this.analogListener, new String[]{"Left", "Right", "RotateLeft", "RotateRight", "Up", "Down"});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.light.DirectionalLight
|
||||
* com.jme3.light.Light
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.material.RenderState$BlendMode
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.renderer.queue.RenderQueue$Bucket
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.shape.Box
|
||||
* com.jme3.scene.shape.Sphere
|
||||
* com.jme3.scene.shape.Sphere$TextureMode
|
||||
* com.jme3.util.TangentBinormalGenerator
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.material.RenderState;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Box;
|
||||
import com.jme3.scene.shape.Sphere;
|
||||
import com.jme3.util.TangentBinormalGenerator;
|
||||
|
||||
public class HelloMaterial
|
||||
extends SimpleApplication {
|
||||
public static void main(String[] args) {
|
||||
HelloMaterial app = new HelloMaterial();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
Box boxshape3 = new Box(new Vector3f(0.0f, 0.0f, 0.0f), 1.0f, 1.0f, 0.01f);
|
||||
Geometry window_frame = new Geometry("window frame", (Mesh)boxshape3);
|
||||
Material mat_tt = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat_tt.setTexture("ColorMap", this.assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
|
||||
mat_tt.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||
window_frame.setMaterial(mat_tt);
|
||||
window_frame.setQueueBucket(RenderQueue.Bucket.Transparent);
|
||||
this.rootNode.attachChild((Spatial)window_frame);
|
||||
Box boxshape4 = new Box(new Vector3f(3.0f, -1.0f, 0.0f), 1.0f, 1.0f, 1.0f);
|
||||
Geometry cube_leak = new Geometry("Leak-through color cube", (Mesh)boxshape4);
|
||||
cube_leak.setMaterial(this.assetManager.loadMaterial("Materials/LeakThrough.j3m"));
|
||||
this.rootNode.attachChild((Spatial)cube_leak);
|
||||
Sphere rock = new Sphere(32, 32, 2.0f);
|
||||
Geometry shiny_rock = new Geometry("Shiny rock", (Mesh)rock);
|
||||
rock.setTextureMode(Sphere.TextureMode.Projected);
|
||||
TangentBinormalGenerator.generate((Mesh)rock);
|
||||
Material mat_lit = new Material(this.assetManager, "Common/MatDefs/Light/Lighting.j3md");
|
||||
mat_lit.setTexture("DiffuseMap", this.assetManager.loadTexture("Textures/Terrain/Pond/Pond.jpg"));
|
||||
mat_lit.setTexture("NormalMap", this.assetManager.loadTexture("Textures/Terrain/Pond/Pond_normal.png"));
|
||||
mat_lit.setBoolean("UseMaterialColors", true);
|
||||
mat_lit.setColor("Specular", ColorRGBA.White);
|
||||
mat_lit.setColor("Diffuse", ColorRGBA.White);
|
||||
mat_lit.setFloat("Shininess", 127.0f);
|
||||
shiny_rock.setMaterial(mat_lit);
|
||||
shiny_rock.setLocalTranslation(0.0f, 2.0f, -2.0f);
|
||||
shiny_rock.rotate(1.6f, 0.0f, 0.0f);
|
||||
this.rootNode.attachChild((Spatial)shiny_rock);
|
||||
DirectionalLight sun = new DirectionalLight();
|
||||
sun.setDirection(new Vector3f(1.0f, 0.0f, -2.0f).normalizeLocal());
|
||||
sun.setColor(ColorRGBA.White);
|
||||
this.rootNode.addLight((Light)sun);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.app.state.AppState
|
||||
* com.jme3.asset.TextureKey
|
||||
* com.jme3.bullet.BulletAppState
|
||||
* com.jme3.bullet.control.RigidBodyControl
|
||||
* com.jme3.font.BitmapText
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.MouseButtonTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.Vector2f
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.control.Control
|
||||
* com.jme3.scene.shape.Box
|
||||
* com.jme3.scene.shape.Sphere
|
||||
* com.jme3.scene.shape.Sphere$TextureMode
|
||||
* com.jme3.texture.Texture
|
||||
* com.jme3.texture.Texture$WrapMode
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.state.AppState;
|
||||
import com.jme3.asset.TextureKey;
|
||||
import com.jme3.bullet.BulletAppState;
|
||||
import com.jme3.bullet.control.RigidBodyControl;
|
||||
import com.jme3.font.BitmapText;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import com.jme3.scene.shape.Box;
|
||||
import com.jme3.scene.shape.Sphere;
|
||||
import com.jme3.texture.Texture;
|
||||
|
||||
public class HelloPhysik
|
||||
extends SimpleApplication {
|
||||
private BulletAppState bulletAppState;
|
||||
Material wall_mat;
|
||||
Material stone_mat;
|
||||
Material floor_mat;
|
||||
private RigidBodyControl brick_phy;
|
||||
private static final Box box;
|
||||
private RigidBodyControl ball_phy;
|
||||
private static final Sphere sphere;
|
||||
private RigidBodyControl floor_phy;
|
||||
private static final Box floor;
|
||||
private static final float brickLength = 0.48f;
|
||||
private static final float brickWidth = 0.24f;
|
||||
private static final float brickHeight = 0.12f;
|
||||
private ActionListener actionListener = new ActionListener(){
|
||||
|
||||
public void onAction(String name, boolean keyPressed, float tpf) {
|
||||
if (name.equals("shoot") && !keyPressed) {
|
||||
HelloPhysik.this.makeCannonBall();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
HelloPhysik app = new HelloPhysik();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
this.bulletAppState = new BulletAppState();
|
||||
this.stateManager.attach((AppState)this.bulletAppState);
|
||||
this.bulletAppState.getPhysicsSpace().enableDebug(this.assetManager);
|
||||
this.cam.setLocation(new Vector3f(0.0f, 4.0f, 6.0f));
|
||||
this.cam.lookAt(new Vector3f(2.0f, 2.0f, 0.0f), Vector3f.UNIT_Y);
|
||||
this.inputManager.addMapping("shoot", new Trigger[]{new MouseButtonTrigger(0)});
|
||||
this.inputManager.addListener((InputListener)this.actionListener, new String[]{"shoot"});
|
||||
this.initMaterials();
|
||||
this.initWall();
|
||||
this.initFloor();
|
||||
this.initCrossHairs();
|
||||
}
|
||||
|
||||
public void initMaterials() {
|
||||
this.wall_mat = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
|
||||
key.setGenerateMips(true);
|
||||
Texture tex = this.assetManager.loadTexture(key);
|
||||
this.wall_mat.setTexture("ColorMap", tex);
|
||||
this.stone_mat = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
||||
key2.setGenerateMips(true);
|
||||
Texture tex2 = this.assetManager.loadTexture(key2);
|
||||
this.stone_mat.setTexture("ColorMap", tex2);
|
||||
this.floor_mat = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
|
||||
key3.setGenerateMips(true);
|
||||
Texture tex3 = this.assetManager.loadTexture(key3);
|
||||
tex3.setWrap(Texture.WrapMode.Repeat);
|
||||
this.floor_mat.setTexture("ColorMap", tex3);
|
||||
}
|
||||
|
||||
public void initFloor() {
|
||||
Geometry floor_geo = new Geometry("Floor", (Mesh)floor);
|
||||
floor_geo.setMaterial(this.floor_mat);
|
||||
floor_geo.setLocalTranslation(0.0f, -0.1f, 0.0f);
|
||||
this.rootNode.attachChild((Spatial)floor_geo);
|
||||
this.floor_phy = new RigidBodyControl(0.0f);
|
||||
floor_geo.addControl((Control)this.floor_phy);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)this.floor_phy);
|
||||
}
|
||||
|
||||
public void initWall() {
|
||||
float startpt = 0.12f;
|
||||
float height = 0.0f;
|
||||
for (int j = 0; j < 15; ++j) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
Vector3f vt = new Vector3f((float)i * 0.48f * 2.0f + startpt, 0.12f + height, 0.0f);
|
||||
this.makeBrick(vt);
|
||||
}
|
||||
startpt = -startpt;
|
||||
height += 0.24f;
|
||||
}
|
||||
}
|
||||
|
||||
public void makeBrick(Vector3f loc) {
|
||||
Geometry brick_geo = new Geometry("brick", (Mesh)box);
|
||||
brick_geo.setMaterial(this.wall_mat);
|
||||
this.rootNode.attachChild((Spatial)brick_geo);
|
||||
brick_geo.setLocalTranslation(loc);
|
||||
this.brick_phy = new RigidBodyControl(2.0f);
|
||||
brick_geo.addControl((Control)this.brick_phy);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)this.brick_phy);
|
||||
}
|
||||
|
||||
public void makeCannonBall() {
|
||||
Geometry ball_geo = new Geometry("cannon ball", (Mesh)sphere);
|
||||
ball_geo.setMaterial(this.stone_mat);
|
||||
this.rootNode.attachChild((Spatial)ball_geo);
|
||||
ball_geo.setLocalTranslation(this.cam.getLocation());
|
||||
this.ball_phy = new RigidBodyControl(10.0f);
|
||||
ball_geo.addControl((Control)this.ball_phy);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)this.ball_phy);
|
||||
this.ball_phy.setLinearVelocity(this.cam.getDirection().mult(25.0f));
|
||||
}
|
||||
|
||||
protected void initCrossHairs() {
|
||||
this.guiNode.detachAllChildren();
|
||||
this.guiFont = this.assetManager.loadFont("Interface/Fonts/Default.fnt");
|
||||
BitmapText ch = new BitmapText(this.guiFont, false);
|
||||
ch.setSize((float)(this.guiFont.getCharSet().getRenderedSize() * 2));
|
||||
ch.setText("+");
|
||||
ch.setLocalTranslation((float)(this.settings.getWidth() / 2 - this.guiFont.getCharSet().getRenderedSize() / 3 * 2), (float)(this.settings.getHeight() / 2) + ch.getLineHeight() / 2.0f, 0.0f);
|
||||
this.guiNode.attachChild((Spatial)ch);
|
||||
}
|
||||
|
||||
static {
|
||||
sphere = new Sphere(32, 32, 0.4f, true, false);
|
||||
sphere.setTextureMode(Sphere.TextureMode.Projected);
|
||||
box = new Box(Vector3f.ZERO, 0.48f, 0.12f, 0.24f);
|
||||
box.scaleTextureCoordinates(new Vector2f(1.0f, 0.5f));
|
||||
floor = new Box(Vector3f.ZERO, 10.0f, 0.1f, 5.0f);
|
||||
floor.scaleTextureCoordinates(new Vector2f(3.0f, 6.0f));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.collision.Collidable
|
||||
* com.jme3.collision.CollisionResult
|
||||
* com.jme3.collision.CollisionResults
|
||||
* com.jme3.effect.ParticleEmitter
|
||||
* com.jme3.effect.ParticleMesh$Type
|
||||
* com.jme3.font.BitmapText
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.KeyTrigger
|
||||
* com.jme3.input.controls.MouseButtonTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.light.DirectionalLight
|
||||
* com.jme3.light.Light
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Ray
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Node
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.shape.Box
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.collision.Collidable;
|
||||
import com.jme3.collision.CollisionResult;
|
||||
import com.jme3.collision.CollisionResults;
|
||||
import com.jme3.effect.ParticleEmitter;
|
||||
import com.jme3.effect.ParticleMesh;
|
||||
import com.jme3.font.BitmapText;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Ray;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Box;
|
||||
|
||||
public class HelloPicking
|
||||
extends SimpleApplication {
|
||||
Node shootables;
|
||||
Node inventory;
|
||||
boolean pickedUp;
|
||||
Geometry mark;
|
||||
private ActionListener actionListener = new ActionListener(){
|
||||
|
||||
public void onAction(String name, boolean keyPressed, float tpf) {
|
||||
Ray ray;
|
||||
CollisionResults results;
|
||||
if (name.equals("Shoot") && !keyPressed) {
|
||||
results = new CollisionResults();
|
||||
ray = new Ray(HelloPicking.this.cam.getLocation(), HelloPicking.this.cam.getDirection());
|
||||
HelloPicking.this.shootables.collideWith((Collidable)ray, results);
|
||||
System.out.println("----- Collisions?" + results.size() + "-----");
|
||||
for (int i = 0; i < results.size(); ++i) {
|
||||
float dist = results.getCollision(i).getDistance();
|
||||
Vector3f pt = results.getCollision(i).getContactPoint();
|
||||
String hit = results.getCollision(i).getGeometry().getName();
|
||||
System.out.println("* Collision #" + i);
|
||||
System.out.println(" You shot " + hit + "at" + pt + "," + dist + "wu away.");
|
||||
}
|
||||
if (results.size() > 0) {
|
||||
CollisionResult closest = results.getClosestCollision();
|
||||
HelloPicking.this.mark.setLocalTranslation(closest.getContactPoint());
|
||||
Geometry geo = closest.getGeometry();
|
||||
Boolean isModel = (Boolean)geo.getUserData("isModel");
|
||||
if (isModel != null && !isModel.booleanValue()) {
|
||||
Material mat = new Material(HelloPicking.this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setColor("Color", ColorRGBA.randomColor());
|
||||
geo.setMaterial(mat);
|
||||
}
|
||||
HelloPicking.this.rootNode.attachChild((Spatial)HelloPicking.this.mark);
|
||||
} else {
|
||||
HelloPicking.this.rootNode.detachChild((Spatial)HelloPicking.this.mark);
|
||||
}
|
||||
}
|
||||
if (name.equals("Inventar") && !keyPressed) {
|
||||
results = new CollisionResults();
|
||||
ray = new Ray(HelloPicking.this.cam.getLocation(), HelloPicking.this.cam.getDirection());
|
||||
HelloPicking.this.shootables.collideWith((Collidable)ray, results);
|
||||
if (results.size() > 0) {
|
||||
CollisionResult closest = results.getClosestCollision();
|
||||
Geometry inv = closest.getGeometry();
|
||||
if (!HelloPicking.this.pickedUp) {
|
||||
HelloPicking.this.pickedUp = true;
|
||||
HelloPicking.this.shootables.detachChild((Spatial)inv);
|
||||
inv.setLocalScale(100.0f);
|
||||
HelloPicking.this.inventory.attachChild((Spatial)inv);
|
||||
} else {
|
||||
HelloPicking.this.pickedUp = false;
|
||||
Geometry box = (Geometry)HelloPicking.this.inventory.getChild(0);
|
||||
box.setLocalScale(1.0f);
|
||||
box.setLocalTranslation(closest.getContactPoint());
|
||||
HelloPicking.this.inventory.detachChild((Spatial)box);
|
||||
HelloPicking.this.shootables.attachChild((Spatial)box);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
HelloPicking app = new HelloPicking();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
this.initCrossHairs();
|
||||
this.initKeys();
|
||||
this.initMark();
|
||||
Spatial model = this.assetManager.loadModel("Models/Oto/Oto.mesh.xml");
|
||||
model.setLocalTranslation(new Vector3f(1.0f, 2.0f, -3.0f));
|
||||
model.setUserData("isModel", (Object)new Boolean(true));
|
||||
model.setLocalScale(0.5f);
|
||||
DirectionalLight light = new DirectionalLight();
|
||||
light.setDirection(new Vector3f(-0.1f, -1.0f, -1.0f).normalizeLocal());
|
||||
this.rootNode.addLight((Light)light);
|
||||
this.shootables = new Node("Shootables");
|
||||
this.inventory = new Node("Inventar");
|
||||
this.guiNode.attachChild((Spatial)this.inventory);
|
||||
this.rootNode.attachChild((Spatial)this.shootables);
|
||||
this.shootables.attachChild((Spatial)this.makeCube("a Dragon", -2.0f, 0.0f, 1.0f));
|
||||
this.shootables.attachChild((Spatial)this.makeCube("a tin can", 1.0f, -2.0f, 0.0f));
|
||||
this.shootables.attachChild((Spatial)this.makeCube("the Sheriff", 0.0f, 1.0f, -2.0f));
|
||||
this.shootables.attachChild((Spatial)this.makeCube("the Deputy", 1.0f, 0.0f, -4.0f));
|
||||
this.shootables.attachChild((Spatial)this.makeFloor());
|
||||
this.shootables.attachChild(model);
|
||||
}
|
||||
|
||||
private void initKeys() {
|
||||
this.inputManager.addMapping("Shoot", new Trigger[]{new KeyTrigger(57), new MouseButtonTrigger(0)});
|
||||
this.inputManager.addMapping("Inventar", new Trigger[]{new MouseButtonTrigger(1)});
|
||||
this.inputManager.addListener((InputListener)this.actionListener, new String[]{"Shoot", "Inventar"});
|
||||
}
|
||||
|
||||
protected Geometry makeCube(String name, float x, float y, float z) {
|
||||
Box box = new Box(new Vector3f(x, y, z), 1.0f, 1.0f, 1.0f);
|
||||
Geometry cube = new Geometry(name, (Mesh)box);
|
||||
cube.setUserData("isModel", (Object)new Boolean(false));
|
||||
Material mat1 = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat1.setColor("Color", ColorRGBA.randomColor());
|
||||
cube.setMaterial(mat1);
|
||||
return cube;
|
||||
}
|
||||
|
||||
protected Geometry makeFloor() {
|
||||
Box box = new Box(new Vector3f(0.0f, -4.0f, -5.0f), 15.0f, 0.2f, 15.0f);
|
||||
Geometry floor = new Geometry("the Floor", (Mesh)box);
|
||||
Material mat1 = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat1.setColor("Color", ColorRGBA.LightGray);
|
||||
floor.setMaterial(mat1);
|
||||
return floor;
|
||||
}
|
||||
|
||||
protected void initMark() {
|
||||
ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30);
|
||||
Material mat_red = new Material(this.assetManager, "Common/MatDefs/Misc/Particle.j3md");
|
||||
mat_red.setTexture("Texture", this.assetManager.loadTexture("Effects/Explosion/flame.png"));
|
||||
fire.setMaterial(mat_red);
|
||||
fire.setImagesX(2);
|
||||
fire.setImagesY(2);
|
||||
fire.setEndColor(new ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
fire.setStartColor(new ColorRGBA(1.0f, 1.0f, 0.0f, 0.5f));
|
||||
fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 2.0f, 0.0f));
|
||||
fire.setStartSize(1.5f);
|
||||
fire.setEndSize(0.1f);
|
||||
fire.setGravity(0.0f, 0.0f, 0.0f);
|
||||
fire.setLowLife(1.0f);
|
||||
fire.setHighLife(3.0f);
|
||||
fire.getParticleInfluencer().setVelocityVariation(0.3f);
|
||||
this.mark = fire;
|
||||
}
|
||||
|
||||
protected void initCrossHairs() {
|
||||
this.guiNode.detachAllChildren();
|
||||
this.guiFont = this.assetManager.loadFont("Interface/Fonts/Default.fnt");
|
||||
BitmapText ch = new BitmapText(this.guiFont, false);
|
||||
ch.setSize((float)(this.guiFont.getCharSet().getRenderedSize() * 2));
|
||||
ch.setText("+");
|
||||
ch.setLocalTranslation((float)(this.settings.getWidth() / 2 - this.guiFont.getCharSet().getRenderedSize() / 3 * 2), (float)(this.settings.getHeight() / 2) + ch.getLineHeight() / 2.0f, 0.0f);
|
||||
this.guiNode.attachChild((Spatial)ch);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.control.Control
|
||||
* com.jme3.terrain.Terrain
|
||||
* com.jme3.terrain.geomipmap.TerrainLodControl
|
||||
* com.jme3.terrain.geomipmap.TerrainQuad
|
||||
* com.jme3.terrain.heightmap.ImageBasedHeightMap
|
||||
* com.jme3.texture.Texture
|
||||
* com.jme3.texture.Texture$WrapMode
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import com.jme3.terrain.Terrain;
|
||||
import com.jme3.terrain.geomipmap.TerrainLodControl;
|
||||
import com.jme3.terrain.geomipmap.TerrainQuad;
|
||||
import com.jme3.terrain.heightmap.ImageBasedHeightMap;
|
||||
import com.jme3.texture.Texture;
|
||||
|
||||
public class HelloTerrain
|
||||
extends SimpleApplication {
|
||||
private TerrainQuad terrain;
|
||||
Material mat_terrain;
|
||||
|
||||
public static void main(String[] agrs) {
|
||||
HelloTerrain app = new HelloTerrain();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
this.flyCam.setMoveSpeed(50.0f);
|
||||
this.mat_terrain = new Material(this.assetManager, "Common/MatDefs/Terrain/Terrain.j3md");
|
||||
this.mat_terrain.setTexture("Alpha", this.assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
|
||||
Texture grass = this.assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
|
||||
grass.setWrap(Texture.WrapMode.Repeat);
|
||||
this.mat_terrain.setTexture("Tex1", grass);
|
||||
this.mat_terrain.setFloat("Tex1Scale", 64.0f);
|
||||
Texture dirt = this.assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
|
||||
dirt.setWrap(Texture.WrapMode.Repeat);
|
||||
this.mat_terrain.setTexture("Tex2", dirt);
|
||||
this.mat_terrain.setFloat("Tex2Scale", 32.0f);
|
||||
Texture rock = this.assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
|
||||
rock.setWrap(Texture.WrapMode.Repeat);
|
||||
this.mat_terrain.setTexture("Tex3", rock);
|
||||
this.mat_terrain.setFloat("Tex3Scale", 128.0f);
|
||||
ImageBasedHeightMap heightmap = null;
|
||||
Texture heightMapImage = this.assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
|
||||
heightmap = new ImageBasedHeightMap(heightMapImage.getImage());
|
||||
heightmap.load();
|
||||
int patchSize = 65;
|
||||
this.terrain = new TerrainQuad("My terrain", patchSize, 513, heightmap.getHeightMap());
|
||||
this.terrain.setMaterial(this.mat_terrain);
|
||||
this.terrain.setLocalTranslation(0.0f, -100.0f, 0.0f);
|
||||
this.terrain.setLocalScale(2.0f, 1.0f, 2.0f);
|
||||
this.rootNode.attachChild((Spatial)this.terrain);
|
||||
TerrainLodControl control = new TerrainLodControl((Terrain)this.terrain, this.getCamera());
|
||||
this.terrain.addControl((Control)control);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Node
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.shape.Box
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Box;
|
||||
|
||||
public class HelloWorld
|
||||
extends SimpleApplication {
|
||||
public static void main(String[] args) {
|
||||
HelloWorld app = new HelloWorld();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
Box box1 = new Box(Vector3f.ZERO, 1.0f, 1.0f, 1.0f);
|
||||
Geometry blue = new Geometry("Box", (Mesh)box1);
|
||||
Material mat1 = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat1.setColor("Color", ColorRGBA.Blue);
|
||||
blue.setMaterial(mat1);
|
||||
blue.move(1.0f, -1.0f, 1.0f);
|
||||
Box box2 = new Box(Vector3f.ZERO, 1.0f, 1.0f, 1.0f);
|
||||
Geometry red = new Geometry("Box", (Mesh)box2);
|
||||
Material mat2 = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat2.setColor("Color", ColorRGBA.Red);
|
||||
red.setMaterial(mat2);
|
||||
red.move(1.0f, 3.0f, 4.0f);
|
||||
Node pivot = new Node("pivot");
|
||||
this.rootNode.attachChild((Spatial)pivot);
|
||||
pivot.attachChild((Spatial)blue);
|
||||
pivot.attachChild((Spatial)red);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.shape.Box
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Box;
|
||||
|
||||
public class SimpleLoop
|
||||
extends SimpleApplication {
|
||||
protected Geometry player;
|
||||
protected Geometry box2;
|
||||
boolean shrink;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SimpleLoop app = new SimpleLoop();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
Box b = new Box(Vector3f.ZERO, 1.0f, 1.0f, 1.0f);
|
||||
this.player = new Geometry("blue cube", (Mesh)b);
|
||||
Material mat = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setColor("Color", ColorRGBA.Yellow);
|
||||
this.player.setMaterial(mat);
|
||||
this.rootNode.attachChild((Spatial)this.player);
|
||||
}
|
||||
|
||||
public void simpleUpdate(float tpf) {
|
||||
this.player.rotate(-2.0f * tpf, 0.0f, -2.0f * tpf);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,522 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.animation.AnimChannel
|
||||
* com.jme3.animation.AnimControl
|
||||
* com.jme3.animation.AnimEventListener
|
||||
* com.jme3.animation.LoopMode
|
||||
* com.jme3.app.Application
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.app.state.AppState
|
||||
* com.jme3.audio.AudioNode
|
||||
* com.jme3.bullet.BulletAppState
|
||||
* com.jme3.bullet.collision.PhysicsCollisionEvent
|
||||
* com.jme3.bullet.collision.PhysicsCollisionListener
|
||||
* com.jme3.bullet.control.RigidBodyControl
|
||||
* com.jme3.collision.Collidable
|
||||
* com.jme3.collision.CollisionResults
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.AnalogListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.KeyTrigger
|
||||
* com.jme3.input.controls.MouseButtonTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.light.AmbientLight
|
||||
* com.jme3.light.Light
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Ray
|
||||
* com.jme3.math.Vector2f
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.post.Filter
|
||||
* com.jme3.post.FilterPostProcessor
|
||||
* com.jme3.post.SceneProcessor
|
||||
* com.jme3.post.filters.CartoonEdgeFilter
|
||||
* com.jme3.renderer.Caps
|
||||
* com.jme3.renderer.queue.RenderQueue$ShadowMode
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.control.Control
|
||||
* com.jme3.shadow.DirectionalLightShadowFilter
|
||||
* com.jme3.shadow.DirectionalLightShadowRenderer
|
||||
* tonegod.gui.controls.extras.Indicator
|
||||
* tonegod.gui.controls.extras.Indicator$Orientation
|
||||
* tonegod.gui.controls.text.Label
|
||||
* tonegod.gui.core.Element
|
||||
* tonegod.gui.core.Screen
|
||||
* tonegod.gui.effects.Effect
|
||||
* tonegod.gui.effects.Effect$EffectEvent
|
||||
* tonegod.gui.effects.Effect$EffectType
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.animation.AnimChannel;
|
||||
import com.jme3.animation.AnimControl;
|
||||
import com.jme3.animation.AnimEventListener;
|
||||
import com.jme3.animation.LoopMode;
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.state.AppState;
|
||||
import com.jme3.audio.AudioNode;
|
||||
import com.jme3.bullet.BulletAppState;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionEvent;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionListener;
|
||||
import com.jme3.bullet.control.RigidBodyControl;
|
||||
import com.jme3.collision.Collidable;
|
||||
import com.jme3.collision.CollisionResults;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.AnalogListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.light.AmbientLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Ray;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.post.Filter;
|
||||
import com.jme3.post.FilterPostProcessor;
|
||||
import com.jme3.post.SceneProcessor;
|
||||
import com.jme3.post.filters.CartoonEdgeFilter;
|
||||
import com.jme3.renderer.Caps;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import com.jme3.shadow.DirectionalLightShadowFilter;
|
||||
import com.jme3.shadow.DirectionalLightShadowRenderer;
|
||||
import java.util.Random;
|
||||
import mygame.Exchange;
|
||||
import mygame.Player;
|
||||
import mygame.Staff;
|
||||
import mygame.Sword;
|
||||
import mygame.WalkingEnemy;
|
||||
import tonegod.gui.controls.extras.Indicator;
|
||||
import tonegod.gui.controls.text.Label;
|
||||
import tonegod.gui.core.Element;
|
||||
import tonegod.gui.core.Screen;
|
||||
import tonegod.gui.effects.Effect;
|
||||
import wpq.tests.PlayerCam;
|
||||
|
||||
public class TestCameraNode
|
||||
extends SimpleApplication
|
||||
implements AnalogListener,
|
||||
ActionListener,
|
||||
AnimEventListener,
|
||||
PhysicsCollisionListener {
|
||||
private Player player;
|
||||
Vector3f direction = new Vector3f();
|
||||
private FilterPostProcessor fpp;
|
||||
private BulletAppState bulletAppState;
|
||||
Screen screen;
|
||||
Indicator ind1;
|
||||
Label spiderCounter;
|
||||
Label label;
|
||||
Indicator waveCounter;
|
||||
Indicator cooldownLeft;
|
||||
Indicator cooldownRight;
|
||||
Indicator skill2;
|
||||
Label gameover;
|
||||
int change = 0;
|
||||
private int winCount = 0;
|
||||
PlayerCam playerCam;
|
||||
private float spawnTimer;
|
||||
private float timer;
|
||||
boolean left = false;
|
||||
boolean right = false;
|
||||
boolean down = false;
|
||||
boolean up = false;
|
||||
Vector3f walkDirection = new Vector3f(Vector3f.ZERO);
|
||||
private DirectionalLightShadowRenderer dlsr;
|
||||
private DirectionalLightShadowFilter dlsf;
|
||||
private static int SPAWN_TIME = 10;
|
||||
private int spawns = 1;
|
||||
private boolean gameover_flag = false;
|
||||
public Exchange exchange;
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestCameraNode app = new TestCameraNode();
|
||||
app.setDisplayFps(false);
|
||||
app.setDisplayStatView(false);
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
this.bulletAppState = new BulletAppState();
|
||||
this.stateManager.attach((AppState)this.bulletAppState);
|
||||
this.exchange = new Exchange();
|
||||
Exchange.setRootNode(this.rootNode);
|
||||
Exchange.setBulletAppState(this.bulletAppState);
|
||||
Exchange.setAssetManager(this.assetManager);
|
||||
Exchange.setViewPort(this.viewPort);
|
||||
Exchange.setApp(this);
|
||||
this.spawnTimer = 0.0f;
|
||||
this.timer = 0.0f;
|
||||
this.setupPlayer();
|
||||
this.setupGround();
|
||||
this.setupWalls();
|
||||
this.setupCam();
|
||||
this.setupLight();
|
||||
this.registerInput();
|
||||
this.setupFilters();
|
||||
this.setupGUI();
|
||||
}
|
||||
|
||||
private void setupPlayer() {
|
||||
this.player = new Player("Player");
|
||||
this.player.setHat(this.assetManager.loadModel("Models/helmet/helmet.j3o"));
|
||||
Staff staff = new Staff("Staff", this.assetManager, this.exchange);
|
||||
staff.setModel(this.assetManager.loadModel("Models/staff/staff.mesh.j3o"));
|
||||
this.player.setLeftHand(staff);
|
||||
Sword sword = new Sword("Sword", this.assetManager, this.exchange);
|
||||
sword.setModel(this.assetManager.loadModel("Models/sword/sword.mesh.j3o"));
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)sword);
|
||||
this.player.setRightHand(sword);
|
||||
this.player.setModel(this.assetManager.loadModel("Models/blob/Blob.mesh.j3o"));
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)this.player.playerControl);
|
||||
this.rootNode.attachChild((Spatial)this.player);
|
||||
this.bulletAppState.getPhysicsSpace().addCollisionListener((PhysicsCollisionListener)this);
|
||||
}
|
||||
|
||||
private void setupSpider(Vector3f spawn) {
|
||||
WalkingEnemy walkingSpider = new WalkingEnemy("Spider", this.assetManager);
|
||||
walkingSpider.setLocalTranslation(spawn);
|
||||
walkingSpider.setModel(this.assetManager.loadModel("Models/spider/spider.mesh.j3o"));
|
||||
walkingSpider.modelAnimChannel.setAnim("walk");
|
||||
walkingSpider.setHealth(100.0f);
|
||||
walkingSpider.modelAnimChannel.setLoopMode(LoopMode.Loop);
|
||||
Exchange.enemies.add(walkingSpider);
|
||||
AudioNode walksound = new AudioNode(this.assetManager, "Sounds/Effects/spiderwalking.ogg", false);
|
||||
walksound.setName("walkingSound");
|
||||
walksound.setLooping(true);
|
||||
walksound.setVolume(2.0f);
|
||||
walkingSpider.attachChild((Spatial)walksound);
|
||||
walksound.play();
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)walkingSpider.ghost);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)walkingSpider.walkingEnemyControl);
|
||||
this.rootNode.attachChild((Spatial)walkingSpider);
|
||||
}
|
||||
|
||||
private void spawnSpider() {
|
||||
Random r = new Random();
|
||||
int spawnx = r.nextInt(81) - 40;
|
||||
int spawnz = r.nextInt(81) - 40;
|
||||
Vector3f spawnpoint = new Vector3f((float)spawnx, 0.0f, (float)spawnz);
|
||||
AudioNode spawnsound = new AudioNode(this.assetManager, "Sounds/Effects/spawn.ogg", false);
|
||||
spawnsound.setLooping(false);
|
||||
spawnsound.setPositional(true);
|
||||
spawnsound.setLocalTranslation(spawnpoint);
|
||||
spawnsound.setVolume(5.0f);
|
||||
this.rootNode.attachChild((Spatial)spawnsound);
|
||||
spawnsound.play();
|
||||
this.setupSpider(spawnpoint);
|
||||
}
|
||||
|
||||
private void setupGround() {
|
||||
int rotation_flag = 0;
|
||||
for (int x = -50; x < 50; x += 10) {
|
||||
for (int z = -50; z < 50; z += 10) {
|
||||
Spatial ground;
|
||||
if (rotation_flag == 5) {
|
||||
rotation_flag = 0;
|
||||
ground = this.assetManager.loadModel("Models/tile2/tile.mesh.j3o");
|
||||
} else {
|
||||
ground = this.assetManager.loadModel("Models/tile1/tile.mesh.j3o");
|
||||
++rotation_flag;
|
||||
}
|
||||
ground.scale(5.0f);
|
||||
ground.setLocalTranslation((float)x, -1.0f, (float)z);
|
||||
RigidBodyControl ground_solid = new RigidBodyControl(0.0f);
|
||||
ground.addControl((Control)ground_solid);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)ground_solid);
|
||||
ground.setShadowMode(RenderQueue.ShadowMode.Receive);
|
||||
this.rootNode.attachChild(ground);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupWalls() {
|
||||
float x;
|
||||
for (x = -60.0f; x < 60.0f; x += 10.0f) {
|
||||
this.createWall(x, 50.0f);
|
||||
this.createWall(x, -50.0f);
|
||||
}
|
||||
for (x = -60.0f; x < 60.0f; x += 10.0f) {
|
||||
this.createWall(50.0f, x);
|
||||
this.createWall(-50.0f, x);
|
||||
}
|
||||
}
|
||||
|
||||
private void createWall(float x, float z) {
|
||||
Spatial wall = this.assetManager.loadModel("Models/wall1/wall1.mesh.j3o");
|
||||
wall.scale(5.0f);
|
||||
wall.setLocalTranslation(x, 0.0f, z);
|
||||
RigidBodyControl wall_solid = new RigidBodyControl(0.0f);
|
||||
wall.addControl((Control)wall_solid);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)wall);
|
||||
wall.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||
this.rootNode.attachChild(wall);
|
||||
}
|
||||
|
||||
private void setupCam() {
|
||||
this.playerCam = new PlayerCam(this.player, "CamNode", this.cam);
|
||||
this.playerCam.setupCamera();
|
||||
this.flyCam.setEnabled(false);
|
||||
}
|
||||
|
||||
private void setupLight() {
|
||||
AmbientLight al = new AmbientLight();
|
||||
al.setColor(new ColorRGBA(0.6f, 0.6f, 0.9f, 1.0f));
|
||||
this.rootNode.addLight((Light)al);
|
||||
}
|
||||
|
||||
public void registerInput() {
|
||||
Trigger[] triggerArray = new Trigger[2];
|
||||
triggerArray[0] = new KeyTrigger(200);
|
||||
triggerArray[1] = new KeyTrigger(17);
|
||||
this.inputManager.addMapping("moveForward", triggerArray);
|
||||
Trigger[] triggerArray2 = new Trigger[2];
|
||||
triggerArray2[0] = new KeyTrigger(208);
|
||||
triggerArray2[1] = new KeyTrigger(31);
|
||||
this.inputManager.addMapping("moveBackward", triggerArray2);
|
||||
Trigger[] triggerArray3 = new Trigger[2];
|
||||
triggerArray3[0] = new KeyTrigger(205);
|
||||
triggerArray3[1] = new KeyTrigger(32);
|
||||
this.inputManager.addMapping("moveRight", triggerArray3);
|
||||
Trigger[] triggerArray4 = new Trigger[2];
|
||||
triggerArray4[0] = new KeyTrigger(203);
|
||||
triggerArray4[1] = new KeyTrigger(30);
|
||||
this.inputManager.addMapping("moveLeft", triggerArray4);
|
||||
this.inputManager.addMapping("rightHand", new Trigger[]{new MouseButtonTrigger(1)});
|
||||
Trigger[] triggerArray5 = new Trigger[1];
|
||||
triggerArray5[0] = new KeyTrigger(18);
|
||||
this.inputManager.addMapping("skill2", triggerArray5);
|
||||
this.inputManager.addMapping("leftHand", new Trigger[]{new MouseButtonTrigger(0)});
|
||||
this.inputManager.addMapping("die", new Trigger[]{new MouseButtonTrigger(2)});
|
||||
this.inputManager.addMapping("jump", new Trigger[]{new KeyTrigger(57)});
|
||||
this.inputManager.addListener((InputListener)this, new String[]{"moveForward", "moveBackward", "moveRight", "moveLeft", "rightHand", "leftHand", "die", "jump", "skill2"});
|
||||
}
|
||||
|
||||
public void setupFilters() {
|
||||
if (this.renderer.getCaps().contains(Caps.GLSL100)) {
|
||||
this.fpp = new FilterPostProcessor(this.assetManager);
|
||||
CartoonEdgeFilter toon = new CartoonEdgeFilter();
|
||||
toon.setEdgeColor(ColorRGBA.Black);
|
||||
this.fpp.addFilter((Filter)toon);
|
||||
this.viewPort.addProcessor((SceneProcessor)this.fpp);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnalog(String name, float value, float tpf) {
|
||||
}
|
||||
|
||||
public void onAction(String name, boolean keyPressed, float tpf) {
|
||||
try {
|
||||
if (name.equals("rightHand") && !keyPressed) {
|
||||
this.player.rightHand.skill1();
|
||||
}
|
||||
if (name.equals("leftHand") && !keyPressed) {
|
||||
this.player.leftHand.skill1();
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
// empty catch block
|
||||
}
|
||||
if (name.equals("skill2") && !keyPressed) {
|
||||
this.player.leftHand.skill2();
|
||||
}
|
||||
if (name.equals("die") && !keyPressed) {
|
||||
this.player.switchHands();
|
||||
}
|
||||
if (name.equals("jump")) {
|
||||
this.player.playerControl.jump();
|
||||
}
|
||||
if (name.equals("moveLeft")) {
|
||||
this.left = keyPressed;
|
||||
} else if (name.equals("moveRight")) {
|
||||
this.right = keyPressed;
|
||||
} else if (name.equals("moveForward")) {
|
||||
this.up = keyPressed;
|
||||
} else if (name.equals("moveBackward")) {
|
||||
this.down = keyPressed;
|
||||
}
|
||||
}
|
||||
|
||||
public void setupGUI() {
|
||||
this.screen = new Screen((Application)this, "tonegod/gui/style/def/style_map.xml");
|
||||
this.screen.initialize();
|
||||
this.guiNode.addControl((Control)this.screen);
|
||||
this.ind1 = new Indicator(this.screen, "Healthbar", new Vector2f(10.0f, 10.0f), Indicator.Orientation.HORIZONTAL){
|
||||
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
};
|
||||
this.ind1.setMaxValue(100.0f);
|
||||
this.ind1.setCurrentValue(this.player.health);
|
||||
this.ind1.setIndicatorColor(ColorRGBA.Red);
|
||||
this.ind1.setDisplayPercentage();
|
||||
this.screen.addElement((Element)this.ind1);
|
||||
this.cooldownLeft = new Indicator(this.screen, "cooldownLeft", new Vector2f(10.0f, (float)(this.settings.getHeight() - 30)), Indicator.Orientation.HORIZONTAL){
|
||||
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
};
|
||||
this.cooldownLeft.setMaxValue(100.0f);
|
||||
this.cooldownLeft.setCurrentValue(100.0f);
|
||||
this.cooldownLeft.setIndicatorColor(ColorRGBA.Blue);
|
||||
this.cooldownLeft.setText("Fireball");
|
||||
this.screen.addElement((Element)this.cooldownLeft);
|
||||
this.cooldownRight = new Indicator(this.screen, "cooldownRight", new Vector2f(10.0f, (float)(this.settings.getHeight() - 70)), Indicator.Orientation.HORIZONTAL){
|
||||
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
};
|
||||
this.cooldownRight.setMaxValue(100.0f);
|
||||
this.cooldownRight.setCurrentValue(100.0f);
|
||||
this.cooldownRight.setIndicatorColor(ColorRGBA.Blue);
|
||||
this.cooldownRight.setText("Sword");
|
||||
this.screen.addElement((Element)this.cooldownRight);
|
||||
this.skill2 = new Indicator(this.screen, "skill2", new Vector2f(10.0f, (float)(this.settings.getHeight() - 50)), Indicator.Orientation.HORIZONTAL){
|
||||
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
};
|
||||
this.skill2.setMaxValue(100.0f);
|
||||
this.skill2.setCurrentValue(100.0f);
|
||||
this.skill2.setIndicatorColor(ColorRGBA.Blue);
|
||||
this.skill2.setText("Teleport");
|
||||
this.screen.addElement((Element)this.skill2);
|
||||
this.label = new Label(this.screen, "Timer", new Vector2f(10.0f, 50.0f), new Vector2f(200.0f, 100.0f));
|
||||
this.label.setFontColor(ColorRGBA.Yellow);
|
||||
this.label.setFontSize(30.0f);
|
||||
this.screen.addElement((Element)this.label);
|
||||
this.waveCounter = new Indicator(this.screen, "waveCounter", new Vector2f(10.0f, 30.0f), Indicator.Orientation.HORIZONTAL){
|
||||
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
};
|
||||
this.waveCounter.setMaxValue((float)SPAWN_TIME);
|
||||
this.waveCounter.setCurrentValue((float)SPAWN_TIME - this.spawnTimer);
|
||||
this.waveCounter.setIndicatorColor(ColorRGBA.Yellow);
|
||||
this.waveCounter.setFontColor(ColorRGBA.Black);
|
||||
this.waveCounter.setText("next Wave in...");
|
||||
this.screen.addElement((Element)this.waveCounter);
|
||||
this.spiderCounter = new Label(this.screen, "SpiderCounter", new Vector2f(10.0f, 30.0f), new Vector2f(200.0f, 100.0f));
|
||||
this.spiderCounter.setFontColor(ColorRGBA.Yellow);
|
||||
this.spiderCounter.setFontSize(30.0f);
|
||||
this.screen.addElement((Element)this.spiderCounter);
|
||||
this.gameover = new Label(this.screen, "GameOver", new Vector2f(0.0f, 0.0f), new Vector2f((float)this.settings.getWidth(), 400.0f));
|
||||
this.gameover.setFont("/Interface/Fonts/FleshWound.fnt");
|
||||
this.gameover.setFontSize(100.0f);
|
||||
this.gameover.setFontColor(ColorRGBA.White);
|
||||
this.gameover.setText("Verloren!");
|
||||
Effect ef = new Effect(Effect.EffectType.FadeIn, Effect.EffectEvent.Show, 2.0f);
|
||||
this.gameover.hide();
|
||||
this.gameover.addEffect(Effect.EffectEvent.Show, ef);
|
||||
this.screen.addElement((Element)this.gameover);
|
||||
}
|
||||
|
||||
public void reduceCooldowns(float tpf) {
|
||||
this.player.leftHand.reduceCooldowns(tpf);
|
||||
this.player.rightHand.reduceCooldowns(tpf);
|
||||
}
|
||||
|
||||
public void simpleUpdate(float tpf) {
|
||||
this.reduceCooldowns(tpf);
|
||||
this.cooldownLeft.setCurrentValue(this.player.leftHand.cooldown1 * (this.cooldownLeft.getMaxValue() / this.player.leftHand.COOLDOWN1_TIME));
|
||||
this.skill2.setCurrentValue(this.player.leftHand.cooldown2 * (this.skill2.getMaxValue() / this.player.leftHand.COOLDOWN2_TIME));
|
||||
this.cooldownRight.setCurrentValue(this.player.rightHand.cooldown1 * (this.cooldownRight.getMaxValue() / this.player.rightHand.COOLDOWN1_TIME));
|
||||
this.spiderCounter.setText("Kills: " + Exchange.killed);
|
||||
if (!this.gameover_flag) {
|
||||
CollisionResults results = new CollisionResults();
|
||||
Vector2f click2d = this.inputManager.getCursorPosition();
|
||||
Vector3f click3d = this.cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0.0f).clone();
|
||||
Vector3f dir = this.cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1.0f).subtractLocal(click3d).normalizeLocal();
|
||||
Ray ray = new Ray(click3d, dir);
|
||||
this.rootNode.collideWith((Collidable)ray, results);
|
||||
for (int i = 0; i < results.size(); ++i) {
|
||||
float dist = results.getCollision(i).getDistance();
|
||||
Vector3f pt = results.getCollision(i).getContactPoint();
|
||||
this.player.wholeBody.lookAt(pt, Vector3f.UNIT_Y);
|
||||
this.player.pt = pt;
|
||||
}
|
||||
Vector3f camDir = this.cam.getDirection().clone().multLocal(8.0f);
|
||||
Vector3f camLeft = this.cam.getLeft().clone().multLocal(8.0f);
|
||||
camDir.y = 0.0f;
|
||||
camLeft.y = 0.0f;
|
||||
this.walkDirection.set(0.0f, 0.0f, 0.0f);
|
||||
if (this.left) {
|
||||
this.walkDirection.addLocal(camLeft);
|
||||
}
|
||||
if (this.right) {
|
||||
this.walkDirection.addLocal(camLeft.negate());
|
||||
}
|
||||
if (this.up) {
|
||||
this.walkDirection.addLocal(camDir);
|
||||
}
|
||||
if (this.down) {
|
||||
this.walkDirection.addLocal(camDir.negate());
|
||||
}
|
||||
if (this.walkDirection.length() == 0.0f) {
|
||||
if ("walk".equals(this.player.modelAnimChannel.getAnimationName())) {
|
||||
this.player.modelAnimChannel.setAnim("stand", 1.0f);
|
||||
}
|
||||
} else if ("stand".equals(this.player.modelAnimChannel.getAnimationName())) {
|
||||
this.player.modelAnimChannel.setAnim("walk", 0.7f);
|
||||
}
|
||||
this.walkDirection.normalizeLocal().multLocal(7.5f);
|
||||
this.player.playerControl.setWalkDirection(this.walkDirection);
|
||||
this.ind1.setCurrentValue(this.player.health);
|
||||
if (this.player.health <= 0.0f) {
|
||||
this.player.die();
|
||||
this.gameover.showWithEffect();
|
||||
AudioNode gameover = new AudioNode(this.assetManager, "Sounds/Effects/gameover.ogg", false);
|
||||
gameover.setLooping(false);
|
||||
gameover.setVolume(5.0f);
|
||||
this.rootNode.attachChild((Spatial)gameover);
|
||||
gameover.play();
|
||||
this.gameover_flag = true;
|
||||
}
|
||||
this.waveCounter.setCurrentValue((float)SPAWN_TIME - this.spawnTimer);
|
||||
this.spawnTimer += tpf;
|
||||
if (this.spawnTimer >= (float)SPAWN_TIME) {
|
||||
for (int spawn_counts = 0; spawn_counts < this.spawns; ++spawn_counts) {
|
||||
this.spawnSpider();
|
||||
}
|
||||
++this.spawns;
|
||||
this.spawnTimer = 0.0f;
|
||||
}
|
||||
this.label.setText("Wave No.:" + (this.spawns - 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
|
||||
if (animName.equals("walk")) {
|
||||
channel.setAnim("stand", 0.1f);
|
||||
channel.setLoopMode(LoopMode.DontLoop);
|
||||
channel.setSpeed(1.0f);
|
||||
}
|
||||
if (animName.equals("skill1")) {
|
||||
channel.setAnim("normal", 0.1f);
|
||||
channel.setLoopMode(LoopMode.DontLoop);
|
||||
channel.setSpeed(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
|
||||
if (animName.equals("skill1")) {
|
||||
// empty if block
|
||||
}
|
||||
}
|
||||
|
||||
public void collision(PhysicsCollisionEvent event) {
|
||||
try {
|
||||
if (event.getNodeA().getName().equals("Spider") && event.getNodeB().getName().equals("Player") || event.getNodeB().getName().equals("Spider") && event.getNodeA().getName().equals("Player")) {
|
||||
this.player.health -= 0.25f;
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.input.ChaseCamera
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.AnalogListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.KeyTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.Quaternion
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.shape.Quad
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.input.ChaseCamera;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.AnalogListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
|
||||
public class TestChaseCamera
|
||||
extends SimpleApplication
|
||||
implements AnalogListener,
|
||||
ActionListener {
|
||||
private Spatial teaGeom;
|
||||
private ChaseCamera chaseCam;
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestChaseCamera app = new TestChaseCamera();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
this.teaGeom = this.assetManager.loadModel("Models/blob/Blob.mesh.xml");
|
||||
Material mat_tea = new Material(this.assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
|
||||
this.teaGeom.setMaterial(mat_tea);
|
||||
this.rootNode.attachChild(this.teaGeom);
|
||||
Material mat_ground = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
Geometry ground = new Geometry("ground", (Mesh)new Quad(50.0f, 50.0f));
|
||||
ground.setLocalRotation(new Quaternion().fromAngleAxis(-1.5707964f, Vector3f.UNIT_X));
|
||||
ground.setLocalTranslation(-25.0f, -1.0f, 25.0f);
|
||||
ground.setMaterial(mat_ground);
|
||||
this.rootNode.attachChild((Spatial)ground);
|
||||
this.flyCam.setEnabled(false);
|
||||
this.chaseCam = new ChaseCamera(this.cam, this.teaGeom, this.inputManager);
|
||||
this.chaseCam.setRotationSpeed(0.0f);
|
||||
this.chaseCam.setSmoothMotion(true);
|
||||
this.chaseCam.setTrailingEnabled(true);
|
||||
this.chaseCam.setLookAtOffset(Vector3f.UNIT_Y.mult(3.0f));
|
||||
this.registerInput();
|
||||
}
|
||||
|
||||
public void registerInput() {
|
||||
Trigger[] triggerArray = new Trigger[2];
|
||||
triggerArray[0] = new KeyTrigger(200);
|
||||
triggerArray[1] = new KeyTrigger(17);
|
||||
this.inputManager.addMapping("moveForward", triggerArray);
|
||||
Trigger[] triggerArray2 = new Trigger[2];
|
||||
triggerArray2[0] = new KeyTrigger(208);
|
||||
triggerArray2[1] = new KeyTrigger(31);
|
||||
this.inputManager.addMapping("moveBackward", triggerArray2);
|
||||
Trigger[] triggerArray3 = new Trigger[2];
|
||||
triggerArray3[0] = new KeyTrigger(205);
|
||||
triggerArray3[1] = new KeyTrigger(32);
|
||||
this.inputManager.addMapping("moveRight", triggerArray3);
|
||||
Trigger[] triggerArray4 = new Trigger[2];
|
||||
triggerArray4[0] = new KeyTrigger(203);
|
||||
triggerArray4[1] = new KeyTrigger(30);
|
||||
this.inputManager.addMapping("moveLeft", triggerArray4);
|
||||
Trigger[] triggerArray5 = new Trigger[1];
|
||||
triggerArray5[0] = new KeyTrigger(25);
|
||||
this.inputManager.addMapping("displayPosition", triggerArray5);
|
||||
this.inputManager.addListener((InputListener)this, new String[]{"moveForward", "moveBackward", "moveRight", "moveLeft"});
|
||||
this.inputManager.addListener((InputListener)this, new String[]{"displayPosition"});
|
||||
}
|
||||
|
||||
public void onAnalog(String name, float value, float tpf) {
|
||||
if (name.equals("moveForward")) {
|
||||
this.teaGeom.move(0.0f, 0.0f, -5.0f * tpf);
|
||||
}
|
||||
if (name.equals("moveBackward")) {
|
||||
this.teaGeom.move(0.0f, 0.0f, 5.0f * tpf);
|
||||
}
|
||||
if (name.equals("moveRight")) {
|
||||
this.teaGeom.move(5.0f * tpf, 0.0f, 0.0f);
|
||||
}
|
||||
if (name.equals("moveLeft")) {
|
||||
this.teaGeom.move(-5.0f * tpf, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAction(String name, boolean keyPressed, float tpf) {
|
||||
if (name.equals("displayPosition") && keyPressed) {
|
||||
this.teaGeom.move(10.0f, 10.0f, 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void simpleUpdate(float tpf) {
|
||||
super.simpleUpdate(tpf);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.jme3.animation.AnimChannel
|
||||
* com.jme3.animation.AnimControl
|
||||
* com.jme3.animation.AnimEventListener
|
||||
* com.jme3.app.SimpleApplication
|
||||
* com.jme3.app.state.AppState
|
||||
* com.jme3.bullet.BulletAppState
|
||||
* com.jme3.bullet.BulletAppState$ThreadingType
|
||||
* com.jme3.bullet.collision.PhysicsCollisionEvent
|
||||
* com.jme3.bullet.collision.PhysicsCollisionListener
|
||||
* com.jme3.bullet.collision.shapes.CapsuleCollisionShape
|
||||
* com.jme3.bullet.collision.shapes.CollisionShape
|
||||
* com.jme3.bullet.control.CharacterControl
|
||||
* com.jme3.bullet.control.RigidBodyControl
|
||||
* com.jme3.input.ChaseCamera
|
||||
* com.jme3.input.controls.ActionListener
|
||||
* com.jme3.input.controls.InputListener
|
||||
* com.jme3.input.controls.KeyTrigger
|
||||
* com.jme3.input.controls.Trigger
|
||||
* com.jme3.light.AmbientLight
|
||||
* com.jme3.light.DirectionalLight
|
||||
* com.jme3.light.Light
|
||||
* com.jme3.material.Material
|
||||
* com.jme3.math.ColorRGBA
|
||||
* com.jme3.math.Quaternion
|
||||
* com.jme3.math.Vector3f
|
||||
* com.jme3.scene.Geometry
|
||||
* com.jme3.scene.Mesh
|
||||
* com.jme3.scene.Node
|
||||
* com.jme3.scene.Spatial
|
||||
* com.jme3.scene.control.Control
|
||||
* com.jme3.scene.shape.Quad
|
||||
*/
|
||||
package jme3.hello;
|
||||
|
||||
import com.jme3.animation.AnimChannel;
|
||||
import com.jme3.animation.AnimControl;
|
||||
import com.jme3.animation.AnimEventListener;
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.state.AppState;
|
||||
import com.jme3.bullet.BulletAppState;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionEvent;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionListener;
|
||||
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
|
||||
import com.jme3.bullet.collision.shapes.CollisionShape;
|
||||
import com.jme3.bullet.control.CharacterControl;
|
||||
import com.jme3.bullet.control.RigidBodyControl;
|
||||
import com.jme3.input.ChaseCamera;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.InputListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.Trigger;
|
||||
import com.jme3.light.AmbientLight;
|
||||
import com.jme3.light.DirectionalLight;
|
||||
import com.jme3.light.Light;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Mesh;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
|
||||
public class test
|
||||
extends SimpleApplication
|
||||
implements ActionListener,
|
||||
PhysicsCollisionListener,
|
||||
AnimEventListener {
|
||||
private BulletAppState bulletAppState;
|
||||
CharacterControl character;
|
||||
Node model;
|
||||
Vector3f walkDirection = new Vector3f();
|
||||
Geometry ground;
|
||||
ChaseCamera chaseCam;
|
||||
boolean left = false;
|
||||
boolean right = false;
|
||||
boolean up = false;
|
||||
boolean down = false;
|
||||
|
||||
public static void main(String[] args) {
|
||||
test app = new test();
|
||||
app.start();
|
||||
}
|
||||
|
||||
public void simpleInitApp() {
|
||||
this.bulletAppState = new BulletAppState();
|
||||
this.bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
|
||||
this.stateManager.attach((AppState)this.bulletAppState);
|
||||
this.setupKeys();
|
||||
this.createLight();
|
||||
this.createCharacter();
|
||||
Material mat = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setTexture("ColorMap", this.assetManager.loadTexture("Textures/Rock.PNG"));
|
||||
this.ground = new Geometry("ground", (Mesh)new Quad(50.0f, 50.0f));
|
||||
this.ground.setLocalRotation(new Quaternion().fromAngleAxis(-1.5707964f, Vector3f.UNIT_X));
|
||||
this.ground.setLocalTranslation(0.0f, 0.0f, 0.0f);
|
||||
this.ground.setMaterial(mat);
|
||||
RigidBodyControl ground_solid = new RigidBodyControl(0.0f);
|
||||
this.ground.addControl((Control)ground_solid);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)ground_solid);
|
||||
this.rootNode.attachChild((Spatial)this.ground);
|
||||
this.setupChaseCamera();
|
||||
}
|
||||
|
||||
private void setupKeys() {
|
||||
this.inputManager.addMapping("CharLeft", new Trigger[]{new KeyTrigger(30)});
|
||||
this.inputManager.addMapping("CharRight", new Trigger[]{new KeyTrigger(32)});
|
||||
this.inputManager.addMapping("CharUp", new Trigger[]{new KeyTrigger(17)});
|
||||
this.inputManager.addMapping("CharDown", new Trigger[]{new KeyTrigger(31)});
|
||||
this.inputManager.addListener((InputListener)this, new String[]{"CharLeft", "CharRight", "CharUp", "CharDown"});
|
||||
}
|
||||
|
||||
private void createLight() {
|
||||
AmbientLight al = new AmbientLight();
|
||||
al.setColor(ColorRGBA.White.mult(1.3f));
|
||||
this.rootNode.addLight((Light)al);
|
||||
DirectionalLight dl = new DirectionalLight();
|
||||
dl.setColor(ColorRGBA.White);
|
||||
dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());
|
||||
this.rootNode.addLight((Light)dl);
|
||||
}
|
||||
|
||||
private void createGround() {
|
||||
Material mat = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setTexture("ColorMap", this.assetManager.loadTexture("Textures/Rock.PNG"));
|
||||
this.ground = new Geometry("ground", (Mesh)new Quad(50.0f, 50.0f));
|
||||
this.ground.setLocalRotation(new Quaternion().fromAngleAxis(-1.5707964f, Vector3f.UNIT_X));
|
||||
this.ground.setLocalTranslation(0.0f, 0.0f, 0.0f);
|
||||
this.ground.setMaterial(mat);
|
||||
RigidBodyControl ground_solid = new RigidBodyControl(0.0f);
|
||||
this.ground.addControl((Control)ground_solid);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)ground_solid);
|
||||
this.rootNode.attachChild((Spatial)this.ground);
|
||||
}
|
||||
|
||||
private void createCharacter() {
|
||||
CapsuleCollisionShape capsule = new CapsuleCollisionShape(1.0f, 1.0f);
|
||||
this.character = new CharacterControl((CollisionShape)capsule, 1.0f);
|
||||
this.model = (Node)this.assetManager.loadModel("Models/spider/Spider.mesh.j3o");
|
||||
this.model.addControl((Control)this.character);
|
||||
this.model.setLocalTranslation(0.0f, 10.0f, 0.0f);
|
||||
this.character.setPhysicsLocation(new Vector3f(-140.0f, 15.0f, -10.0f));
|
||||
this.rootNode.attachChild((Spatial)this.model);
|
||||
this.bulletAppState.getPhysicsSpace().add((Object)this.character);
|
||||
}
|
||||
|
||||
private void setupChaseCamera() {
|
||||
this.flyCam.setEnabled(false);
|
||||
this.chaseCam = new ChaseCamera(this.cam, (Spatial)this.model, this.inputManager);
|
||||
}
|
||||
|
||||
public void simpleUpdate(float tpf) {
|
||||
this.walkDirection.set(0.0f, 0.0f, 0.0f);
|
||||
Vector3f camDir = this.cam.getDirection().clone().multLocal(0.1f);
|
||||
Vector3f camLeft = this.cam.getLeft().clone().multLocal(0.1f);
|
||||
camDir.y = 0.0f;
|
||||
camLeft.y = 0.0f;
|
||||
this.walkDirection.set(0.0f, 0.0f, 0.0f);
|
||||
if (this.left) {
|
||||
this.walkDirection.addLocal(camLeft);
|
||||
}
|
||||
if (this.right) {
|
||||
this.walkDirection.addLocal(camLeft.negate());
|
||||
}
|
||||
if (this.up) {
|
||||
this.walkDirection.addLocal(camDir);
|
||||
}
|
||||
if (this.down) {
|
||||
this.walkDirection.addLocal(camDir.negate());
|
||||
}
|
||||
if (this.walkDirection.length() != 0.0f) {
|
||||
this.character.setViewDirection(this.walkDirection);
|
||||
}
|
||||
this.character.setWalkDirection(this.walkDirection);
|
||||
}
|
||||
|
||||
public void onAction(String binding, boolean value, float tpf) {
|
||||
if (binding.equals("CharLeft")) {
|
||||
this.left = value;
|
||||
} else if (binding.equals("CharRight")) {
|
||||
this.right = value;
|
||||
} else if (binding.equals("CharUp")) {
|
||||
this.up = value;
|
||||
} else if (binding.equals("CharDown")) {
|
||||
this.down = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void collision(PhysicsCollisionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user