PDA

View Full Version : Daylight System Time Controller giving odd results


LoneRobot
08-17-2008, 11:28 AM
hi everyone,

posted this as im not sure if it's a bug or my coding. I am trying to set the time on a daylight system for a render pass utility. in the mxs help it says -

To access the controller, create a Daylight system using the Create>Systems tab in the UI and use: $daylight01.controller

this gives acces to a sunanim called solar time which is, i quote "The solar time expressed as an integer value of seconds since midnight. To calculate the hours, minutes and seconds, you can use the following function etc"


when i attempt to get the time it returns odd results. for example if i manually set the time to 14hours:23mins:32secs, typing $Daylight01.controller.solar_time yields 15??

it seems to return a rounded integer of the hour, not the seconds since midnight. anyone else get any joy with this?

TzMtN
08-17-2008, 11:57 AM
try this:
$Daylight01.controller.solar_time.controller.value

LoneRobot
08-17-2008, 12:22 PM
hi matan, thanks for your reply.


i didnt realise that subanim was a controller from the MXs help, it looks like a property that returns a float value. however, while it says it returns a float it follows with "The solar time expressed as an integer value of seconds since midnight." :shrug:

however, im using your method I get a float value but not what i expect from the related function .

example time - 16hrs 36mins 23 secs

fn TimeFromSolarTime solar_time =
(
hrs = int(solar_time/3600.0) -- full hours in the solar_time value
min = int((solar_time - hrs*3600.0)/60.0) -- full minutes in the difference between the full time and the full hours
sec = int(solar_time - hrs*3600.0 - min*60.0 + 0.5) -- full seconds in the rest of the value
#(hrs,min,sec) -- return the result as a 3 elements array
)

-- output
$daylight01.controller.solar_time.controller.value
16.6064
TimeFromSolarTime 16.6064
#(0, 0, 17)

in any case it's not the number of seconds since midnight as per the MXS help, as for the above time it would be 218183? is it that the 16.6064 value apears to be a decimal representation of the time itself rather than elapsed seconds?

TzMtN
08-17-2008, 12:36 PM
try this function:
fn TimeFromSolarTime solarTime =
(
local timeInSecs = solarTime * 3600
local hrs = solarTime as integer
local minsAndSecs = mod timeInSecs 3600
local min = (minsAndSecs / 60) as integer
local sec = (mod minsAndSecs 60) as integer
print ("the time is: " + hrs as string + " hours, " + min as string + " minutes and " + sec as string + " seconds.")
#(hrs,min,sec)
)

LoneRobot
08-17-2008, 01:10 PM
thanks matan! so when I have to set the time i do it as a decimal fraction of the minutes and seconds.

TzMtN
08-17-2008, 01:27 PM
the reverse function is as easy as this:
fn solarTimeFromTime hrs min sec =
(
hrs + min / 60.0 + sec / 3600.0
)

LoneRobot
08-17-2008, 08:07 PM
now that's the sort of maths i like! thanks matan!

CGTalk Moderation
08-17-2008, 08:07 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.