package adventure;
import java.awt.*;
import com.jme3.scene.Spatial;
import com.jme3.light.DirectionalLight;
import com.jme3.font.BitmapText;
import java.awt.event.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Iterator;
import java.applet.*;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
public class Dungeon3D extends SimpleApplication implements Playable {
private JPanel buttons;
private PlaceView placeview;
private Commands commands;
private TextArea textarea;
class MyWindowAdapter extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
// Load an image from the net, making sure it has already been
// loaded when the method returns
public Image loadPicture(String imageName) {
Image im = null;
// Load the image from the net
try {
URL imageSource = new URL(
"http://www.student.nada.kth.se/~d99-nro/" + imageName);
} catch (MalformedURLException e) {
}
return im;
}
// Load and play a sound from /usr/local/hacks/sounds/
public void playSound(String name) {
URL u = null;
try {
u = new URL("file:" + "/usr/local/hacks/sounds/" + name + ".au");
} catch (MalformedURLException e) {
}
AudioClip a = Applet.newAudioClip(u);
a.play();
}
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
AppSettings settings = new AppSettings(true);
settings.setWidth(850);
settings.setHeight(440);
Dungeon3D canvasApplication = new Dungeon3D();
canvasApplication.setSettings(settings);
canvasApplication.createCanvas(); // create canvas!
JmeCanvasContext ctx = (JmeCanvasContext) canvasApplication
.getContext();
ctx.setSystemListener(canvasApplication);
Dimension dim = new Dimension(640, 480);
ctx.getCanvas().setPreferredSize(dim);
JFrame window = new JFrame("Swing Application");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// JPanel panel = new JPanel(new FlowLayout()); // a panel
JPanel panel = new JPanel(new BorderLayout()); // a panel
World world = new DungeonWorld(canvasApplication);
Person me = new Person(world, "You", null);
PlaceView placeview = new PlaceView(me);
Commands commands = new Commands(me);
TextArea textarea = new TextArea("", 10, 60,
TextArea.SCROLLBARS_VERTICAL_ONLY);
textarea.append("You are in a dungeon. The horrible shrieks of the undead chill your bones.\n");
textarea.setEditable(false);
panel.add("West", ctx.getCanvas());
panel.add("East", commands);
panel.add("South", textarea);
// add all your Swing components ...
// panel.add(new JButton("Some Swing Component"));
// add the JME canvas
// panel.add(ctx.getCanvas());
window.add(panel);
window.pack();
window.setVisible(true);
canvasApplication.startCanvas();
}
});
}
@Override
public void simpleInitApp() {
// activate windowed input behaviour
flyCam.setDragToRotate(true);
// Set up inputs and load your scene as usual
Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
Material mat_default = new Material(assetManager,
"Common/MatDefs/Misc/ShowNormals.j3md");
teapot.setMaterial(mat_default);
rootNode.attachChild(teapot);
// Create a wall with a simple texture from test_data
Box box = new Box(Vector3f.ZERO, 2.5f, 2.5f, 1.0f);
Spatial wall = new Geometry("Box", box);
Material mat_brick = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md");
mat_brick.setTexture("ColorMap", assetManager
.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
wall.setMaterial(mat_brick);
wall.setLocalTranslation(2.0f, -2.5f, 0.0f);
rootNode.attachChild(wall);
// Display a line of text with a default font
guiNode.detachAllChildren();
guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
BitmapText helloText = new BitmapText(guiFont, false);
helloText.setSize(guiFont.getCharSet().getRenderedSize());
helloText.setText("Hello World");
helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);
guiNode.attachChild(helloText);
// Load a model from test_data (OgreXML + material + texture)
Spatial ninja = 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);
rootNode.attachChild(ninja);
// You must add a light to make the model visible
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
rootNode.addLight(sun);
}
}

![Validate my KML 2.2 feed [Valid KML 2.2]](valid-kml.png)
