Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Change ambient light as sun/moon rotates?

Author
Message
Mugen Wizardry
User Banned
Posted: 23rd Jan 2011 20:16 Edited at: 23rd Jan 2011 20:36
Hi all. Can someone please tell me how to make the ambient light brighter or darker depending where the sun / moon is positioned?

Here's the code:



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Jan 2011 22:19
You get strange results if you set the ambient light percentage to a negative value or a value greater than 100 which is what your code does.

If you have IanM's matrix1 utilities a simple fix is:

Mugen Wizardry
User Banned
Posted: 24th Jan 2011 00:53
thanks alot, green gandalf! ^^

While i'm at it, I might as well ask how to turn the positions / angles of the sun and moon into Hours, Minutes, and seconds dependant on speed

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jan 2011 00:54
Why should they depend on speed?
Mugen Wizardry
User Banned
Posted: 24th Jan 2011 00:59
Because I want the time to be real time. not game time.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jan 2011 13:36 Edited at: 24th Jan 2011 13:45
If the sun goes round your world once that is presumably an angle of 360 degrees in 24 hours (or whatever day length you choose for your world). So time depends entirely on angle. Speed only changes how fast the angle changes. Speed shouldn't affect time directly or you'll get in a muddle.

If you want it to correspond to real earth time then just use changes in timer() to control the changes in angle. You'll need to scale it of course by using the fact that 360 degrees corresponds to 24 hours (= 86400000 milliseconds), i.e. 1 timer() unit means the angle will have changed by 360/86400000 = 0.0000041666666666 degrees.

You'll have to run your program for at least 24 hours to check that it works correctly though.

[Edit: inserted missing word. ]
Mugen Wizardry
User Banned
Posted: 24th Jan 2011 15:35
how exactly would i do this with the material i have?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Jan 2011 19:46
By working it out and testing using seconds instead of miliseconds first.

(Point 1)
For example, Take the timer value, then multiply it by 0.0000041666666666 to get an angle, then rotate your sun object to that angle. (Obviously you'll have to position it into the sky of your world)

What I'd do, is position the sun at 0, 0, 0, then angle the sun on the X or Z angle to get the correct tilt, then rotate it on the Y angle to what the correct sun angle should be. (See point 1) Then move object by a set amount to put it into the sky.

Sorted.

My signature is NOT a moderator plaything! Stop changing it!

Login to post a reply

Server time is: 2026-07-16 12:20:07
Your offset time is: 2026-07-16 12:20:07