Skip to content

Instantly share code, notes, and snippets.

@jrenner
Created August 30, 2014 07:53
Show Gist options
  • Save jrenner/169438e75773d0dbe861 to your computer and use it in GitHub Desktop.
Save jrenner/169438e75773d0dbe861 to your computer and use it in GitHub Desktop.
GroundChunk.java
public class GroundChunk extends ModelInstance implements Visible {
private static final BoundingBox box = new BoundingBox();
public Vector3 position;
public Vector3 dimensions;
public float radius;
public GroundChunk(Model model) {
super(model);
calculateTransforms();
calculateBoundingBox(box);
dimensions = new Vector3(box.getDimensions());
radius = dimensions.len() / 2f;
position = new Vector3(box.getCenter());
Lists.groundChunks.add(this);
}
@Override
public boolean isVisible(PerspectiveCamera cam) {
return cam.frustum.sphereInFrustum(position, radius);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment