---------------------------------------------------------------------------------------
local PREFIX_PATH = "Data/Textures/Scenes/09_Andreas_house/Anim/Bg/"
---------------------------------------------------------------------------------------
createCompositionBG = nil
createCompositionBlue_rays_smal = nil
createCompositionPIL = nil
createCompositionPilka = nil
createCompositionpiluka = nil
createCompositionSky = nil
---------------------------------------------------------------------------------------
createCompositionBG = function()
	local compositionBG = CreateCompositionSequence()
	local compositionDuration = 8
	compositionBG:setDuration(compositionDuration)
	compositionBG:setName("compositionBG" )
	compositionBG:setBoundingBox( Rectanglef(0, 0, 1366,768) )
 
	local element
	local effector
 
	-- Layer PIL/1
	element = createCompositionPIL()
	element:setName("PIL/1")
	compositionBG:addElement(element)
	element:setHotSpot(512, 384)
	element:setParentElement(compositionBG)
	element:setXY(1365, 384)
 
	element:setOpacity(0.7)
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
 
	-- Layer PIL/2
	element = createCompositionPIL()
	element:setName("PIL/2")
	compositionBG:addElement(element)
	element:setHotSpot(512, 384)
	element:setParentElement(compositionBG)
	element:setXY(347, 384)
 
	element:setOpacity(0.7)
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
 
	-- Layer night_fly_[].png/3
	element = CreateCompositionElement(PREFIX_PATH.."night_fly_[].png")
	element:setName("night_fly_[].png/3")
	compositionBG:addElement(element)
	element:setHotSpot(64, 64)
	element:setParentElement(compositionBG)
	element:setXY(281, 172)
 
	element:setScale(0.7,0.7)
	element:setOpacity(0.6)
					local anim = element
					anim:setAnimationSize(128,128)
					anim:setFramesCount(22)
					anim:setFPS(11)
					anim:setMode(_ANIM_FWD + _ANIM_LOOP)
					anim:setBlend(_EBlendModeColorAdd)
					anim:play()
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
 
	-- Layer ogon.png/4
	element = CreateCompositionElement(PREFIX_PATH.."ogon.png")
	element:setName("ogon.png/4")
	compositionBG:addElement(element)
	element:setHotSpot(32.5, 33)
	element:setParentElement(compositionBG)
	element:setXY(283, 190.5)
 
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:setKey(_TRACK_SX, 0, 0.92286563737728)
	effector:setKey(_TRACK_SY, 0, 1.02749727045937)
	effector:setKey(_TRACK_SX, 0.375, 1.13958498391133)
	effector:setKey(_TRACK_SY, 0.375, 0.8805789284435)
	effector:setKey(_TRACK_SX, 0.5, 1.14591008450161)
	effector:setKey(_TRACK_SY, 0.5, 0.86960216273398)
	effector:setKey(_TRACK_SX, 0.625, 1.03397824531072)
	effector:setKey(_TRACK_SY, 0.625, 0.86941735680003)
	effector:setKey(_TRACK_SX, 0.91666666666667, 1.00208184320465)
	effector:setKey(_TRACK_SY, 0.91666666666667, 1.09941998147861)
	effector:setKey(_TRACK_SX, 1.29166666666667, 1.01408482437379)
	effector:setKey(_TRACK_SY, 1.29166666666667, 1.07005366519392)
	effector:setKey(_TRACK_SX, 1.625, 0.91048174746057)
	effector:setKey(_TRACK_SY, 1.625, 1.03041802168746)
	effector:setKey(_TRACK_SX, 1.875, 1.06165222744827)
	effector:setKey(_TRACK_SY, 1.875, 0.944571173541)
	effector:setKey(_TRACK_SX, 2.08333333333333, 1.13038293724501)
	effector:setKey(_TRACK_SY, 2.08333333333333, 0.95943980752466)
	effector:setKey(_TRACK_SX, 2.75, 1.00213170721605)
	effector:setKey(_TRACK_SY, 2.75, 1.00477863852541)
	effector:setKey(_TRACK_SX, 3.08333333333333, 0.87958282891902)
	effector:setKey(_TRACK_SY, 3.08333333333333, 0.90665454499603)
	effector:setKey(_TRACK_SX, 3.125, 0.87921763898502)
	effector:setKey(_TRACK_SY, 3.125, 0.91438761242909)
	effector:setKey(_TRACK_SX, 3.83333333333333, 1.0999053486479)
	effector:setKey(_TRACK_SY, 3.83333333333333, 1.14161713176349)
	effector:setKey(_TRACK_SX, 4.16666666666667, 1.13080027558929)
	effector:setKey(_TRACK_SY, 4.16666666666667, 0.94163125852853)
	effector:setKey(_TRACK_SX, 4.33333333333333, 1.13599969392148)
	effector:setKey(_TRACK_SY, 4.33333333333333, 0.94493219070675)
	effector:setKey(_TRACK_SX, 4.875, 1.12088727462265)
	effector:setKey(_TRACK_SY, 4.875, 0.98164835603369)
	effector:setKey(_TRACK_SX, 4.95833333333333, 1.04588650243842)
	effector:setKey(_TRACK_SY, 4.95833333333333, 0.98318166869301)
	effector:setKey(_TRACK_SX, 5.16666666666667, 0.95986273658379)
	effector:setKey(_TRACK_SY, 5.16666666666667, 0.98283482151035)
	effector:setKey(_TRACK_SX, 5.33333333333333, 1.00810887448882)
	effector:setKey(_TRACK_SY, 5.33333333333333, 0.80420555446971)
	effector:setKey(_TRACK_SX, 5.5, 0.99827095933974)
	effector:setKey(_TRACK_SY, 5.5, 0.80441411233554)
	effector:setKey(_TRACK_SX, 5.66666666666667, 0.87669951958248)
	effector:setKey(_TRACK_SY, 5.66666666666667, 0.8199507842089)
	effector:setKey(_TRACK_SX, 5.83333333333333, 0.92946571378127)
	effector:setKey(_TRACK_SY, 5.83333333333333, 0.91237930543282)
	effector:setKey(_TRACK_SX, 5.91666666666667, 0.93582969983122)
	effector:setKey(_TRACK_SY, 5.91666666666667, 0.90167060383751)
	effector:setKey(_TRACK_SX, 6.08333333333333, 0.94663409919377)
	effector:setKey(_TRACK_SY, 6.08333333333333, 0.86632257570083)
	effector:setKey(_TRACK_SX, 6.41666666666667, 1.1261943359978)
	effector:setKey(_TRACK_SY, 6.41666666666667, 0.98129155110353)
	effector:setKey(_TRACK_SX, 6.70833333333333, 1.12555313198558)
	effector:setKey(_TRACK_SY, 6.70833333333333, 0.90897194557504)
	effector:setKey(_TRACK_SX, 6.83333333333333, 1.12410934909521)
	effector:setKey(_TRACK_SY, 6.83333333333333, 0.90515462313325)
	effector:setKey(_TRACK_SX, 7.16666666666667, 1.02197277334664)
	effector:setKey(_TRACK_SY, 7.16666666666667, 1.0453869720402)
	effector:setKey(_TRACK_SX, 7.25, 1.01587942992284)
	effector:setKey(_TRACK_SY, 7.25, 1.04014811337576)
	effector:setKey(_TRACK_SX, 7.5, 0.99164877611812)
	effector:setKey(_TRACK_SY, 7.5, 0.95123294027517)
	effector:setKey(_TRACK_SX, 7.95833333333333, 0.92286563737728)
	effector:setKey(_TRACK_SY, 7.95833333333333, 1.02749727045937)
	effector:setKey(_TRACK_O, 0, 0.75992303676713)
	effector:setKey(_TRACK_O, 0.25, 0.91462079226463)
	effector:setKey(_TRACK_O, 0.41666666666667, 0.99030751987904)
	effector:setKey(_TRACK_O, 1.58333333333333, 0.7552848789919)
	effector:setKey(_TRACK_O, 1.83333333333333, 0.90009661877295)
	effector:setKey(_TRACK_O, 2.04166666666667, 0.98606725186955)
	effector:setKey(_TRACK_O, 3.125, 0.62104038288667)
	effector:setKey(_TRACK_O, 3.375, 0.76140339130256)
	effector:setKey(_TRACK_O, 3.58333333333333, 0.8539390602371)
	effector:setKey(_TRACK_O, 4, 0.80751063009675)
	effector:setKey(_TRACK_O, 4.41666666666667, 0.95166397041528)
	effector:setKey(_TRACK_O, 5.125, 0.74929395499675)
	effector:setKey(_TRACK_O, 5.375, 0.83535953062337)
	effector:setKey(_TRACK_O, 5.70833333333333, 0.73290961972651)
	effector:setKey(_TRACK_O, 6.16666666666667, 0.72378071419113)
	effector:setKey(_TRACK_O, 6.79166666666667, 0.91063740085899)
	effector:setKey(_TRACK_O, 7.16666666666667, 0.7509611181416)
	effector:setKey(_TRACK_O, 7.79166666666667, 0.79807159419522)
	effector:setKey(_TRACK_O, 7.95833333333333, 0.75992303676713)
	effector:play()
 
 
	-- Layer Yellow_glow.png/5
	element = CreateCompositionElement(PREFIX_PATH.."Yellow_glow.png")
	element:setName("Yellow_glow.png/5")
	compositionBG:addElement(element)
	element:setHotSpot(50, 50)
	element:setParentElement(compositionBG)
	element:setXY(282.25, 177.75)
 
					local anim = element
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:setKey(_TRACK_O, 0, 0.64967776242618)
	effector:setKey(_TRACK_O, 0.125, 0.70830300981596)
	effector:setKey(_TRACK_O, 0.29166666666667, 0.64080246100783)
	effector:setKey(_TRACK_O, 0.41666666666667, 0.60126350793715)
	effector:setKey(_TRACK_O, 0.58333333333333, 0.65543136832112)
	effector:setKey(_TRACK_O, 1.08333333333333, 0.59989239786197)
	effector:setKey(_TRACK_O, 1.375, 0.53595056527965)
	effector:setKey(_TRACK_O, 1.5, 0.58050861238045)
	effector:setKey(_TRACK_O, 1.625, 0.66243199613781)
	effector:setKey(_TRACK_O, 1.75, 0.69079957503465)
	effector:setKey(_TRACK_O, 2.875, 0.49389296466741)
	effector:setKey(_TRACK_O, 3.45833333333333, 0.56685612325497)
	effector:setKey(_TRACK_O, 3.625, 0.49959937187926)
	effector:setKey(_TRACK_O, 3.75, 0.46296393411448)
	effector:setKey(_TRACK_O, 4, 0.64917319550462)
	effector:setKey(_TRACK_O, 4.125, 0.70328970194782)
	effector:setKey(_TRACK_O, 4.41666666666667, 0.61307780336308)
	effector:setKey(_TRACK_O, 4.625, 0.65170586555384)
	effector:setKey(_TRACK_O, 4.75, 0.5771973529629)
	effector:setKey(_TRACK_O, 4.91666666666667, 0.52118510939552)
	effector:setKey(_TRACK_O, 5.16666666666667, 0.64438920375849)
	effector:setKey(_TRACK_O, 5.33333333333333, 0.58486926709692)
	effector:setKey(_TRACK_O, 6.08333333333333, 0.49847004115299)
	effector:setKey(_TRACK_O, 6.25, 0.45533388294309)
	effector:setKey(_TRACK_O, 6.5, 0.61953759054462)
	effector:setKey(_TRACK_O, 6.66666666666667, 0.69292526617365)
	effector:setKey(_TRACK_O, 6.91666666666667, 0.54791646628954)
	effector:setKey(_TRACK_O, 7.125, 0.4971359770955)
	effector:setKey(_TRACK_O, 7.25, 0.47541533947867)
	effector:setKey(_TRACK_O, 7.95833333333333, 0.64967776242618)
	effector:play()
 
 
	-- Layer Blue_rays_smal/6
	element = createCompositionBlue_rays_smal()
	element:setName("Blue_rays_smal/6")
	compositionBG:addElement(element)
	element:setHotSpot(683, 384)
	element:setParentElement(compositionBG)
	element:setXY(683, 384)
 
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
 
	local points = vector_Vector2f()
	local point_table = {{ x = 1031, y = 86}, { x = 930, y = 92}, { x = 641, y = 108}, { x = 600, y = 433}, { x = 1047, y = 426}, { x = 1033, y = 204}, }
	for _, v in ipairs(point_table) do
	    points:push_back( Vector2f(v.x, v.y) )
	end
	local ver = vector_Vector2f()
	local index = vector_unsigned_short()
	triangulation(points, ver, index)
	
	local ro = CreateRenderedObject()
	ro:attachTo(element)
	ro:setPosition(-element:getPosition())
	ro:getSurface(0):setVertices(ver)
	ro:getSurface(0):setTexCoords(points)
	ro:getSurface(0):setIndices(index)
	element:setMaskObject(ro)
	element:setMaskInside(true)
 
 
	-- Layer Luchi.png/7
	element = CreateCompositionElement(PREFIX_PATH.."Luchi.png")
	element:setName("Luchi.png/7")
	compositionBG:addElement(element)
	element:setHotSpot(142.5, 127.5)
	element:setParentElement(compositionBG)
	element:setXY(897, 204)
 
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
 
	-- Layer Sky/8
	element = createCompositionSky()
	element:setName("Sky/8")
	compositionBG:addElement(element)
	element:setHotSpot(683, 384)
	element:setParentElement(compositionBG)
	element:setXY(683, 384)
 
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
 
	local points = vector_Vector2f()
	local point_table = {{ x = 1031.5, y = 86}, { x = 930, y = 91.5}, { x = 932, y = 204.5}, { x = 1034.5, y = 205.5}, }
	for _, v in ipairs(point_table) do
	    points:push_back( Vector2f(v.x, v.y) )
	end
	local ver = vector_Vector2f()
	local index = vector_unsigned_short()
	triangulation(points, ver, index)
	
	local ro = CreateRenderedObject()
	ro:attachTo(element)
	ro:setPosition(-element:getPosition())
	ro:getSurface(0):setVertices(ver)
	ro:getSurface(0):setTexCoords(points)
	ro:getSurface(0):setIndices(index)
	element:setMaskObject(ro)
	element:setMaskInside(true)
 
	compositionBG:play()
 
	return compositionBG
end
 
createCompositionBlue_rays_smal = function()
	local compositionBlue_rays_smal = CreateCompositionSequence()
	local compositionDuration = 8
	compositionBlue_rays_smal:setDuration(compositionDuration)
	compositionBlue_rays_smal:setName("compositionBlue_rays_smal" )
	compositionBlue_rays_smal:setBoundingBox( Rectanglef(0, 0, 1366,768) )
 
	local element
	local effector
 
	-- Layer Blue_rays_smal_[].png/1
	element = CreateCompositionElement(PREFIX_PATH.."Blue_rays_smal_[].png")
	element:setName("Blue_rays_smal_[].png/1")
	compositionBlue_rays_smal:addElement(element)
	element:setHotSpot(34, 59)
	element:setParentElement(compositionBlue_rays_smal)
	element:setXY(897, 220)
 
	element:setScale(5.70638450868209,1.45831908665583)
	element:setRotationRad(-0.6981317)
					local anim = element
					anim:setAnimationSize(68,118)
					anim:setFramesCount(42)
					anim:setFPS(21)
					anim:setMode(_ANIM_FWD + _ANIM_LOOP)
					anim:setBlend(_EBlendModeColorAdd)
					anim:play()
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
	compositionBlue_rays_smal:play()
 
	return compositionBlue_rays_smal
