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:

lighting illustration


1 Answer 1


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:

    //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];



Result: enter image description here

  • \$\begingroup\$ 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. \$\endgroup\$
    – Adam Law
    Jul 25, 2015 at 6:15
  • \$\begingroup\$ @Adam Law you're right. \$\endgroup\$ Aug 1, 2015 at 3:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .