Search in sources :

Example 1 with Camera

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

the class CameraSystem method process.

@Override
protected void process(int entityId) {
    CameraComponent cameraComponent = cameraMapper.get(entityId);
    NodeComponent nodeComponent = nodeMapper.get(entityId);
    Camera camera = cameraComponent.camera;
    camera.position.set(nodeComponent.getTranslation());
    camera.direction.rotate(camera.up, nodeComponent.getYRotationDelta());
    camera.up.rotate(camera.direction, nodeComponent.getZRotationDelta());
    vec.set(camera.direction).crs(camera.up).nor();
    camera.direction.rotate(vec, nodeComponent.getXRotationDelta());
    camera.update();
    if (!cameras.contains(camera, true)) {
        cameras.add(camera);
    }
}
Also used : NodeComponent(io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent) CameraComponent(io.github.voidzombie.nhglib.runtime.ecs.components.graphics.CameraComponent) Camera(com.badlogic.gdx.graphics.Camera)

Example 2 with Camera

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

the class GraphicsSystem method begin.

@Override
protected void begin() {
    super.begin();
    if (physicsSystem == null) {
        physicsSystem = entities.getEntitySystem(PhysicsSystem.class);
    }
    if (cameraSystem == null) {
        cameraSystem = entities.getEntitySystem(CameraSystem.class);
    }
    if (physicsSystem.isPhysicsInitialized()) {
        if (debugDrawer == null) {
            debugDrawer = new DebugDrawer();
            debugDrawer.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_MAX_DEBUG_DRAW_MODE);
        }
        physicsSystem.setDebugDrawer(debugDrawer);
    }
    cameras = cameraSystem.cameras;
    for (int i = 0; i < cameras.size - modelBatches.size; i++) {
        modelBatches.add(new ModelBatch(shaderProvider));
        dynamicCaches.add(new ModelCache());
        staticCaches.add(new ModelCache());
    }
    for (int i = 0; i < cameras.size; i++) {
        Camera camera = cameras.get(i);
        ModelCache dynamicCache = dynamicCaches.get(i);
        dynamicCache.begin(camera);
    }
}
Also used : DebugDrawer(com.badlogic.gdx.physics.bullet.DebugDrawer) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Camera(com.badlogic.gdx.graphics.Camera) ModelCache(com.badlogic.gdx.graphics.g3d.ModelCache)

Example 3 with Camera

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

the class PongState method initialize.

@Override
public void initialize() {
    // Input
    Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera();
    Batch batch = engine.getManager(BaseSceneManager.class).getBatch();
    BitmapFont font = engine.getManager(BaseGUIManager.class).getDefaultFont();
    context.core.createEntity().addBall(false).addView(new Circle(0, 0, 8)).addMotion(MathUtils.clamp(1, 230, 300), 300);
    context.core.createEntity().addPlayer(Player.ID.PLAYER1).addScore("Player 1: ", 180, 470).addView(new Rectangle(-350, 0, Pong.PLAYER_WIDTH, Pong.PLAYER_HEIGHT)).addMotion(0, 0);
    context.core.createEntity().addPlayer(Player.ID.PLAYER2).addScore("Player 2: ", 480, 470).addView(new Rectangle(350, 0, Pong.PLAYER_WIDTH, Pong.PLAYER_HEIGHT)).addMotion(0, 0);
    systems.add(new InputSystem(context.core)).add(new ContactSystem(context.core)).add(new BoundsSystem(context.core)).add(new MoveSystem(context.core)).add(new RendererSystem(context.core, engine.sr, camera, batch, font));
}
Also used : Circle(com.badlogic.gdx.math.Circle) Batch(com.badlogic.gdx.graphics.g2d.Batch) BaseSceneManager(com.ilargia.games.entitas.egdx.base.managers.BaseSceneManager) Rectangle(com.badlogic.gdx.math.Rectangle) BaseGUIManager(com.ilargia.games.entitas.egdx.base.managers.BaseGUIManager) Camera(com.badlogic.gdx.graphics.Camera) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 4 with Camera

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

the class SplashState method initialize.

@Override
public void initialize() {
    // Input
    Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera();
    Batch batch = engine.getManager(BaseSceneManager.class).getBatch();
    BitmapFont font = engine.getManager(BaseGUIManager.class).getDefaultFont();
    systems.add(new DelaySystem(context.core)).add(new RendererSystem(context.core, engine.sr, camera, batch, font));
    Texture texture = assetsManager.getTexture(splash);
    context.core.createEntity().addTextureView("Pong", new TextureRegion(texture, 0, 0, texture.getWidth(), texture.getHeight()), new Vector2(), 0, Pong.SCREEN_HEIGHT, Pong.SCREEN_WIDTH).addDelay(3);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Batch(com.badlogic.gdx.graphics.g2d.Batch) Vector2(com.badlogic.gdx.math.Vector2) BaseSceneManager(com.ilargia.games.entitas.egdx.base.managers.BaseSceneManager) BaseGUIManager(com.ilargia.games.entitas.egdx.base.managers.BaseGUIManager) RendererSystem(com.ilargia.games.entitas.systems.RendererSystem) Camera(com.badlogic.gdx.graphics.Camera) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) Texture(com.badlogic.gdx.graphics.Texture) DelaySystem(com.ilargia.games.entitas.systems.DelaySystem)

Example 5 with Camera

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

the class MainShader method bindDirectionalShadows.

public void bindDirectionalShadows(final Attributes attributes) {
    final DirectionalLightsAttribute dla = attributes.get(DirectionalLightsAttribute.class, DirectionalLightsAttribute.Type);
    final Array<DirectionalLight> dirs = dla == null ? null : dla.lights;
    if (dirLightsLoc >= 0) {
        for (int i = 0; i < directionalLights.length; i++) {
            if (dirs == null || dirs.size <= i) {
                continue;
            }
            int idx = dirShadowsLoc + i * dirShadowsSize;
            // Shadow
            ObjectMap<DirectionalLight, LightProperties> dirCameras = shadowSystem.getDirectionalCameras();
            DirectionalLight dl = dirs.get(i);
            if (shadowSystem.hasLight(dl)) {
                // UVTransform
                final TextureRegion tr = dirCameras.get(dl).region;
                Camera cam = dirCameras.get(dl).camera;
                if (cam != null) {
                    program.setUniformf(idx + dirShadowsUvTransformOffset, tr.getU(), tr.getV(), tr.getU2() - tr.getU(), tr.getV2() - tr.getV());
                    // ProjViewTrans
                    idx = dirShadowMapProjViewTransLoc + i * dirShadowMapProjViewTransSize;
                    program.setUniformMatrix(idx, dirCameras.get(dl).camera.combined);
                }
            }
            if (dirLightsSize <= 0)
                break;
        }
    }
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) DirectionalLightsAttribute(com.badlogic.gdx.graphics.g3d.attributes.DirectionalLightsAttribute) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) LightProperties(com.badlogic.gdx.tests.g3d.shadows.system.BaseShadowSystem.LightProperties) Camera(com.badlogic.gdx.graphics.Camera)

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