--boxEngine
--reddit.com/r/boxengine 	<- for discussion!
--Doc.txt					<- boxEngine documentation!

dofile "data/scripts/lib/bxeGeneral.lua"
dofile "data/scripts/lib/bxeMath.lua"


function KeyHappen( inVal, inDown )	--also registers mouse clicks
	
	if ( inDown == true ) then
		print ( inVal, inDown, chVal )
	end
	
end

function Init()
	AddGeom( "data/geom/core/common.bxo" )
	AddGeom( "data/geom/core/monkey.bxo" )
	AddGeom( "data/geom/core/funkyboxes.bxo" )
	
	
	AddTex( "data/textures/grad1.png" )
	AddTex( "data/textures/grad2.png", 'gr' )
	AddTex( "data/textures/hueH.png", 'gr' )
	AddShad( "data/shaders/00000.shad" )
	AddShad( "data/shaders/00001.shad" )
	AddShad( "data/shaders/00002.shad" )
	AddShad( "data/shaders/00003.shad" )
	AddShad( "data/shaders/00004.shad" )
	AddShad( "data/shaders/00005.shad" )
	AddShad( "data/shaders/00006.shad" )
	SetAmbientColor( .1, .1, .1 )
	Shad( 6 )
	DeclareUniform( 0, 'inTime', 1, 1 )
	Shad( - 1 )
end

function Draw( t, dt )	--time and deltaTime ( time since last frame )
	mouseX, mouseY = GetMouseTotal()
	
	Shad( 6 )
	Uniform( 0, sin( t * 10 ) + 50 * sin( .2 * t ) )
	Shad( - 1 )
	
	camDist = 7-- 7 + 2 * sin( t )
	
	LookAt( 0, -camDist, 0, 0, 0, 0 )	--3d view
	
	Rotate( 1, 0, 0, mouseY )
	Rotate( 0, 0, 1, mouseX )
	lightX = 3 * sin( .8 * t )-- 3 * mouseX
	lightY = 3 * cos( .8 * t )--0-- -3 * mouseY
	lightZ = 0
	Push()
	Move( lightX, lightY, lightZ )
	Scale( .1 )
	Geom( 'cube' )
	Pop()
	Tex( "gr", 1 )
	Tex( 0 )
	SetLight( 0, lightX, lightY, lightZ )
	
	---onum = { 'monkey1', 'monkey2', 'sphere3', 'ico3', 'boxA', 'boxAs' }
	
	Geom( 0 )
	
	
	SetLighting( 0 )
	Tex( -1 )
	Shad( -1 )
end