Home > Blender > Scripts > Sun Engine - sun objects and properties reference

Sun Engine - sun objects and properties reference

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

sun core object :

the sun core object is the one with the script controler logic brick linked to
by default :

  • he is the object to move as the sun, (it is also the sun object)
  • it contains all the configuration, (it is also the sun configuration object)
  • it receives the current time properties (it is also the sun display object)

properties to distribute the sun configuration :

  • sunconfig (type:String) : optionnal. the name of the scene where the configuration object is stored /  the name of the object
  • sundisplay (type:String) : optionnal. the name of the scene where the display object is /  the name of the object
  • sun (type:String) : optionnal. the name of the scene where the sun object is /  the name of the object

    the scene name can be omitted if the object is in the same scene than the sun core object.

  • in any case the script creates the following properties :
    . sunconfigsc : the scene of the sun configuration object,
    . sunconfigob : the sun configuration object name.
  • the sun configuration object will contain the same kind of properties for the sun display and the sun objects

you can act on these 6 properties to change the objects during the game, or you can change sun, sunconfig and sundisplay values then set suninit to True.

sun configuration object :

  • location :
    . lat (type:float) : latitude
    . long (type:float) : longitude
  • starting time :
    . startSecs (type:string). the starting date in seconds since epoch. update this value will update the sun position, keeping the current speed and time offset. if omitted, the local time will be used.
    . TZ (type:int) : the timezone of the location. only used for display, add your local time in the other fields.
    . LTZ (type:int) : local timezone (hours). this value is determined by the script.
    . year (type:int). will be used if startSecs is empty or omitted. starting time will be the 1st january of the configured year if the following propeties are omitted (or if one is missing) :
    . month (type:int)
    . day (type:int)
    . hours (type:int)
    . mins (type:int)
    . secs (type:int)
    . DST (type:int) : daylight saving time
  • uselocaltime (type:Bool) - True if omitted and no time configured
    . True : use the local time,
    . False : use the time configured in the properties.
    . if uselocaltime and sunrestart are True, the current time will be used as starting time.
    . local time is always available, just set this property to True.
    . suntimemode (type:Bool) - is equals to uselocaltime. used by the script to check wether the user want to switch between configured and local time.
  • timeSecs (type:string). is the current active time in seconds since epoch. let the script create this value ; then you can add a time offset in seconds once the game is running.
  • sunspeed (type:int). offset in seconds. 120 if omitted.
    . if 0, it will stop the sun,
    . if > 0, it the time will increase,
    . if < 0, it will decrease.
  • realsunspeed (type:Bool) False if omitted
    . True : use the 'true' time for animation
    . if True and sunspeed = 0, the sun will stop
    . False : use the sunspeed value.
  • sunrestart (type:Bool) False if omitted
    . True tells the script to restart the animation from the configured time or the local time,
    . the script will toggle the value to False by itself.
  • sundist (type:Float) - 10 if omitted
    . a multiplicator used for the sun-earth distance.
  • uselocalstring (type:Bool) - False if omitted
    . language used for month and day strings, see next page.
    . True : local date strings,
    . False : use your own strings.
  • sundebug (type:Bool) - True if omitted
    . True : displays time in the Blender console
    . False : displays nothing
  • suninit (type:Bool) - False at init
    . False tells the script to re-initialize (parse the whole configuration again and restart),
    . True for normal operations. the script will toggle the value by itself.
  • sun objects :
    . sunsc : the scene of the sun object,
    . sunob : the sun object name,
    . sundisplaysc : the scene of the sun display object,
    . sundisplayob : the sun display object name,
  • alt. mecanism for sun object :
    . sunZ (type:string) name of the empty for sun rotation
    . sunY (type:string) name of the empty for sun altitude
  • internal properties. you shouldn't need to use them directly :
    . ltstartSecs
    . sunpause
    . rtimeoffset
    . pstartSecs

if the sundisplay property is omitted in the sun core object, the sun configuration will receive the sun display object properties below.
year, month, day, hours, mins, secs and DST properties are only used at init. to update during the game, use startSecs or update year, month... etc and set suninit to False

sun display object :

  • this object will receive the following properties from the sun core object :
    . cyear (type:int)
    . cmonth (type:int)
    . cday (type:int)
    . chours (type:int)
    . cmins (type:int)
    . csecs (type:int)
    . cdaystring (type:string) - display the day of the week,
    . cmonthstring (type:string) - display the month full name,
    . cdayshortstring (type:string) - display the day of the week, short format,
    . cmonthshortstring (type:string) - display the month short name.
    . cTZ (type:int) - Time Zone
    . cDST (type:int) - Daylight Saving Time
    . gametime (type:string) - the current time in seconds since epoch (01/01/1970). is equals to timeSecs (sun config object)
    . suntimemode (type : Bool) - True if localtime is used

reserved object names :

  • OBsunrotZ
  • OBsunrotY


Last Updated on Friday, 23 October 2009 14:20