Code Monkey home page Code Monkey logo

Comments (10)

rinold avatar rinold commented on May 18, 2024

Looking at stack trace - the RayHandler instance passed to PointLight constructor is null. Could you debug or use logging to verify that you are passing the correct initialized RayHandler instance during that lights creation?

from box2dlights.

IHazABone avatar IHazABone commented on May 18, 2024

I am most definitely passing a correct, initialized RayHandler.

from box2dlights.

rinold avatar rinold commented on May 18, 2024

Also tried to change the color during runtime in test project - works fine. Could you share some code of actual box2dlights usage in your project, that is not working?

from box2dlights.

IHazABone avatar IHazABone commented on May 18, 2024

rayHandler = new RayHandler(world);
rayHandler.useDiffuseLight(false);
rayHandler.setCombinedMatrix(camera.combined);
rayHandler.setAmbientLight(0.0f, 0.0f, 0.0f, 0.0f);
...
a = new PointLight(rayHandler, 1024, Color.CYAN, light, -200, 200);
b = new PointLight(rayHandler, 1024, Color.MAGENTA, light, -200, -200);
c = new PointLight(rayHandler, 1024, Color.YELLOW, light, 250, 100);
d = new PointLight(rayHandler, 1024, Color.MAROON, light, 200, 200);
pl.attachToBody(p.body, 0f, 0f);
pl2.attachToBody(p.body, 0f, 0f);
pl.setXray(false);
pl2.setXray(true);
pl.setSoft(true);
pl2.setSoft(true);
...
public void lightOn() {
new PointLight(rayHandler, 1024, Color.ORANGE, 200, 174, 430); //NullPointerException
c.setColor(Color.BLUE); //NullPointerException
}

Sorry, I'm not really sure how to format it as code here.

from box2dlights.

rinold avatar rinold commented on May 18, 2024

Yeah your code looks absolutely fine. What version of box2dlights are you using?
You can try to find the code difference with box2dlights demo app (in tests - it's 100% working, tried it today).

from box2dlights.

IHazABone avatar IHazABone commented on May 18, 2024

It's the latest version... Hm. I'll take a look.
Oh, and, just a question - is there any way to reduce the intensity of the center of a PointLight?
What about reducing how incredibly bright it gets when you stack two together (I have a player light that follows the player and a torch, and if the player goes near the torch, it gets almost too intense to see the sprites).

from box2dlights.

rinold avatar rinold commented on May 18, 2024

What about reducing how incredibly bright it gets when you stack two together

Have you tried using the diffuse light model?

rayHandler.useDiffuseLight(true);

I see you set it to false in your code, is it essential for you?

from box2dlights.

IHazABone avatar IHazABone commented on May 18, 2024

The diffuse model, while being prominent in any 3D work I do (not with this engine of course), doesn't seem to work very well with this. It makes shadows appear as circular blobs about half the radius of the actual sprite, which looks dreadful.

from box2dlights.

rinold avatar rinold commented on May 18, 2024

The diffuse model, while being prominent in any 3D work I do (not with this engine of course), doesn't seem to work very well with this. It makes shadows appear as circular blobs about half the radius of the actual sprite, which looks dreadful.

This is quite an important comment, I will investigate it. Unfortunately, can't give you any estimates currently.

Also, about the exceptions, have you found any solution or root cause of it?

from box2dlights.

IHazABone avatar IHazABone commented on May 18, 2024

Actually, just today I managed to get it working: instead of calling some of my methods from inner classes and/or objects, I called them directly from the main class and it worked.

from box2dlights.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.