use of com.badlogic.gdx.graphics.g3d.environment.DirectionalLight 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));
}
use of com.badlogic.gdx.graphics.g3d.environment.DirectionalLight 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)));
}
use of com.badlogic.gdx.graphics.g3d.environment.DirectionalLight 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");
}
use of com.badlogic.gdx.graphics.g3d.environment.DirectionalLight 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();
}
use of com.badlogic.gdx.graphics.g3d.environment.DirectionalLight 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));
}
Aggregations