How to use the bullet with the BombControl effect in TestWalkingChar?

I can run the example with the robot and pressing spacebar then it fires the bullet with an effect in the TestWalkingChar. Now I want it to work with my scene with jmeplanet and a UFO that should be able to fire bullet / bomb with effect like in the TestWalkingChar. But when I add the functionality and start the app and press spacebar, nothing get rendered. Could you know what I’m doing wrong?

[java]public class UFOSpaceWorld extends SimpleApplication implements AnalogListener,
ActionListener, PhysicsCollisionListener { //

boolean player2update = false;
private PlanetAppState planetAppState;
private Geometry mark;
private Node ufoNode;
private RigidBodyControl ufoControl;
private RigidBodyControl ufoControl2;
private Node ufoNode2;
private CylinderCollisionShape shape;
private BoundingBox bv;
private RigidBodyControl jumpGateControl;
private RigidBodyControl jumpGateControl2;
private AnimChannel channel;
private AnimControl control;
private Node spacemanNode;
private RigidBodyControl spacemanControl;
private Node alien;
private String serverName = "localhost";
private int portNumber = 6143;
private RigidBodyControl alienControl;
Spatial jumpgateSpatial;
CameraNode camNode;
ChaseCamera chaseCam;
Planet moon;
static UFOSpaceWorld app;
Client myClient = null;
Vector3f ufoDirection = new Vector3f();
Vector3f ufoDirection2 = new Vector3f();
Vector3f ufoCamDir2 = new Vector3f();
Vector3f gate2vector = new Vector3f(10f, 10f, 1598300f);
Vector3f gate1vector = new Vector3f(10f, 10f, 1098300f);
private BulletAppState bulletAppState;
private boolean left = false, right = false, up = false, down = false,
		forward = false, backward = false, attack = false, rotate = false,
		pitch1 = false, yaw1 = false, roll1 = false;
private long starttime = 0;
private long playtime = 0;
 public void collision(PhysicsCollisionEvent event) {
        if (event.getObjectA() instanceof BombControl) {
            final Spatial node = event.getNodeA();
            /*effect.killAllParticles();
            effect.setLocalTranslation(node.getLocalTranslation());
            effect.emitAllParticles();*/
        } else if (event.getObjectB() instanceof BombControl) {
            final Spatial node = event.getNodeB();
            /*effect.killAllParticles();
            effect.setLocalTranslation(node.getLocalTranslation());
            effect.emitAllParticles();*/
        }
    }
public Vector3f getUfoCamDir2() {
	return ufoCamDir2;
}

public void setUfoCamDir2(Vector3f ufoCamDir2) {
	this.ufoCamDir2 = ufoCamDir2;
}

public Vector3f getUfoDirection2() {
	return ufoDirection2;
}

public void setUfoDirection2(Vector3f ufoDirection2) {
	this.ufoDirection2 = ufoDirection2;
}

private void setupChaseCamera() {
	flyCam.setEnabled(false);
	chaseCam = new ChaseCamera(cam, ufoNode, inputManager);
	chaseCam.setDefaultDistance(2237);
}

@Override
public void destroy() {
	// custom code
	if (myClient != null) {
		myClient.close();
	}
	super.destroy();
}

public static void main(String[] args) {
	AppSettings settings = new AppSettings(true);
	settings.setResolution(1280, 1024);
	settings.setSettingsDialogImage("Interface/spacesplash.png");
	settings.setTitle("Space World");
	app = new UFOSpaceWorld();
	if (args.length > 0) {
		app.serverName = args[0];
	}
	if (args.length > 1) {
		app.portNumber = new Integer(args[0]);
	}
	app.setSettings(settings);
	app.start();
}

@Override
public void simpleInitApp() {
	playtime = 0;
	starttime = System.currentTimeMillis();
	this.setDisplayStatView(false);
	setDisplayFps(false);
	java.util.logging.Logger.getLogger("com.jme3").setLevel(
			java.util.logging.Level.SEVERE);
	bulletAppState = new BulletAppState();
	bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
	stateManager.attach(bulletAppState);
	bulletAppState.setDebugEnabled(false);
	DirectionalLight sun = new DirectionalLight();
	sun.setDirection(new Vector3f(-.1f, 0f, -1f));
	sun.setColor(new ColorRGBA(0.75f, 0.75f, 0.75f, 1.0f));
	rootNode.addLight(sun);
	// Add sky
	Node sceneNode = new Node("Scene");
	sceneNode.attachChild(Utility.createSkyBox(this.getAssetManager(),
			"Textures/blue-glow-1024.dds"));
	rootNode.attachChild(sceneNode);
	// Create collision test mark
	Sphere sphere = new Sphere(30, 30, 5f);
	mark = new Geometry("mark", sphere);
	Material mark_mat = new Material(assetManager,
			"Common/MatDefs/Misc/Unshaded.j3md");
	mark_mat.setColor("Color", ColorRGBA.Red);
	mark.setMaterial(mark_mat);
	// Add planet app state
	planetAppState = new PlanetAppState(rootNode, sun);
	stateManager.attach(planetAppState);
	// Add planet
	FractalDataSource planetDataSource = new FractalDataSource(4);
	planetDataSource.setHeightScale(900f);
	Planet planet = Utility.createEarthLikePlanet(getAssetManager(),
			293710.0f, null, planetDataSource);
	planet.addControl(new RigidBodyControl(new PlanetCollisionShape(planet
			.getLocalTranslation(), planet.getRadius(), planetDataSource),
			0f));
	planetAppState.addPlanet(planet);
	rootNode.attachChild(planet);
	bulletAppState.getPhysicsSpace().add(planet);

	// Add moon
	FractalDataSource moonDataSource = new FractalDataSource(5);
	moonDataSource.setHeightScale(300f);
	moon = Utility.createMoonLikePlanet(getAssetManager(), 50000,
			moonDataSource);
	moon.setLocalTranslation(new Vector3f(10f, 10f, 1505000f));
	RigidBodyControl moonControl = new RigidBodyControl(
			new PlanetCollisionShape(moon.getLocalTranslation(),
					moon.getRadius(), moonDataSource), 0f);
	moon.addControl(moonControl);
	planetAppState.addPlanet(moon);
	// add saucer

	addSaucer();
	jumpgateSpatial = assetManager.loadModel("JumpGate.j3o");
	jumpgateSpatial.setLocalScale(10000f);
	BoundingBox jbv = (BoundingBox) jumpgateSpatial.getWorldBound();
	CylinderCollisionShape jshape = new CylinderCollisionShape(
			new Vector3f(jbv.getXExtent(), jbv.getYExtent(),
					jbv.getZExtent()), 1);
	;
	jumpGateControl = new RigidBodyControl(jshape, 0);
	jumpgateSpatial.addControl(jumpGateControl);
	jumpGateControl.setMass(0f);
	jumpGateControl.setPhysicsLocation(gate1vector);
	jumpGateControl.setPhysicsRotation(new Quaternion().fromAngleAxis(
			90 * FastMath.DEG_TO_RAD, new Vector3f(1, 0, 0)));

	Spatial jumpgateSpatial2 = assetManager.loadModel("JumpGate.j3o");
	jumpgateSpatial2.setLocalScale(10000f);

	BoundingBox jbv2 = (BoundingBox) jumpgateSpatial2.getWorldBound();
	CylinderCollisionShape jshape2 = new CylinderCollisionShape(
			new Vector3f(jbv2.getXExtent(), jbv2.getYExtent(),
					jbv2.getZExtent()), 1);
	;

	Quaternion roll180 = new Quaternion();
	roll180.fromAngleAxis(FastMath.PI / 2, new Vector3f(0, 1, 0));

	jumpGateControl2 = new RigidBodyControl(jshape2, 0);
	jumpgateSpatial2.addControl(jumpGateControl2);
	jumpGateControl2.setMass(0f);
	jumpGateControl2.setPhysicsLocation(gate2vector);
	jumpGateControl2.setPhysicsRotation(new Quaternion().fromAngleAxis(
			90 * FastMath.DEG_TO_RAD, new Vector3f(1, 0, 0)));

	Spatial spaceStationSpatial = assetManager
			.loadModel("SpaceStation.blend");
	spaceStationSpatial.setLocalScale(3500f);

	BoundingBox sbv = (BoundingBox) spaceStationSpatial.getWorldBound();

	CompoundCollisionShape shape3 = new CompoundCollisionShape();
	shape3.addChildShape(
			new CylinderCollisionShape(new Vector3f(sbv.getXExtent(), sbv
					.getYExtent(), sbv.getZExtent()), 1), new Vector3f(0,
					0, 0));
	RigidBodyControl spaceStationControl = new RigidBodyControl(shape3, 0);
	spaceStationSpatial.addControl(spaceStationControl);
	spaceStationControl.setMass(0f);
	spaceStationControl.setPhysicsLocation(new Vector3f(10000f, -10f,
			705000f));

	BlenderKey blenderKey = new BlenderKey(
			"objects/creatures/alien/alienmodel.blend");

	Spatial alien = (Spatial) assetManager.loadModel(blenderKey);
	alien.setLocalScale(20 * 2000f);
	alienControl = new RigidBodyControl(3 * 500f);
	alien.addControl(alienControl);

	alienControl.setPhysicsLocation(new Vector3f(11000f, -50f, 755000f));
	//
	BlenderKey blenderKey2 = new BlenderKey(
			"objects/creatures/spaceman/man.mesh.xml");

	Spatial man = (Spatial) assetManager.loadModel(blenderKey2);
	man.setLocalScale(200f);
	spacemanControl = new RigidBodyControl(4 * 500f);
	man.addControl(spacemanControl);

	spacemanControl
			.setPhysicsLocation(new Vector3f(10700f, -590f, 775000f));

	createNewOtoBot();
	BulletAppState bas = app.getStateManager().getState(
			BulletAppState.class);
	bas.getPhysicsSpace().addAll(spaceStationSpatial);
	bas.getPhysicsSpace().addAll(man);
	bas.getPhysicsSpace().addAll(alien);
	bas.getPhysicsSpace().addAll(jumpgateSpatial);
	bas.getPhysicsSpace().addAll(jumpgateSpatial2);
	bas.getPhysicsSpace().addAll(moon);
	bas.getPhysicsSpace().addAll(planet);
	bas.getPhysicsSpace().setGravity(new Vector3f(0, 0, 0));
    prepareBullet();
	// rootNode.attachChild(man);
	// rootNode.attachChild(alien);
	rootNode.attachChild(spaceStationSpatial);
	rootNode.attachChild(jumpgateSpatial);
	rootNode.attachChild(jumpgateSpatial2);
	rootNode.attachChild(moon);

	setupChaseCamera();
	registerInput();

	try {
		System.out.println("connecting to " + serverName);
		myClient = Network.connectToServer(serverName, portNumber);
		System.out.println("connected to " + serverName);
		// Serializer.registerClass(AutoControlMessage.class);
		Serializer.registerClass(ActionMessage.class);
		ClientListener cl = new ClientListener(app, myClient);
		myClient.addMessageListener(cl, ActionMessage.class);// ,
																// AutoControlMessage.class);
		myClient.addMessageListener(cl, AutoControlMessage.class);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	if (myClient != null) {
		myClient.start();
		System.out.println("myClient started");
	} else {
		System.out.println("myClient == null " + serverName);
	}
}

public void clientConnected(Client c) {
	System.out.println("clientConnected ");
}

private PhysicsSpace getPhysicsSpace() {
	return bulletAppState.getPhysicsSpace();
}

public void addSaucer() {

	ufoNode = (Node) assetManager.loadModel("usaucer_v01.j3o");
	ufoNode.setLocalScale(200f);
	BoundingBox bv = (BoundingBox) ufoNode.getWorldBound();
	CylinderCollisionShape shape = new CylinderCollisionShape(new Vector3f(
			bv.getXExtent(), bv.getYExtent(), bv.getZExtent()), 1);
	ufoControl = new RigidBodyControl(shape, 500f);
	ufoNode.addControl(ufoControl);
	System.out.println("addSaucer 200:");
	ufoControl.setPhysicsLocation(new Vector3f(10850f, -5979f, 785020f));
	BulletAppState bas = app.getStateManager().getState(
			BulletAppState.class);
	bas.getPhysicsSpace().addAll(ufoNode);
	rootNode.attachChild(ufoNode);
}

public void addNewSaucer() {
	ufoNode2 = (Node) assetManager.loadModel("usaucer_v01.j3o");
	ufoNode2.setLocalScale(700f);
	bv = (BoundingBox) ufoNode2.getWorldBound();
	shape = new CylinderCollisionShape(new Vector3f(bv.getXExtent(),
			bv.getYExtent(), bv.getZExtent()), 1);
	ufoControl2 = new RigidBodyControl(shape, 500f);
	ufoNode2.addControl(ufoControl2);
	ufoControl2.setPhysicsLocation(new Vector3f(10850f, -5979f, 785020f));
	ufoControl2.setGravity(Vector3f.ZERO);
	ufoControl2.setLinearVelocity(Vector3f.ZERO);
	ufoControl2.clearForces();
	BulletAppState bas = app.getStateManager().getState(
			BulletAppState.class);
	bas.getPhysicsSpace().addAll(ufoNode2);
	rootNode.attachChild(ufoNode2);
}

public void createNewOtoBot() {
	BlenderKey otoblenderKey = new BlenderKey("Models/Oto/Oto.mesh.xml");
	Spatial otoBot = (Spatial) assetManager.loadModel(otoblenderKey);
	otoBot.setLocalScale(600f);
	RigidBodyControl otoControl = new RigidBodyControl(30 * 500f);
	otoBot.addControl(otoControl);
	otoControl.setPhysicsLocation(new Vector3f(10800f, -579f, 785000f));
	control = otoBot.getControl(AnimControl.class);
	channel = control.createChannel();
	for (String anim : control.getAnimationNames())
		System.out.println("otoBot can:" + anim);
	channel.setAnim("pull");
	BulletAppState bas = app.getStateManager().getState(
			BulletAppState.class);
	bas.getPhysicsSpace().addAll(otoBot);
	rootNode.attachChild(otoBot);
}

public void registerInput() {
	inputManager.addMapping("moveForward", new KeyTrigger(keyInput.KEY_UP),
			new KeyTrigger(keyInput.KEY_W));
	inputManager.addMapping("moveBackward", new KeyTrigger(
			keyInput.KEY_DOWN), new KeyTrigger(keyInput.KEY_S));
	inputManager.addMapping("moveRight",
			new KeyTrigger(keyInput.KEY_RIGHT), new KeyTrigger(
					keyInput.KEY_D));
	inputManager.addMapping("moveLeft", new KeyTrigger(keyInput.KEY_LEFT),
			new KeyTrigger(keyInput.KEY_A));
	inputManager.addMapping("moveUp", new KeyTrigger(keyInput.KEY_E));
	inputManager.addMapping("startServer", new KeyTrigger(keyInput.KEY_M));
	inputManager.addMapping("moveDown", new KeyTrigger(keyInput.KEY_C));
	inputManager.addMapping("pitch1", new KeyTrigger(keyInput.KEY_P));
	inputManager.addMapping("roll1", new KeyTrigger(keyInput.KEY_R));
	inputManager.addMapping("yaw1", new KeyTrigger(keyInput.KEY_Y));
	inputManager.addMapping("toggleRotate", new MouseButtonTrigger(
			MouseInput.BUTTON_LEFT));
	inputManager.addMapping("rotateRight", new MouseAxisTrigger(
			MouseInput.AXIS_X, true));
	inputManager.addMapping("rotateLeft", new MouseAxisTrigger(
			MouseInput.AXIS_X, false));
	inputManager.addMapping("rotateUp", new MouseAxisTrigger(
			MouseInput.AXIS_Y, true));
	inputManager.addMapping("rotateDown", new MouseAxisTrigger(
			MouseInput.AXIS_Y, false));
	inputManager.addListener(this, "moveForward", "moveBackward",
			"moveRight", "moveLeft", "moveUp", "moveDown", "pitch1",
			"roll1", "yaw1");
	inputManager.addListener(this, "rotateRight", "rotateLeft", "rotateUp",
			"rotateDown", "toggleRotate", "startServer");
	// Toggle mouse cursor
	inputManager.addMapping("TOGGLE_CURSOR", new MouseButtonTrigger(
			MouseInput.BUTTON_LEFT), new KeyTrigger(KeyInput.KEY_SPACE));
	inputManager.addListener(actionListener, "TOGGLE_CURSOR");
	// Toggle wireframe
	inputManager.addMapping("TOGGLE_WIREFRAME", new KeyTrigger(
			KeyInput.KEY_T));
	inputManager.addListener(actionListener, "TOGGLE_WIREFRAME");
	// Collision test
	inputManager.addMapping("COLLISION_TEST", new MouseButtonTrigger(
			MouseInput.BUTTON_RIGHT));
	inputManager.addListener(actionListener, "COLLISION_TEST");

	inputManager
			.addMapping("CharShoot", new KeyTrigger(KeyInput.KEY_SPACE));

	inputManager.addListener(this, "CharShoot");

}

public void toggleToFullscreen() {
	GraphicsDevice device = GraphicsEnvironment
			.getLocalGraphicsEnvironment().getDefaultScreenDevice();
	DisplayMode[] modes = device.getDisplayModes();
	int i = 0; // note: there are usually several, let's pick the first
	settings.setResolution(modes[i].getWidth(), modes[i].getHeight());
	settings.setFrequency(modes[i].getRefreshRate());
	settings.setBitsPerPixel(modes[i].getBitDepth());
	settings.setFullscreen(device.isFullScreenSupported());
	app.setSettings(settings);
	app.restart(); // restart the context to apply changes
}

long time = 0;

public void simpleUpdatePlayer2(float tpf) {
	System.out.println("LOOP simpleUpdatePlayer2 player 2");
	int speed = 8000 * 25;// *
	Vector3f camDir = cam.getDirection().clone().multLocal(speed * tpf);
	Vector3f camUp = cam.getUp().clone().mult(speed * tpf);
	Quaternion roll = new Quaternion();
	camDir.y = 0;
	ufoDirection2.set(0, 0, 0);
	// ufoControl2.setLinearVelocity(Vector3f.ZERO);
	if (doRoll == true) {
		System.out.println("doRoll == true");
		roll.fromAngleAxis(FastMath.QUARTER_PI / 3, cam.getDirection());
		ufoDirection2.set(cam.getLeft()).multLocal(-speed * tpf);
	}
	if (doRoll2 == true) {
		System.out.println("doRoll2 == true");
		roll.fromAngleAxis(-FastMath.QUARTER_PI / 3, cam.getDirection());
		ufoDirection2.set(cam.getLeft()).multLocal(speed * tpf);
	}
	if (doRoll3 == true) {
		System.out.println("doRoll3 == true");
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection2.addLocal(camUp);
	}
	if (doRoll4 == true) {
		System.out.println("doRoll4 == true");
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection2.addLocal(cam.getUp().multLocal(-speed * tpf));
	}
	if (doRoll5 == true) {
		System.out.println("doRoll5 == true");
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection2.set(camDir);
	}
	if (doRoll6 == true) {
		System.out.println("doRoll6 == true");
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection2.set(camDir.multLocal(-1f));
	}
	/*
	 * if (up) { roll.fromAngleAxis(0, cam.getDirection());
	 * ufoDirection.addLocal(camUp); } if (down) { roll.fromAngleAxis(0,
	 * cam.getDirection());
	 * ufoDirection.addLocal(cam.getUp().multLocal(-speed * tpf)); }
	 */
	if (ufoControl2 == null) {
		System.out.println("ufoControl2 == null");
	}
	ufoControl2.setPhysicsRotation(roll);
	ufoControl2.setLinearVelocity(ufoDirection2);
	if (System.currentTimeMillis() - time > 1000) {
		System.out.println("LOOP BREAK");
		ufoDirection2.set(0, 0, 0);
		ufoControl2.setLinearVelocity(Vector3f.ZERO);
		time = 0;
		player2update = false;
	}
}

private boolean doRoll2 = false;
private boolean doRoll3 = false;
private boolean doRoll5 = false;

public boolean isDoRoll5() {
	return doRoll5;
}

public void setDoRoll5(boolean doRoll5) {
	this.doRoll5 = doRoll5;
}

private boolean doRoll6 = false;

public boolean isDoRoll6() {
	return doRoll6;
}

public void setDoRoll6(boolean doRoll6) {
	this.doRoll6 = doRoll6;
}

public boolean isDoRoll3() {
	return doRoll3;
}

public void setDoRoll3(boolean doRoll3) {
	this.doRoll3 = doRoll3;
}

private boolean doRoll4 = false;

public boolean isDoRoll4() {
	return doRoll4;
}

public void setDoRoll4(boolean doRoll4) {
	this.doRoll4 = doRoll4;
}

public boolean isDoRoll2() {
	return doRoll2;
}

public void setDoRoll2(boolean doRoll2) {
	this.doRoll2 = doRoll2;
}

private boolean doRoll = false;

public boolean isDoRoll() {
	return doRoll;
}

public void setDoRoll(boolean doRoll) {
	this.doRoll = doRoll;
}

@Override
public void simpleUpdate(float tpf) {
	playtime = System.currentTimeMillis() - starttime;
	int speed = 25 * 80000;
	Vector3f camDir = cam.getDirection().clone().multLocal(speed * tpf);
	Vector3f camUp = cam.getUp().clone().mult(speed * tpf);
	Quaternion roll = new Quaternion();
	Quaternion yaw = new Quaternion();
	Quaternion pitch = new Quaternion();
	camDir.y = 0;
	ufoDirection.set(0, 0, 0);
	ufoControl.setLinearVelocity(Vector3f.ZERO);
	if (left) {
		roll.fromAngleAxis(-FastMath.QUARTER_PI / 3, cam.getDirection());
		ufoDirection.set(cam.getLeft().multLocal(speed * tpf));
	}
	if (right) {
		roll.fromAngleAxis(FastMath.QUARTER_PI / 3, cam.getDirection());
		ufoDirection.set(cam.getLeft()).multLocal(-speed * tpf);
	}
	if (up) {
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection.addLocal(camUp);
	}
	if (down) {
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection.addLocal(cam.getUp().multLocal(-speed * tpf));
	}
	if (forward) {
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection.set(camDir);
	}
	if (backward) {
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection.set(camDir.multLocal(-1f));
	}
	if (pitch1) {
		System.out.println("PITCH1");
		roll.fromAngleAxis(-FastMath.QUARTER_PI / 2, cam.getDirection()
				.cross(Vector3f.UNIT_Y));
	}
	if (yaw1) {
		System.out.println("yaw1");
		// pitch.fromAngleAxis(angle, axis)
		// roll.fromAngleAxis(-FastMath.QUARTER_PI, );
		roll.fromAngles(0, FastMath.QUARTER_PI / 2, 0);
		// ufoControl.setP
		// ufoControl.setPhysicsLocation(Vector3f.UNIT_Y);
		// ufoControl.setPhysicsRotation(roll);

	}
	if (roll1) {
		System.out.println("roll1");
		roll.fromAngleAxis(-FastMath.QUARTER_PI / 2, cam.getDirection());
	}
	ufoControl.setPhysicsRotation(roll);
	ufoControl.setLinearVelocity(ufoDirection);
	CollisionResults results = new CollisionResults();

	// System.out.println("1 #Collisions between" + ufoNode.getName()
	// + " and " + jumpgateSpatial.getName() + ": " + results.size());
	ufoNode.collideWith((BoundingBox) jumpgateSpatial.getWorldBound(),
			results);
	// System.out.println("2 #Collisions between" + ufoNode.getName()
	// + " and " + jumpgateSpatial.getName() + ": " + results.size());
	CollisionResults results2 = new CollisionResults();

	// Use the results

	if (results.size() > 0 && playtime > 50000) {
		System.out.println("playtime" + playtime);
		System.out.println("#Collisions between" + ufoNode.getName()
				+ " and " + jumpgateSpatial.getName() + ": "
				+ results.size());

		// how to react when a collision was detected
		CollisionResult closest = results.getClosestCollision();
		System.out.println("What was hit? "
				+ closest.getGeometry().getName());
		System.out
				.println("Where was it hit? " + closest.getContactPoint());
		System.out.println("Distance? " + closest.getDistance());
		ufoControl
				.setPhysicsLocation(jumpGateControl2.getPhysicsLocation());
		System.out.println("Warped");

	} else {
		// how to react when no collision occured
	}

	if (results2.size() > 0) {
		System.out.println("Number of Collisions between"
				+ ufoNode.getName() + " and " + moon.getName() + ": "
				+ results2.size());

		// how to react when a collision was detected
		CollisionResult closest2 = results2.getClosestCollision();
		System.out.println("What was hit? "
				+ closest2.getGeometry().getName());
		System.out.println("Where was it hit? "
				+ closest2.getContactPoint());
		System.out.println("Distance? " + closest2.getDistance());
	}
	if (myClient != null) {
		Message message = new ActionMessage(1, myClient.getId(), right, 1);
		Message message2 = new ActionMessage(2, myClient.getId(), left, 2);
		Message message3 = new ActionMessage(2, myClient.getId(), up, 3);
		Message message4 = new ActionMessage(2, myClient.getId(), down, 4);
		Message message5 = new ActionMessage(2, myClient.getId(), forward,
				5);
		Message message6 = new ActionMessage(2, myClient.getId(), backward,
				6);
		if (myClient != null) {
			myClient.send(message);
			myClient.send(message2);
			myClient.send(message3);
			myClient.send(message4);
			myClient.send(message5);
			myClient.send(message6);
		}
		if (player2update == true) {
			System.out.println("simpleUpdatePlayer2 player 2 "
					+ message.toString());
			time = System.currentTimeMillis();
			simpleUpdatePlayer2(tpf);
		}
	}
}

public boolean isPlayer2update() {
	return player2update;
}

public void setPlayer2update(boolean player2update) {
	this.player2update = player2update;
}

private void createOto() {
	BlenderKey blenderKey = new BlenderKey("Models/Oto/Oto.mesh.xml");
	Spatial man = (Spatial) assetManager.loadModel(blenderKey);
	man.setLocalTranslation(new Vector3f(69, 15, -60));
	man.setShadowMode(ShadowMode.CastAndReceive);
	rootNode.attachChild(man);

}

public void onAnalog(String name, float value, float tpf) {

	if (name.equals("rotateRight") && rotate) {
		ufoNode.rotate(0, 1 * tpf, 0);
	}
	if (name.equals("rotateLeft") && rotate) {
		ufoNode.rotate(0, -1 * tpf, 0);
	}
	if (name.equals("rotateUp") && rotate) {
		ufoNode.rotate(0, 0, -1 * tpf);
	}
	if (name.equals("rotateDown") && rotate) {
		ufoNode.rotate(0, 0, 1 * tpf);
	}
}

public void onAction(String name, boolean keyPressed, float tpf) {

	Message message = new ActionMessage(name, keyPressed);
	if (myClient != null) {
		myClient.send(message);
	}

	if (name.equals("moveLeft")) {
		if (keyPressed) {
			left = true;
		} else {
			left = false;
		}
	} else if (name.equals("moveRight")) {
		if (keyPressed) {
			right = true;
		} else {
			right = false;
		}
	} else if (name.equals("moveUp")) {
		if (keyPressed) {
			up = true;
		} else {
			up = false;
		}
	} else if (name.equals("moveDown")) {
		if (keyPressed) {
			down = true;
		} else {
			down = false;
		}
	} else if (name.equals("moveForward")) {
		if (keyPressed) {
			forward = true;
		} else {
			forward = false;
		}
	} else if (name.equals("moveBackward")) {
		if (keyPressed) {
			backward = true;
		} else {
			backward = false;
		}
	}

	else if (name.equals("pitch1")) {
		if (keyPressed) {
			pitch1 = true;
		} else {
			pitch1 = false;
		}
	} else if (name.equals("CharShoot") ) { // && !keyPressed) {
		System.out.println("CharShoot ");
		bulletControl();
	}

	else if (name.equals("roll1")) {
		if (keyPressed) {
			roll1 = true;
		} else {
			roll1 = false;
		}
	}

	else if (name.equals("yaw1")) {
		if (keyPressed) {
			yaw1 = true;
		} else {
			yaw1 = false;
		}
	}

	// toggling rotation on or off
	if (name.equals("toggleRotate") && keyPressed) {
		rotate = true;
		inputManager.setCursorVisible(false);
	}
	if (name.equals("toggleRotate") && !keyPressed) {
		rotate = false;
		inputManager.setCursorVisible(true);
	}
	if (name.equals("TOGGLE_CURSOR") && !keyPressed) {
		if (inputManager.isCursorVisible()) {
			inputManager.setCursorVisible(false);
		} else {
			inputManager.setCursorVisible(true);
		}
	}
	if (name.equals("TOGGLE_WIREFRAME") && !keyPressed) {
		for (Planet planet : planetAppState.getPlanets()) {
			planet.toogleWireframe();
		}
	}
	if (name.equals("COLLISION_TEST") && !keyPressed) {
		CollisionResults results = new CollisionResults();
		Ray ray = new Ray(cam.getLocation(), cam.getDirection());
		// Test collision with closest planet's terrain only
		planetAppState.getNearestPlanet().getTerrainNode()
				.collideWith(ray, results);
		System.out.println("----- Collisions? " + results.size() + "-----");
		for (int i = 0; i < results.size(); i++) {
			// For each hit, we know distance, impact point, name of
			// geometry.
			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) {
			// The closest collision point is what was truly hit:
			CollisionResult closest = results.getClosestCollision();
			// Let's interact - we mark the hit with a red dot.
			mark.setLocalTranslation(closest.getContactPoint());
			rootNode.attachChild(mark);
		} else {
			// No hits? Then remove the red mark.
			rootNode.detachChild(mark);
		}
	}
}

Material matRock;
Material matBullet;
Sphere bullet;
SphereCollisionShape bulletCollisionShape;

private void prepareBullet() {
	System.out.println("prepareBullet ");
	bullet = new Sphere(40*32, 40*32, 40*0.4f, true, false);
	bullet.setTextureMode(TextureMode.Projected);
	bulletCollisionShape = new SphereCollisionShape(40*0.4f);
	matBullet = new Material(getAssetManager(),
			"Common/MatDefs/Misc/Unshaded.j3md");
	matBullet.setColor("Color", ColorRGBA.Green);
	matBullet.setColor("GlowColor", ColorRGBA.Green);
	getPhysicsSpace().addCollisionListener(this);
}

private void bulletControl() {
	System.out.println("bulletControl ");
	// shootingChannel.setAnim("Dodge", 0.1f);
	// shootingChannel.setLoopMode(LoopMode.DontLoop);
	Geometry bulletg = new Geometry("bullet", bullet);
	bulletg.setMaterial(matBullet);
	bulletg.setShadowMode(ShadowMode.CastAndReceive);
	bulletg.setLocalTranslation(ufoControl.getPhysicsLocation().add(
			cam.getDirection().mult(5)));
	RigidBodyControl bulletControl = new BombControl(bulletCollisionShape,
			1);
	bulletControl.setCcdMotionThreshold(0.1f);
	bulletControl.setLinearVelocity(cam.getDirection().mult(80));
	bulletg.addControl(bulletControl);
	rootNode.attachChild(bulletg);
	getPhysicsSpace().add(bulletControl);
}

private ActionListener actionListener = new ActionListener() {
	public void onAction(String name, boolean pressed, float tpf) {
		if (name.equals("TOGGLE_CURSOR") && !pressed) {
			if (inputManager.isCursorVisible()) {
				inputManager.setCursorVisible(false);
			} else {
				inputManager.setCursorVisible(true);
			}
		}
		if (name.equals("TOGGLE_WIREFRAME") && !pressed) {
			for (Planet planet : planetAppState.getPlanets()) {
				planet.toogleWireframe();
			}
		}
		if (name.equals("COLLISION_TEST") && !pressed) {
			CollisionResults results = new CollisionResults();
			Ray ray = new Ray(cam.getLocation(), cam.getDirection());
			// Test collision with closest planet's terrain only
			planetAppState.getNearestPlanet().getTerrainNode()
					.collideWith(ray, results);
			System.out.println("----- Collisions? " + results.size()
					+ "-----");
			for (int i = 0; i < results.size(); i++) {
				// For each hit, we know distance, impact point, name of
				// geometry.
				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) {
				// The closest collision point is what was truly hit:
				CollisionResult closest = results.getClosestCollision();
				// Let's interact - we mark the hit with a red dot.
				mark.setLocalTranslation(closest.getContactPoint());
				rootNode.attachChild(mark);
			} else {
				// No hits? Then remove the red mark.
				rootNode.detachChild(mark);
			}
		}
	}
};

}
[/java]

I looked more at the example code and now I can get the green “bombs” shooting forward in the direction of the spacecraft if I press the spacebar. But should the color really be this green or am I missing a texture or similar? Is it a green plasma bomb? Or that the green color mean that the texture of the bomb is not loaded?

[java]public class UFOSpaceWorld extends SimpleApplication implements AnalogListener,
ActionListener, PhysicsCollisionListener {
Material matRock;
Material matBullet;
Sphere bullet;
SphereCollisionShape bulletCollisionShape;
ParticleEmitter fire;
private boolean doRoll2 = false;
private boolean doRoll3 = false;
private boolean doRoll5 = false;
boolean player2update = false;
private PlanetAppState planetAppState;
private Geometry mark;
private Node ufoNode;
private Node ufoNode2;
private CylinderCollisionShape shape;
private BoundingBox bv;
private RigidBodyControl ufoControl, ufoControl2, jumpGateControl,
jumpGateControl2, spacemanControl, alienControl;
private AnimChannel channel;
private AnimControl control;
private Node spacemanNode;
private Node alien;
private String serverName = “localhost”;
private int portNumber = 6143;
private BulletAppState bulletAppState;
private boolean left = false, right = false, up = false, down = false,
forward = false, backward = false, attack = false, rotate = false,
pitch1 = false, yaw1 = false, roll1 = false;
private long starttime = 0;
private long playtime = 0;
long time = 0;
static UFOSpaceWorld app;
Client myClient = null;
Vector3f ufoDirection = new Vector3f();
Vector3f ufoDirection2 = new Vector3f();
Vector3f ufoCamDir2 = new Vector3f();
Vector3f gate2vector = new Vector3f(10f, 10f, 1598300f);
Vector3f gate1vector = new Vector3f(10f, 10f, 1098300f);
Spatial jumpgateSpatial;
CameraNode camNode;
ChaseCamera chaseCam;
Planet moon;
ParticleEmitter effect;

public void collision(PhysicsCollisionEvent event) {
	System.out.println("COLLISION");
	if (event.getObjectA() instanceof BombControl) {
		final Spatial node = event.getNodeA();
		System.out.println("COLLISION etObjectA() instanceof BombCo" +node.getLocalTranslation());			
		effect.killAllParticles();
		effect.setLocalTranslation(node.getLocalTranslation());
		BombControl bc = (BombControl) event.getObjectA();
		//bc.
		
		effect.emitAllParticles();
	} else if (event.getObjectB() instanceof BombControl) {
		final Spatial node = event.getNodeB();
		System.out.println("COLLISION getObjectB() instanceof BombCon" +node.getLocalTranslation());	
		
		effect.killAllParticles();
		effect.setLocalTranslation(node.getLocalTranslation());
		System.out.println("COLLISION emitAllParticles");
		effect.emitAllParticles();
		//fire.setLocalTranslation(node.getLocalTranslation());
		//fire.emitAllParticles();
	}/*
    if ("bullet".equals(event.getNodeA().getName())) {
		System.out.println("COLLISION nt.getNodeA().getName()");
        final Spatial node = event.getNodeA();
        enqueue(new Callable() {
            public Object call() throws Exception {
                getPhysicsSpace().remove(node);
                node.removeFromParent();
                effect.killAllParticles();
                effect.setLocalTranslation(node.getLocalTranslation());
                effect.emitAllParticles();
                return null;
            }
        });
    } else if (event.getNodeB() != null && "bullet".equals(event.getNodeB().getName())) {
		System.out.println("COLLISION event.getNodeB().getName()");
        final Spatial node = event.getNodeB();
        enqueue(new Callable() {

            public Object call() throws Exception {
                getPhysicsSpace().remove(node);
                node.removeFromParent();
                effect.killAllParticles();
                effect.setLocalTranslation(node.getLocalTranslation());
                effect.emitAllParticles();
                return null;
            }
        });
    }*/
}



public Vector3f getUfoCamDir2() {
	return ufoCamDir2;
}

public void setUfoCamDir2(Vector3f ufoCamDir2) {
	this.ufoCamDir2 = ufoCamDir2;
}

public Vector3f getUfoDirection2() {
	return ufoDirection2;
}

public void setUfoDirection2(Vector3f ufoDirection2) {
	this.ufoDirection2 = ufoDirection2;
}

private void setupChaseCamera() {
	flyCam.setEnabled(false);
	chaseCam = new ChaseCamera(cam, ufoNode, inputManager);
	chaseCam.setDefaultDistance(2237);
}

@Override
public void destroy() {
	// custom code
	if (myClient != null) {
		myClient.close();
	}
	super.destroy();
}

public static void main(String[] args) {
	AppSettings settings = new AppSettings(true);
	settings.setResolution(1280, 1024);
	settings.setSettingsDialogImage("Interface/spacesplash.png");
	settings.setTitle("Space World");
	app = new UFOSpaceWorld();
	if (args.length > 0) {
		app.serverName = args[0];
	}
	if (args.length > 1) {
		app.portNumber = new Integer(args[0]);
	}
	app.setSettings(settings);
	app.start();
}

private void prepareEffect() {
	int COUNT_FACTOR = 1;
	float COUNT_FACTOR_F = 1f;
	effect = new ParticleEmitter("Flame", Type.Triangle, 32 * COUNT_FACTOR);
	effect.setSelectRandomImage(true);
	effect.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f,
			(float) (1f / COUNT_FACTOR_F)));
	effect.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f));
	effect.setStartSize(1000*1.3f);
	effect.setEndSize(1000*2f);
	effect.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
	effect.setParticlesPerSec(0);
	effect.setGravity(0, -5, 0);
	effect.setLowLife(.4f);
	effect.setHighLife(.5f);
	effect.setInitialVelocity(new Vector3f(0, 7, 0));
	effect.setVelocityVariation(1f);
	effect.setImagesX(2);
	effect.setImagesY(2);
	Material mat = new Material(assetManager,
			"Common/MatDefs/Misc/Particle.j3md");
	mat.setTexture("Texture",
			assetManager.loadTexture("Effects/Explosion/flame.png"));
	effect.setMaterial(mat);
	System.out.println("prepared effect");
	effect.setLocalScale(100);
	BulletAppState bas = app.getStateManager().getState(
			BulletAppState.class);
	bas.getPhysicsSpace().addAll(effect);
	
	rootNode.attachChild(effect);
}

