Search in sources :

Example 11 with PerspectiveCamera

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

the class BaseShadowSystem method addLight.

@Override
public void addLight(PointLight point, Set<CubemapSide> sides) {
    PointLightProperties plProperty = new PointLightProperties();
    for (int i = 0; i < 6; i++) {
        CubemapSide cubemapSide = Cubemap.CubemapSide.values()[i];
        if (sides.contains(cubemapSide)) {
            PerspectiveCamera camera = new PerspectiveCamera(90, 0, 0);
            camera.position.set(point.position);
            camera.direction.set(cubemapSide.direction);
            camera.up.set(cubemapSide.up);
            camera.near = 1;
            camera.far = 100;
            LightProperties p = new LightProperties(camera);
            plProperty.properties.put(cubemapSide, p);
        }
    }
    pointCameras.put(point, plProperty);
}
Also used : PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) CubemapSide(com.badlogic.gdx.graphics.Cubemap.CubemapSide)

Example 12 with PerspectiveCamera

use of com.badlogic.gdx.graphics.PerspectiveCamera in project bdx by GoranM.

the class Camera method initData.

public void initData(Type type) {
    this.type = type;
    if (type == Type.PERSPECTIVE) {
        data = new PerspectiveCamera();
    } else {
        data = new OrthographicCamera();
    }
    resolution = new Vector2f();
    ignoreObjects = new ArrayListNamed<GameObject>();
}
Also used : Vector2f(javax.vecmath.Vector2f) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera)

Example 13 with PerspectiveCamera

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

the class BasicBulletTest method create.

@Override
public void create() {
    super.create();
    instructions = "Swipe for next test";
    lights = new Environment();
    lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.2f, 0.2f, 0.2f, 1.f));
    lights.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1f, -0.7f));
    // Set up the camera
    final float width = Gdx.graphics.getWidth();
    final float height = Gdx.graphics.getHeight();
    if (width > height)
        camera = new PerspectiveCamera(67f, 3f * width / height, 3f);
    else
        camera = new PerspectiveCamera(67f, 3f, 3f * height / width);
    camera.position.set(10f, 10f, 10f);
    camera.lookAt(0, 0, 0);
    camera.update();
    // Create the model batch
    modelBatch = new ModelBatch();
    // Create some basic models
    final Model groundModel = modelBuilder.createRect(20f, 0f, -20f, -20f, 0f, -20f, -20f, 0f, 20f, 20f, 0f, 20f, 0, 1, 0, new Material(ColorAttribute.createDiffuse(Color.BLUE), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(16f)), Usage.Position | Usage.Normal);
    models.add(groundModel);
    final Model sphereModel = modelBuilder.createSphere(1f, 1f, 1f, 10, 10, new Material(ColorAttribute.createDiffuse(Color.RED), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(64f)), Usage.Position | Usage.Normal);
    models.add(sphereModel);
    // Load the bullet library
    // Normally use: Bullet.init();
    BaseBulletTest.init();
    // Create the bullet world
    collisionConfiguration = new btDefaultCollisionConfiguration();
    dispatcher = new btCollisionDispatcher(collisionConfiguration);
    broadphase = new btDbvtBroadphase();
    solver = new btSequentialImpulseConstraintSolver();
    collisionWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
    collisionWorld.setGravity(gravity);
    // Create the shapes and body construction infos
    btCollisionShape groundShape = new btBoxShape(tempVector.set(20, 0, 20));
    shapes.add(groundShape);
    btRigidBodyConstructionInfo groundInfo = new btRigidBodyConstructionInfo(0f, null, groundShape, Vector3.Zero);
    bodyInfos.add(groundInfo);
    btCollisionShape sphereShape = new btSphereShape(0.5f);
    shapes.add(sphereShape);
    sphereShape.calculateLocalInertia(1f, tempVector);
    btRigidBodyConstructionInfo sphereInfo = new btRigidBodyConstructionInfo(1f, null, sphereShape, tempVector);
    bodyInfos.add(sphereInfo);
    // Create the ground
    ModelInstance ground = new ModelInstance(groundModel);
    instances.add(ground);
    btDefaultMotionState groundMotionState = new btDefaultMotionState();
    groundMotionState.setWorldTransform(ground.transform);
    motionStates.add(groundMotionState);
    btRigidBody groundBody = new btRigidBody(groundInfo);
    groundBody.setMotionState(groundMotionState);
    bodies.add(groundBody);
    collisionWorld.addRigidBody(groundBody);
    // Create the spheres
    for (float x = -10f; x <= 10f; x += 2f) {
        for (float y = 5f; y <= 15f; y += 2f) {
            for (float z = 0f; z <= 0f; z += 2f) {
                ModelInstance sphere = new ModelInstance(sphereModel);
                instances.add(sphere);
                sphere.transform.trn(x + 0.1f * MathUtils.random(), y + 0.1f * MathUtils.random(), z + 0.1f * MathUtils.random());
                btDefaultMotionState sphereMotionState = new btDefaultMotionState();
                sphereMotionState.setWorldTransform(sphere.transform);
                motionStates.add(sphereMotionState);
                btRigidBody sphereBody = new btRigidBody(sphereInfo);
                sphereBody.setMotionState(sphereMotionState);
                bodies.add(sphereBody);
                collisionWorld.addRigidBody(sphereBody);
            }
        }
    }
}
Also used : com.badlogic.gdx.physics.bullet.collision.btBoxShape(com.badlogic.gdx.physics.bullet.collision.btBoxShape) com.badlogic.gdx.physics.bullet.collision.btCollisionDispatcher(com.badlogic.gdx.physics.bullet.collision.btCollisionDispatcher) Material(com.badlogic.gdx.graphics.g3d.Material) com.badlogic.gdx.physics.bullet.collision.btDefaultCollisionConfiguration(com.badlogic.gdx.physics.bullet.collision.btDefaultCollisionConfiguration) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) com.badlogic.gdx.physics.bullet.linearmath.btDefaultMotionState(com.badlogic.gdx.physics.bullet.linearmath.btDefaultMotionState) com.badlogic.gdx.physics.bullet.collision.btCollisionShape(com.badlogic.gdx.physics.bullet.collision.btCollisionShape) com.badlogic.gdx.physics.bullet.dynamics.btRigidBody.btRigidBodyConstructionInfo(com.badlogic.gdx.physics.bullet.dynamics.btRigidBody.btRigidBodyConstructionInfo) ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) com.badlogic.gdx.physics.bullet.dynamics.btRigidBody(com.badlogic.gdx.physics.bullet.dynamics.btRigidBody) com.badlogic.gdx.physics.bullet.collision.btSphereShape(com.badlogic.gdx.physics.bullet.collision.btSphereShape) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Model(com.badlogic.gdx.graphics.g3d.Model) com.badlogic.gdx.physics.bullet.collision.btDbvtBroadphase(com.badlogic.gdx.physics.bullet.collision.btDbvtBroadphase) Environment(com.badlogic.gdx.graphics.g3d.Environment) com.badlogic.gdx.physics.bullet.dynamics.btDiscreteDynamicsWorld(com.badlogic.gdx.physics.bullet.dynamics.btDiscreteDynamicsWorld) com.badlogic.gdx.physics.bullet.dynamics.btSequentialImpulseConstraintSolver(com.badlogic.gdx.physics.bullet.dynamics.btSequentialImpulseConstraintSolver) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)

Example 14 with PerspectiveCamera

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

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

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