Home > Blender > Scripts > Sun Engine - sun position mecanism alternative

Sun Engine - sun position mecanism alternative

Article Index
Sun Engine
latitude and longitude
configure date and time
sun revolution speed
change the sun revolution speed during the game
display the current date and time in the game
script integration
sun position mecanism alternative
sun objects and properties reference

so far the sun is an object that is located somewhere around your world by the script. the sundist property allows you to configure the distance between the object origin and the sun location. you can also parent the sun to another object and move or rotate it, as the script uses the local coordinates system.

but depending on the way you build your world, this concept is not always easy to use (skydome case). also, viewed from earth, the sun is more like a circle of light than a real object.

here's what you can do if you have a skydome :

the selected spot (pink) projects a light on the skydome : here comes the sun.
to do that you could build a track system (OBsun tracks its origin, a spot at -180° is parented to OBsun)
you can also directly track OBsun (which would be an empty) from its origin, with a spot parented to the origin.

the script can achieve that :

  • replace the OBsun object by an empty.
  • create an empty, call it sunrotZ,
  • create another empty, call it sunrotY,
  • parent sunrotY to sunrotZ and locate them at the same location. (the center of the skydome sphere)
  • create a spot. locate it somewhere on the positive x axis (on the left of sunrotY, front view)
  • parent the spot to sunrotY
  • start the G.E.

the script now projects a light towards the sun position.


you can also specify the names of the two empties in the configuration object :

  • select the sun configuration object,
  • in the logic panel, add the following property :
    . sunZ (type:String) : enter the name of the sunrotZ empty
    . sunY (type:String) : enter the name of the sunrotY empty

don't forget to add 'OB' at the beginning of the object names.

wow, you're such a nice person.. you almost read all this frenchy-english documentation.. bravo !
as a gift, here's a demo file that contains all the things described here already setuped + some code goodies :
demo file

Last Updated on Friday, 23 October 2009 14:20