@Override
public void simpleInitApp() {
	playtime = 0;
	starttime = System.currentTimeMillis();
	this.setDisplayStatView(false);
	setDisplayFps(false);
	java.util.logging.Logger.getLogger("com.jme3").setLevel(
			java.util.logging.Level.SEVERE);
	bulletAppState = new BulletAppState();
	bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
	stateManager.attach(bulletAppState);	
	bulletAppState.setDebugEnabled(false);
	DirectionalLight sun = new DirectionalLight();
	sun.setDirection(new Vector3f(-.1f, 0f, -1f));
	sun.setColor(new ColorRGBA(0.75f, 0.75f, 0.75f, 1.0f));
	rootNode.addLight(sun);
	// Add sky
	Node sceneNode = new Node("Scene");
	sceneNode.attachChild(Utility.createSkyBox(this.getAssetManager(),
			"Textures/blue-glow-1024.dds"));
	rootNode.attachChild(sceneNode);
	// Create collision test mark
	Sphere sphere = new Sphere(30, 30, 5f);
	mark = new Geometry("mark", sphere);
	Material mark_mat = new Material(assetManager,
			"Common/MatDefs/Misc/Unshaded.j3md");
	mark_mat.setColor("Color", ColorRGBA.Red);
	mark.setMaterial(mark_mat);
	// Add planet app state
	planetAppState = new PlanetAppState(rootNode, sun);
	stateManager.attach(planetAppState);
	// Add planet
	FractalDataSource planetDataSource = new FractalDataSource(4);
	planetDataSource.setHeightScale(900f);
	Planet planet = Utility.createEarthLikePlanet(getAssetManager(),
			293710.0f, null, planetDataSource);
	planet.addControl(new RigidBodyControl(new PlanetCollisionShape(planet
			.getLocalTranslation(), planet.getRadius(), planetDataSource),
			0f));
	planetAppState.addPlanet(planet);
	rootNode.attachChild(planet);
	bulletAppState.getPhysicsSpace().add(planet);
	// Add moon
	FractalDataSource moonDataSource = new FractalDataSource(5);
	moonDataSource.setHeightScale(300f);
	moon = Utility.createMoonLikePlanet(getAssetManager(), 50000,
			moonDataSource);
	moon.setLocalTranslation(new Vector3f(10f, 10f, 1505000f));
	RigidBodyControl moonControl = new RigidBodyControl(
			new PlanetCollisionShape(moon.getLocalTranslation(),
					moon.getRadius(), moonDataSource), 0f);
	moon.addControl(moonControl);
	planetAppState.addPlanet(moon);
	// add saucer
	addSaucer();
	jumpgateSpatial = assetManager.loadModel("JumpGate.j3o");
	jumpgateSpatial.setLocalScale(10000f);
	BoundingBox jbv = (BoundingBox) jumpgateSpatial.getWorldBound();
	CylinderCollisionShape jshape = new CylinderCollisionShape(
			new Vector3f(jbv.getXExtent(), jbv.getYExtent(),
					jbv.getZExtent()), 1);
	;
	jumpGateControl = new RigidBodyControl(jshape, 0);
	jumpgateSpatial.addControl(jumpGateControl);
	jumpGateControl.setMass(0f);
	jumpGateControl.setPhysicsLocation(gate1vector);
	jumpGateControl.setPhysicsRotation(new Quaternion().fromAngleAxis(
			90 * FastMath.DEG_TO_RAD, new Vector3f(1, 0, 0)));

	Spatial jumpgateSpatial2 = assetManager.loadModel("JumpGate.j3o");
	jumpgateSpatial2.setLocalScale(10000f);
	BoundingBox jbv2 = (BoundingBox) jumpgateSpatial2.getWorldBound();
	CylinderCollisionShape jshape2 = new CylinderCollisionShape(
			new Vector3f(jbv2.getXExtent(), jbv2.getYExtent(),
					jbv2.getZExtent()), 1);
	;
	Quaternion roll180 = new Quaternion();
	roll180.fromAngleAxis(FastMath.PI / 2, new Vector3f(0, 1, 0));
	jumpGateControl2 = new RigidBodyControl(jshape2, 0);
	jumpgateSpatial2.addControl(jumpGateControl2);
	jumpGateControl2.setMass(0f);
	jumpGateControl2.setPhysicsLocation(gate2vector);
	jumpGateControl2.setPhysicsRotation(new Quaternion().fromAngleAxis(
			90 * FastMath.DEG_TO_RAD, new Vector3f(1, 0, 0)));
	Spatial spaceStationSpatial = assetManager
			.loadModel("SpaceStation.blend");
	spaceStationSpatial.setLocalScale(3500f);
	BoundingBox sbv = (BoundingBox) spaceStationSpatial.getWorldBound();
	CompoundCollisionShape shape3 = new CompoundCollisionShape();
	shape3.addChildShape(
			new CylinderCollisionShape(new Vector3f(sbv.getXExtent(), sbv
					.getYExtent(), sbv.getZExtent()), 1), new Vector3f(0,
					0, 0));
	RigidBodyControl spaceStationControl = new RigidBodyControl(shape3, 0);
	spaceStationSpatial.addControl(spaceStationControl);
	spaceStationControl.setMass(0f);
	spaceStationControl.setPhysicsLocation(new Vector3f(10000f, -10f,
			705000f));
	/*
	 * BlenderKey blenderKey = new BlenderKey(
	 * "objects/creatures/alien/alienmodel.blend");
	 * 
	 * Spatial alien = (Spatial) assetManager.loadModel(blenderKey);
	 * alien.setLocalScale(20 * 2000f); alienControl = new
	 * RigidBodyControl(3 * 500f); alien.addControl(alienControl);
	 * 
	 * alienControl.setPhysicsLocation(new Vector3f(11000f, -50f, 755000f));
	 * // BlenderKey blenderKey2 = new BlenderKey(
	 * "objects/creatures/spaceman/man.mesh.xml");
	 * 
	 * Spatial man = (Spatial) assetManager.loadModel(blenderKey2);
	 * man.setLocalScale(200f); spacemanControl = new RigidBodyControl(4 *
	 * 500f); man.addControl(spacemanControl);
	 * 
	 * spacemanControl .setPhysicsLocation(new Vector3f(10700f, -590f,
	 * 775000f));
	 */
	createNewOtoBot();
	BulletAppState bas = app.getStateManager().getState(
			BulletAppState.class);
	bas.getPhysicsSpace().addAll(spaceStationSpatial);
	// bas.getPhysicsSpace().addAll(man);
	// bas.getPhysicsSpace().addAll(alien);
	bas.getPhysicsSpace().addAll(jumpgateSpatial);
	bas.getPhysicsSpace().addAll(jumpgateSpatial2);
	bas.getPhysicsSpace().addAll(moon);
	bas.getPhysicsSpace().addAll(planet);
	bas.getPhysicsSpace().setGravity(new Vector3f(0, 0, 0));
	// rootNode.attachChild(man);
	// rootNode.attachChild(alien);
	
	   fire = new ParticleEmitter("Emitter", Type.Triangle, 30);
	    Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
	    mat_red.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
	    fire.setMaterial(mat_red);
	    fire.setImagesX(2); fire.setImagesY(2); // 2x2 texture animation
	    fire.setEndColor(  new ColorRGBA(1f, 0f, 0f, 1f));   // red
	    fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow
	        fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0,2,0));
	    fire.setStartSize(1.5f);
	    fire.setEndSize(0.1f);
	    fire.setGravity(0,0,0);
	    fire.setLowLife(0.5f);
	    fire.setHighLife(3f);
	    fire.getParticleInfluencer().setVelocityVariation(0.3f);
	
	    rootNode.attachChild(fire);
		bas.getPhysicsSpace().addAll(fire);
	rootNode.attachChild(spaceStationSpatial);
	rootNode.attachChild(jumpgateSpatial);
	rootNode.attachChild(jumpgateSpatial2);
	rootNode.attachChild(moon);
	setupChaseCamera();
	registerInput();
	// prepareBullet();
	prepareEffect();
	System.out.println("prepareBullet ");
	bullet = new Sphere(32, 32, 200 * 0.4f, true, false);
	bullet.setTextureMode(TextureMode.Projected);
	bulletCollisionShape = new SphereCollisionShape(200 * 0.4f);
	matBullet = new Material(getAssetManager(),
			"Common/MatDefs/Misc/Unshaded.j3md");
	matBullet.setColor("Color", ColorRGBA.Green);
	matBullet.setColor("GlowColor", ColorRGBA.Green);
	getPhysicsSpace().addCollisionListener(app); // "this" ?
	Geometry bulletg = new Geometry("bullet", bullet);
	bulletg.setMaterial(matBullet);
	bulletg.setShadowMode(ShadowMode.CastAndReceive);

	stone_mat = new Material(assetManager,
			"Common/MatDefs/Misc/Unshaded.j3md");
	TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
	key2.setGenerateMips(true);
	Texture tex2 = assetManager.loadTexture(key2);
	stone_mat.setTexture("ColorMap", tex2);

	try {
		System.out.println("connecting to " + serverName);
		myClient = Network.connectToServer(serverName, portNumber);
		System.out.println("connected to " + serverName);
		// Serializer.registerClass(AutoControlMessage.class);
		Serializer.registerClass(ActionMessage.class);
		ClientListener cl = new ClientListener(app, myClient);
		myClient.addMessageListener(cl, ActionMessage.class);// ,
																// AutoControlMessage.class);
		myClient.addMessageListener(cl, AutoControlMessage.class);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	if (myClient != null) {
		myClient.start();
		System.out.println("myClient started");
	} else {
		System.out.println("myClient == null " + serverName);
	}
}

/*
 * public void clientConnected(Client c) {
 * System.out.println("clientConnected "); }
 */
private PhysicsSpace getPhysicsSpace() {
	return bulletAppState.getPhysicsSpace();
}

public void addSaucer() {
	ufoNode = (Node) assetManager.loadModel("usaucer_v01.j3o");
	ufoNode.setLocalScale(200f);
	BoundingBox bv = (BoundingBox) ufoNode.getWorldBound();
	CylinderCollisionShape shape = new CylinderCollisionShape(new Vector3f(
			bv.getXExtent(), bv.getYExtent(), bv.getZExtent()), 1);
	ufoControl = new RigidBodyControl(shape, 500f);
	ufoNode.addControl(ufoControl);
	System.out.println("addSaucer 200:");
	ufoControl.setPhysicsLocation(new Vector3f(10850f, -5979f, 785020f));
	BulletAppState bas = app.getStateManager().getState(
			BulletAppState.class);
	bas.getPhysicsSpace().addAll(ufoNode);
	rootNode.attachChild(ufoNode);
}

public void addNewSaucer() {
	ufoNode2 = (Node) assetManager.loadModel("usaucer_v01.j3o");
	ufoNode2.setLocalScale(700f);
	bv = (BoundingBox) ufoNode2.getWorldBound();
	shape = new CylinderCollisionShape(new Vector3f(bv.getXExtent(),
			bv.getYExtent(), bv.getZExtent()), 1);
	ufoControl2 = new RigidBodyControl(shape, 500f);
	ufoNode2.addControl(ufoControl2);
	ufoControl2.setPhysicsLocation(new Vector3f(10850f, -5979f, 785020f));
	ufoControl2.setGravity(Vector3f.ZERO);
	ufoControl2.setLinearVelocity(Vector3f.ZERO);
	ufoControl2.clearForces();
	BulletAppState bas = app.getStateManager().getState(
			BulletAppState.class);
	bas.getPhysicsSpace().addAll(ufoNode2);
	rootNode.attachChild(ufoNode2);
}

