-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Light control fix #1466
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
Light control fix #1466
Conversation
…pot lights to better handle rotations. The directional light was using outdated code from before 3.0 that didn't make sense in these days, to the point of confusion whenever the Also, the spotlight code wasn't working properly, as can be demonstrated by the new TestLightControlSpot test. Thanks @pspeed42 for the help with simplifying the quaternion.
…obal coordinates and spot lights. The spot light wasn't implemented at all, and the directional light didn't work.
There should be far less (although one will inevitably pop up when the test first starts, for some reason.
jme3-core/src/main/java/com/jme3/scene/control/LightControl.java
Outdated
Show resolved
Hide resolved
jme3-core/src/main/java/com/jme3/scene/control/LightControl.java
Outdated
Show resolved
Hide resolved
It wastes less objects.
|
It is nit picking, but would you mind following https://app.codacy.com/gh/jMonkeyEngine/jmonkeyengine/pullRequest?prid=6891987? |
|
Right, Codacity is now happy with the PR. It does have a duplication rating of +28, but that is likely due to the fact that the four tests I contributed are technically just copy/pastes of each other with minor changes. |
|
I'm not convinced that |
|
At lines 184 through 186, I just set the rotation and translation of the spatial based on vect1 (translation) and vect2 (direction). Since PointLight doesn't have a direction and DirectionalLight doesn't have a position, I just fill those fields with what the spatial already has (lines 168 and 171). This way, a PointLight won't change the existing rotation of a spatial and DirectionalLight won't change the existing position. The alternative would be to reset the rotation or translation of the spatial with a default, but I decided against it. |
|
You fill those fields with the local translation and direction, relative to the parent. But that doesn't work if the parent happens to be translated and rotated. Wouldn't it be simpler and less error-prone to update only the translation OR rotation in those cases? |
|
I must have forgotten about that. I primarily did it because it looked elegent. That said, trying to get the parent-offsets and such would be harder than its worth. I'll fix that.
Mar 7, 2021, 12:59 PM by [email protected]:
…
You fill those fields with the > local> translation and direction, relative to the parent. But that doesn't work if the parent happens to be translated and rotated. Wouldn't it be simpler and less error-prone to update only the translation OR rotation in those cases?
—
You are receiving this because you authored the thread.
Reply to this email directly, > view it on GitHub <#1466 (comment)>> , or > unsubscribe <https://github.com/notifications/unsubscribe-auth/ASC2KANCGMHC2WVNUN452SDTCPLLNANCNFSM4W7LAWEQ>> .
|
…n't have those options. It is a little less error-prone.
jme3-core/src/main/java/com/jme3/scene/control/LightControl.java
Outdated
Show resolved
Hide resolved
|
I appreciate your cooperation and patience. A few more items:
/*
* Offset the light node to check global stuff
*/
Node axis = new Node();
axis.setLocalTranslation(5, -3, 2.5F);
axis.setLocalRotation(new Quaternion().fromAngles(FastMath.PI / -4F, FastMath.PI / 2F, 0));
axis.attachChild(lightNode);It seems to me that |
stephengold
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much improved.
As @tlf30, @pspeed42 and I were working on #1443, it became apparent that the LightControl class wasn't entirely functional, particularly when it came to spot lights. This PR not only fixes that (including filling out the missing spotlight code in the lightToSpatial method), but also replaces some legacy code relating to directional lights from before version 3.
https://hub.jmonkeyengine.org/t/gltf-unlit-material-and-punctual-light-extensions/44132/29?u=markil3
Note that, when dealing with "world" coordinates when moving the spatial to the light, the rotations aren't always entirely accurate (the distance between the vectors can be as much as 4 units during testing). However, they appear close enough in debugging that I'm not concerned (Line 141 of TestLightControl2Spot).