Search in sources :

Example 1 with Environment

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

the class BaseBulletTest method create.

@Override
public void create() {
    init();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, 1.f));
    light = shadows ? new DirectionalShadowLight(1024, 1024, 20f, 20f, 1f, 300f) : new DirectionalLight();
    light.set(0.8f, 0.8f, 0.8f, -0.5f, -1f, 0.7f);
    environment.add(light);
    if (shadows)
        environment.shadowMap = (DirectionalShadowLight) light;
    shadowBatch = new ModelBatch(new DepthShaderProvider());
    modelBatch = new ModelBatch();
    world = createWorld();
    world.performanceCounter = performanceCounter;
    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 some simple 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.WHITE), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(16f)), Usage.Position | Usage.Normal);
    disposables.add(groundModel);
    final Model boxModel = modelBuilder.createBox(1f, 1f, 1f, new Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(64f)), Usage.Position | Usage.Normal);
    disposables.add(boxModel);
    // Add the constructors
    // mass = 0: static body
    world.addConstructor("ground", new BulletConstructor(groundModel, 0f));
    // mass = 1kg: dynamic body
    world.addConstructor("box", new BulletConstructor(boxModel, 1f));
    // mass = 0: static body
    world.addConstructor("staticbox", new BulletConstructor(boxModel, 0f));
}
Also used : DirectionalShadowLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalShadowLight) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Model(com.badlogic.gdx.graphics.g3d.Model) 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) DepthShaderProvider(com.badlogic.gdx.graphics.g3d.utils.DepthShaderProvider)

Example 2 with Environment

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

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

the class ModelTest method create.

@Override
public void create() {
    super.create();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));
    cam.position.set(1, 1, 1);
    cam.lookAt(0, 0, 0);
    cam.update();
    showAxes = true;
    onModelClicked("g3d/teapot.g3db");
}
Also used : DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) Environment(com.badlogic.gdx.graphics.g3d.Environment) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)

Example 4 with Environment

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

the class ParticleControllerTest method create.

@Override
public void create() {
    super.create();
    emitters = new Array<ParticleController>();
    assets.load(DEFAULT_PARTICLE, Texture.class);
    assets.load(DEFAULT_SKIN, Skin.class);
    loading = true;
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0f, 0f, 0.1f, 1f));
    environment.add(new DirectionalLight().set(1f, 1f, 1f, 0, -0.5f, -1));
    billboardParticleBatch = new BillboardParticleBatch();
    billboardParticleBatch.setCamera(cam);
    ui = new Stage();
    builder = new StringBuilder();
}
Also used : ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) Environment(com.badlogic.gdx.graphics.g3d.Environment) BillboardParticleBatch(com.badlogic.gdx.graphics.g3d.particles.batches.BillboardParticleBatch) Stage(com.badlogic.gdx.scenes.scene2d.Stage) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)

Example 5 with Environment

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

the class HeightMapTest method create.

@Override
public void create() {
    super.create();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    int w = 20, h = 20;
    Pixmap data = new Pixmap(Gdx.files.internal("data/g3d/heightmap.png"));
    field = new HeightField(true, data, true, Usage.Position | Usage.Normal | Usage.ColorUnpacked | Usage.TextureCoordinates);
    data.dispose();
    field.corner00.set(-10f, 0, -10f);
    field.corner10.set(10f, 0, -10f);
    field.corner01.set(-10f, 0, 10f);
    field.corner11.set(10f, 0, 10f);
    field.color00.set(0, 0, 1, 1);
    field.color01.set(0, 1, 1, 1);
    field.color10.set(1, 0, 1, 1);
    field.color11.set(1, 1, 1, 1);
    field.magnitude.set(0f, 5f, 0f);
    field.update();
    ground = new Renderable();
    ground.environment = environment;
    ground.meshPart.mesh = field.mesh;
    ground.meshPart.primitiveType = GL20.GL_TRIANGLES;
    ground.meshPart.offset = 0;
    ground.meshPart.size = field.mesh.getNumIndices();
    ground.meshPart.update();
    ground.material = new Material(TextureAttribute.createDiffuse(texture));
}
Also used : Renderable(com.badlogic.gdx.graphics.g3d.Renderable) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) Environment(com.badlogic.gdx.graphics.g3d.Environment) Material(com.badlogic.gdx.graphics.g3d.Material) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute) Texture(com.badlogic.gdx.graphics.Texture) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Aggregations

Environment (com.badlogic.gdx.graphics.g3d.Environment)23 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)17 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)17 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)13 Material (com.badlogic.gdx.graphics.g3d.Material)12 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)10 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)10 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)8 CameraInputController (com.badlogic.gdx.graphics.g3d.utils.CameraInputController)6 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)4 Texture (com.badlogic.gdx.graphics.Texture)4 Model (com.badlogic.gdx.graphics.g3d.Model)4 DefaultShaderProvider (com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider)4 DirectionalShadowLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalShadowLight)3 PointLight (com.badlogic.gdx.graphics.g3d.environment.PointLight)3 DepthShaderProvider (com.badlogic.gdx.graphics.g3d.utils.DepthShaderProvider)3 MeshPartBuilder (com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder)3 JsonValue (com.badlogic.gdx.utils.JsonValue)3 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)2 SpotLight (com.badlogic.gdx.graphics.g3d.environment.SpotLight)2