Search in sources :

Example 31 with PerspectiveCamera

use of com.badlogic.gdx.graphics.PerspectiveCamera 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

PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)31 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)18 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)15 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)13 Material (com.badlogic.gdx.graphics.g3d.Material)12 Environment (com.badlogic.gdx.graphics.g3d.Environment)10 Texture (com.badlogic.gdx.graphics.Texture)9 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)9 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)9 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)9 CameraInputController (com.badlogic.gdx.graphics.g3d.utils.CameraInputController)8 Model (com.badlogic.gdx.graphics.g3d.Model)7 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)6 AssetManager (com.badlogic.gdx.assets.AssetManager)5 ShaderProgram (com.badlogic.gdx.graphics.glutils.ShaderProgram)5 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)4 TextureAttribute (com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute)4 DefaultShaderProvider (com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider)4 PerspectiveCamController (com.badlogic.gdx.tests.utils.PerspectiveCamController)4 Mesh (com.badlogic.gdx.graphics.Mesh)3