Skip to content

Runtime usage

James edited this page Jul 15, 2022 · 17 revisions

Including in Project

To use this library in your gradle project, add the version number and jitpack repository information to your root build.gradle file:

allprojects {
    ext {
    	...
        mundusGdxRuntime = 'v0.3.1'
    }
    repositories {
	...
	maven { url 'https://jitpack.io' }
    }
}

And add the dependency in your core project:

dependencies {
    ...
    api "com.github.jamestkhan.mundus:gdx-runtime:$mundusGdxRuntime"
}

Usage

Copy your mundus project into your core/assets/mundus directory.

public class LibGDXMundusExample extends ApplicationAdapter {

        private ModelBatch batch;

        private Mundus mundus;
        private Scene scene;

        private FirstPersonCameraController controller;

        @Override
        public void create () {
                batch = new ModelBatch();

                mundus = new Mundus(Gdx.files.internal("mundus"));
                scene = mundus.loadScene("Main Scene.mundus", batch);

                scene.cam.position.set(230, 150, 190);
                scene.cam.direction.rotate(Vector3.Y, 70);
                scene.cam.direction.rotate(Vector3.Z, -20);

                controller = new FirstPersonCameraController(scene.cam);
                controller.setVelocity(200f);
                Gdx.input.setInputProcessor(controller);
        }

        @Override
        public void render () {
                ScreenUtils.clear(1, 0, 0, 1);

                Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

                controller.update();
                scene.sceneGraph.update();
                scene.render();
        }

        @Override
        public void dispose () {
                mundus.dispose();
                batch.dispose();
        }
}