package sg.env;

import sg.SpaceGame;

import com.jme.image.Texture;
import com.jme.scene.Node;
import com.jme.scene.Skybox;
import com.jme.util.TextureManager;

public class Environment extends Node {
	private static final long serialVersionUID = 1L;

	public Environment(){
		buildSkyBox();
	}
	
	private void buildSkyBox() {
		Skybox skybox = new Skybox("skybox", 500, 500, 500);
		Texture north = TextureManager.loadTexture(
				SpaceGame.class.getClassLoader().getResource(
				"sg/data/skybox/advanced/front.png"),
                Texture.MinificationFilter.BilinearNearestMipMap,
                Texture.MagnificationFilter.Bilinear);
		Texture south = TextureManager.loadTexture(
				SpaceGame.class.getClassLoader().getResource(
				"sg/data/skybox/advanced/rest.png"),
                Texture.MinificationFilter.BilinearNearestMipMap,
                Texture.MagnificationFilter.Bilinear);
		Texture east = TextureManager.loadTexture(
				SpaceGame.class.getClassLoader().getResource(
				"sg/data/skybox/advanced/rest.png"),
                Texture.MinificationFilter.BilinearNearestMipMap,
                Texture.MagnificationFilter.Bilinear);
		Texture west = TextureManager.loadTexture(
				SpaceGame.class.getClassLoader().getResource(
				"sg/data/skybox/advanced/rest.png"),
                Texture.MinificationFilter.BilinearNearestMipMap,
                Texture.MagnificationFilter.Bilinear);
		Texture up = TextureManager.loadTexture(
				SpaceGame.class.getClassLoader().getResource(
				"sg/data/skybox/advanced/rest.png"),
                Texture.MinificationFilter.BilinearNearestMipMap,
                Texture.MagnificationFilter.Bilinear);
		Texture down = TextureManager.loadTexture(
				SpaceGame.class.getClassLoader().getResource(
				"sg/data/skybox/advanced/rest.png"),
                Texture.MinificationFilter.BilinearNearestMipMap,
                Texture.MagnificationFilter.Bilinear);
		skybox.setTexture(Skybox.Face.North, north);
		skybox.setTexture(Skybox.Face.West, west);
		skybox.setTexture(Skybox.Face.South, south);
		skybox.setTexture(Skybox.Face.East, east);
		skybox.setTexture(Skybox.Face.Up, up);
		skybox.setTexture(Skybox.Face.Down, down);
		skybox.preloadTextures();
		skybox.updateRenderState();
		this.attachChild(skybox);
	}
}
