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) != ...

Get Building a 3D Game with LibGDX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.