Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectionalLight extension for "top-down" view #68

Closed
adam-law opened this issue Jul 16, 2015 · 14 comments
Closed

DirectionalLight extension for "top-down" view #68

adam-law opened this issue Jul 16, 2015 · 14 comments

Comments

@adam-law
Copy link

Hi,

I either don't understand the concept or it's not possible right now, but I would like to use the effect of a DirectionalLight to be the sun for a world in a top-down view. Additionally, an argument to set its "position" (I understand this is not a positional light) over the scene would be great, to simulate the transit through of a body like the sun over periods of time.

Thanks.

@rinold
Copy link
Contributor

rinold commented Jul 17, 2015

No it's not possible in box2lights now, but you can check the pseudo3d branch - it was specially created for "top-down" 2d world support, but unfortunatelly it's only in development stage, and I have no time to work on it as I wanted to currently...

UPD. It has no downlodable jars, and you will need to build it from source.
UPD2. Not shure if it will work with latest libgdx, but this could be fixed.

@adam-law
Copy link
Author

ah, was it related to that great piece of work you did with shadow lengths? by the way, I hope it's related, but is there a way then that I can "lighten up" the dimness? When box2dlights is active it seems to set things to "night". I understand this is to contrast with the created lights, but if there is a way to control how dark it is then it may work for as a substitute for a topdown sun. I was thinking it was setAmbientLight(), but regardless of the values I put in, it's still "nighttime".

Edit: I think I may need to open another issue for ambient lighting? I took some time to try out all constructors, in a world without box2d bodies to collide with, and the whole scene is just "dark" / unlit, no matter what the setting is for ambient lighting.

@rinold
Copy link
Contributor

rinold commented Oct 2, 2015

Sorry for a very very late reply... Got much overhead last months :) I've checked the pseudo3d branch and it's currently missing such DirectionalLight implementation.

I'll try to complete it and merge it to pseudo3d branch in a few days.

@adam-law
Copy link
Author

adam-law commented Oct 2, 2015

that's okay, things like this are worth the wait :)

does the pseudo3d branch conflict with anything from the main box2dlights? if not, why can't they be merged if it will add such nice new features?

rinold added a commit that referenced this issue Oct 2, 2015
Adding draft implementation of P3dDirectionalLight for #68
@rinold
Copy link
Contributor

rinold commented Oct 2, 2015

I've just added the P3dDirectionalLight to pseudo3d branch. You can set the direction in the same way as in usual box2dlights and you can also use the:

    float degrees = 70f;
    dirLight.setHeight(degrees);

to set the degree of this light from horizont - the 90f means it's absolutely on top of world and shadows should disappear, while moving over the 90f will flip the shadows direction automatically.

UPD. Regarding the merging - I think that will be a bit hard, as they use different algorithms for shadow calculations and rendering...

@adam-law
Copy link
Author

adam-law commented Oct 4, 2015

I understand, w/o looking at the source, I can only imagine the difficulty. I guess it won't be so much of a problem if the pseudo branch is always in pace with the main project. Thanks for the info, and for implementing this :)

@adam-law
Copy link
Author

Something gave me pause in trying out the p3d branch. It was mentioned on issue #40 that p3d doesn't work for colors?

I've found that current implementation is a bit awful :) it doesn't work for colored lights as usual box2dlight do.

@rinold
Copy link
Contributor

rinold commented Oct 23, 2015

It works currently - you can check the video on the branch page. However, it has only point and directional lights currently, and also with high chances there might be some bugs in it :) As it's hanging in development I really not sure about using it in production, but from other side if no one will try to use it, it will be hard to find out what needs to be fixed or emhaced :)

@adam-law
Copy link
Author

very nice. I'll give it a shot. Just wondering though, even if nothing new is added, will p3d always be in step with an update to the main box2dlights? I could be wrong, but I see both are at 1.4.0. Lastly I built p3d from the provided pom. I assume this is the correct way? It had really old references in it, so I was wondering if this was an obsolete method. I didn't have Java 6 in the system, so I had to bump stuff up to build successfully under Java 7/8.

thanks.

@kdenzel
Copy link

kdenzel commented Aug 30, 2020

Hello there, i made a fork and updated the code especially the directional lights code and light class. I changed it for my personal needs. Here is my Repo. Pushed it on the master branch. Dunno if that was a good idea to do so. Only used the directional light class for 3D, all the other light classes work the same as Version 1.6-SNAPSHOT at the current time.

@crykn
Copy link
Member

crykn commented Aug 30, 2020

Hey @kdenzel, it seems like you changed the line endings in the files you edited. This makes it very difficult to compare the differences between your repo and the master branch. Could you change the line endings on your end? Your IDE should provide some tools for you to make that easier.

@kdenzel
Copy link

kdenzel commented Aug 30, 2020

Oh sorry, i messed up with whitespaces. But there is a little Trick: when you enter the url to compare the files, you can enter in the URL the get Parameter w=1 see here

@crykn
Copy link
Member

crykn commented Aug 30, 2020

You never stop learning.

Box2d-lights isn't really my area of expertise, but judging by the comments here and in the other issue those changes in the initial pseudo3d branch seemed to be well appreciated. If you would be willing to create a PR for your changes, maybe another member of the team finds the time to review it.

@SimonIT
Copy link
Member

SimonIT commented Oct 31, 2024

#124 was merged

@SimonIT SimonIT closed this as completed Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants