Search in sources :

Example 11 with Camera

use of com.badlogic.gdx.graphics.Camera in project libgdx by libgdx.

the class Stage method draw.

public void draw() {
    Camera camera = viewport.getCamera();
    camera.update();
    if (!root.isVisible())
        return;
    Batch batch = this.batch;
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    root.draw(batch, 1);
    batch.end();
    if (debug)
        drawDebug();
}
Also used : Batch(com.badlogic.gdx.graphics.g2d.Batch) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Camera(com.badlogic.gdx.graphics.Camera) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera)

Example 12 with Camera

use of com.badlogic.gdx.graphics.Camera in project Entitas-Java by Rubentxu.

the class MatchOneState method initialize.

@Override
public void initialize() {
    entitas = new Entitas();
    EntityIndexExtension.addEntityIndices(entitas);
    // Input
    World physics = engine.getManager(BasePhysicsManager.class).getPhysics();
    BodyBuilder bodyBuilder = engine.getManager(BasePhysicsManager.class).getBodyBuilder();
    Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera();
    Batch batch = engine.getManager(BaseSceneManager.class).getBatch();
    EmitInputSystem emitInputSystem = new EmitInputSystem(entitas.input, physics, camera);
    systems.add(new ProcessInputSystem(entitas)).add(new GameBoardSystem(entitas.game)).add(new FallSystem(entitas.game)).add(new FillSystem(entitas.game)).add(new ScoreSystem(entitas)).add(new RemoveViewSystem(entitas.game, physics)).add(new AddViewSystem(entitas.game, assetsManager, bodyBuilder)).add(new AnimatePositionSystem(entitas.game)).add(new DestroySystem(entitas.game)).add(new RendererSystem(entitas, camera, batch, physics));
}
Also used : BaseSceneManager(com.ilargia.games.entitas.egdx.base.managers.BaseSceneManager) World(com.badlogic.gdx.physics.box2d.World) BodyBuilder(com.ilargia.games.entitas.egdx.base.util.BodyBuilder) Batch(com.badlogic.gdx.graphics.g2d.Batch) BasePhysicsManager(com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager) Camera(com.badlogic.gdx.graphics.Camera) Entitas(com.ilargia.games.entitas.core.Entitas)

Example 13 with Camera

use of com.badlogic.gdx.graphics.Camera in project nhglib by VoidZombie.

the class GraphicsSystem method rebuildCache.

private void rebuildCache(RenderableProvider... renderableProviders) {
    Array<ModelCache> previousModelCaches = new Array<>(staticCaches);
    for (int i = 0; i < cameras.size; i++) {
        ModelCache previousModelCache = previousModelCaches.get(i);
        ModelCache staticCache = staticCaches.get(i);
        Camera camera = cameras.get(i);
        previousModelCache.begin(camera);
        previousModelCache.add(staticCache);
        previousModelCache.end();
        staticCache.begin(camera);
        staticCache.add(previousModelCache);
        for (RenderableProvider provider : renderableProviders) {
            staticCache.add(provider);
        }
        staticCache.end();
    }
}
Also used : Array(com.badlogic.gdx.utils.Array) RenderableProvider(com.badlogic.gdx.graphics.g3d.RenderableProvider) Camera(com.badlogic.gdx.graphics.Camera) ModelCache(com.badlogic.gdx.graphics.g3d.ModelCache)

Example 14 with Camera

use of com.badlogic.gdx.graphics.Camera in project nhglib by VoidZombie.

the class GraphicsSystem method end.

@Override
protected void end() {
    super.end();
    for (int i = 0; i < cameras.size; i++) {
        Camera camera = cameras.get(i);
        ModelBatch modelBatch = modelBatches.get(i);
        ModelCache dynamicCache = dynamicCaches.get(i);
        ModelCache staticCache = staticCaches.get(i);
        dynamicCache.end();
        GLUtils.clearScreen(clearColor);
        modelBatch.begin(camera);
        modelBatch.render(staticCache, environment);
        modelBatch.render(dynamicCache, environment);
        modelBatch.end();
        if (Nhg.debugDrawPhysics && debugDrawer != null) {
            debugDrawer.begin(camera);
            physicsSystem.debugDraw();
            debugDrawer.end();
        }
    }
}
Also used : ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Camera(com.badlogic.gdx.graphics.Camera) ModelCache(com.badlogic.gdx.graphics.g3d.ModelCache)

Example 15 with Camera

use of com.badlogic.gdx.graphics.Camera in project nhglib by VoidZombie.

the class CameraComponentJson method parse.

@Override
public void parse(JsonValue jsonValue) {
    CameraComponent cameraComponent = entities.createComponent(entity, CameraComponent.class);
    Camera camera;
    float nearPlane = jsonValue.getFloat("nearPlane");
    float farPlane = jsonValue.getFloat("farPlane");
    CameraComponent.Type type = CameraComponent.Type.fromString(jsonValue.getString("cameraType"));
    switch(type) {
        default:
        case PERSPECTIVE:
            float fieldOfView = jsonValue.getFloat("fieldOfView");
            camera = new PerspectiveCamera(fieldOfView, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
            break;
        case ORTHOGRAPHIC:
            camera = new OrthographicCamera();
            break;
    }
    camera.near = nearPlane;
    camera.far = farPlane;
    cameraComponent.camera = camera;
    cameraComponent.type = type;
    output = cameraComponent;
}
Also used : OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) CameraComponent(io.github.voidzombie.nhglib.runtime.ecs.components.graphics.CameraComponent) Camera(com.badlogic.gdx.graphics.Camera) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera)

Aggregations

Camera (com.badlogic.gdx.graphics.Camera)15 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)4 Batch (com.badlogic.gdx.graphics.g2d.Batch)4 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)3 ModelCache (com.badlogic.gdx.graphics.g3d.ModelCache)3 BaseSceneManager (com.ilargia.games.entitas.egdx.base.managers.BaseSceneManager)3 Texture (com.badlogic.gdx.graphics.Texture)2 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)2 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)2 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)2 LightProperties (com.badlogic.gdx.tests.g3d.shadows.system.BaseShadowSystem.LightProperties)2 BaseGUIManager (com.ilargia.games.entitas.egdx.base.managers.BaseGUIManager)2 CameraComponent (io.github.voidzombie.nhglib.runtime.ecs.components.graphics.CameraComponent)2 AssetManager (com.badlogic.gdx.assets.AssetManager)1 Material (com.badlogic.gdx.graphics.g3d.Material)1 Model (com.badlogic.gdx.graphics.g3d.Model)1 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)1 RenderableProvider (com.badlogic.gdx.graphics.g3d.RenderableProvider)1 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)1