end
 
createCompositionPIL = function()
	local compositionPIL = CreateCompositionSequence()
	local compositionDuration = 8
	compositionPIL:setDuration(compositionDuration)
	compositionPIL:setName("compositionPIL" )
	compositionPIL:setBoundingBox( Rectanglef(0, 0, 1024,768) )
 
	local element
	local effector
 
	-- Layer piluka/1
	element = createCompositionpiluka()
	element:setName("piluka/1")
	compositionPIL:addElement(element)
	element:setHotSpot(320, 240)
	element:setParentElement(compositionPIL)
	element:setXY(205, 354)
 
	element:setScale(-1.01,1.0289375)
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
 
	-- Layer piluka/2
	element = createCompositionpiluka()
	element:setName("piluka/2")
	compositionPIL:addElement(element)
	element:setHotSpot(320, 240)
	element:setParentElement(compositionPIL)
	element:setXY(479, 422)
 
	element:setScale(-1.83,1.8643125)
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
 
	-- Layer piluka/3
	element = createCompositionpiluka()
	element:setName("piluka/3")
	compositionPIL:addElement(element)
	element:setHotSpot(320, 240)
	element:setParentElement(compositionPIL)
	element:setXY(199, 310)
 
	element:setScale(0.55,0.55)
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
 
	-- Layer piluka/4
	element = createCompositionpiluka()
	element:setName("piluka/4")
	compositionPIL:addElement(element)
	element:setHotSpot(320, 240)
	element:setParentElement(compositionPIL)
	element:setXY(199, 310)
 
	element:setScale(0.55,0.55)
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
	compositionPIL:play()
 
	return compositionPIL
end
 
createCompositionPilka = function()
	local compositionPilka = CreateCompositionSequence()
	local compositionDuration = 8
	compositionPilka:setDuration(compositionDuration)
	compositionPilka:setName("compositionPilka" )
	compositionPilka:setBoundingBox( Rectanglef(0, 0, 1024,768) )
 
	local element
	local effector
 
	-- Layer PIL/1
	element = createCompositionPIL()
	element:setName("PIL/1")
	compositionPilka:addElement(element)
	element:setHotSpot(512, 384)
	element:setParentElement(compositionPilka)
	element:setXY(512, 384)
 
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:play()
 
	compositionPilka:play()
 
	return compositionPilka
end
 
createCompositionpiluka = function()
	local compositionpiluka = CreateCompositionSequence()
	local compositionDuration = 8
	compositionpiluka:setDuration(compositionDuration)
	compositionpiluka:setName("compositionpiluka" )
	compositionpiluka:setBoundingBox( Rectanglef(0, 0, 640,480) )
 
	local element
	local effector
 
	-- Layer piluka.png/1
	element = CreateCompositionElement(PREFIX_PATH.."piluka.png")
	element:setName("piluka.png/1")
	compositionpiluka:addElement(element)
	element:setHotSpot(320, 240)
	element:setParentElement(compositionpiluka)
					local anim = element
					anim:setBlend(_EBlendModeColorAdd)
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:setKey(_TRACK_X, 0, 332.88456758836)
	effector:setKey(_TRACK_Y, 0, 228.910974877944)
	effector:setKey(_TRACK_X, 7.95833333333333, 121)
	effector:setKey(_TRACK_Y, 7.95833333333333, 212)
	effector:setKey(_TRACK_SX, 0, 1.18094240837696)
	effector:setKey(_TRACK_SY, 0, 1.18094240837696)
	effector:setKey(_TRACK_SX, 7.95833333333333, 1.36)
	effector:setKey(_TRACK_SY, 7.95833333333333, 1.36)
	effector:setKey(_TRACK_O, 0, 1)
	effector:setKey(_TRACK_O, 7.95833333333333, 0)
	effector:play()
 
 
	-- Layer piluka.png/2
	element = CreateCompositionElement(PREFIX_PATH.."piluka.png")
	element:setName("piluka.png/2")
	compositionpiluka:addElement(element)
	element:setHotSpot(320, 240)
	element:setParentElement(compositionpiluka)
					local anim = element
					anim:setBlend(_EBlendModeColorAdd)
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:setKey(_TRACK_X, 0, 547)
	effector:setKey(_TRACK_Y, 0, 246)
	effector:setKey(_TRACK_X, 7.95833333333333, 332.88456758836)
	effector:setKey(_TRACK_Y, 7.95833333333333, 228.910974877944)
	effector:setKey(_TRACK_SX, 0, 1)
	effector:setKey(_TRACK_SY, 0, 1)
	effector:setKey(_TRACK_SX, 7.95833333333333, 1.18094240837696)
	effector:setKey(_TRACK_SY, 7.95833333333333, 1.18094240837696)
	effector:setKey(_TRACK_O, 0, 0)
	effector:setKey(_TRACK_O, 7.95833333333333, 1)
	effector:play()
 
	compositionpiluka:play()
 
	return compositionpiluka
