#####################################################
#                                                   #
#   HEADER                                          #
#                                                   #
#####################################################

header {
	title: fr-001: Attraction
	width: 1280
	height: 720	
	music: friction.wav.mp3
	bpm: 125.0
}

#####################################################
#                                                   #
#    OBJECTS                                        #
#                                                   #
#####################################################

objects {
	cam: camera {
	}
	env: enviroment {
		lighting: 0
		
		light[0].enable: 1
		light[0].position.z: 20
		light[0].position.y: 20	
	}
	
	# scene 1 OBJECTS
	
	plane: 3ds plane.3ds {
		meshes.image1.lighting: 0
		pos.y: -0.1
		texture: 0 fraction.jpg
	}
	prts1: particles {
		textures: particle1.jpg
		box: ( -1000, 0, -1000 ), ( 1000, 1000, 1000 )
		gravity.y: -10
		maxParticles: 1000
		fadeAway: 0
		emitter {
			radius: 1
			pos: 0, 5, 0
			dir.x: -1, 1
			dir.z: -1, 1
			dir.y: -1, 1
			lifeTime: 1, 10
			color.r: 0.0, 0.5
			color.g: 0.25, 0.5
			color.b: 0.5, 1.0
			color.a: 1.0
			elasticity: 0.1, 0.25
			size: 0.01, 0.1
			#friction: 0.25, 0.5
		}
	}
	
	# scene 2 OBJECTS
	
	build: 3ds build.3ds {
		shader: build.shader
		meshes.cube1.lighting: 0
		wireframe: 1
		generateTexCoords: 1
		materials[0].blendMode: 2
	}
	
	# scene 3 OBJECTS
	
	helix: 3ds helix.3ds {
		shader: build.shader
		meshes.Loft01.lighting: 0
		#wireframe: 1
		generateTexCoords: 1
		materials[0].blendMode: 2
		depthMask: 0
	}
	helix2: duplicate helix {
		rot.y: 90
	}
	helix3: duplicate helix {
		wireframe: 1
		rot.z: 90
	}
	prts2: particles {
		textures: particle1.jpg
		maxParticles: 1000
		emitter {
			radius: 5, 50
			color.a: 0.25, 1.0
			size: 0.1, 0.5
			lifeTime: -1
		}
	}

	# scene 4 OBJECTS
	
	helixb: 3ds helix2.3ds {
		shader: build.shader
		meshes.Loft01.lighting: 0
		#wireframe: 1
		generateTexCoords: 1
		materials[0].blendMode: 2
		depthMask: 0
	}
	helixb2: duplicate helixb {
		rot.y: 90
	}
	helixb3: duplicate helixb {
		wireframe: 1
		rot.z: 90
	}
	
	# scene 5 OBJECTS
	
	prts3: particles {
		textures: particle1.jpg
		maxParticles: 1000
		emitter {
			radius: 5, 50
			color.a: 0.2, 0.5
			size: 0.1, 3.0
			lifeTime: -1
		}
		attractor {
			pos: -25 -15 -10
			gravity: 10000
		}
		attractor {
			pos: 25 15 10
			gravity: 1000
		}
	}
	
	# scene 7 OBJECTS
	
	nice: 3ds nice2.3ds {
		shader: build2.shader
		meshes.cube1.lighting: 0
		#wireframe: 1
		generateTexCoords: 1
		materials[0].blendMode: 2
		depthMask: 0
	}
	
	# scene 8 OBJECTS
	
	flowers: 3ds kukkia.3ds {
		shader: build2.shader
		meshes.cylinder1.lighting: 0
		#wireframe: 1
		generateTexCoords: 1
		materials[0].blendMode: 2
		depthMask: 0
	}
	
	
	# POST PROCESSING
	
	greetImg: image c1.png c2.png c3.png c4.png {
		blend: 1
	}
	glowImg: image *main {
		stretch: 1
	}
	blurXImg: image *glow {
		stretch: 1
		shader: blurX.frag
		shaders[0].blurAmount: 50
	}
	blurYImg: image *blurX {
		stretch: 1
		shader: blurY.frag
		shaders[0].blurAmount: 50
	}
	mainImg: image *main *blurY glowmap.jpg colormap.jpg colormap2.jpg {
		stretch: 1
		shader: final.frag
		multiTexturing: 1
		shaders[0].glowTex: 1
		shaders[0].glowMapTex: 2
		shaders[0].colorMapTex: 3
	}
	overlayImg: image friction001.jpg friction.jpg friction2.jpg jotai.jpg {
		blend: 2
	}
}

#####################################################
#                                                   #
#    RENDER LINES                                   #
#                                                   #
#####################################################

