1
votes

I have type of light in my game that needs to penetrate all obstacles, how can I achieve this?

I tried this:

final short IGNORED = 0x001;

FixtureDef fd = new FixtureDef();
fd.filter.categoryBits = IGNORED;
fd.filter.groupIndex = IGNORED;
fd.filter.maskBits = IGNORED;

new PointLight(rayHandler, 1000, Color.CYAN, 1000, 200, 400);

PointLight.setContactFilter(IGNORED,IGNORED,IGNORED);

but I still get shadows from that light.

Another thing is that my shadows are black and continue forever, is there a way to create shadows that arent so dark and long?

Basically this is what I get: enter image description here

but this is what I want: enter image description here

4
Sounds more like a graphics question than a box2d or a physics questionSteven Lu

4 Answers

2
votes

If you only want everything to become brighter you might want to try using ambient light. For instance:

rayHandler.setAmbientLight(0.5f);

makes everything 50% brighter, which may achieve the effect you want. You can also add colors to this (to for instance achieve a sunset-ish vibe).

1
votes

To "ignore all bodies" you can just use xRay parameter and you don't need filters, but in your topic i see another question. Anyway:

PointLight pointLight = new PointLight(...);
pointLight.setXray(true);
0
votes

I'm not familiar with libgdx in particular, but box2d allows you to create a body as a sensor.

From the manual:

Sometimes game logic needs to know when two fixtures overlap yet there should be no collision response. This is done by using sensors. A sensor is a fixture that detects collision but does not produce a response.

You can flag any fixture as being a sensor. Sensors may be static or dynamic. Remember that you may have multiple fixtures per body and you can have any mix of sensors and solid fixtures.

Sensors do not generate contact points. There are two ways to get the state of a sensor:

b2Contact::IsTouching b2ContactListener::BeginContact and EndContact

So you should be able to use your contact listener to detect if it is colliding, but not get a collision response out of the physics system.

Was this helpful?

0
votes

If you want that to penetrate all obstacles in your game then make them sensor true. If you want to check collision then you have to check collision in the BeginContact or end contact.

Just like

fd.isSensor = true;