FM_ALPHABLEND = 0
FM_ADDITIVE = 1
FM_SUBTRACTIVE = 2
FM_INVERT = 3
FM_INVERTDEST = 4
FM_MASK = 5
FM_MULTIPLY = 6
FM_INVMULTIPLY = 7
FM_COLORMULTIPLY = 8
SET_VAR_INT = 0
SET_VAR_FLOAT = 1
SET_VAR_BOOL = 2
EV_FX_ATTACH = 0
EV_FX_UNATTACH = 1
EV_FX_RESET = 2
EV_FX_SETSPEED = 3
EV_FX_SETALPHA = 4
EV_FX_SETBLEND = 5
EV_FX_SETTIME = 6
EV_FX_SETFILTER = 7
EV_FX_SETVAR = 8
EV_FF_SETVAR = 9
CInit(175.0, 0, 17, false)
CLoadMusic("soundtrack.mp3")
------------INIT
envi_smth = CLoadFX("qt/3d/envi_smth.nly")
shinelight = CLoadFX("qt/3d/shinelight.nly")
noise = CLoadFX("qt/2d/noise.nly")
glow = CLoadFX("qt/2d/glow.nly")
cave = CLoadFX("qt/3d/cave.nly")
orbInv = CLoadFX("qt/3d/orb_inv.nly")
clickZ = CLoadFX("qt/3d/clickZ.nly")
click = CLoadFX("qt/3d/click.nly")
multicube = CLoadFX("qt/3d/multicube.nly")
varray = CLoadFX("qt/3d/varray.nly")
eye = CLoadFX("qt/3d/eye.nly")

cCod = CLoadFX("qt/2d/code.nly")
cGfx = CLoadFX("qt/2d/3d.nly")
cMus = CLoadFX("qt/2d/music.nly")
cThk = CLoadFX("qt/2d/thank.nly")
cSpm = CLoadFX("qt/2d/spacemail.nly")

fxGamma1 = CLoadFX("qt/fx/gamma1.nly")

------------SMOOTH
CAddEvent(EV_FX_ATTACH, 0, fxGamma1, 9)
CAddEvent(EV_FX_ATTACH, 0.5, envi_smth, 0)
CAddEvent(EV_FX_ATTACH, 0.5, shinelight, 1)
CAddEvent(EV_FX_ATTACH, 0.5, noise, 7)

CAddEvent(EV_FX_SETALPHA, 0, envi_smth, 0, 1, 2)

CAddEvent(EV_FX_SETALPHA, 0.75, noise, 0.06)
CAddEvent(EV_FX_SETALPHA, 0, shinelight, 0.6)

CAddEvent(EV_FX_SETALPHA, 20.0, glow, 0, 0.33, 1)
CAddEvent(EV_FX_ATTACH, 20, glow, 3)
CAddEvent(EV_FX_SETALPHA, 21.5, noise, 0.06, 0.16, 0.5)

------------HUE CHANGE
CAddEvent(EV_FF_SETVAR, 0, fxGamma1, SET_VAR_FLOAT, "hue", 0.5, 0.1, 40) 
--CAddEvent(EV_FF_SETVAR, 43, fxGamma1, SET_VAR_FLOAT, "hue", 0.1, 0.4, 20)
CAddEvent(EV_FF_SETVAR, 28, fxGamma1, SET_VAR_FLOAT, "saturation", 0.49, 0.6, 4)
------CAddEvent(EV_FF_SETVAR, 40, fxGamma1, SET_VAR_FLOAT, "saturation", 0.6, 0.49, 2)
------------CAVE
CAddEvent(EV_FX_SETALPHA, 42, shinelight, 0.6, 0.3, 5)
-----------------CAddEvent(EV_FF_SETVAR, 41.5, fxGamma1, SET_VAR_FLOAT, "saturation", 0.4, 0.7, 30)
CAddEvent(EV_FX_SETALPHA, 41.5, noise, 0.16, 0.08, 1)


--speedup
CAddEvent(EV_FX_SETALPHA, 40, envi_smth, 1, 0, 1)
CAddEvent(EV_FX_UNATTACH, 41.5, envi_smth)
CAddEvent(EV_FX_SETALPHA, 44.6, envi_smth, 1)
--
CAddEvent(EV_FF_SETVAR, 35, fxGamma1, SET_VAR_FLOAT, "saturation", 0.6, 1, 7)
CAddEvent(EV_FF_SETVAR, 42.7, fxGamma1, SET_VAR_FLOAT, "saturation", 1, 0.7, 0.3)
CAddEvent(EV_FF_SETVAR, 42.7, fxGamma1, SET_VAR_FLOAT, "hue", 0.8, 0.4, 20)

CAddEvent(EV_FX_SETALPHA, 40, cave, 0)
CAddEvent(EV_FX_ATTACH, 41.6, cave, 2)
CAddEvent(EV_FX_SETALPHA, 41.5, cave, 0, 0.4, 2)
CAddEvent(EV_FF_SETVAR, 41, cave, SET_VAR_FLOAT, "Radio", 1, 0.07, 3) 
CAddEvent(EV_FX_SETALPHA, 61.5, cave, 0.4, 0, 3)
CAddEvent(EV_FF_SETVAR, 61.5, cave, SET_VAR_FLOAT, "Radio", 0.07, 1, 3) 
CAddEvent(EV_FX_UNATTACH, 63.7, cave)
------------SCENE2
CAddEvent(EV_FX_ATTACH, 63.7, envi_smth, 0)
CAddEvent(EV_FX_ATTACH, 63.7, orbInv, 2)
CAddEvent(EV_FX_SETALPHA, 64, orbInv, 0, 0.5, 0.1)
CAddEvent(EV_FX_SETSPEED, 64, orbInv, 5, 1.5, 2.5)
CAddEvent(EV_FF_SETVAR, 64-0.25, fxGamma1, SET_VAR_FLOAT, "hue", 0.4, 0.5, 0.5)
CAddEvent(EV_FX_SETSPEED, 66.6, orbInv, 5, 1.5, 1.5)
CAddEvent(EV_FF_SETVAR, 66.6-0.25, fxGamma1, SET_VAR_FLOAT, "hue", 0.5, 0.6, 0.5)
CAddEvent(EV_FX_SETSPEED, 69.2, orbInv, 5, 1.5, 2.5)
CAddEvent(EV_FF_SETVAR, 69.2-0.25, fxGamma1, SET_VAR_FLOAT, "hue", 0.6, 0.68, 0.5)
CAddEvent(EV_FX_SETSPEED, 71.6, orbInv, 5, 1.5, 0.75)
CAddEvent(EV_FF_SETVAR, 71.6-0.25, fxGamma1, SET_VAR_FLOAT, "hue", 0.68, 0.75, 0.5)
CAddEvent(EV_FX_SETSPEED, 72.6, orbInv, 3, 1.5, 0.75)
CAddEvent(EV_FF_SETVAR, 72.6-0.25, fxGamma1, SET_VAR_FLOAT, "hue", 0.75, 0.77, 0.5)
CAddEvent(EV_FX_SETSPEED, 74.6, orbInv, 5, 1.5, 2.5)
CAddEvent(EV_FF_SETVAR, 74.6-0.25, fxGamma1, SET_VAR_FLOAT, "hue", 0.77, 0.90, 0.5)
CAddEvent(EV_FX_SETALPHA, 74.6, orbInv, 0.5, 0, 5)
CAddEvent(EV_FX_UNATTACH, 80.0, orbInv)
------------SCENE3
CAddEvent(EV_FF_SETVAR, 79.3, fxGamma1, SET_VAR_FLOAT, "saturation", 0.7, 1, 0.8)
CAddEvent(EV_FF_SETVAR, 80.1, fxGamma1, SET_VAR_FLOAT, "hue", 0.6)
CAddEvent(EV_FF_SETVAR, 80.1, fxGamma1, SET_VAR_FLOAT, "saturation", 1, 0.7, 0.8)
CAddEvent(EV_FX_ATTACH, 80.1, clickZ, 2)
CAddEvent(EV_FX_SETALPHA, 90.8, clickZ, 0, 0.6, 0.2)
CAddEvent(EV_FX_SETSPEED, 85.3, clickZ, 4, 1, 2)
CAddEvent(EV_FX_SETSPEED, 90.6, clickZ, 4, 1, 2)
CAddEvent(EV_FX_SETALPHA, 90.6, clickZ, 0.6, 0, 5)
CAddEvent(EV_FX_UNATTACH, 95.7, clickZ)
------------SCENE4
CAddEvent(EV_FF_SETVAR, 95.0, fxGamma1, SET_VAR_FLOAT, "saturation", 0.7, 1, 0.8)
CAddEvent(EV_FF_SETVAR, 95.8, fxGamma1, SET_VAR_FLOAT, "hue", 0.25)
CAddEvent(EV_FF_SETVAR, 95.8, fxGamma1, SET_VAR_FLOAT, "saturation", 1, 0.7, 0.8)
CAddEvent(EV_FX_SETVAR, 95.7, multicube, SET_VAR_FLOAT, "Cameras", "1", "Fov", 1, 0.06, 12)
CAddEvent(EV_FX_ATTACH, 95.8, multicube, 2)
CAddEvent(EV_FX_SETALPHA, 95.8, multicube, 0, 0.3, 0.2)

