#######################################################################################
##                                                                                   ##
## This scene defines the box scene used in a number of my recent papers             ##
##                                                                                   ##
## Chris Wyman (7/16/2008)                                                           ##
#######################################################################################

# These are added to the path for searching for various objects.  There's a number
#    of good defaults (i.e. in the current directory) but if you have a central 
#    repository for textures, models, shaders, this is where to put them.
#
# These lines should be unnecessary for this demo
dir model   c:\CHRIS'~1\Models\
dir model   c:\CHRIS'~1\Models\hem\


# Setup a camera to view the scene
camera pinhole
	eye 1.12 2.63 0.375
   	up 0 1 0
    at 0 0 -1
   	fovy 90
   	near 0.1
   	far 50
	res 1024 1024
	trackball
end


# Defines variables used by the program.  If the program *expects* these to
#   be here, you'd best make sure your code double checks if they are not and
#   creates a variable with a reasonable default...  This is currently
#   true with all the variables below.
# Note that variables should be defined early, certainly before use...  
int   displayID        1        # Selects which of the rendering modes is default
float shadowMapBias    -0.005   # Default shadow map bias
float lightIntensity   3.0      # Modifier on the intensity of the light
float extinctionCoef   0.4      # Extinction coefficient for foggy environments
float lightFOV         70.0     # The light's field of view for shadow/caustic mapping


# Currently, whenever a shadow map is used, so is a spot light.  However, you
#   should be able to declare any texture here, and even reuse it later in the file.
#texture spotlight       spot_white.ppm
#texture spotlightLowRes spot_white64.ppm
texture spotlight        spot_blueHeron.ppm
texture spotlightLowRes  spot_blueHeron64.ppm



# Declare a point light source.  This one is bound to light-trackball0

light point
	pos -2 3 3
    trackball 0
end


# Declare material types.  These can either be declared globally, or inside
#   the object that uses them

material shader cylmat
    vert phongObjectShader.vert.glsl
    frag phongObjectShader.frag.glsl
	bind amb   const 0.049000 0.045000 0.012900 1.0
	bind dif   const 0.346150 0.314300 0.090300 1.0
	bind spec  const 0.797357 0.723991 0.208006 1.0
	bind shiny const 83.2 0.0 0.0 0.0
	bind spotLight tex 0 spotlight
	allowsShadows
	allowsCaustics
end

material shader redruby
    vert phongObjectShader.vert.glsl
    frag phongObjectShader.frag.glsl
	bind amb   const 0.034900 0.002300  0.002300 1.0
	bind dif   const 0.614240 0.041360 	0.041360 1.0
	bind spec  const 0.727811 0.626959 	0.626959 1.0
	bind shiny const 76.8 0.0 0.0 0.0
	bind spotLight tex 0 spotlight
	allowsShadows
	allowsCaustics
end

material shader greendragon
    vert phongObjectShader.vert.glsl
    frag phongObjectShader.frag.glsl
    bind amb   const 0.01 0.02 0.0 1.0
	bind dif   const 0.15 0.8  0.0 1.0
	bind spec  const 0.2  1.0  0.0 1.0
	bind shiny const 50.0 0.0  0.0 0.0
	bind spotLight tex 0 spotlight
	allowsShadows
	allowsCaustics
end

material shader white
    vert phongObjectShader.vert.glsl
    frag phongObjectShader.frag.glsl
	bind amb   const 0.05 0.05 0.05 1.0
	bind dif   const 1.0  1.0  1.0 1.0
	bind spec  const 0.0  0.0  0.0 1.0
	bind shiny const 0.0  0.0  0.0 0.0
	bind spotLight tex 0 spotlight
	allowsShadows
end

material shader tex1
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 bigBrickWall.ppm
	bind spotLight tex 1 spotlight
end

material shader tex2
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 sandDune.ppm
	bind spotLight tex 1 spotlight
end

material shader tex3
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 stoneFloor.ppm
	bind spotLight tex 1 spotlight
end

material shader tex4
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 squareWhiteTiles.ppm
	bind spotLight tex 1 spotlight
end

material shader tex5
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex   tex 0 wallColor.ppm
	bind spotLight tex 1 spotlight
end

material shader tex7
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 rose_512.ppm
	bind spotLight tex 1 spotlight
end

material shader tex8
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 newZealand_512.ppm
	bind spotLight tex 1 spotlight
