# How do I query a LibGDX Box2DLights "light" and "dark" regions?

I have lighting implemented using Box2dLight. I want to update/render things inside the player's PointLight area. Stuff in the dark area should not be rendered.

How can I find which areas are lit or dark?

My PointLights and Body look like this:

I found the solution, so I think I should write here for other ones later. First I download the source code of box2dlights. Then open BaseLight.java and find "segments" member variable. This variable contains all information about what I was finding. This code below is just for debugging purpose:

    rayHandler.setCombinedMatrix(camera.combined);
rayHandler.updateAndRender();
//Only first two elements are positions
float[] vertices = new float[spriteLight.segments.length/2];
int count = 0;
for (int i=0;i<spriteLight.segments.length;i+=4)
{
vertices[count++] = spriteLight.segments[i];
vertices[count++] = spriteLight.segments[i + 1];

}

shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
shapeRenderer.polyline(vertices);
shapeRenderer.end();


Result:

• this saved me time. thanks, but I think you mean the Light class. It seems BaseLight is from another package entirely i.e. 3d. Also, for those who don't want to check out the source, it's best to extend the class then make a method to return this variable, anyway, there's bound to be extra processing to be done so an extension is warranted. Jul 25, 2015 at 6:15
• @Adam Law you're right. Aug 1, 2015 at 3:35