@Override public void dispose () { super.dispose(); floorModel.dispose(); shadowLight.dispose(); } }
environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1.0f, 1f, .6f, 1f)); environment.add((shadowLight = new DirectionalShadowLight(1024, 1024, 60f, 60f, .1f, 50f)) .set(1f, 1f, 1f, 40.0f, -35f, -35f)); environment.shadowMap = shadowLight; public void render(float delta) { shadowLight.begin(Vector3.Zero, camera.direction); shadowBatch.begin(shadowLight.getCamera()); shadowLight.end();
@Override public void create () { modelBatch = new ModelBatch(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f)); environment.add((shadowLight = new DirectionalShadowLight(1024, 1024, 30f, 30f, 1f, 100f)).set(0.8f, 0.8f, 0.8f, -1f, -.8f, -.2f)); environment.shadowMap = shadowLight; cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(0f, 7f, 10f); cam.lookAt(0, 0, 0); cam.near = 1f; cam.far = 50f; cam.update(); ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder mpb = modelBuilder.part("parts", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.ColorUnpacked, new Material(ColorAttribute.createDiffuse(Color.WHITE))); mpb.setColor(1f, 1f, 1f, 1f); mpb.box(0, -1.5f, 0, 10, 1, 10); mpb.setColor(1f, 0f, 1f, 1f); mpb.sphere(2f, 2f, 2f, 10, 10); model = modelBuilder.end(); instance = new ModelInstance(model); shadowBatch = new ModelBatch(new DepthShaderProvider()); Gdx.input.setInputProcessor(camController = new CameraInputController(cam)); }
assets.load(DEFAULT_TEX_PATH, Texture.class); Camera shadowCamera = ((DirectionalShadowLight)light).getCamera(); shadowCamera.viewportWidth = shadowCamera.viewportHeight = 120;
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);
public void update (final Camera camera) { update(tmpV.set(camera.direction).scl(halfHeight), camera.direction); }
lights = new Environment(); lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); lights.add((shadowLight = new DirectionalShadowLight(1024, 1024, 30f, 30f, 1f, 100f)) .set(0.8f, 0.8f, 0.8f, -.4f, -.4f, -.4f)); lights.shadowMap = shadowLight; inputController.rotateLeftKey = inputController.rotateRightKey = inputController.forwardKey = inputController.backwardKey = 0;
public void update (final Camera camera) { update(tmpV.set(camera.direction).scl(halfHeight), camera.direction); }
protected void renderWorld () { if (shadows) { ((DirectionalShadowLight)light).begin(Vector3.Zero, camera.direction); shadowBatch.begin(((DirectionalShadowLight)light).getCamera()); world.render(shadowBatch, null); shadowBatch.end(); ((DirectionalShadowLight)light).end(); } modelBatch.begin(camera); world.render(modelBatch, environment); modelBatch.end(); }
public void setEnvironmentLights(Array<BaseLight<?>> lights, Vector3 sunDirection) { environment = new Environment(); environment.add((shadowLight = new DirectionalShadowLight( GameSettings.SHADOW_MAP_WIDTH, GameSettings.SHADOW_MAP_HEIGHT, GameSettings.SHADOW_VIEWPORT_WIDTH, GameSettings.SHADOW_VIEWPORT_HEIGHT, GameSettings.SHADOW_NEAR, GameSettings.SHADOW_FAR)) .set(GameSettings.SHADOW_INTENSITY, GameSettings.SHADOW_INTENSITY, GameSettings.SHADOW_INTENSITY, sunDirection.nor())); environment.shadowMap = shadowLight; float ambientLight = GameSettings.SCENE_AMBIENT_LIGHT; environment.set(new ColorAttribute(ColorAttribute.AmbientLight, ambientLight, ambientLight, ambientLight, 1)); for (BaseLight<?> light : lights) { environment.add(light); } }
@Override public void dispose () { world.dispose(); world = null; for (Disposable disposable : disposables) disposable.dispose(); disposables.clear(); modelBatch.dispose(); modelBatch = null; shadowBatch.dispose(); shadowBatch = null; if (shadows) ((DirectionalShadowLight)light).dispose(); light = null; super.dispose(); }
public void update (final Camera camera) { update(tmpV.set(camera.direction).scl(halfHeight), camera.direction); }
@Override public void render () { camController.update(); Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); shadowLight.begin(Vector3.Zero, cam.direction); shadowBatch.begin(shadowLight.getCamera()); shadowBatch.render(instance); shadowBatch.end(); shadowLight.end(); modelBatch.begin(cam); modelBatch.render(instance, environment); modelBatch.end(); }
@Override public void dispose() { modelBatch.dispose(); shadowBatch.dispose(); shapeRenderer.dispose(); spriteBatch.dispose(); font.dispose(); shadowLight.dispose(); }