end
 
createCompositionSky = function()
	local compositionSky = CreateCompositionSequence()
	local compositionDuration = 8
	compositionSky:setDuration(compositionDuration)
	compositionSky:setName("compositionSky" )
	compositionSky:setBoundingBox( Rectanglef(0, 0, 1366,768) )
 
	local element
	local effector
 
	-- Layer Sky.png/1
	element = CreateCompositionElement(PREFIX_PATH.."Sky.png")
	element:setName("Sky.png/1")
	compositionSky:addElement(element)
	element:setHotSpot(59, 66.5)
	element:setParentElement(compositionSky)
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:setKey(_TRACK_X, 0, 996.197281886913)
	effector:setKey(_TRACK_Y, 0, 147.756323137401)
	effector:setKey(_TRACK_X, 7.95833333333333, 1035)
	effector:setKey(_TRACK_Y, 7.95833333333333, 149)
	effector:setKey(_TRACK_X, 8, 1035)
	effector:setKey(_TRACK_Y, 8, 149)
	effector:setKey(_TRACK_SX, 0, 1.75130890052356)
	effector:setKey(_TRACK_SY, 0, 1.75130890052356)
	effector:setKey(_TRACK_SX, 7.95833333333333, 2)
	effector:setKey(_TRACK_SY, 7.95833333333333, 2)
	effector:setKey(_TRACK_SX, 8, 2)
	effector:setKey(_TRACK_SY, 8, 2)
	effector:setKey(_TRACK_O, 0, 1)
	effector:setKey(_TRACK_O, 7.95833333333333, 0)
	effector:play()
 
 
	-- Layer Sky.png/2
	element = CreateCompositionElement(PREFIX_PATH.."Sky.png")
	element:setName("Sky.png/2")
	compositionSky:addElement(element)
	element:setHotSpot(59, 66.5)
	element:setParentElement(compositionSky)
 
	effector = element:getEffector()
	effector:setLifeTime(0, 8)
	effector:setKey(_TRACK_X, 0, 957)
	effector:setKey(_TRACK_Y, 0, 146.5)
	effector:setKey(_TRACK_X, 7.95833333333333, 996.197281886913)
	effector:setKey(_TRACK_Y, 7.95833333333333, 147.756323137401)
	effector:setKey(_TRACK_SX, 0, 1.5)
	effector:setKey(_TRACK_SY, 0, 1.5)
	effector:setKey(_TRACK_SX, 7.95833333333333, 1.75130890052356)
	effector:setKey(_TRACK_SY, 7.95833333333333, 1.75130890052356)
	effector:setKey(_TRACK_O, 0, 0)
	effector:setKey(_TRACK_O, 7.95833333333333, 1)
	effector:play()
 
	compositionSky:play()
 
	return compositionSky
end
 
