Search in sources :

Example 1 with CameraInputController

use of com.badlogic.gdx.graphics.g3d.utils.CameraInputController in project libgdx by libgdx.

the class BulletTestCollection method create.

@Override
public void create() {
    if (app == null) {
        app = Gdx.app;
        tests[testIndex].create();
    }
    cameraController = new CameraInputController(tests[testIndex].camera);
    cameraController.activateKey = Keys.CONTROL_LEFT;
    cameraController.autoUpdate = false;
    cameraController.forwardTarget = false;
    cameraController.translateTarget = false;
    Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this)));
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
    hud = new Stage();
    hud.addActor(fpsLabel = new Label(" ", new Label.LabelStyle(font, Color.WHITE)));
    fpsLabel.setPosition(0, 0);
    hud.addActor(titleLabel = new Label(tests[testIndex].getClass().getSimpleName(), new Label.LabelStyle(font, Color.WHITE)));
    titleLabel.setY(hud.getHeight() - titleLabel.getHeight());
    hud.addActor(instructLabel = new Label("A\nB\nC\nD\nE\nF", new Label.LabelStyle(font, Color.WHITE)));
    instructLabel.setY(titleLabel.getY() - instructLabel.getHeight());
    instructLabel.setAlignment(Align.top | Align.left);
    instructLabel.setText(tests[testIndex].instructions);
}
Also used : CameraInputController(com.badlogic.gdx.graphics.g3d.utils.CameraInputController) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) GestureDetector(com.badlogic.gdx.input.GestureDetector) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 2 with CameraInputController

use of com.badlogic.gdx.graphics.g3d.utils.CameraInputController in project libgdx by libgdx.

the class TextureRegion3DTest method create.

@Override
public void create() {
    Gdx.gl.glClearColor(0.2f, 0.3f, 1.0f, 0.f);
    atlas = new TextureAtlas(Gdx.files.internal("data/testpack"));
    regions = atlas.getRegions();
    modelBatch = new ModelBatch(new DefaultShaderProvider());
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(10f, 10f, 10f);
    cam.lookAt(0, 0, 0);
    cam.near = 0.1f;
    cam.far = 300f;
    cam.update();
    ModelBuilder modelBuilder = new ModelBuilder();
    final Material material = new Material(ColorAttribute.createDiffuse(1f, 1f, 1f, 1f), new TextureAttribute(TextureAttribute.Diffuse));
    model = modelBuilder.createBox(5f, 5f, 5f, material, Usage.Position | Usage.Normal | Usage.TextureCoordinates);
    instance = new ModelInstance(model);
    attribute = instance.materials.get(0).get(TextureAttribute.class, TextureAttribute.Diffuse);
    Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
Also used : DefaultShaderProvider(com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider) Material(com.badlogic.gdx.graphics.g3d.Material) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) CameraInputController(com.badlogic.gdx.graphics.g3d.utils.CameraInputController) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Environment(com.badlogic.gdx.graphics.g3d.Environment) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute) TextureAttribute(com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute)

Example 3 with CameraInputController

use of com.badlogic.gdx.graphics.g3d.utils.CameraInputController in project libgdx by libgdx.

the class Basic3DTest method create.

@Override
public void create() {
    modelBatch = new ModelBatch(new DefaultShaderProvider());
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(10f, 10f, 10f);
    cam.lookAt(0, 0, 0);
    cam.near = 1f;
    cam.far = 30f;
    cam.update();
    ModelBuilder modelBuilder = new ModelBuilder();
    model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal);
    instance = new ModelInstance(model);
    Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) DefaultShaderProvider(com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) CameraInputController(com.badlogic.gdx.graphics.g3d.utils.CameraInputController) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Environment(com.badlogic.gdx.graphics.g3d.Environment) Material(com.badlogic.gdx.graphics.g3d.Material) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)

Example 4 with CameraInputController

use of com.badlogic.gdx.graphics.g3d.utils.CameraInputController in project libgdx by libgdx.

the class BaseG3dTest method create.

@Override
public void create() {
    if (assets == null)
        assets = new AssetManager();
    modelBatch = new ModelBatch();
    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(10f, 10f, 10f);
    cam.lookAt(0, 0, 0);
    cam.near = 0.1f;
    cam.far = 1000f;
    cam.update();
    createAxes();
    Gdx.input.setInputProcessor(inputController = new CameraInputController(cam));
}
Also used : CameraInputController(com.badlogic.gdx.graphics.g3d.utils.CameraInputController) AssetManager(com.badlogic.gdx.assets.AssetManager) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera)

Example 5 with CameraInputController

use of com.badlogic.gdx.graphics.g3d.utils.CameraInputController in project libgdx by libgdx.

the class Basic3DSceneTest method create.

@Override
public void create() {
    modelBatch = new ModelBatch();
    lights = new Environment();
    lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
    lights.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(0f, 7f, 10f);
    cam.lookAt(0, 0, 0);
    cam.near = 0.1f;
    cam.far = 300f;
    cam.update();
    camController = new CameraInputController(cam);
    Gdx.input.setInputProcessor(camController);
    assets = new AssetManager();
    assets.load("data/g3d/invaders.g3dj", Model.class);
    loading = true;
}
Also used : CameraInputController(com.badlogic.gdx.graphics.g3d.utils.CameraInputController) AssetManager(com.badlogic.gdx.assets.AssetManager) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Environment(com.badlogic.gdx.graphics.g3d.Environment) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)

Aggregations

CameraInputController (com.badlogic.gdx.graphics.g3d.utils.CameraInputController)9 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)8 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)8 Environment (com.badlogic.gdx.graphics.g3d.Environment)6 Material (com.badlogic.gdx.graphics.g3d.Material)6 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)6 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)6 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)6 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)5 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)5 DefaultShaderProvider (com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider)4 AssetManager (com.badlogic.gdx.assets.AssetManager)2 Cubemap (com.badlogic.gdx.graphics.Cubemap)1 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1 Texture (com.badlogic.gdx.graphics.Texture)1 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)1 Renderable (com.badlogic.gdx.graphics.g3d.Renderable)1 CubemapAttribute (com.badlogic.gdx.graphics.g3d.attributes.CubemapAttribute)1