public void createNewOtoBot() {
	BlenderKey otoblenderKey = new BlenderKey("Models/Oto/Oto.mesh.xml");
	Spatial otoBot = (Spatial) assetManager.loadModel(otoblenderKey);
	otoBot.setLocalScale(600f);
	RigidBodyControl otoControl = new RigidBodyControl(30 * 500f);
	otoBot.addControl(otoControl);
	otoControl.setPhysicsLocation(new Vector3f(10800f, -579f, 785000f));
	control = otoBot.getControl(AnimControl.class);
	channel = control.createChannel();
	for (String anim : control.getAnimationNames())
		System.out.println("otoBot can:" + anim);
	channel.setAnim("pull");
	BulletAppState bas = app.getStateManager().getState(
			BulletAppState.class);
	bas.getPhysicsSpace().addAll(otoBot);
	rootNode.attachChild(otoBot);
}

public void registerInput() {
	inputManager.addMapping("fx",  new KeyTrigger(keyInput.KEY_B));
	inputManager.addListener(actionListener, "fx");
	inputManager.addMapping("shoot", new MouseButtonTrigger(
			MouseInput.BUTTON_RIGHT));
	inputManager.addListener(actionListener, "shoot");
	inputManager.addMapping("moveForward", new KeyTrigger(keyInput.KEY_UP),
			new KeyTrigger(keyInput.KEY_W));
	inputManager.addMapping("moveBackward", new KeyTrigger(
			keyInput.KEY_DOWN), new KeyTrigger(keyInput.KEY_S));
	inputManager.addMapping("moveRight",
			new KeyTrigger(keyInput.KEY_RIGHT), new KeyTrigger(
					keyInput.KEY_D));
	inputManager.addMapping("moveLeft", new KeyTrigger(keyInput.KEY_LEFT),
			new KeyTrigger(keyInput.KEY_A));
	inputManager.addMapping("moveUp", new KeyTrigger(keyInput.KEY_E));
	inputManager.addMapping("startServer", new KeyTrigger(keyInput.KEY_M));
	inputManager.addMapping("moveDown", new KeyTrigger(keyInput.KEY_C));
	inputManager.addMapping("pitch1", new KeyTrigger(keyInput.KEY_P));
	inputManager.addMapping("roll1", new KeyTrigger(keyInput.KEY_R));
	inputManager.addMapping("yaw1", new KeyTrigger(keyInput.KEY_Y));
	inputManager.addMapping("toggleRotate", new MouseButtonTrigger(
			MouseInput.BUTTON_LEFT));
	inputManager.addMapping("rotateRight", new MouseAxisTrigger(
			MouseInput.AXIS_X, true));
	inputManager.addMapping("rotateLeft", new MouseAxisTrigger(
			MouseInput.AXIS_X, false));
	inputManager.addMapping("rotateUp", new MouseAxisTrigger(
			MouseInput.AXIS_Y, true));
	inputManager.addMapping("rotateDown", new MouseAxisTrigger(
			MouseInput.AXIS_Y, false));
	inputManager.addListener(this, "moveForward", "moveBackward",
			"moveRight", "moveLeft", "moveUp", "moveDown", "pitch1",
			"roll1", "yaw1");
	inputManager.addListener(this, "rotateRight", "rotateLeft", "rotateUp",
			"rotateDown", "shoot", "fx", "startServer", "toggleRotate");
	// Toggle mouse cursor
	inputManager.addMapping("TOGGLE_CURSOR", new MouseButtonTrigger(
			MouseInput.BUTTON_LEFT), new KeyTrigger(KeyInput.KEY_T));
	inputManager.addListener(actionListener, "TOGGLE_CURSOR");
	// Toggle wireframe
	inputManager.addMapping("TOGGLE_WIREFRAME", new KeyTrigger(
			KeyInput.KEY_T));
	inputManager.addListener(actionListener, "TOGGLE_WIREFRAME");
	// Collision test
	inputManager.addMapping("COLLISION_TEST", new MouseButtonTrigger(
			MouseInput.BUTTON_RIGHT));
	inputManager.addListener(actionListener, "COLLISION_TEST");

	inputManager
			.addMapping("CharShoot", new KeyTrigger(KeyInput.KEY_SPACE));
	inputManager.addListener(this, "CharShoot");
}

