SHARE
TWEET

Untitled

a guest Sep 14th, 2014 160 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Test extends ApplicationAdapter {
  2.  
  3.         private ModelBatch modelBatch;
  4.         private PerspectiveCamera camera;
  5.         private ModelInstance modelInstance;
  6.         private AssetManager assets;
  7.         private CameraInputController cameraController;
  8.         private Viewport viewport;
  9.         private Environment environment;
  10.  
  11.         @Override
  12.         public void create() {
  13.                 assets = new AssetManager();
  14.                 // assets.load("BrickHouse.g3db", Model.class);
  15.                 // assets.finishLoading();
  16.                 // modelInstance = new ModelInstance(assets.get("BrickHouse.g3db",
  17.                 // Model.class));
  18.                 modelBatch = new ModelBatch();
  19.                 camera = new PerspectiveCamera();
  20.                 cameraController = new CameraInputController(camera);
  21.                 camera.position.set(10, 10, 10);
  22.                 camera.lookAt(0, 0, 0);
  23.                 Gdx.input.setInputProcessor(cameraController);
  24.                 viewport = new ScreenViewport(camera);
  25.                 ModelBuilder builder = new ModelBuilder();
  26.                 modelInstance = new ModelInstance(builder.createBox(1, 1, 1, new Material(), Usage.Position | Usage.Normal), new Matrix4());
  27.                 environment = new Environment();
  28.                 environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
  29.                 environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
  30.         }
  31.  
  32.         @Override
  33.         public void render() {
  34.                 Gdx.gl.glClearColor(0, 0, 0, 1);
  35.                 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  36.  
  37.                 cameraController.update();
  38.                 camera.update(true);
  39.  
  40.                 modelBatch.begin(camera);
  41.                 modelBatch.render(modelInstance, environment);
  42.                 modelBatch.end();
  43.         }
  44.  
  45.         @Override
  46.         public void resize(int width, int height) {
  47.                 viewport.update(width, height);
  48.         }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top