end

material shader tex9
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 sunnyWaterfall.ppm
	bind spotLight tex 1 spotlight
end

material shader tex10
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 niceSunset.ppm
	bind spotLight tex 1 spotlight
end

material shader tex11
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 skiSlope.ppm
	bind spotLight tex 1 spotlight
end

material shader tex12
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 stHonoratMonestary.ppm
	bind spotLight tex 1 spotlight
end

material shader tex13
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 foggyBunny.ppm
	bind spotLight tex 1 spotlight
end

material shader tex14
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 dragonCaustic.ppm
	bind spotLight tex 1 spotlight
end

material shader tex15
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 sponza_bw.ppm
	bind spotLight tex 1 spotlight
end

material shader tex16
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 lake.ppm
	bind spotLight tex 1 spotlight
end

material shader tex17
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 riverReflections.ppm
	bind spotLight tex 1 spotlight
end

material shader tex18
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 ruinedRomanBath.ppm
	bind spotLight tex 1 spotlight
end

material shader tex19
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 volumeTree.ppm
	bind spotLight tex 1 spotlight
end

material shader tex22
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 glassDragon.ppm
	bind spotLight tex 1 spotlight
end

material shader tex20
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 skullTeaser.ppm
	bind spotLight tex 1 spotlight
end

material shader tex21
	vert texturedWallShader.vert.glsl
	frag texturedWallShader.frag.glsl
	allowsShadows
	allowsCaustics
	bind wallTex tex 0 cornellBox.ppm
	bind spotLight tex 1 spotlight
end


object texparallelogram brick_wall3
	pt0    -30 -5 -8
	edge2  0 20 0
	edge1  38 0 0
	tdel2  0 1.2 0
	tdel1  0.95 0 0
	material tex1
	background
end

object texparallelogram brick_wall4
	pt0    -30 -5 14
	edge1  0 20 0
	edge2  38 0 0
	tdel1  0 1.2 0
	tdel2  0.95 0 0
	material tex1
	background
end

object texparallelogram wall1_tile
	pt0    8 -5 -8
	edge2  0 5 0
	edge1  0 0 40
	tdel1  20 0 0
	tdel2  0 2.5 0
	material tex4
	background
end

object texparallelogram wall2_tile
	pt0    -13 -5 -8
	edge1  0 5 0
	edge2  0 0 40
	tdel2  20 0 0
	tdel1  0 2.5 0
	material tex4
	background
end

object texparallelogram wall2_solid
  pt0    -13 0 -8
	edge1  0 15 0
	edge2  0 0 40
	tdel2  1 0 0
	tdel1  0 1 0
	material tex5
	background
end

object texparallelogram wall1_solid
	pt0    8 0 -8
	edge2  0 15 0
	edge1  0 0 40
	tdel1  1 0 0
	tdel2  0 1 0
	material tex5
	background
end

object texparallelogram ceiling
	pt0    -30 15 -8
	edge1  38 0 0
	edge2  0 0 40
	tdel2  10 0 0
	tdel1  0 9.5 0
	material tex2
	background
end

object texparallelogram floor
	pt0    -30 -2 -8
	edge2  38 0 0
	edge1  0 0 40
	tdel2  0 -10 0
	tdel1  -9.5 0 0
	material tex3
	background
end

object instance
   object group rose512 
   	  object texparallelogram picturequad
				pt0    0.05 3.95 0.02
				edge2  3.9 0 0
				edge1  0 -3.9 0
				tdel2  1 0 0
				tdel1  0 -1 0
   		end
   		material tex7
   end
	 object group frame
	    object cylinder
   			center 0.05 2 0.02
   			height 4.1
   			radius 0.1
   			axis 0 1 0
   		end
   		object cylinder
   			center 3.95 2 0.02
   			height 4.1
   			radius 0.1
   			axis 0 1 0
   		end
   		object cylinder
   			center 2 0.05 0.02
   			height 4.1
   			radius 0.1
   			axis 1 0 0
   		end
   		object cylinder
   			center 2 3.95 0.02
   			height 4.1
   			radius 0.1
   			axis 1 0 0
   		end
   		material cylmat
   end
   matrix translate 8 1 -6
   matrix rotate -90 0 1 0	
   background
end