CAddEvent(EV_FX_SETSPEED, 101.2, multicube, 3, 1, 1)
CAddEvent(EV_FX_SETSPEED, 106.4, multicube, 2, 1, 1)
CAddEvent(EV_FX_SETALPHA, 106.4, multicube, 0.3, 0, 5)
CAddEvent(EV_FX_UNATTACH, 111, multicube)


------------SCENE5
CAddEvent(EV_FF_SETVAR, 112.0, fxGamma1, SET_VAR_FLOAT, "hue", 0.25, 0.065, 16)
--CAddEvent(EV_FX_UNATTACH, 112.1, envi_smth)
CAddEvent(EV_FX_ATTACH, 112.2, eye, 2)
CAddEvent(EV_FX_SETALPHA, 112.2, eye, 0, 0.125, 0.2)
CAddEvent(EV_FX_SETSPEED, 114.8, eye, 5, 2.5, 1)
CAddEvent(EV_FX_SETSPEED, 117.4, eye, 5, 2.5, 1)
CAddEvent(EV_FX_SETSPEED, 126.4, eye, 5, 2.5, 1)

CAddEvent(EV_FX_SETALPHA, 126.4, eye, 0.125, 0, 2)
CAddEvent(EV_FX_UNATTACH, 128.5, eye)
--CAddEvent(EV_FX_ATTACH, 128.6, envi_smth, 0)



------------SCENE6
----CAddEvent(EV_FF_SETVAR, 119.6, fxGamma1, SET_VAR_FLOAT, "hue", 0.065)
--CAddEvent(EV_FX_ATTACH, 119.6, click, 2)
--CAddEvent(EV_FX_SETALPHA, 119.6, click, 0, 0.6, 0.2)
--CAddEvent(EV_FX_SETVAR, 119.6, click, SET_VAR_FLOAT, "Cameras", "2", "Fov", 0.5, 0.8, 8)
--CAddEvent(EV_FX_SETVAR, 127.6, click, SET_VAR_FLOAT, "Cameras", "2", "Fov", 0.8, 1, 6)

--CAddEvent(EV_FX_SETSPEED, 126.4, click, 3, 1, 1)
--CAddEvent(EV_FX_SETALPHA, 122.4, click, 0.6, 0, 6)
--CAddEvent(EV_FX_SETSPEED, 122.4, click, 1, 0.1, 6)
--CAddEvent(EV_FX_UNATTACH, 128.5, click)


------------SCENE7
CAddEvent(EV_FF_SETVAR, 128.5, fxGamma1, SET_VAR_FLOAT, "gamma", 0.69,0.75,2)
CAddEvent(EV_FF_SETVAR, 128.5, fxGamma1, SET_VAR_FLOAT, "saturation", 0.7,0.6,3)
CAddEvent(EV_FF_SETVAR, 128.5, fxGamma1, SET_VAR_FLOAT, "brightness", 0.6,0.55,4)
CAddEvent(EV_FF_SETVAR, 128.5, fxGamma1, SET_VAR_FLOAT, "hue", 0.065, 0.6, 40)
CAddEvent(EV_FX_SETALPHA, 128.5, noise, 0.08, 0.04, 5)