public void toggleToFullscreen() {
	GraphicsDevice device = GraphicsEnvironment
			.getLocalGraphicsEnvironment().getDefaultScreenDevice();
	DisplayMode[] modes = device.getDisplayModes();
	int i = 0; // note: there are usually several, let's pick the first
	settings.setResolution(modes[i].getWidth(), modes[i].getHeight());
	settings.setFrequency(modes[i].getRefreshRate());
	settings.setBitsPerPixel(modes[i].getBitDepth());
	settings.setFullscreen(device.isFullScreenSupported());
	app.setSettings(settings);
	app.restart(); // restart the context to apply changes
}

public void simpleUpdatePlayer2(float tpf) {
	// System.out.println("LOOP simpleUpdatePlayer2 player 2");
	int speed = 8000 * 25;// *
	Vector3f camDir = cam.getDirection().clone().multLocal(speed * tpf);
	Vector3f camUp = cam.getUp().clone().mult(speed * tpf);
	Quaternion roll = new Quaternion();
	camDir.y = 0;
	ufoDirection2.set(0, 0, 0);
	// ufoControl2.setLinearVelocity(Vector3f.ZERO);
	if (doRoll == true) {
		System.out.println("doRoll == true");
		roll.fromAngleAxis(FastMath.QUARTER_PI / 3, cam.getDirection());
		ufoDirection2.set(cam.getLeft()).multLocal(-speed * tpf);
	}
	if (doRoll2 == true) {
		System.out.println("doRoll2 == true");
		roll.fromAngleAxis(-FastMath.QUARTER_PI / 3, cam.getDirection());
		ufoDirection2.set(cam.getLeft()).multLocal(speed * tpf);
	}
	if (doRoll3 == true) {
		System.out.println("doRoll3 == true");
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection2.addLocal(camUp);
	}
	if (doRoll4 == true) {
		System.out.println("doRoll4 == true");
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection2.addLocal(cam.getUp().multLocal(-speed * tpf));
	}
	if (doRoll5 == true) {
		System.out.println("doRoll5 == true");
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection2.set(camDir);
	}
	if (doRoll6 == true) {
		System.out.println("doRoll6 == true");
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection2.set(camDir.multLocal(-1f));
	}
	/*
	 * if (up) { roll.fromAngleAxis(0, cam.getDirection());
	 * ufoDirection.addLocal(camUp); } if (down) { roll.fromAngleAxis(0,
	 * cam.getDirection());
	 * ufoDirection.addLocal(cam.getUp().multLocal(-speed * tpf)); }
	 */
	if (ufoControl2 == null) {
		System.out.println("ufoControl2 == null");
	}
	ufoControl2.setPhysicsRotation(roll);
	ufoControl2.setLinearVelocity(ufoDirection2);
	if (System.currentTimeMillis() - time > 1000) {
		System.out.println("LOOP BREAK");
		ufoDirection2.set(0, 0, 0);
		ufoControl2.setLinearVelocity(Vector3f.ZERO);
		time = 0;
		player2update = false;
	}
}