object instance
   object group newZealand512
      object picturequad
      material tex8
   end
   object frame
   matrix translate 8 1 -1
   matrix rotate -90 0 1 0	
   background
end

object instance
   object group monestary
      object picturequad
      material tex12
   end
   object frame
   matrix translate 8 1 4
   matrix rotate -90 0 1 0	
   background
end

object instance
   object group sunnyWaterfall
      object picturequad
      material tex9
   end
   object frame
   matrix translate 8 1 9
   matrix rotate -90 0 1 0	
   background
end

object instance
   object group cornellBox
      object picturequad
      material tex21
   end
   object frame
   matrix translate 7 1 14
   matrix rotate -180 0 1 0	
   background
end

object instance
   object group sponza
      object picturequad
      material tex15
   end
   object frame
   matrix translate 2 1 14
   matrix rotate -180 0 1 0	
   background
end

object instance
   object group skullTeaser
      object picturequad
      material tex20
   end
   object frame
   matrix translate -3 1 14
   matrix rotate -180 0 1 0	
   background
end

object instance
   object group lakeScene
      object picturequad
      material tex16
   end
   object frame
   matrix translate -8 1 14
   matrix rotate -180 0 1 0	
   background
end

object instance
   object group riverReflections
      object picturequad
      material tex17
   end
   object frame
   matrix translate -13 1 -3
   matrix rotate -270 0 1 0	
   background
end

object instance
   object group volumeTree
      object picturequad
      material tex19
   end
   object frame
   matrix translate -13 1 2
   matrix rotate -270 0 1 0	
   background
end

object instance
   object group romanBath
      object picturequad
      material tex18
   end
   object frame
   matrix translate -13 1 7
   matrix rotate -270 0 1 0	
   background
end

object instance
   object group glassDragon
      object picturequad
      material tex22
   end
   object frame
   matrix translate -13 1 12
   matrix rotate -270 0 1 0	
   background
end

object instance
   object group foggyBunny
      object picturequad
      material tex13
   end
   object frame
   matrix translate 3 1 -8	
   background
end

object instance
   object group niceSunset
      object picturequad
      material tex10
   end
   object frame
   matrix translate -2 1 -8	
   background
end

object instance
   object group skiSlope
      object picturequad
      material tex11
   end
   object frame
   matrix translate -7 1 -8	
   background
end

object instance
   object group dragonCaustic
      object picturequad
      material tex14
   end
   object frame
   matrix translate -12 1 -8	
   background
end

object instance
		object mesh hem Buddha
			file buddha_50k.hem
			lowres buddha_10k.hem
		end
		material redruby
		matrix translate 6 2 -6
		matrix rotate -40 0 1 0
		matrix scale 6 6 6
		background
end

object instance
		object mesh hem Dragon
			file dragon_250k.hem
			lowres dragon_10k.hem
			enableEdges
		end
		material greendragon
		matrix translate -3 0.2 -4.5
		matrix rotate 40 0 1 0
		matrix scale 4 4 4
		background
end


object instance
		object group
		    object Dragon
#########################################		    
# If you'd like to try another object here, comment out the previous line 
#   and uncomment the following lines.
########################################
#			object mesh hem Sphere
#				file sphere.hem
#				matrix scale 0.5 0.5 0.5
#				enableEdges
#			end
			move
				rotate
					axis 0 1 0
					speed 10
				end
			end
			material white
			trackball 0
		end
		matrix scale 2 2 2
		foreground
		refractive
end





controls
	map quit                                             q
	map reload-shaders                                   r
	map screen-capture                                   f12
	map eye-trackball                                    mouse-left
	map obj-trackball-0                                  mouse-middle
	map light-trackball-0                                mouse-right
	map help-screen                                      h
	map animation                                        a
	incr int displayID by 1 max 2                        *
	decr int displayID by 1 min 0                        /  	
	incr float lightIntensity by 0.1 max 100.0           .
	decr float lightIntensity by 0.1 min 0.2             ,
	incr float shadowMapBias by 0.001 max 0.0            ]
	decr float shadowMapBias by 0.001 min -0.05          [
	incr float extinctionCoef by 0.01 max 1.5            up-arrow
	decr float extinctionCoef by 0.01 min 0.0            down-arrow	
	incr float lightFOV by 0.5 max 90.0                  right-arrow
	decr float lightFOV by 0.5 min 5.0                   left-arrow	
end
