Day and Night Cycle


For the python city to create a day and night cycle I wanted to use a a direction light so that when it moves it looks like the sunlight moves away and the darkness of light follows. So my initial idea was generate a light source and key it turning so that it looked like the sun and night going clockwise around the city. 

Once I had the idea established I ended up with this piece of code: 

    #Day and Night Cycle creation using a directional light with it turning clockwise and keying it every few frames to create the turning motion.

    light = cmds.directionalLight(i = 10)

    for i in range(25):

        cmds.currentTime( i*15, edit=True )

        cmds.setKeyframe("directionalLight1",v=i*15, at="rotateX")

This piece of code allows me to generate a directional light and set it to spin clockwise five times to replicate a constant day to night throughout the entire city which properly illuminates the city.

Leave a comment

Log in with itch.io to leave a comment.