
-- Globals contain all main scene variables

globals = {
	-- Camera
	camera = { x = 0, y=0.0, z=2.0 },
	-- Target position
	target = { x = 0, y=0.3, z=0 },
	up = { x=0, y=1, z=0 },
 	-- Field of view
	fov = 80, 
	-- Currently, only 1 light is supported
	light0 = {   	direction = { x=1, y=10, z=2 }, 
				color = { x=1, y=1, z=1}, 
			},

	-- Ambient background color
	ambient = { x = 0, y = 0, z = 0 },

	-- Sky intensity, 0 to 1     
	sky = 1,
	-- Shadow intensity multiplier, from 1 (no shadows) to 0 (black)
	shadow_scale = 0.5,
	-- Pause scene
	isPaused = 0,

	-- Marching steps, lower value yields faster but less accurate rendering

	raymarch_steps = 100,
	raymarch_shadow_steps = 40

}

-- Output section

output = {
	-- Image output 
	resolution = { width = 320, height=200 },
	-- C64 charset image on / off (if "on", resolution must be <160x200)
	output_type = 0, -- RGB output
	aspect = 1.2,
	-- 0=charset, 1 = multicolor image 
	c64_imageType = 0,
}


-- Sample material #1, low reflections

Material1 = {
	color = { x=1.0, y=0.5, z=0.2 },
	reflection = 0.2,
	shininess = 100,
	shininess_intensity = 1 
}
-- Sample material #2, high relfections

Material2 = {
	color = { x=0.2, y=1.0, z=0.4 },
	reflection = 0.9,
	shininess = 100,
	shininess_intensity = 1 
}

-- Sample material #1, ground

MaterialGround = {
	color = { x=0.2, y=0.6, z=0.4 },
	reflection = 0.0,
	shininess = 10,
	shininess_intensity = 0 

}


-- Init is called on start, sets up the scene
 
function Init()

	--[[ 
		Adding objects parameters: 
			#1 : Type of object (plane, torus, box, cylinder, sphere). Can also be a mesh, load from wavefront .obj file
			#2: Name of the object. All later referals point to this name. 
			#3: Material used
			#4: Position xyz
			#5 and more: Additional parameters (sphere radius, torus, plane normals, box size etc)
			
	]]--


 	AddObject("plane","plane1","","MaterialGround",  0,-1.5,0,   0,1,0);
	AddObject("torus","torus1","","Material1",  0,0,0,    0.5, 0.2,0);

--	AddObject("perlin","torus1","","Material1",  "torus1", 0.2,1.95,0);
	
	AddObject("box","box1","","Material2",  0,0,4,    1,1,1);
	AddObject("sphere","sphere1","","Material2",  4,0,0,    1,1,1);

	-- Sets rotation of torus1 using euler angles xyz (0-360)

	SetRotation("torus1",-45,45,34)
end


time = 0


function Update()

	time = time + 0.1
	-- Moves the camera around
	globals.camera.x = sin(time)*3
	globals.camera.z = cos(time)*3
	globals.camera.y = cos(time*0.7)*2+2


end