public boolean isDoRoll5() {
	return doRoll5;
}

public void setDoRoll5(boolean doRoll5) {
	this.doRoll5 = doRoll5;
}

private boolean doRoll6 = false;

public boolean isDoRoll6() {
	return doRoll6;
}

public void setDoRoll6(boolean doRoll6) {
	this.doRoll6 = doRoll6;
}

public boolean isDoRoll3() {
	return doRoll3;
}

public void setDoRoll3(boolean doRoll3) {
	this.doRoll3 = doRoll3;
}

private boolean doRoll4 = false;

public boolean isDoRoll4() {
	return doRoll4;
}

public void setDoRoll4(boolean doRoll4) {
	this.doRoll4 = doRoll4;
}

public boolean isDoRoll2() {
	return doRoll2;
}

public void setDoRoll2(boolean doRoll2) {
	this.doRoll2 = doRoll2;
}

private boolean doRoll = false;

public boolean isDoRoll() {
	return doRoll;
}

public void setDoRoll(boolean doRoll) {
	this.doRoll = doRoll;
}

@Override
public void simpleUpdate(float tpf) {
	playtime = System.currentTimeMillis() - starttime;
	int speed = 25 * 80000;
	Vector3f camDir = cam.getDirection().clone().multLocal(speed * tpf);
	Vector3f camUp = cam.getUp().clone().mult(speed * tpf);
	Quaternion roll = new Quaternion();
	Quaternion yaw = new Quaternion();
	Quaternion pitch = new Quaternion();
	camDir.y = 0;
	ufoDirection.set(0, 0, 0);
	ufoControl.setLinearVelocity(Vector3f.ZERO);

	if (fx) {
		System.out.println("FX");
		effect.setLocalTranslation(ufoControl.getPhysicsLocation());
		effect.emitAllParticles();
	}
	if (left) {
		roll.fromAngleAxis(-FastMath.QUARTER_PI / 3, cam.getDirection());
		ufoDirection.set(cam.getLeft().multLocal(speed * tpf));
	}
	if (right) {
		roll.fromAngleAxis(FastMath.QUARTER_PI / 3, cam.getDirection());
		ufoDirection.set(cam.getLeft()).multLocal(-speed * tpf);
	}
	if (up) {
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection.addLocal(camUp);
	}
	if (down) {
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection.addLocal(cam.getUp().multLocal(-speed * tpf));
	}
	if (forward) {
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection.set(camDir);
	}
	if (backward) {
		roll.fromAngleAxis(0, cam.getDirection());
		ufoDirection.set(camDir.multLocal(-1f));
	}
	if (pitch1) {
		System.out.println("PITCH1");
		roll.fromAngleAxis(-FastMath.QUARTER_PI / 2, cam.getDirection()
				.cross(Vector3f.UNIT_Y));
	}
	if (yaw1) {
		System.out.println("yaw1");
		// pitch.fromAngleAxis(angle, axis)
		// roll.fromAngleAxis(-FastMath.QUARTER_PI, );
		roll.fromAngles(0, FastMath.QUARTER_PI / 2, 0);
		// ufoControl.setP
		// ufoControl.setPhysicsLocation(Vector3f.UNIT_Y);
		// ufoControl.setPhysicsRotation(roll);

	}
	if (roll1) {
		System.out.println("roll1");
		roll.fromAngleAxis(-FastMath.QUARTER_PI / 2, cam.getDirection());
	}
	ufoControl.setPhysicsRotation(roll);
	ufoControl.setLinearVelocity(ufoDirection);
	CollisionResults results = new CollisionResults();

	// System.out.println("1 #Collisions between" + ufoNode.getName()
	// + " and " + jumpgateSpatial.getName() + ": " + results.size());
	ufoNode.collideWith((BoundingBox) jumpgateSpatial.getWorldBound(),
			results);
	// System.out.println("2 #Collisions between" + ufoNode.getName()
	// + " and " + jumpgateSpatial.getName() + ": " + results.size());
	CollisionResults results2 = new CollisionResults();

	// Use the results

	if (results.size() > 0 && playtime > 50000) {
		System.out.println("playtime" + playtime);
		System.out.println("#Collisions between" + ufoNode.getName()
				+ " and " + jumpgateSpatial.getName() + ": "
				+ results.size());

		// how to react when a collision was detected
		CollisionResult closest = results.getClosestCollision();
		System.out.println("What was hit? "
				+ closest.getGeometry().getName());
		System.out
				.println("Where was it hit? " + closest.getContactPoint());
		System.out.println("Distance? " + closest.getDistance());
		ufoControl
				.setPhysicsLocation(jumpGateControl2.getPhysicsLocation());
		System.out.println("Warped");

	} else {
		// how to react when no collision occured
	}

	if (results2.size() > 0) {
		System.out.println("Number of Collisions between"
				+ ufoNode.getName() + " and " + moon.getName() + ": "
				+ results2.size());

		// how to react when a collision was detected
		CollisionResult closest2 = results2.getClosestCollision();
		System.out.println("What was hit? "
				+ closest2.getGeometry().getName());
		System.out.println("Where was it hit? "
				+ closest2.getContactPoint());
		System.out.println("Distance? " + closest2.getDistance());
	}
	if (myClient != null) {
		Message message = new ActionMessage(1, myClient.getId(), right, 1);
		Message message2 = new ActionMessage(2, myClient.getId(), left, 2);
		Message message3 = new ActionMessage(2, myClient.getId(), up, 3);
		Message message4 = new ActionMessage(2, myClient.getId(), down, 4);
		Message message5 = new ActionMessage(2, myClient.getId(), forward,
				5);
		Message message6 = new ActionMessage(2, myClient.getId(), backward,
				6);
		if (myClient != null) {
			myClient.send(message);
			myClient.send(message2);
			myClient.send(message3);
			myClient.send(message4);
			myClient.send(message5);
			myClient.send(message6);
		}
		if (player2update == true) {
			System.out.println("simpleUpdatePlayer2 player 2 "
					+ message.toString());
			time = System.currentTimeMillis();
			simpleUpdatePlayer2(tpf);
		}
	}
}