CAddEvent(EV_FX_SETALPHA, 128.5, varray, 0)
CAddEvent(EV_FX_ATTACH, 128.6, varray, 2)
CAddEvent(EV_FX_SETALPHA, 128.6, varray, 0, 0.4, 1)




CAddEvent(EV_FF_SETVAR, 142, fxGamma1, SET_VAR_FLOAT, "brightness", 0.55,0.45,4)
CAddEvent(EV_FF_SETVAR, 151, fxGamma1, SET_VAR_FLOAT, "brightness", 0.45,0.55,4)
------------CREDITS
theend = function(start, alpha, dist, length)
   CAddEvent(EV_FX_ATTACH, start, cThk, 4)
   CAddEvent(EV_FX_ATTACH, start+dist, cSpm, 5)
   CAddEvent(EV_FX_SETALPHA, start,	   cThk, 0, 0.33, length)
   CAddEvent(EV_FX_SETALPHA, start+dist,   cSpm, 0, 0.33, length)
   CAddEvent(EV_FX_SETALPHA, start+length*2,		cThk, 0.33, 0, length)
   CAddEvent(EV_FX_SETALPHA, start+dist+length*2,	cSpm, 0.33, 0, length)
   CAddEvent(EV_FX_UNATTACH, start+length*3,	    cThk)
   CAddEvent(EV_FX_UNATTACH, start+dist+length*3,   cSpm)
end


credits = function(start, alpha, dist, length)
   CAddEvent(EV_FX_ATTACH, start, cCod, 4)
   CAddEvent(EV_FX_ATTACH, start+dist, cMus, 5)
   CAddEvent(EV_FX_ATTACH, start+dist*2, cGfx, 6)
   CAddEvent(EV_FX_SETALPHA, start,	   cCod, 0, 0.33, length)
   CAddEvent(EV_FX_SETALPHA, start+dist,   cMus, 0, 0.33, length)
   CAddEvent(EV_FX_SETALPHA, start+dist*2, cGfx, 0, 0.33, length)
   CAddEvent(EV_FX_SETALPHA, start+length*2,		cCod, 0.33, 0, length)
   CAddEvent(EV_FX_SETALPHA, start+dist+length*2,	cMus, 0.33, 0, length)
   CAddEvent(EV_FX_SETALPHA, start+dist*2+length*2,cGfx, 0.33, 0, length)
   CAddEvent(EV_FX_UNATTACH, start+length*3,	    cCod)
   CAddEvent(EV_FX_UNATTACH, start+dist+length*3,   cGfx)
   CAddEvent(EV_FX_UNATTACH, start+dist*2+length*3, cMus)
end

fader1 = function(start, name, alpha, tin, thold, tout, col)
   CAddEvent(EV_FX_ATTACH, start, name, col)
   CAddEvent(EV_FX_SETALPHA, start, name, 0, alpha, tin)
   CAddEvent(EV_FX_SETALPHA, start+hold+tin, name, alpha, 0, tout)
   CAddEvent(EV_FX_UNATTACH, start+hold+tin+tout, name)
end



credits(152,0.5,3.5,2.3)
theend(128,0.5,3,6)
CAddEvent(EV_FF_SETVAR, 168.0, fxGamma1, SET_VAR_FLOAT, "brightness", 0.55,0.2,10)
CAddEvent(EV_FF_SETVAR, 168.0, fxGamma1, SET_VAR_FLOAT, "gamma", 0.75,1,10)
CAddEvent(EV_FF_SETVAR, 168.0, fxGamma1, SET_VAR_FLOAT, "saturation", 0.6,1,5)
CAddEvent(EV_FX_UNATTACH, 173, varray)
CAddEvent(EV_FX_UNATTACH, 174.9, fxGamma1)
CAddEvent(EV_FX_UNATTACH, 174, noise)
CAddEvent(EV_FX_UNATTACH, 174, shinelight)
CAddEvent(EV_FX_UNATTACH, 174, envi_smth)

