@author normenhansen
*/
public class Main extends SimpleApplication {
private Geometry geom1;
private TextureKey texKey1;
private Texture tex1;
private Material mat1;
private Geometry geom2;
private TextureKey texKey2;
private Texture tex2;
private Material mat2;
private Geometry geom3;
private TextureKey texKey3;
private Texture tex3;
private Material mat3;
private Geometry geom4;
private TextureKey texKey4;
private Texture tex4;
private Material mat4;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
flyCam.setDragToRotate(true);
MyAppState myAppStateController = new MyAppState();
getStateManager().attach(myAppStateController);
Box b1 = new Box(Vector3f.ZERO, 1, 1, 1);
geom1 = new Geometry("Box", b1);
texKey1 = new TextureKey("Textures/Sky/Lagoon/lagoon_west.jpg", true);
tex1 = assetManager.loadTexture(texKey1);
mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat1.setColor("Color", ColorRGBA.Blue);
mat1.setTexture("ColorMap", tex1);
geom1.setMaterial(mat1);
geom1.setLocalTranslation(-2f, -2f, 0f);
rootNode.attachChild(geom1);
Box b2 = new Box(Vector3f.ZERO, 1, 1, 1);
geom2 = new Geometry("Box", b2);
texKey2 = new TextureKey("Textures/Sky/Lagoon/lagoon_east.jpg", true);
tex2 = assetManager.loadTexture(texKey2);
mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat2.setColor("Color", ColorRGBA.Blue);
mat2.setTexture("ColorMap", tex2);
geom2.setMaterial(mat2);
geom2.setLocalTranslation(2f, -2f, 0f);
rootNode.attachChild(geom2);
Box b3 = new Box(Vector3f.ZERO, 1, 1, 1);
geom3 = new Geometry("Box", b3);
texKey3 = new TextureKey("Textures/Sky/Lagoon/lagoon_north.jpg", true);
tex3 = assetManager.loadTexture(texKey3);
mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat3.setColor("Color", ColorRGBA.Blue);
mat3.setTexture("ColorMap", tex3);
geom3.setMaterial(mat3);
geom3.setLocalTranslation(-2f, 2f, 0f);
rootNode.attachChild(geom3);
Box b4 = new Box(Vector3f.ZERO, 1, 1, 1);
geom4 = new Geometry("Box", b4);
texKey4 = new TextureKey("Textures/Sky/Lagoon/lagoon_south.jpg", true);
tex4 = assetManager.loadTexture(texKey4);
mat4 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat4.setColor("Color", ColorRGBA.Blue);
mat4.setTexture("ColorMap", tex4);
geom4.setMaterial(mat4);
geom4.setLocalTranslation(2f, 2f, 0f);
rootNode.attachChild(geom4);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
private class MyAppState extends AbstractAppState {
SimpleApplication app;
float CAMERA_VIEW_ANGLE = 45f;
float MIN_VIEW_DISTANCE = 1f;
float MAX_VIEW_DISTANCE = 100f;
@Override
public void initialize(AppStateManager stateManager, Application a) {
super.initialize(stateManager, a);
this.app = (SimpleApplication) a;
Camera cam = app.getCamera();
cam.setFrustumPerspective(CAMERA_VIEW_ANGLE,
cam.getWidth() / cam.getHeight(), MIN_VIEW_DISTANCE,
MAX_VIEW_DISTANCE);
}
}
}
[/java]