sun engine allow you to locate and animate a sun in the Blender Game Engine.
it is based on a geocentric model, the sun goes around the earth at the right location, depending on the latitude and longitude and the current time in the game.
it relies on the fiat_lux script core functions for the sun position, and optionnaly can be used the same way than the sun_D script, with a sun that is animated by a parent empty rotation.
the setup is simple and fast to achieve, but a lot of options are availables.
quick setup :
- open Blender and load the script in the text editor.
- add a sphere (or any mesh/lamp type you want), call it sun (not mandatory).
- in the logic panel (with the sphere selected) :
. add an 'always' sensor. enable TRUE level triggering,
. add a 'python' controler. name it sun engine. in the 'script' text field type sun_engine.py,
. link the sensor to the actuator. - ground (not mandatory) :
. from the front view, add a filled plane,
. rescale it to 9 blender units (check with the object properties, n key in the 3d view),
. rotate it 180° (x or y) or swap normals in edit mode,
. locate it to the world origin (alt-G).
- switch the 3d view to full screen (CTRL+UP or DOWN arrow) then start the Game Engine (P key)
the sun should move around the ground.the blender console displays the current date and time
for the moment this sun uses a default longitude and latitude ( europe/france/paris/19th district/my flat ;-) ) and the current date/time configured on your computer ( function locatime() ). the sun distance is around 10 blender units, the animation speed is two minutes per script execution (per tic)
next we'll change these defaults.