|
TNTmips Downloads Menu

|
DayNight.sml
See other
examples of TNTsim3D scripts ...
# DayNight.sml
# TNTsim3D script to vary sun position, sky color, and fog to create day/night cycles
#####################################################################################
### For a script to run under TNTsim3D, it must include an instance of
### class TNTSIM3D named "TNTsim3D". The script must also be saved as an RVC
### object in the TNTsim3D Landscape File you want to run it with.
#####################################################################################
# declare class instance for TNTsim3D interface class
class TNTSIM3D TNTsim3D;
class COLOR bgcolor, fcolor; # class instances for background and fog colors
# set initial sky color to pale blue
bgcolor.red = 70; bgcolor.green = 90; bgcolor.blue = 100;
TNTsim3D.BackgroundColor = bgcolor;
# compute HIS values for initial background color
numeric hue, intmax, satmax;
ConvertRGBtoHIS(100, bgcolor.red, bgcolor.green, bgcolor.blue, hue, intmax, satmax);
# set intial fog parameters
fcolor.red = 0; fcolor.green = 0; fcolor.blue = 0; # black fog for night
TNTsim3D.FogColor = fcolor;
TNTsim3D.FogType = "Exponential";
TNTsim3D.UseFog = 1;
# Reference angle; start at noon
numeric angle = 90;
########################################################################
### SML function name predefined in TNTsim3D, called for each frame.
########################################################################
func OnFrame ()
{
# Decrement reference angle and compute scale from it.
# Scale varies between 1 (noon = 90 degrees) and 0 (midnight = 270 degrees)
# once in each 360 degree cycle.
angle = angle - 0.2;
if (angle <= 0)
angle = 360;
local numeric scale = (sind(angle) + 1) * .5;
# Vary intensity and saturation of sky color between initial values and 0
local numeric inten, sat, red, green, blue;
inten = intmax * scale;
sat = satmax * scale;
# Convert to RGB to find components of background color
ConvertHIStoRGB(100, hue, inten, sat, red, green, blue);
# assign components of background color class and set background color for frame
bgcolor.red = red;
bgcolor.green = green;
bgcolor.blue = blue;
TNTsim3D.BackgroundColor = bgcolor;
# Vary fog density
TNTsim3D.FogDensity = 300 - (scale * 300);
# Vary sun elevation angle between -60 and + 60 and azimuth from 100 to 260
TNTsim3D.SunElevationAngle = (scale * 120) - 60;
if (TNTsim3D.SunElevationAngle <= 0) then
TNTsim3D.SunElevationAngle = -90;
TNTsim3D.SunAzimuthAngle = 360 - (angle + 90);
}
©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010 USA
Business & Sales: (402)477-9554 Support: (402)477-9562 Fax: (402)477-9559
Business info@microimages.com
Support support@microimages.com
Web webmaster@microimages.com
| |