Add game source, converter pipeline, and web port

This commit is contained in:
2026-08-12 18:59:06 +02:00
parent 3e6635eac6
commit bd13ad67cc
97 changed files with 8781 additions and 0 deletions
+112
View File
@@ -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"});
}
}
+68
View File
@@ -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);
}
}
+89
View File
@@ -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());
}
}
+150
View File
@@ -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());
}
}
+62
View File
@@ -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();
}
}
+122
View File
@@ -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"});
}
}
+78
View File
@@ -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);
}
}
+175
View File
@@ -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));
}
}
+199
View File
@@ -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);
}
}
+67
View File
@@ -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);
}
}
+52
View File
@@ -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);
}
}
+48
View File
@@ -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);
}
}
+522
View File
@@ -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
}
}
}
+117
View File
@@ -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);
}
}
+206
View File
@@ -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.");
}
}
@@ -0,0 +1,7 @@
/*
* Decompiled with CFR 0.152.
*/
package mygame;
interface AnimeEventListener {
}
+31
View File
@@ -0,0 +1,31 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.animation.AnimChannel
* com.jme3.animation.AnimControl
* com.jme3.scene.Spatial
*/
package mygame;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.scene.Spatial;
import mygame.Interactive;
public abstract class Character
extends Interactive {
public AnimChannel modelAnimChannel;
public AnimControl modelAnimControl;
public Character(String name) {
super(name);
}
public void setModel(Spatial model) {
super.setModel(model);
this.setupModelControl();
}
public abstract void setupModelControl();
}
+106
View File
@@ -0,0 +1,106 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.animation.AnimControl
* com.jme3.bullet.collision.shapes.CapsuleCollisionShape
* com.jme3.bullet.collision.shapes.CollisionShape
* com.jme3.bullet.control.GhostControl
* com.jme3.effect.ParticleEmitter
* com.jme3.effect.ParticleMesh$Type
* com.jme3.light.Light
* com.jme3.light.PointLight
* com.jme3.material.Material
* com.jme3.math.ColorRGBA
* com.jme3.math.Vector3f
* com.jme3.scene.Spatial
* com.jme3.scene.control.Control
*/
package mygame;
import com.jme3.animation.AnimControl;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.GhostControl;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.light.Light;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;
import mygame.Character;
import mygame.CrossControl;
import mygame.Exchange;
public class Cross
extends Character {
public GhostControl collision;
public CrossControl control;
private PointLight light;
public Cross(String name) {
super(name);
this.setModel();
this.setupControl();
}
public void setupModelControl() {
this.modelAnimControl = (AnimControl)this.model.getControl(AnimControl.class);
this.modelAnimChannel = this.modelAnimControl.createChannel();
this.modelAnimChannel.setAnim("normal");
this.modelAnimChannel.setSpeed(0.5f);
}
void setupModel() {
this.wholeBody.attachChild(this.model);
}
public void setupControl() {
this.collision = new GhostControl((CollisionShape)new CapsuleCollisionShape(1.0f, 0.5f));
this.collision.addCollideWithGroup(2);
this.addControl((Control)this.collision);
this.control = new CrossControl();
this.addControl((Control)this.control);
Exchange.bulletAppState.getPhysicsSpace().add((Object)this.collision);
}
public void setModel() {
this.model = Exchange.assetManager.loadModel("Models/kross/kross.mesh.j3o");
this.setLocalScale(0.25f);
this.setupModel();
this.setupModelControl();
this.wholeBody.attachChild(this.model);
ParticleEmitter funken = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 50);
Material mat_red = new Material(Exchange.assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat_red.setTexture("Texture", Exchange.assetManager.loadTexture("Effects/flame.png"));
funken.setMaterial(mat_red);
funken.setImagesX(2);
funken.setImagesY(2);
funken.setEndColor(new ColorRGBA(0.0f, 1.0f, 0.0f, 1.0f));
funken.setStartColor(new ColorRGBA(0.0f, 1.0f, 0.0f, 1.0f));
funken.getParticleInfluencer().setInitialVelocity(new Vector3f(0.25f, 2.0f, 0.25f));
funken.setStartSize(0.1f);
funken.setEndSize(0.1f);
funken.setGravity(0.0f, 0.0f, 0.0f);
funken.setLowLife(1.0f);
funken.setHighLife(2.0f);
funken.getParticleInfluencer().setVelocityVariation(1.0f);
this.attachChild((Spatial)funken);
}
public void kill() {
this.removeFromParent();
Exchange.rootNode.removeLight((Light)this.light);
}
public void setLight() {
this.light = new PointLight();
this.light.setPosition(this.getLocalTranslation().add(new Vector3f(0.0f, 1.0f, 0.0f)));
this.light.setColor(ColorRGBA.Green);
this.light.setRadius(10.0f);
Exchange.rootNode.addLight((Light)this.light);
}
}
+31
View File
@@ -0,0 +1,31 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.renderer.RenderManager
* com.jme3.renderer.ViewPort
* com.jme3.scene.control.AbstractControl
*/
package mygame;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl;
import mygame.Cross;
import mygame.Exchange;
import mygame.Player;
public class CrossControl
extends AbstractControl {
protected void controlUpdate(float tpf) {
Cross cross = (Cross)this.spatial;
Player player = (Player)Exchange.rootNode.getChild("Player");
if (cross.collision.getOverlappingObjects().contains(player.collision)) {
player.heal(25.0f);
cross.kill();
}
}
protected void controlRender(RenderManager rm, ViewPort vp) {
}
}
+101
View File
@@ -0,0 +1,101 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.app.SimpleApplication
* com.jme3.asset.AssetManager
* com.jme3.bullet.BulletAppState
* com.jme3.math.Vector3f
* com.jme3.renderer.ViewPort
* com.jme3.scene.Node
* com.jme3.scene.Spatial
*/
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.AssetManager;
import com.jme3.bullet.BulletAppState;
import com.jme3.math.Vector3f;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import java.util.ArrayList;
import java.util.Random;
import mygame.Cross;
import mygame.WalkingEnemy;
public class Exchange {
public static ArrayList<WalkingEnemy> enemies;
public static Node rootNode;
public static BulletAppState bulletAppState;
public static AssetManager assetManager;
public static ViewPort viewPort;
public static SimpleApplication app;
public static int killed;
public static int getKilled() {
return killed;
}
public static void setKilled(int killed) {
Exchange.killed = killed;
}
public static SimpleApplication getApp() {
return app;
}
public static void setApp(SimpleApplication app) {
Exchange.app = app;
}
public static AssetManager getAssetManager() {
return assetManager;
}
public static void setAssetManager(AssetManager assetManager) {
Exchange.assetManager = assetManager;
}
public static BulletAppState getBulletAppState() {
return bulletAppState;
}
public static void setBulletAppState(BulletAppState bulletAppState) {
Exchange.bulletAppState = bulletAppState;
}
public static Node getRootNode() {
return rootNode;
}
public static void setRootNode(Node rootNode) {
Exchange.rootNode = rootNode;
}
public Exchange() {
enemies = new ArrayList();
}
public static void removeEnemy(WalkingEnemy en) {
enemies.remove((Object)en);
}
public static ViewPort getViewPort() {
return viewPort;
}
public static void setViewPort(ViewPort viewPort) {
Exchange.viewPort = viewPort;
}
public static void spawnItem(Vector3f place) {
Random r = new Random();
if (r.nextInt(100) > 90) {
Cross cross = new Cross("Cross");
cross.setLocalTranslation(place);
cross.setLight();
rootNode.attachChild((Spatial)cross);
}
}
}
+181
View File
@@ -0,0 +1,181 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.asset.AssetManager
* com.jme3.audio.AudioNode
* com.jme3.bullet.collision.shapes.CapsuleCollisionShape
* com.jme3.bullet.collision.shapes.CollisionShape
* com.jme3.bullet.control.BetterCharacterControl
* com.jme3.bullet.control.GhostControl
* com.jme3.effect.ParticleEmitter
* com.jme3.effect.ParticleMesh$Type
* com.jme3.light.Light
* com.jme3.light.PointLight
* com.jme3.material.Material
* com.jme3.math.ColorRGBA
* com.jme3.math.Vector3f
* com.jme3.post.SceneProcessor
* com.jme3.scene.Node
* com.jme3.scene.Spatial
* com.jme3.scene.control.Control
* com.jme3.scene.control.LightControl
* com.jme3.shadow.EdgeFilteringMode
* com.jme3.shadow.PointLightShadowFilter
* com.jme3.shadow.PointLightShadowRenderer
*/
package mygame;
import com.jme3.asset.AssetManager;
import com.jme3.audio.AudioNode;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.BetterCharacterControl;
import com.jme3.bullet.control.GhostControl;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.light.Light;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.post.SceneProcessor;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;
import com.jme3.scene.control.LightControl;
import com.jme3.shadow.EdgeFilteringMode;
import com.jme3.shadow.PointLightShadowFilter;
import com.jme3.shadow.PointLightShadowRenderer;
import mygame.Exchange;
import mygame.FireballControl;
public class Fireball
extends Node {
ParticleEmitter fire;
PointLight light;
LightControl lightControl;
GhostControl collisionGhost;
GhostControl damageAreaGhost;
BetterCharacterControl bodyControl;
PointLightShadowRenderer dlsr;
PointLightShadowFilter dlsf;
FireballControl fireballControl;
private AssetManager assetManager;
Vector3f direction;
Exchange exchange;
boolean explode;
float timer;
float lifetime = 1.0f;
public Fireball(AssetManager assetManager, Vector3f finish, Vector3f start, Exchange ex) {
this.direction = finish;
this.exchange = ex;
assetManager = Exchange.assetManager;
this.setLocalTranslation(start.add(new Vector3f(1.0f, 1.0f, 1.0f)));
this.fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30);
Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat_red.setTexture("Texture", assetManager.loadTexture("Effects/flame.png"));
this.fire.setMaterial(mat_red);
this.fire.setImagesX(2);
this.fire.setImagesY(2);
this.fire.setEndColor(new ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f));
this.fire.setStartColor(new ColorRGBA(1.0f, 1.0f, 0.0f, 0.5f));
this.fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 2.0f, 0.0f));
this.fire.setStartSize(1.5f);
this.fire.setEndSize(0.1f);
this.fire.setGravity(0.0f, 0.0f, 0.0f);
this.fire.setLowLife(1.0f);
this.fire.setHighLife(3.0f);
this.fire.getParticleInfluencer().setVelocityVariation(0.3f);
this.attachChild((Spatial)this.fire);
this.light = new PointLight();
this.light.setColor(new ColorRGBA(1.0f, 0.5f, 0.0f, 1.0f));
this.light.setPosition(this.getLocalTranslation());
this.light.setRadius(100.0f);
Exchange.rootNode.addLight((Light)this.light);
this.dlsr = new PointLightShadowRenderer(assetManager, 128);
this.dlsr.setLight(this.light);
this.dlsr.setShadowIntensity(0.2f);
this.dlsr.setEdgeFilteringMode(EdgeFilteringMode.Dither);
Exchange.viewPort.addProcessor((SceneProcessor)this.dlsr);
this.dlsf = new PointLightShadowFilter(assetManager, 128);
this.dlsf.setLight(this.light);
this.dlsf.setShadowIntensity(0.2f);
this.dlsf.setEdgeFilteringMode(EdgeFilteringMode.Dither);
this.dlsf.setEnabled(false);
this.collisionGhost = new GhostControl((CollisionShape)new CapsuleCollisionShape(1.0f, 0.5f));
this.collisionGhost.setSpatial((Spatial)this);
this.collisionGhost.addCollideWithGroup(1);
this.addControl((Control)this.collisionGhost);
this.damageAreaGhost = new GhostControl((CollisionShape)new CapsuleCollisionShape(5.0f, 1.0f));
this.damageAreaGhost.addCollideWithGroup(1);
this.addControl((Control)this.damageAreaGhost);
this.bodyControl = new BetterCharacterControl(0.1f, 0.1f, 1.0f);
this.addControl((Control)this.bodyControl);
this.fireballControl = new FireballControl();
this.addControl((Control)this.fireballControl);
Exchange.rootNode.attachChild((Spatial)this);
Exchange.bulletAppState.getPhysicsSpace().add((Object)this.damageAreaGhost);
Exchange.bulletAppState.getPhysicsSpace().add((Object)this.collisionGhost);
Exchange.bulletAppState.getPhysicsSpace().add((Object)this.bodyControl);
AudioNode hit = new AudioNode(assetManager, "Sounds/Effects/fireball.ogg", false);
hit.setLooping(false);
hit.setPositional(true);
hit.setLocalTranslation(this.getLocalTranslation());
hit.setVolume(5.0f);
this.attachChild((Spatial)hit);
hit.play();
}
public void explode() {
ParticleEmitter xplosion = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 50);
Material mat_red = new Material(Exchange.assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat_red.setTexture("Texture", Exchange.assetManager.loadTexture("Effects/flame.png"));
xplosion.setMaterial(mat_red);
xplosion.setImagesX(2);
xplosion.setParticlesPerSec(0.0f);
xplosion.setImagesY(2);
xplosion.setEndColor(new ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f));
xplosion.setStartColor(new ColorRGBA(1.0f, 1.0f, 0.0f, 0.5f));
xplosion.getParticleInfluencer().setInitialVelocity(new Vector3f(0.5f, 0.5f, 0.5f));
xplosion.setStartSize(1.5f);
xplosion.setEndSize(2.0f);
xplosion.setGravity(0.0f, 1.0f, 0.0f);
xplosion.setLowLife(1.0f);
xplosion.setHighLife(2.0f);
xplosion.getParticleInfluencer().setVelocityVariation(2.0f);
this.attachChild((Spatial)xplosion);
xplosion.emitAllParticles();
ParticleEmitter stones = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 20);
Material mat_stones = new Material(Exchange.assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat_stones.setTexture("Texture", Exchange.assetManager.loadTexture("Effects/stein.png"));
mat_stones.setTexture("GlowMap", Exchange.assetManager.loadTexture("Effects/stein.png"));
mat_stones.setTexture("DepthTexture", Exchange.assetManager.loadTexture("Effects/stein.png"));
stones.setMaterial(mat_stones);
stones.setImagesX(2);
stones.setParticlesPerSec(0.0f);
stones.setImagesY(2);
stones.setEndColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
stones.setStartColor(new ColorRGBA(0.0f, 0.0f, 0.0f, 1.0f));
stones.getParticleInfluencer().setInitialVelocity(new Vector3f(2.0f, 0.0f, 2.0f));
stones.setStartSize(0.1f);
stones.setEndSize(0.5f);
stones.setGravity(2.0f, 0.0f, 2.0f);
stones.setLowLife(1.0f);
stones.setHighLife(1.0f);
stones.getParticleInfluencer().setVelocityVariation(5.0f);
this.attachChild((Spatial)stones);
stones.emitAllParticles();
AudioNode explode = new AudioNode(Exchange.assetManager, "Sounds/Effects/explosion.ogg", false);
explode.setLooping(false);
explode.setPositional(true);
explode.setLocalTranslation(this.getLocalTranslation());
explode.setVolume(5.0f);
this.attachChild((Spatial)explode);
explode.play();
this.explode = true;
this.fire.emitAllParticles();
this.timer = 0.1f;
}
}
+89
View File
@@ -0,0 +1,89 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.light.Light
* com.jme3.math.Vector3f
* com.jme3.post.SceneProcessor
* com.jme3.renderer.RenderManager
* com.jme3.renderer.ViewPort
* com.jme3.scene.control.AbstractControl
* com.jme3.scene.control.Control
*/
package mygame;
import com.jme3.light.Light;
import com.jme3.math.Vector3f;
import com.jme3.post.SceneProcessor;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.control.Control;
import mygame.Exchange;
import mygame.Fireball;
import mygame.WalkingEnemy;
public class FireballControl
extends AbstractControl {
protected void controlUpdate(float tpf) {
WalkingEnemy enemy;
Fireball fireball = (Fireball)this.spatial;
if (!fireball.explode) {
fireball.bodyControl.setWalkDirection(fireball.direction);
} else {
fireball.bodyControl.setWalkDirection(Vector3f.ZERO);
}
Vector3f lightpos = fireball.collisionGhost.getPhysicsLocation();
lightpos.setY(0.5f);
fireball.light.setPosition(lightpos);
int i = 0;
while (true) {
Exchange cfr_ignored_0 = fireball.exchange;
if (i >= Exchange.enemies.size()) break;
Exchange cfr_ignored_1 = fireball.exchange;
enemy = Exchange.enemies.get(i);
if (fireball.collisionGhost.getOverlappingObjects().contains(enemy.ghost)) {
fireball.explode = true;
}
++i;
}
if (fireball.explode) {
i = 0;
while (true) {
Exchange cfr_ignored_2 = fireball.exchange;
if (i >= Exchange.enemies.size()) break;
Exchange cfr_ignored_3 = fireball.exchange;
enemy = Exchange.enemies.get(i);
if (fireball.damageAreaGhost.getOverlappingObjects().contains(enemy.ghost)) {
enemy.doDamage(100.0f);
fireball.explode();
}
++i;
}
}
fireball.lifetime -= tpf;
if (fireball.lifetime <= 0.0f && !fireball.explode) {
fireball.explode();
}
if (fireball.timer > 0.0f) {
fireball.timer += tpf;
if ((double)fireball.timer > 0.2) {
fireball.bodyControl.setEnabled(false);
fireball.removeControl((Control)fireball.bodyControl);
fireball.removeControl((Control)fireball.collisionGhost);
fireball.collisionGhost.setEnabled(false);
fireball.removeControl((Control)fireball.damageAreaGhost);
fireball.damageAreaGhost.setEnabled(false);
fireball.fire.setEnabled(false);
}
if (fireball.timer > 2.0f) {
fireball.removeFromParent();
Exchange.viewPort.removeProcessor((SceneProcessor)fireball.dlsr);
Exchange.rootNode.removeLight((Light)fireball.light);
}
}
}
protected void controlRender(RenderManager rm, ViewPort vp) {
}
}
+38
View File
@@ -0,0 +1,38 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.renderer.queue.RenderQueue$ShadowMode
* com.jme3.scene.Node
* com.jme3.scene.Spatial
*/
package mygame;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
public abstract class Interactive
extends Node {
public Spatial model;
public Node wholeBody;
public Interactive(String name) {
super(name);
this.setShadowMode(RenderQueue.ShadowMode.Cast);
this.wholeBody = new Node(name);
this.attachChild((Spatial)this.wholeBody);
}
public Spatial getModel() {
return this.model;
}
public void setModel(Spatial model) {
this.model = model;
this.setupModel();
this.wholeBody.attachChild(model);
}
abstract void setupModel();
}
+15
View File
@@ -0,0 +1,15 @@
/*
* Decompiled with CFR 0.152.
*/
package mygame;
import jme3.hello.TestCameraNode;
public class Main {
public static void main(String[] args) {
TestCameraNode app = new TestCameraNode();
app.setDisplayFps(false);
app.setDisplayStatView(false);
app.start();
}
}
+150
View File
@@ -0,0 +1,150 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.animation.AnimChannel
* com.jme3.animation.AnimControl
* com.jme3.animation.LoopMode
* com.jme3.bullet.collision.shapes.CapsuleCollisionShape
* com.jme3.bullet.collision.shapes.CollisionShape
* com.jme3.bullet.control.BetterCharacterControl
* com.jme3.bullet.control.GhostControl
* com.jme3.math.Vector3f
* com.jme3.scene.Spatial
* com.jme3.scene.control.Control
*/
package mygame;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.LoopMode;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.BetterCharacterControl;
import com.jme3.bullet.control.GhostControl;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;
import mygame.Character;
import mygame.Exchange;
import mygame.Weapon;
public class Player
extends Character {
public Weapon rightHand;
public Weapon leftHand;
public Spatial hat;
public Spatial model;
public BetterCharacterControl playerControl;
public AnimChannel leftHandAnimChannel;
public AnimControl leftHandAnimControl;
public AnimChannel rightHandAnimChannel;
public AnimControl rightHandAnimControl;
public Vector3f pt;
public GhostControl collision;
public float health = 100.0f;
public static float MAX_HEALTH = 100.0f;
public Player(String name) {
super(name);
}
public Spatial getRightHand() {
return this.rightHand;
}
public void setRightHand(Weapon rightHand) {
this.rightHand = rightHand;
this.setupRightHand();
}
public Spatial getLeftHand() {
return this.leftHand;
}
public void setLeftHand(Weapon leftHand) {
this.leftHand = leftHand;
this.setupLeftHand();
}
public Spatial getHat() {
return this.hat;
}
public void setHat(Spatial hat) {
this.hat = hat;
this.setupHat();
}
public Spatial getModel() {
return this.model;
}
public void setModel(Spatial model) {
this.model = model;
this.setupModel();
this.setupControl();
this.setupModelControl();
this.wholeBody.attachChild(this.model);
}
public void switchHands() {
this.wholeBody.detachChild((Spatial)this.leftHand);
this.wholeBody.detachChild((Spatial)this.rightHand);
Weapon temp = this.rightHand;
this.setRightHand(this.leftHand);
this.setLeftHand(temp);
}
public void die() {
this.modelAnimChannel.setAnim("die");
this.modelAnimChannel.setLoopMode(LoopMode.DontLoop);
this.wholeBody.setLocalTranslation(0.0f, 0.5f, 0.0f);
this.wholeBody.detachChild(this.hat);
this.wholeBody.detachChild((Spatial)this.rightHand);
this.wholeBody.detachChild((Spatial)this.leftHand);
}
private void setupLeftHand() {
this.leftHand.setLocalTranslation(0.4f, 0.3f, 0.4f);
this.leftHand.setLocalScale(0.35f);
this.wholeBody.attachChild((Spatial)this.leftHand);
}
private void setupRightHand() {
this.rightHand.setLocalTranslation(-0.4f, 0.3f, 0.4f);
this.rightHand.setLocalScale(0.35f);
this.wholeBody.attachChild((Spatial)this.rightHand);
}
private void setupHat() {
this.hat.setLocalScale(0.35f);
this.hat.setLocalTranslation(0.0f, 0.9f, -0.2f);
this.hat.rotate(-0.4f, 0.0f, 0.0f);
this.wholeBody.attachChild(this.hat);
}
public void setupModel() {
this.model.setLocalScale(0.5f);
this.wholeBody.attachChild(this.model);
}
private void setupControl() {
this.playerControl = new BetterCharacterControl(0.5f, 1.0f, 8.0f);
this.addControl((Control)this.playerControl);
this.collision = new GhostControl((CollisionShape)new CapsuleCollisionShape(1.0f, 0.5f));
this.collision.addCollideWithGroup(2);
this.addControl((Control)this.collision);
Exchange.bulletAppState.getPhysicsSpace().add((Object)this.collision);
}
public void setupModelControl() {
this.modelAnimControl = (AnimControl)this.model.getControl(AnimControl.class);
this.modelAnimChannel = this.modelAnimControl.createChannel();
this.modelAnimChannel.setAnim("stand");
}
public void heal(float amount) {
this.health = amount + this.health > MAX_HEALTH ? MAX_HEALTH : (this.health += amount);
}
}
+92
View File
@@ -0,0 +1,92 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.animation.AnimControl
* com.jme3.bullet.collision.shapes.CapsuleCollisionShape
* com.jme3.bullet.collision.shapes.CollisionShape
* com.jme3.bullet.control.GhostControl
* com.jme3.effect.ParticleEmitter
* com.jme3.effect.ParticleMesh$Type
* com.jme3.material.Material
* com.jme3.math.ColorRGBA
* com.jme3.math.Quaternion
* com.jme3.math.Vector3f
* com.jme3.scene.Spatial
* com.jme3.scene.control.Control
*/
package mygame;
import com.jme3.animation.AnimControl;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.GhostControl;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;
import mygame.Character;
import mygame.Exchange;
public class PowerUpShield
extends Character {
public GhostControl collision;
public PowerUpShield(String name) {
super(name);
this.setModel();
this.setupControl();
}
public void setupModelControl() {
this.modelAnimControl = (AnimControl)this.model.getControl(AnimControl.class);
this.modelAnimChannel = this.modelAnimControl.createChannel();
this.modelAnimChannel.setAnim("normal");
this.modelAnimChannel.setSpeed(0.5f);
}
void setupModel() {
this.wholeBody.attachChild(this.model);
}
public void setupControl() {
this.collision = new GhostControl((CollisionShape)new CapsuleCollisionShape(1.0f, 0.5f));
this.collision.addCollideWithGroup(2);
this.addControl((Control)this.collision);
Exchange.bulletAppState.getPhysicsSpace().add((Object)this.collision);
}
public void setModel() {
this.model = Exchange.assetManager.loadModel("Models/shield/shield.mesh.j3o");
this.model.setMaterial(Exchange.assetManager.loadMaterial("Materials/PowerUpShield.j3m"));
this.model.rotate(new Quaternion().fromAngleAxis((float)Math.PI, new Vector3f(0.0f, 1.0f, 0.0f)));
this.model.setLocalTranslation(0.0f, 1.0f, 0.0f);
this.setLocalScale(0.5f);
this.setupModel();
this.setupModelControl();
this.wholeBody.attachChild(this.model);
ParticleEmitter bobble = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 1);
Material mat_red = Exchange.assetManager.loadMaterial("Materials/bubble.j3m");
bobble.setMaterial(mat_red);
bobble.setImagesX(1);
bobble.setImagesY(1);
bobble.setEndColor(new ColorRGBA(1.0f, 1.0f, 0.0f, 0.75f));
bobble.setStartColor(new ColorRGBA(1.0f, 1.0f, 0.0f, 1.0f));
bobble.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f, 0.0f, 0.0f));
bobble.setStartSize(1.0f);
bobble.setEndSize(1.1f);
bobble.setGravity(0.0f, 0.0f, 0.0f);
bobble.setLowLife(1.0f);
bobble.setHighLife(1.0f);
bobble.getParticleInfluencer().setVelocityVariation(0.0f);
this.attachChild((Spatial)bobble);
}
public void kill() {
this.removeFromParent();
}
}
+32
View File
@@ -0,0 +1,32 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.animation.AnimChannel
* com.jme3.animation.AnimControl
* com.jme3.animation.AnimEventListener
*/
package mygame;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import mygame.Weapon;
public class SkillListener
implements AnimEventListener {
private Weapon weapon;
public SkillListener(Weapon w) {
this.weapon = w;
}
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
if (animName.equals("skill1")) {
this.weapon.skill1 = false;
}
}
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
}
}
+76
View File
@@ -0,0 +1,76 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.animation.LoopMode
* com.jme3.asset.AssetManager
* com.jme3.audio.AudioNode
* com.jme3.bullet.control.GhostControl
* com.jme3.math.Ray
* com.jme3.math.Vector3f
* com.jme3.scene.Spatial
*/
package mygame;
import com.jme3.animation.LoopMode;
import com.jme3.asset.AssetManager;
import com.jme3.audio.AudioNode;
import com.jme3.bullet.control.GhostControl;
import com.jme3.math.Ray;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import mygame.Exchange;
import mygame.Fireball;
import mygame.Player;
import mygame.Weapon;
public class Staff
extends Weapon {
GhostControl ghost;
AssetManager assetManager;
public Staff(String name) {
super(name);
}
public Staff(String name, AssetManager am, Exchange ex) {
super(name);
this.assetManager = am;
this.exchange = ex;
this.COOLDOWN1_TIME = 5.0f;
this.COOLDOWN2_TIME = 50.0f;
}
protected void setupControl() {
}
public void skill1() {
if (this.cooldown1 <= 0.0f) {
this.cooldown1 = this.COOLDOWN1_TIME;
this.modelAnimChannel.setAnim("skill1");
Player player = (Player)this.getParent().getParent();
Ray ray = new Ray(this.getWorldTranslation(), player.pt);
Vector3f direction = player.pt.subtract(this.getWorldTranslation()).normalize().mult(25.0f);
direction.setY(0.0f);
this.modelAnimChannel.setLoopMode(LoopMode.DontLoop);
Fireball fireball = new Fireball(this.assetManager, direction, player.getLocalTranslation(), this.exchange);
}
}
public void skill2() {
if (this.cooldown2 <= 0.0f) {
this.cooldown2 = this.COOLDOWN2_TIME;
AudioNode hit = new AudioNode(this.assetManager, "Sounds/Effects/teleport.ogg", false);
hit.setLooping(false);
hit.setPositional(true);
hit.setLocalTranslation(this.getLocalTranslation());
hit.setVolume(5.0f);
this.attachChild((Spatial)hit);
hit.play();
Player player = (Player)Exchange.getRootNode().getChild("Player");
Vector3f place = player.pt;
place.setY(1.0f);
player.playerControl.warp(place);
}
}
}
+91
View File
@@ -0,0 +1,91 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.animation.AnimEventListener
* com.jme3.animation.LoopMode
* com.jme3.asset.AssetManager
* com.jme3.audio.AudioNode
* com.jme3.bullet.collision.shapes.BoxCollisionShape
* com.jme3.bullet.collision.shapes.CollisionShape
* com.jme3.bullet.control.GhostControl
* com.jme3.math.Vector3f
* com.jme3.scene.Spatial
* com.jme3.scene.control.Control
*/
package mygame;
import com.jme3.animation.AnimEventListener;
import com.jme3.animation.LoopMode;
import com.jme3.asset.AssetManager;
import com.jme3.audio.AudioNode;
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.GhostControl;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;
import mygame.Exchange;
import mygame.Player;
import mygame.SkillListener;
import mygame.WalkingEnemy;
import mygame.Weapon;
public class Sword
extends Weapon
implements Runnable {
GhostControl ghost;
AssetManager assetManager;
public Sword(String name) {
super(name);
}
public Sword(String name, AssetManager am, Exchange ex) {
super(name);
this.assetManager = am;
this.exchange = ex;
this.COOLDOWN1_TIME = 0.5f;
}
protected void setupControl() {
this.ghost = new GhostControl((CollisionShape)new BoxCollisionShape(new Vector3f(0.25f, 0.25f, 1.75f)));
this.ghost.addCollideWithGroup(1);
this.addControl((Control)this.ghost);
this.modelAnimControl.addListener((AnimEventListener)new SkillListener(this));
}
public void skill1() {
if (this.cooldown1 <= 0.0f && !this.skill1) {
this.skill1 = true;
this.cooldown1 = this.COOLDOWN1_TIME;
this.modelAnimChannel.setAnim("skill1");
this.modelAnimChannel.setSpeed(2.0f);
this.modelAnimChannel.setLoopMode(LoopMode.DontLoop);
AudioNode hit = new AudioNode(this.assetManager, "Sounds/Effects/sword_hit1.ogg", false);
hit.setLooping(false);
hit.setPositional(true);
hit.setLocalTranslation(this.getLocalTranslation());
hit.setVolume(5.0f);
this.attachChild((Spatial)hit);
hit.play();
int i = 0;
while (true) {
if (i >= Exchange.enemies.size()) break;
WalkingEnemy enemy = Exchange.enemies.get(i);
if (this.ghost.getOverlappingObjects().contains(enemy.ghost)) {
enemy.doDamage(50.0f);
Player player = (Player)this.getParent().getParent();
}
++i;
}
}
}
public void run() {
this.skill1();
}
public void skill2() {
}
}
+152
View File
@@ -0,0 +1,152 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.animation.AnimControl
* com.jme3.animation.LoopMode
* com.jme3.app.Application
* com.jme3.asset.AssetManager
* com.jme3.audio.AudioNode
* com.jme3.bullet.collision.shapes.CapsuleCollisionShape
* com.jme3.bullet.collision.shapes.CollisionShape
* com.jme3.bullet.control.BetterCharacterControl
* com.jme3.bullet.control.GhostControl
* 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
* com.jme3.scene.control.Control
* tonegod.gui.core.Screen
*/
package mygame;
import com.jme3.animation.AnimControl;
import com.jme3.animation.LoopMode;
import com.jme3.app.Application;
import com.jme3.asset.AssetManager;
import com.jme3.audio.AudioNode;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.BetterCharacterControl;
import com.jme3.bullet.control.GhostControl;
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;
import com.jme3.scene.control.Control;
import mygame.Character;
import mygame.Exchange;
import mygame.WalkingEnemyControl;
import tonegod.gui.core.Screen;
public class WalkingEnemy
extends Character {
public BetterCharacterControl walkingEnemyControl;
public GhostControl ghost;
private WalkingEnemyControl control = new WalkingEnemyControl();
private float health;
private AssetManager assetManager;
public float reverseWalk;
public ParticleEmitter blood;
public boolean dead = false;
public float deadtimer = 0.0f;
public WalkingEnemy(String name) {
super(name);
this.addControl((Control)this.control);
}
public WalkingEnemy(String name, AssetManager am) {
super(name);
this.addControl((Control)this.control);
this.assetManager = am;
}
public void setupModelControl() {
this.modelAnimControl = (AnimControl)this.model.getControl(AnimControl.class);
this.modelAnimChannel = this.modelAnimControl.createChannel();
this.modelAnimChannel.setAnim("stand");
}
public void setupGUI() {
Screen screen = new Screen((Application)Exchange.app, "tonegod/gui/style/def/style_map.xml");
}
public void setModel(Spatial model) {
this.model = model;
this.setupModel();
this.setupControl();
this.setupModelControl();
this.wholeBody.attachChild(this.model);
this.blood = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 10);
Material mat_red = this.assetManager.loadMaterial("Materials/blood.j3m");
this.blood.setMaterial(mat_red);
this.blood.setImagesX(2);
this.blood.setImagesY(2);
this.blood.setEndColor(new ColorRGBA(1.0f, 0.0f, 0.0f, 0.75f));
this.blood.setStartColor(new ColorRGBA(1.0f, 0.0f, 0.0f, 0.25f));
this.blood.getParticleInfluencer().setInitialVelocity(new Vector3f(1.0f, 2.0f, 1.0f));
this.blood.setParticlesPerSec(0.0f);
this.blood.setStartSize(1.0f);
this.blood.setEndSize(1.0f);
this.blood.setGravity(0.0f, 2.0f, 0.0f);
this.blood.setLowLife(1.0f);
this.blood.setHighLife(0.5f);
this.blood.getParticleInfluencer().setVelocityVariation(0.3f);
this.blood.setRandomAngle(true);
this.blood.setSelectRandomImage(true);
this.attachChild((Spatial)this.blood);
}
void setupModel() {
this.model.setLocalScale(0.5f);
this.wholeBody.attachChild(this.model);
}
private void setupControl() {
this.walkingEnemyControl = new BetterCharacterControl(1.0f, 2.0f, 8.0f);
this.addControl((Control)this.walkingEnemyControl);
this.ghost = new GhostControl((CollisionShape)new CapsuleCollisionShape(1.0f, 0.5f));
this.ghost.addCollideWithGroup(1);
this.addControl((Control)this.ghost);
}
public float getHealth() {
return this.health;
}
public void setHealth(float health) {
this.health = health;
}
public void doDamage(float damage) {
this.health -= damage;
this.reverseWalk = 0.5f;
if (this.health <= 0.0f) {
this.die();
}
AudioNode hit = new AudioNode(this.assetManager, "Sounds/Effects/damage.ogg", false);
hit.setLooping(false);
hit.setVolume(100.0f);
this.getParent().attachChild((Spatial)hit);
hit.play();
this.blood.emitAllParticles();
}
public void die() {
this.modelAnimChannel.setAnim("die");
this.modelAnimChannel.setLoopMode(LoopMode.DontLoop);
this.ghost.setEnabled(false);
this.walkingEnemyControl.setEnabled(false);
AudioNode an = (AudioNode)this.getChild("walkingSound");
an.stop();
Exchange.removeEnemy(this);
Exchange.setKilled(Exchange.killed + 1);
Exchange.spawnItem(this.getLocalTranslation());
this.dead = true;
}
}
@@ -0,0 +1,42 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.math.Vector3f
* com.jme3.renderer.RenderManager
* com.jme3.renderer.ViewPort
* com.jme3.scene.control.AbstractControl
*/
package mygame;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl;
import mygame.WalkingEnemy;
public class WalkingEnemyControl
extends AbstractControl {
public WalkingEnemy walkingEnemy;
protected void controlUpdate(float tpf) {
this.walkingEnemy = (WalkingEnemy)this.spatial;
if (!this.walkingEnemy.dead) {
Vector3f walkdirection = new Vector3f(this.walkingEnemy.walkingEnemyControl.getViewDirection().x, 0.0f, this.walkingEnemy.walkingEnemyControl.getViewDirection().z).normalize().mult(6.0f);
if (this.walkingEnemy.reverseWalk > 0.0f) {
walkdirection.negateLocal();
this.walkingEnemy.reverseWalk -= tpf;
}
this.walkingEnemy.walkingEnemyControl.setViewDirection(this.spatial.getParent().getChild("Player").getLocalTranslation().subtract(this.spatial.getLocalTranslation()));
this.walkingEnemy.walkingEnemyControl.setWalkDirection(walkdirection);
} else {
this.walkingEnemy.deadtimer += tpf;
if (this.walkingEnemy.deadtimer > 10.0f) {
this.walkingEnemy.removeFromParent();
}
}
}
protected void controlRender(RenderManager rm, ViewPort vp) {
}
}
+73
View File
@@ -0,0 +1,73 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.animation.AnimControl
* com.jme3.bullet.control.GhostControl
* com.jme3.scene.Spatial
*/
package mygame;
import com.jme3.animation.AnimControl;
import com.jme3.bullet.control.GhostControl;
import com.jme3.scene.Spatial;
import mygame.Character;
import mygame.Exchange;
public abstract class Weapon
extends Character {
GhostControl weaponControl;
public Exchange exchange;
public boolean skill1 = false;
public float cooldown1 = 0.0f;
public float cooldown2 = 0.0f;
public float cooldown3 = 0.0f;
public float COOLDOWN1_TIME = 0.0f;
public float COOLDOWN2_TIME = 0.0f;
public float COOLDOWN3_TIME = 0.0f;
public Weapon(String name) {
super(name);
}
public Weapon(String name, Exchange ex) {
super(name);
this.exchange = ex;
}
public void setModel(Spatial model) {
this.model = model;
this.setupModel();
this.setupModelControl();
this.setupControl();
this.wholeBody.attachChild(this.model);
}
protected abstract void setupControl();
public void setupModelControl() {
this.modelAnimControl = (AnimControl)this.model.getControl(AnimControl.class);
this.modelAnimChannel = this.modelAnimControl.createChannel();
this.modelAnimChannel.setAnim("normal");
}
void setupModel() {
this.wholeBody.attachChild(this.model);
}
public void reduceCooldowns(float tpf) {
if (this.cooldown1 > 0.0f) {
this.cooldown1 -= tpf;
}
if (this.cooldown2 > 0.0f) {
this.cooldown2 -= tpf;
}
if (this.cooldown3 > 0.0f) {
this.cooldown3 -= tpf;
}
}
public abstract void skill1();
public abstract void skill2();
}
+44
View File
@@ -0,0 +1,44 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.app.SimpleApplication
* 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 mygame;
import com.jme3.app.SimpleApplication;
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 test1
extends SimpleApplication {
private Spatial player;
public static void main(String[] args) {
test1 app = new test1();
app.start();
}
public void simpleInitApp() {
this.player = this.assetManager.loadModel("Models/blob/Blob.mesh.xml");
Material mat_ground = new Material(this.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat_ground.setTexture("ColorMap", this.assetManager.loadTexture("Textures/Rock.PNG"));
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);
}
}
+49
View File
@@ -0,0 +1,49 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.jme3.math.Quaternion
* com.jme3.math.Vector3f
* com.jme3.renderer.Camera
* com.jme3.scene.CameraNode
* com.jme3.scene.Node
* com.jme3.scene.Spatial
* com.jme3.scene.control.CameraControl
*/
package wpq.tests;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.CameraNode;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.CameraControl;
public class PlayerCam
extends CameraNode {
private Node player;
private Quaternion CAM_ROTATION;
public static Vector3f CAM_VECTOR = new Vector3f(0.0f, 25.0f, -15.0f);
public void setPlayer(Node player) {
this.player = player;
}
public Node getPlayer() {
return this.player;
}
public PlayerCam(Node player, String name, Camera camera) {
super(name, new CameraControl(camera));
this.player = player;
this.CAM_ROTATION = new Quaternion();
this.CAM_ROTATION.fromAngleAxis(0.7853982f, Vector3f.UNIT_X);
}
public void setupCamera() {
this.player.attachChild((Spatial)this);
this.setLocalTranslation(CAM_VECTOR);
this.lookAt(this.player.getLocalTranslation(), Vector3f.UNIT_Y);
}
}