Day and Night Cycle
city Project TB2 » Devlog
This code utilizes the cmds
module from Maya to create a directional light representing the sun. It then animates the position and rotation of the light to simulate a day and night cycle.
Here's how the code works:
- The
create_day_night_cycle()
function creates a directional light named 'sunlight' to represent the sun. - The initial position of the sun is set to (0, 50, 0) using the
cmds.move()
function. - The function then enters a loop that iterates over 24 frames, representing the hours of the day.
- Inside the loop, the current time is set using
cmds.currentTime(i)
, wherei
represents the current hour. - The rotation of the sun_light is adjusted based on the current hour to simulate its movement throughout the day.
- The intensity of the sun_light is also adjusted based on the time of day, with a lower intensity during night-time hours and a higher intensity during daytime hours.
- The
cmds.refresh()
function is called to refresh the scene and update the changes made to the sunlight.
Executing the code will result in a day and night cycle, with the sun moving across the sky and the intensity of the light changing accordingly.
city Project TB2
Status | Prototype |
Category | Other |
Author | oakley landing |
More posts
- SnowMay 26, 2023
- Creating the buildingsMay 26, 2023
Leave a comment
Log in with itch.io to leave a comment.