I have 2 questions about SkyControl:
- I have added SkyControl to my project and the sun is setting in the north! I have found this in the Javadoc:
In world coordinates:
+X points to the north horizon
+Y points to the zenith
+Z points to the east horizon
My world coordinates have +X pointing to the east horizon.
How do I tell SkyControl to spin everything around 90 degrees, so the sun sets in the west?
- The horizon is rendering too high. If I climb to the top of a mountain, the sky / clouds etc is only rendered from half way up the sky. Below that is just a light grey background. How do I get the sky to render all the way to the “bottom” of the screen.
I noted this in the Javadoc:
“For scenes with low horizons, an optional “bottom” dome can also be added.”
I’m not sure what a “low horizon” is. I have set bottomDome to true in the constructor but it doesn’t seem to make any difference.
How can I set the horizon to render lower?
I managed to change the direction of the sunset. For others with the same issue:
- The class to change is jme3utilities.sky.SunAndStars
- The method to change is public Vector3f convertToWorld(Vector3f equatorial)
To rotate 90 degrees clockwise, so positive x coordinates are in the east, I simple swapped the x and z coordinates of the result: (not being much good at matrix maths etc)
// Vector3f world = new Vector3f(-rotated.x, rotated.z, rotated.y); // old code
Vector3f world = new Vector3f(rotated.y, rotated.z, rotated.x);
I imagine you could do something similar to rotate the sky by 180 or 270 degrees.
@sgold Does the position of the sun change throughout the year? i.e. is it further toward the poles / horizon in winter and closer to the equator / higher overhead in summer?
Yes, seasonal changes are simulated.
SkyControl calculates the sun’s position based on solar longitude, which in real life is closely (but not perfectly) correlated with the day of the year. A crude conversion is provided by the
setSolarLongitude(int month, int day) method. It’s up to the app developer to decide whether to use the crude method or alternatively to account for the eccentricity of the Earth’s orbit, leap years, and so forth.
… and just when all the poor enterprise developers thought they were finally going to dive into game dev to escape from all the craziness related to dates & calendar time…