renderLines {
	main {
		exclude: blurXImg, blurYImg, mainImg, overlayImg, glowImg
		output: *main
	}
	glowCopy {
		objects: glowImg
		output: *glow (640, 360)
	}
	blurX {
		objects: blurXImg
		output: *blurX (640, 360)
	}
	blurY {
		objects: blurYImg
		output: *blurY (640, 360)
	}
	final {
		objects: mainImg, overlayImg
	}
}

#####################################################
#                                                   #
#    SCRIPT                                         #
#                                                   #
#####################################################

script {
	@0.0 enable cam, env, blurXImg, blurYImg, mainImg, glowImg
	
	@0.0 call scene_intro
	
	@16.0 call scene_helix
	@24.0 call scene_hexplane
	@32.0 call scene_particles
	@40.0 call scene_weird
	
	@48.0 call scene_credits
	@56.0 call scene_hexplaneb
	@64.0 call scene_particlesb
	@72.0 call scene_flowers
	
	@80.0 call scene_ending
	@88.0 end
}

disableObjs {
	@0.0 disable prts1, plane, build, helix, helix2, helix3, prts2, helixb, helixb2, helixb3, overlayImg, prts3, nice, greetImg, flowers
	@0.0 mainImg.shaders[0].useColorMap = 0
}

scene_hexplane {
	@0.0 call disableObjs
	@0.0 enable prts1, plane

	@0.0 call scene_hexplane_cam( 5, 3.5, @2.0 )
	@2.0 call scene_hexplane_cam( 1, 3.5, @2.0 )
	@4.0 call scene_hexplane_cam( 7, 3.5, @2.0 )
	@6.0 call scene_hexplane_cam( 1, 2, @2.0 )
	@0.0 cam.up.x = -1 to 1 in @8.0

	@0.0 cam.lookAt.x = 0
	@0.0 cam.lookAt.y = 0
	@0.0 cam.lookAt.z = 0
	@0.0 cam.up.z = -1
	
	@0.0 loop @4.0 2 times {
		@0.0 mainImg.shaders[0].glowAmount = 5.0 to 2.0 in @4.0
	}	
}

scene_hexplaneb {
	@0.0 call disableObjs
	@0.0 enable prts1, plane

	@0.0 cam.fovy = 90

	@0.0 loop @4.0 2 times {
		@0.0 call scene_hexplane_cam( 5, 4, @1.0 )
		@1.0 call scene_hexplane_cam( 3, 4, @1.0 )
		@2.0 call scene_hexplane_cam( 3, 2, @1.0 )
		@3.0 call scene_hexplane_cam( 1, 2, @1.0 )
	}
	@0.0 cam.up.x = -1 to 1 in @8.0

	@0.0 cam.lookAt.x = 0
	@0.0 cam.lookAt.y = 0
	@0.0 cam.lookAt.z = 0
	@0.0 cam.up.z = -1
	
	@0.0 prts1.emitter[0].size.max = 0.1 to 0.5 in @8.0
	@0.0 prts1.emitter[0].elasticity.max = 0.25 to 1.0 in @8.0
	
	@0.0 loop @1.0 8 times {
		@0.0 mainImg.shaders[0].glowAmount = 5.0 to 2.0 in @0.1
		@0.1 mainImg.shaders[0].glowAmount = 10.0 to 2.0 in @0.1
		@0.2 mainImg.shaders[0].glowAmount = 5.0 to 2.0 in @0.1
		@0.3 mainImg.shaders[0].glowAmount = 10.0 to 2.0 in @0.1
	}	
}

scene_hexplane_cam: %Y1 %Y2 %TIME {
	@0.0 cam.pos.z = rand( -5 - 5 )
	@0.0 cam.pos.x = rand( -5 - 5 )
	@0.0 cam.pos.y = %Y1 to %Y2 in %TIME
}

scene_intro {
	@0.0 call disableObjs
	@0.0 enable build
	@0.0 mainImg.shaders[0].useColorMap = 1
		
	@0.0 loop @8.0 2 times {
		@0.0 build.shaders[0].end = 0.0 to 1.0 in @8.0
		@0.0 build.shaders[0].start = 0.0
		@6.0 build.shaders[0].start = 0.0 to 1.0 in @2.0
	}

	@0.0 loop @8.0 2 times {
		@0.0 call scene_intro_cam( 5, -5, @4.0 )
		@4.0 call scene_intro_cam( 5, 0, @2.0 )
		@6.0 call scene_intro_cam( -5, 0, @2.0 )
	}
	@0.0 cam.lookAt.x = 0
	@0.0 cam.lookAt.y = 0
	@0.0 cam.lookAt.z = 0
	@0.0 cam.up.z = -1
	@0.0 cam.up.x = -1 to 1 in @4.0

	@0.0 loop @4.0 4 times {
		@0.0 mainImg.shaders[0].glowAmount = 10.0 to 5.0 in @4.0
	}

	@8.0 enable overlayImg
	@8.0 overlayImg.zoom = 0.0 to 0.1 in @8.0
	@15.0 overlayImg.col.a = 1.0 to 0.0 in @1.0
}

scene_intro_cam: %Y1 %Y2 %TIME {
	@0.0 cam.pos.z = rand( -30 - -20 )
	@0.0 cam.pos.x = rand( -10 - 10 )
	@0.0 cam.pos.y = %Y1 to %Y2 in %TIME
}

scene_helix {
	@0.0 call disableObjs
	@0.0 enable helix, helix2, helix3, prts2
	
	@0.0 mainImg.shaders[0].useColorMap = 1
		
	@0.0 loop @4.0 2 times {
		@0.0 helix.shaders[0].start = 0
		@0.0 helix.shaders[0].end = 0
		@0.0 helix2.shaders[0].start = 0
		@0.0 helix2.shaders[0].end = 0
		@0.0 helix3.shaders[0].start = 0
		@0.0 helix3.shaders[0].end = 0
		
		@0.0 helix.shaders[0].end = 0.0 to 1.0 in @4.0
		@1.0 helix.shaders[0].start = 0.0 to 1.0 in @3.0
		@1.0 helix2.shaders[0].end = 0.0 to 1.0 in @2.0
		@2.0 helix2.shaders[0].start = 0.0 to 1.0 in @2.0
		@0.0 helix3.shaders[0].end = 0.0 to 1.0 in @3.0
		@2.0 helix3.shaders[0].start = 0.0 to 1.0 in @2.0
	}
	
	@0.0 helix.rot.y = 0 to 90 in @8.0
	@0.0 helix2.rot.z = 0 to -70 in @8.0
	@0.0 helix3.rot.x = 0 to 50 in @8.0

	@0.0 call scene_intro_cam( 10, -10, @4.0 )
	@4.0 call scene_intro_cam( 5, 0, @2.0 )
	@6.0 call scene_intro_cam( -5, 0, @2.0 )

	@0.0 cam.lookAt.x = 0
	@0.0 cam.lookAt.y = 0
	@0.0 cam.lookAt.z = 0
	@0.0 cam.up.z = -1
	@0.0 cam.up.x = -1 to 1 in @8.0

	@0.0 loop @4.0 2 times {
		@0.0 mainImg.shaders[0].glowAmount = 13.0 to 5.0 in @4.0
	}
}

scene_credits {
	@0.0 call disableObjs
	@0.0 enable helixb, helixb2, helixb3, prts2, greetImg
	
	@0.0 mainImg.shaders[0].useColorMap = 1
		
	@0.0 loop @4.0 2 times {
		@0.0 helixb.shaders[0].start = 0
		@0.0 helixb.shaders[0].end = 0
		@0.0 helixb2.shaders[0].start = 0
		@0.0 helixb2.shaders[0].end = 0
		@0.0 helixb3.shaders[0].start = 0
		@0.0 helixb3.shaders[0].end = 0
		
		@0.0 helixb.shaders[0].end = 0.0 to 1.0 in @4.0
		@1.0 helixb.shaders[0].start = 0.0 to 1.0 in @3.0
		@1.0 helixb2.shaders[0].end = 0.0 to 1.0 in @2.0
		@2.0 helixb2.shaders[0].start = 0.0 to 1.0 in @2.0
		@0.0 helixb3.shaders[0].end = 0.0 to 1.0 in @3.0
		@2.0 helixb3.shaders[0].start = 0.0 to 1.0 in @2.0
	}
	
	@0.0 helixb.rot.y = 0 to 90 in @8.0
	@0.0 helixb2.rot.z = 0 to -70 in @8.0
	@0.0 helixb3.rot.x = 0 to 50 in @8.0

	@0.0 call scene_intro_cam( 5, -5, @4.0 )
	@4.0 call scene_intro_cam( 5, 0, @2.0 )
	@6.0 call scene_intro_cam( -5, 0, @2.0 )

	@0.0 cam.lookAt.x = 0
	@0.0 cam.lookAt.y = 0
	@0.0 cam.lookAt.z = 0
	@0.0 cam.up.z = -1
	#@0.0 cam.up.x = -1 to 1 in @4.0

	@0.0 loop @4.0 2 times {
		@0.0 mainImg.shaders[0].glowAmount = 7.0 to 2.0 in @4.0
	}
	
	@0.0 loop @2.0 4 times {
		@0.0 greetImg.col.a = 0 to 1 in @0.2
		@1.2 greetImg.col.a = 1 to 0 in @0.2
		@0.0 greetImg.pos.x = -200 to -150 in @2.0
	}
	@0.0 greetImg.frame = 0 to 4 in @8.0
}

scene_particles {
	@0.0 call disableObjs
	@0.0 enable prts2, prts3, overlayImg
	@0.0 mainImg.shaders[0].useColorMap = 1
	@0.0 loop @0.2 16 times {
		@0.1 cam.pos.x = rand( -50 - 50 )
		@0.1 cam.pos.y = rand( -50 - 50 )
		@0.1 cam.pos.z = rand( -50 - 50 )
	}
	@0.0 cam.lookAt.x = -25 to 25 in @8.0
	@0.0 cam.lookAt.y = -15 to 15 in @8.0
	@0.0 cam.lookAt.z = -10 to 10 in @8.0
	@0.0 cam.fovy = 80
	@0.0 overlayImg.frame = 3
}

scene_particlesb {
	@0.0 call scene_particles
	@0.0 overlayImg.frame = 1
	@0.0 overlayImg.zoom = 0 to 0.1 in @8.0
	@0.0 overlayImg.col.a = 0 to 1 in @0.2
	@3.0 overlayImg.col.a = 1 to 0 in @1.0
}

scene_ending {
	@0.0 call disableObjs
	@0.0 enable overlayImg
	@0.0 overlayImg.frame = 2
	@0.0 overlayImg.col.a = 0 to 1 in @2.0
	@0.0 overlayImg.zoom = 0.0 to 0.1 in @8.0
	@4.0 overlayImg.col.a = 1.0 to 0.0 in @4.0
	#@4.0 overlayImg.col.r = 1.0 to 0.0 in @4.0
}

scene_weird {
	@0.0 call disableObjs
	@0.0 enable nice, overlayImg
	@0.0 mainImg.shaders[0].useColorMap = 1
	@0.0 nice.shaders[0].foo = 0 to 10 in @8.0
	
	@0.0 loop @0.2 16 times {
		@0.1 cam.pos.x = rand( -10 - 10 )
		@0.1 cam.pos.y = rand( -10 - 10 )
		@0.1 cam.pos.z = rand( -10 - 10 )
	}
	@0.0 cam.lookAt.x = 0
	@0.0 cam.lookAt.y = 0
	@0.0 cam.lookAt.z = 0
	
	@0.0 overlayImg.frame = 3
	@0.0 overlayImg.col.a = 1.0
	@0.0 overlayImg.zoom = 0.0 to 1.0 in @8.0	
	
	@0.0 loop @0.2 15 times {
		@0.1 mainImg.shaders[0].glowAmount = 5.0 to 2.0 in @0.2
	}

	@0.0 cam.fovy = 140
	@8.0 cam.fovy = 45
}

scene_flowers {
	@0.0 call disableObjs
	@0.0 enable flowers, prts2, overlayImg

	@0.0 mainImg.shaders[0].useColorMap = 1
	@0.0 mainImg.shaders[0].colorMapTex = 4
	
	@0.0 loop @0.2 16 times {
		@0.0 cam.pos.x = rand( -10 - 10 )
		@0.0 cam.pos.z = rand( -10 - 10 )
	}
	@0.0 cam.pos.y = -5 to 5 in @4.0
	@4.0 cam.pos.y = 5 to -5 in @4.0
	@0.0 cam.fovy = 90
	@0.0 cam.lookAt.x = 0
	@0.0 cam.lookAt.y = 0
	@0.0 cam.lookAt.z = 0
	
	@0.0 flowers.shaders[0].foo = 0.0 to 8.0 in @8.0
	@0.0 loop @1.0 8 times {
		@0.0 mainImg.shaders[0].glowAmount = 3.0 to 2.0 in @0.1
		@0.1 mainImg.shaders[0].glowAmount = 6.0 to 2.0 in @0.1
		@0.2 mainImg.shaders[0].glowAmount = 3.0 to 2.0 in @0.1
		@0.3 mainImg.shaders[0].glowAmount = 9.0 to 2.0 in @0.1
	}
	@0.0 overlayImg.frame = 3
	@0.0 overlayImg.zoom = 0
	@0.0 overlayImg.col.a = 0 to 1 in @0.2
	@7.2 overlayImg.col.a = 1 to 0 in @0.2
	
}