Simple example:
Graphics3D 1024,768
SetBuffer BackBuffer()
Global camera = CreateCamera()
Global plane = CreatePlane()
RotateEntity plane, -90,0,0
PositionEntity plane, 0,0,5
Global aR, aG, aB, DayNight#
While Not KeyDown(1)
DayNight = ( DayNight + .001 ) Mod 1.0
COLORinterpolate( DayNight , 64,255,64, 64,64,255, 255,64,255 , 64,255,64 )
AmbientLight aR, aG, aB
RenderWorld()
Text 0,0, ar + " "+ ag + " " + ab
Flip
Wend
End
Function COLORinterpolate( t#, r1,g1,b1 , r2, g2, b2 , r3, g3, b3 , r4, g4, b4 )
aR = r1 * (1-t)^3 + 3 * r2 * (1-t)^2 * t + 3 * r3 * (1-t) * t^2 + r4 * t^3
aG = g1 * (1-t)^3 + 3 * g2 * (1-t)^2 * t + 3 * g3 * (1-t) * t^2 + g4 * t^3
aB = b1 * (1-t)^3 + 3 * b2 * (1-t)^2 * t + 3 * b3 * (1-t) * t^2 + b4 * t^3
End Function
[EDIT] Actually, you'd need a 5 pt bezier to do this
An alternative, using Ross's linear interpolation :
Graphics3D 1024,768
SetBuffer BackBuffer()
Global camera = CreateCamera()
Global plane = CreatePlane()
RotateEntity plane, -90,0,0
PositionEntity plane, 0,0,5
Global aR, aG, aB, DayNight#
While Not KeyDown(1)
DayNight = ( DayNight + .01 ) Mod 4.0
COLORinterpolate( DayNight , 64,255,64, 64,64,255, 255,64,64, 255,64,255 )
AmbientLight aR, aG, aB
RenderWorld()
Text 0,0, ar + " "+ ag + " " + ab
Flip
Wend
End
Function COLORinterpolate( t#, r1,g1,b1 , r2, g2, b2 , r3, g3, b3 , r4, g4, b4 )
;get nearest integer below
i = Floor( t )
;get timestep 0 .. 1
t# = t - i
Select i
Case 0
aR = r1 + ( r2 - r1 ) * t
aG = g1 + ( g2 - g1 ) * t
aB = b1 + ( b2 - b1 ) * t
Case 1
aR = r2 + ( r3 - r2 ) * t
aG = g2 + ( g3 - g2 ) * t
aB = b2 + ( b3 - b2 ) * t
Case 2
aR = r3 + ( r4 - r3 ) * t
aG = g3 + ( g4 - g3 ) * t
aB = b3 + ( b4 - b3 ) * t
Case 3
aR = r4 + ( r1 - r4 ) * t
aG = g4 + ( g1 - g4 ) * t
aB = b4 + ( b1 - b4 ) * t
End Select
End Function
Where you pass a float between 0 and 4 ( not including 4 as this gets set back to 0 ) and this determined the time of day and interpolates accordingly.
Stevie