O'Reilly logo

Building a 3D Game with LibGDX by Elmar van Rijnswou, Andreas Krühlmann, Sebastián Di Giuseppe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performance improvements and frustum culling

For simplicity reasons, we will use this simple method to create shadows, and it's up you to improve and explore its options with the actual models.

Let's fire up the RenderSystem class and add this:

public class RenderSystem extends EntitySystem { ... private boolean isVisible(Camera cam, final ModelInstance instance) { return cam.frustum.pointInFrustum(instance.transform.getTranslation (position)); } private void drawShadows(float delta) { shadowLight.begin(Vector3.Zero, perspectiveCamera.direction); batch.begin(shadowLight.getCamera()); for (int x = 0; x < entities.size(); x++) { if (entities.get(x).getComponent(PlayerComponent.class) != null || entities.get(x).getComponent (EnemyComponent.class) != ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required