--simple example script that demonstrates most/all avail functions.
--http://www.lua.org/pil/ 	<- lua how2s!
--reddit.com/r/boxengine 	<- for discussion!
--Doc.txt					<- boxEngine documentation!

dofile "data/scripts/lib/objReferences.lua"	--defines names -> geom indices
dofile "data/scripts/lib/bxeGeneral.lua"	--defines names -> geom indices


function KeyHappen( inVal, inDown )	--also registers mouse clicks
	chVal = string.format( "%c", inVal )
	
	if ( inDown == true ) then
		print ( inVal, inDown, chVal )
	end
	
end

function Init()
	AddGeom( "data/geom/core/common.bxo" )
	AddTex( "data/textures/noise3.png" )
	
end


function Draw( t, dt )	--time and deltaTime ( time since last frame )
	mouseX, mouseY = GetMouseTotal()
	
	camDist = 3
	LookAt( 0, -camDist, 0, 0, 0, 0 )	--3d view
	Push()
	
	Rotate( 1, 0, 0, mouseY )
	Rotate( 0, 0, 1, mouseX )
	
	Scale( 1.5, 1.5, 1 + .3 * math.sin( t ) )
	Tex( 0 )
	SetLight( 0, 0, -3, 2 * math.sin( t ) )
	SetLight( 1, 0, 2.5 + 1 * math.sin( t + 1 ), 0 )
	Geom( 'sphere3' )
	Scale( 1, 1, .4 )
	Move( 0, 0, -1 )
	Geom( 'cube' )
	SetLighting( 0 )
	Pop()
	Tex( -1 )
	
end