- public class Test extends ApplicationAdapter {
- private ModelBatch modelBatch;
- private PerspectiveCamera camera;
- private ModelInstance modelInstance;
- private AssetManager assets;
- private CameraInputController cameraController;
- private Viewport viewport;
- private Environment environment;
- @Override
- public void create() {
- assets = new AssetManager();
- // assets.load("BrickHouse.g3db", Model.class);
- // assets.finishLoading();
- // modelInstance = new ModelInstance(assets.get("BrickHouse.g3db",
- // Model.class));
- modelBatch = new ModelBatch();
- camera = new PerspectiveCamera();
- cameraController = new CameraInputController(camera);
- camera.position.set(10, 10, 10);
- camera.lookAt(0, 0, 0);
- Gdx.input.setInputProcessor(cameraController);
- viewport = new ScreenViewport(camera);
- ModelBuilder builder = new ModelBuilder();
- modelInstance = new ModelInstance(builder.createBox(1, 1, 1, new Material(), Usage.Position | Usage.Normal), new Matrix4());
- environment = new Environment();
- environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
- environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
- }
- @Override
- public void render() {
- Gdx.gl.glClearColor(0, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- cameraController.update();
- camera.update(true);
- modelBatch.begin(camera);
- modelBatch.render(modelInstance, environment);
- modelBatch.end();
- }
- @Override
- public void resize(int width, int height) {
- viewport.update(width, height);
- }
- }
SHARE
TWEET
Untitled
a guest
Sep 14th, 2014
160
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
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.
