2014-06-22 2 views
1

방금 ​​LibGDX 게임에서 Box2DLights를 구현했습니다. 그렇지 않으면 잘 작동하지만 정적 바디를 추가 한 후에는 그림자를 투영하지 않습니다.Box2Dlights 그림자가 작동하지 않습니다.

As you can see, the wall doesn’t cast a shadow

벽 그러나 어떻게 든 점 광원을 곱 않습니다. 나는 수많은에서 일을 시도

// After I have rendered walls sprites etc.                      
world.step(1/60f, 6, 2);                           
rayHandler.setCombinedMatrix(camera.combined, camera.position.x, camera.position.y,camera.viewportWidth, camera.viewportHeight); 
rayHandler.updateAndRender();                         
debugRenderer.render(this.world, camera.combined); 

:

Vector2 gravity = new Vector2(0,0); 
debugRenderer = new Box2DDebugRenderer(); 
world = new World(gravity, false); 

rayHandler = new RayHandler(world); 
rayHandler.setCombinedMatrix(camera.combined); 
rayHandler.setShadows(true); 

// This adds wall tiles from TiledMap into obstacles and to box2d world   
for (MapObject wall : mapObjects) {            
    RectangleMapObject rmo = (RectangleMapObject) wall;       

    if (rmo.getName() == null || !rmo.getName().contentEquals("window")) {  
     Rectangle rec = rmo.getRectangle();          


     obstacles.add(rec);              
     rec.set(rec.x/128 - mapRec.x, rec.y/128 - mapRec.y,     
       rec.width/128, rec.height/128);        

     BodyDef bodyDef = new BodyDef();           
     bodyDef.type = BodyType.StaticBody;          
     bodyDef.position.set(rec.getX()+rec.width/2,rec.getY()+rec.height/2); 

     Body body = world.createBody(bodyDef);         

     PolygonShape groundBox = new PolygonShape();        

     groundBox.setAsBox(rec.width/2,rec.height/2);       

     body.createFixture(groundBox, 1.0f);          

     groundBox.dispose();              
    }                   
}          

//The point light and the cone light;                                
pointLight= new PointLight(rayHandler, 100, new Color(1,1,1,0.5f), 0.5f, myCharacter.getAdjustedPosX(), myCharacter.getAdjustedPosY());        
coneLight = new ConeLight(rayHandler, 100, new Color(1,1,1,0.5f), 3, myCharacter.getAdjustedPosX(), myCharacter.getAdjustedPosY(), myCharacter.getRotation(), 30f); 

그리고 렌더링 부분 : 여기

It even multiply point light somehow

내가 Box2D의 및 Box2Dlights을 사용하고 내 코드의 부분입니다 튜토리얼 및 예를 들어, 예를 들어 world.step()을 추가했지만, 변경되지 않았습니다.

답변

2

부드러움 길이를 0으로 설정 한 후 그림자가 작동하기 시작했습니다.

pointLight.setSoftnessLength(0); 
coneLight.setSoftnessLength(0); 
관련 문제