package sg;

import sg.env.Environment;
import sg.input.SGFirstPersonHandler;
import sg.util.SGUtil;

import com.jme.scene.Node;
import com.jme.math.Vector3f;
import com.jmex.physics.DynamicPhysicsNode;
import com.jmex.physics.StaticPhysicsNode;
import com.jmex.physics.util.SimplePhysicsGame;

public class SpaceGame extends SimplePhysicsGame {
	private StaticPhysicsNode staticNode;
	private DynamicPhysicsNode dynamicNode;
	private Environment environment;
	private Node ship;
	private DynamicPhysicsNode shipNode;
	private SGFirstPersonHandler firstPersonHandler;

	public static void main(String[] args) {
		//Logger.getLogger("").setLevel( Level.WARNING );
		SpaceGame game = new SpaceGame();
		game.setConfigShowMode(ConfigShowMode.AlwaysShow);
		game.start(); 
	}

	protected void simpleInitGame() {
		display.setTitle("SpaceGame");

		//physics
		getPhysicsSpace().setDirectionalGravity(new Vector3f(0f, 0f, 0f));
		staticNode = getPhysicsSpace().createStaticNode();
		rootNode.attachChild(staticNode);
		dynamicNode = getPhysicsSpace().createDynamicNode();
		rootNode.attachChild(dynamicNode);
		shipNode = getPhysicsSpace().createDynamicNode();
		rootNode.attachChild(shipNode);

		//environment
		environment = new Environment(rootNode);
		rootNode.attachChild(environment);

		//light
		//TODO

		//ship
		ship = SGUtil.loadModel("sg/data/models/ships/G6.3ds");
		ship.setLocalTranslation(new Vector3f(0,0,-40));
		shipNode.attachChild(ship);
		
		//controll
		firstPersonHandler = new SGFirstPersonHandler(ship, shipNode, cam);
	}

	public void simpleUpdate(){
		environment.update();
		firstPersonHandler.update(0.1f);
	}
}