public DirectionalLight set (final DirectionalLight copyFrom) { return set(copyFrom.color, copyFrom.direction); }
public DirectionalLight set (final DirectionalLight copyFrom) { return set(copyFrom.color, copyFrom.direction); }
@Override public void begin (final Camera camera, final RenderContext context) { super.begin(camera, context); for (final DirectionalLight dirLight : directionalLights) dirLight.set(0, 0, 0, 0, -1, 0); for (final PointLight pointLight : pointLights) pointLight.set(0, 0, 0, 0, 0, 0, 0); for (final SpotLight spotLight : spotLights) spotLight.set(0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0); lightsSet = false; if (has(u_time)) set(u_time, time += Gdx.graphics.getDeltaTime()); }
@Override public void begin (final Camera camera, final RenderContext context) { super.begin(camera, context); for (final DirectionalLight dirLight : directionalLights) dirLight.set(0, 0, 0, 0, -1, 0); for (final PointLight pointLight : pointLights) pointLight.set(0, 0, 0, 0, 0, 0, 0); for (final SpotLight spotLight : spotLights) spotLight.set(0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0); lightsSet = false; if (has(u_time)) set(u_time, time += Gdx.graphics.getDeltaTime()); }
@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(); }
@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"); }
@Override public void create () { super.create(); environment.clear(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.2f, 0.2f, 0.2f, 1.0f)); environment.add(dirLight = new DirectionalLight().set(0.8f, 0.2f, 0.2f, -1f, -2f, -0.5f)); environment.add(pointLight = new PointLight().set(0.2f, 0.8f, 0.2f, 0f, 0f, 0f, 100f)); ModelBuilder mb = new ModelBuilder(); lightModel = mb.createSphere(1, 1, 1, 10, 10, new Material(ColorAttribute.createDiffuse(1, 1, 1, 1)), Usage.Position); lightModel.nodes.get(0).parts.get(0).setRenderable(pLight = new Renderable()); }
@Override public void create () { spriteBatch = new SpriteBatch(); font = new BitmapFont(); modelBatch = new ModelBatch(); DefaultShader.defaultCullFace = GL20.GL_FRONT; camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); camera.near = 0.5f; camera.far = 1000; controller = new FirstPersonCameraController(camera); Gdx.input.setInputProcessor(controller); lights = new Environment(); lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); lights.add(new DirectionalLight().set(1, 1, 1, 0, -1, 0)); Texture texture = new Texture(Gdx.files.internal("data/g3d/tiles.png")); TextureRegion[][] tiles = TextureRegion.split(texture, 32, 32); MathUtils.random.setSeed(0); voxelWorld = new VoxelWorld(tiles[0], 20, 4, 20); PerlinNoiseGenerator.generateVoxels(voxelWorld, 0, 63, 10); float camX = voxelWorld.voxelsX / 2f; float camZ = voxelWorld.voxelsZ / 2f; float camY = voxelWorld.getHighest(camX, camZ) + 1.5f; camera.position.set(camX, camY, camZ); }
@Override public void create () { super.create(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.1f, 0.1f, 0.1f, 1.f)); environment.add(dirLight = new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f)); shaderProvider = new TestShaderProvider(); shaderBatch = new ModelBatch(shaderProvider); cam.position.set(1, 1, 1); cam.lookAt(0, 0, 0); cam.update(); showAxes = true; onModelClicked("g3d/shapes/teapot.g3dj"); shaderRoot = (hotLoadFolder != null && Gdx.app.getType() == ApplicationType.Desktop) ? Gdx.files.absolute(hotLoadFolder) : Gdx.files.internal("data/g3d/shaders"); }
@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; }
lights = new Environment(); lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); light = new DirectionalLight().set(0.8f, 0.8f, 0.8f, -.4f, -.4f, -.4f); lights.add(light = new DirectionalLight().set(0.8f, 0.8f, 0.8f, -.4f, -.4f, -.4f)); cam.position.set(10, 10, 10); cam.lookAt(0, 0, 0);
protected void randomizeLights () { int pointLights = MathUtils.random(5); int directionalLights = MathUtils.random(5); DefaultShader.Config config = new Config(); config.numDirectionalLights = directionalLights; config.numPointLights = pointLights; config.numSpotLights = 0; modelBatch.dispose(); modelBatch = new ModelBatch(new DefaultShaderProvider(config)); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); for (int i = 0; i < pointLights; i++) { environment.add(new PointLight().set(randomColor(), randomPosition(), MathUtils.random(10f))); } for (int i = 0; i < directionalLights; i++) { environment.add(new DirectionalLight().set(randomColor(), randomPosition())); } }
@Override public void create () { 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 = 1f; cam.far = 30f; cam.update(); ModelBuilder modelBuilder = new ModelBuilder(); model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal); instance = new ModelInstance(model); Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam))); }
@Override public void create () { modelBatch = new ModelBatch(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); environment.set(new ColorAttribute(ColorAttribute.Fog, 0.13f, 0.13f, 0.13f, 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(30f, 10f, 30f); cam.lookAt(0, 0, 0); cam.near = 0.1f; cam.far = 45f; cam.update(); ModelBuilder modelBuilder = new ModelBuilder(); model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal); instance = new ModelInstance(model); Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam))); }
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, 1.f)); shadowLight = new DirectionalLight(); shadowLight.set(0.8f, 0.8f, 0.8f, -0.5f, -1f, 0.7f); environment.add(shadowLight);
@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)); }
@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))); }
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, ambientLight, ambientLight, ambientLight, 1f)); DirectionalLight directionalLight = new DirectionalLight(); directionalLight.set(Color.WHITE, 10f, 0f, -5f); environment.add(directionalLight);
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)
continue; else directionalLights[i].set(dirs.get(i));