public boolean isPlayer2update() {
	return player2update;
}

public void setPlayer2update(boolean player2update) {
	this.player2update = player2update;
}

private void createOto() {
	BlenderKey blenderKey = new BlenderKey("Models/Oto/Oto.mesh.xml");
	Spatial man = (Spatial) assetManager.loadModel(blenderKey);
	man.setLocalTranslation(new Vector3f(69, 15, -60));
	man.setShadowMode(ShadowMode.CastAndReceive);
	rootNode.attachChild(man);

}

Material stone_mat;
private static final Sphere sphere2;
private RigidBodyControl ball_phy;

static {
	/** Initialize the cannon ball geometry */
	sphere2 = new Sphere(32, 32, 0.4f, true, false);
	sphere2.setTextureMode(TextureMode.Projected);
	/** Initialize the brick geometry */
	// box.scaleTextureCoordinates(new Vector2f(1f, .5f));
	/** Initialize the floor geometry */
	// floor = new Box(10f, 0.1f, 5f);
	// floor.scaleTextureCoordinates(new Vector2f(3, 6));
}

/**
 * This method creates one individual physical cannon ball. By defaul, the
 * ball is accelerated and flies from the camera position in the camera
 * direction.
 */
public void makeCannonBall() {
	/** Create a cannon ball geometry and attach to scene graph. */
	Geometry ball_geo = new Geometry("cannon ball", sphere2);
	ball_geo.setMaterial(stone_mat);
	rootNode.attachChild(ball_geo);
	/** Position the cannon ball */
	ball_geo.setLocalTranslation(cam.getLocation());
	/** Make the ball physcial with a mass > 0.0f */
	ball_phy = new RigidBodyControl(1f);
	/** Add physical ball to physics space. */
	ball_geo.addControl(ball_phy);
	bulletAppState.getPhysicsSpace().add(ball_phy);
	/** Accelerate the physcial ball to shoot it. */
	ball_phy.setLinearVelocity(cam.getDirection().mult(25));
}

public void onAnalog(String name, float value, float tpf) {

	if (name.equals("rotateRight") && rotate) {
		ufoNode.rotate(0, 1 * tpf, 0);
	}
	if (name.equals("rotateLeft") && rotate) {
		ufoNode.rotate(0, -1 * tpf, 0);
	}
	if (name.equals("rotateUp") && rotate) {
		ufoNode.rotate(0, 0, -1 * tpf);
	}
	if (name.equals("rotateDown") && rotate) {
		ufoNode.rotate(0, 0, 1 * tpf);
	}
}

private boolean fx = false;
public void onAction(String name, boolean keyPressed, float tpf) {

	Message message = new ActionMessage(name, keyPressed);
	if (myClient != null) {
		myClient.send(message);
	}

	if (name.equals("moveLeft")) {
		if (keyPressed) {
			left = true;
		} else {
			left = false;
		}
	} else if (name.equals("moveRight")) {
		if (keyPressed) {
			right = true;
		} else {
			right = false;
		}
	} else if (name.equals("fx")) {
		if (keyPressed) {
			fx = true;
		} else {
			fx = false;
		}
	}
	
	else if (name.equals("moveUp")) {
		if (keyPressed) {
			up = true;
		} else {
			up = false;
		}
	} else if (name.equals("moveDown")) {
		if (keyPressed) {
			down = true;
		} else {
			down = false;
		}
	} else if (name.equals("moveForward")) {
		if (keyPressed) {
			forward = true;
		} else {
			forward = false;
		}
	} else if (name.equals("moveBackward")) {
		if (keyPressed) {
			backward = true;
		} else {
			backward = false;
		}
	}

	if (name.equals("shoot") && !keyPressed) {
		makeCannonBall();
	}

	else if (name.equals("pitch1")) {
		if (keyPressed) {
			pitch1 = true;
		} else {
			pitch1 = false;
		}
	} else if (name.equals("CharShoot") && !keyPressed) {
		bulletControl();
	} else if (name.equals("roll1")) {
		if (keyPressed) {
			roll1 = true;
		} else {
			roll1 = false;
		}
	} else if (name.equals("yaw1")) {
		if (keyPressed) {
			yaw1 = true;
		} else {
			yaw1 = false;
		}
	}
	// toggling rotation on or off
	if (name.equals("toggleRotate") && keyPressed) {
		rotate = true;
		inputManager.setCursorVisible(false);
	}
	if (name.equals("toggleRotate") && !keyPressed) {
		rotate = false;
		inputManager.setCursorVisible(true);
	}
	if (name.equals("TOGGLE_CURSOR") && !keyPressed) {
		if (inputManager.isCursorVisible()) {
			inputManager.setCursorVisible(false);
		} else {
			inputManager.setCursorVisible(true);
		}
	}
	if (name.equals("TOGGLE_WIREFRAME") && !keyPressed) {
		for (Planet planet : planetAppState.getPlanets()) {
			planet.toogleWireframe();
		}
	}
	if (name.equals("COLLISION_TEST") && !keyPressed) {
		CollisionResults results = new CollisionResults();
		Ray ray = new Ray(cam.getLocation(), cam.getDirection());
		// Test collision with closest planet's terrain only
		planetAppState.getNearestPlanet().getTerrainNode()
				.collideWith(ray, results);
		System.out.println("----- Collisions? " + results.size() + "-----");
		for (int i = 0; i < results.size(); i++) {
			// For each hit, we know distance, impact point, name of
			// geometry.
			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) {
			// The closest collision point is what was truly hit:
			CollisionResult closest = results.getClosestCollision();
			// Let's interact - we mark the hit with a red dot.
			mark.setLocalTranslation(closest.getContactPoint());
			rootNode.attachChild(mark);
		} else {
			// No hits? Then remove the red mark.
			rootNode.detachChild(mark);
		}
	}
}

private void prepareBullet() {
	System.out.println("prepareBullet ");
	bullet = new Sphere(5 * 32, 5 * 32, 5 * 0.4f, true, false);
	bullet.setTextureMode(TextureMode.Projected);
	bulletCollisionShape = new SphereCollisionShape(5 * 0.4f);
	matBullet = new Material(getAssetManager(),
			"Common/MatDefs/Misc/Unshaded.j3md");
	matBullet.setColor("Color", ColorRGBA.Green);
	matBullet.setColor("GlowColor", ColorRGBA.Green);
	getPhysicsSpace().addCollisionListener(this);
}
RigidBodyControl bulletControl;
private void bulletControl() {
	// System.out.println("bulletControl ");
	// shootingChannel.setAnim("Dodge", 0.1f);
	// shootingChannel.setLoopMode(LoopMode.DontLoop);
	Geometry bulletg = new Geometry("bullet", bullet);
	bulletg.setMaterial(matBullet);
	bulletg.setShadowMode(ShadowMode.CastAndReceive);
	bulletControl = new BombControl(bulletCollisionShape,
			1);
	bulletg.addControl(bulletControl);
	Vector3f camDir = cam.getDirection().clone().multLocal(3000);
	camDir.y = 0;
	bulletControl.setPhysicsLocation(ufoControl.getPhysicsLocation()
			.addLocal(camDir));
	bulletControl.setCcdMotionThreshold(0.1f);
	bulletControl.setLinearVelocity(cam.getDirection().mult(1200));
	BulletAppState bas = app.getStateManager().getState(
			BulletAppState.class);
	bas.getPhysicsSpace().add(bulletControl);
	rootNode.attachChild(bulletg);
}

private ActionListener actionListener = new ActionListener() {
	public void onAction(String name, boolean pressed, float tpf) {
		if (name.equals("TOGGLE_CURSOR") && !pressed) {
			if (inputManager.isCursorVisible()) {
				inputManager.setCursorVisible(false);
			} else {
				inputManager.setCursorVisible(true);
			}
		}
		if (name.equals("TOGGLE_WIREFRAME") && !pressed) {
			for (Planet planet : planetAppState.getPlanets()) {
				planet.toogleWireframe();
			}
		}
		if (name.equals("COLLISION_TEST") && !pressed) {
			CollisionResults results = new CollisionResults();
			Ray ray = new Ray(cam.getLocation(), cam.getDirection());
			// Test collision with closest planet's terrain only
			planetAppState.getNearestPlanet().getTerrainNode()
					.collideWith(ray, results);
			System.out.println("----- Collisions? " + results.size()
					+ "-----");
			for (int i = 0; i < results.size(); i++) {
				// For each hit, we know distance, impact point, name of
				// geometry.
				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) {
				// The closest collision point is what was truly hit:
				CollisionResult closest = results.getClosestCollision();
				// Let's interact - we mark the hit with a red dot.
				mark.setLocalTranslation(closest.getContactPoint());
				rootNode.attachChild(mark);
			} else {
				// No hits? Then remove the red mark.
				rootNode.detachChild(mark);
			}
		}
	}
};

}

[/java]

[video]- YouTube