我有一个使用 Box2d 和 Box2d Lights 的 libgdx 游戏。
我的问题是如何让 Bodys / Bodydefs 忽略来自 Box2d Light 的光源而不投射阴影?
谢谢。
PolygonShape groundBox = new PolygonShape();
groundBox.setAsBox(2f, 2f);
FixtureDef gridBox = new FixtureDef();
gridBox.shape = groundBox;
gridBox.density = 1.0f;
gridBox.filter.groupIndex = GRID_GROUP;
gridBox.filter.categoryBits = GRID_CAT;
gridBox.filter.maskBits = GRID_MASK;
bodyDefs[i][j] = new BodyDef();
bodyDefs[i][j].position.set(j*factor + factor, i*factor + factor);
bodyDefs[i][j].fixedRotation = true;
bodyDefs[i][j].type = BodyDef.BodyType.DynamicBody;
bodies[i][j] = world.createBody(bodyDefs[i][j]);
bodies[i][j].createFixture(gridBox);
handler = new RayHandler(world);
handler.setCombinedMatrix(camera.combined);
Filter filter = new Filter();
filter.groupIndex = GRID_GROUP; // GRID_GROUP = 1
filter.categoryBits = GRID_CAT; // GRID_CAT = 0x0001;
filter.maskBits = GRID_MASK; // GRID_MASK = 1;
new PointLight(handler, 1000, Color.RED, 2000, 0, height);
PointLight.setContactFilter(filter);