//constructor
		public SphereDrawer(Vector3 position)
		{
			//setup the sphere geometry
			var size = new Vector3(1,1,1);
			//Use the prebuilt sphere geometry class
			this.sphereGeometry = new Sphere(size, 32);

			//Setup the world matrix
			this.worldMatrix = Matrix.CreateTranslation(position);

			//Create a lighting shader with some nice looking lighting
			//'MaterialShader' is a prebuilt class in Xen.Ex. It is similar to the XNA BasicEffect
			//This class implements the IShader interface. All Xen shaders implement IShader.
			this.shader = new MaterialShader();
			this.shader.SpecularColour = Color.LightYellow.ToVector3();						//give the material a nice sheen

			var lightDirection = new Vector3(0.5f,1,-0.5f); //a dramatic direction

			//create a light collection and add a couple of lights to it
			var lights = new MaterialLightCollection();

			lights.AmbientLightColour = Color.CornflowerBlue.ToVector3() * 0.5f;	//set the ambient
			lights.CreateDirectionalLight(lightDirection, Color.Gray);				//add the first of two light sources
			lights.CreateDirectionalLight(-lightDirection, Color.DarkSlateBlue);

			//set the light collection used by the material shader
			this.shader.LightCollection = lights;
		}
		protected override void Initialise()
		{
			Camera3D camera = new Camera3D();
			camera.LookAt(Vector3.Zero, new Vector3(0, 0, 5), Vector3.UnitY);

			//create the draw target.
			drawToScreen = new DrawTargetScreen(camera);
			drawToScreen.ClearBuffer.ClearColour = Color.CornflowerBlue;



			//create a shader to display the geometry (this is the same as tutorial 02)
			var lightDirection = new Vector3(1.0f, 0.5f, 0.5f);
			var material = new MaterialShader();
			material.SpecularColour = Color.LightYellow.ToVector3();				//give the material a nice sheen

			var lights = new MaterialLightCollection();

			lights.AmbientLightColour = Color.CornflowerBlue.ToVector3() * 0.5f;	//set the ambient
			lights.CreateDirectionalLight(lightDirection, Color.Gray);				//add the first of two light sources
			lights.CreateDirectionalLight(-lightDirection, Color.DarkSlateBlue);

			material.LightCollection = lights;

			//create a simpler shader to display the wireframe (and also used for the bounding cube)
			var simpleShader = new Xen.Ex.Shaders.FillSolidColour();
			simpleShader.FillColour = Vector4.One * 0.01f;


			var sphereSize = new Vector3(0.5f, 0.5f, 0.5f);

			//create the complex sphere, this will have ~100k triangles.
			//pass in a shader for wireframe rendering
			sphere = new GeometryDrawer(new Xen.Ex.Geometry.Sphere(sphereSize, 200), material, simpleShader);

			//create the bounding cube
			sphereBoundingBox = new GeometryDrawer(new Xen.Ex.Geometry.Cube(sphereSize), simpleShader, null);

			//create the occluding cube, and position it close to the camera
			cube = new GeometryDrawer(new Xen.Ex.Geometry.Cube(Vector3.One), material, null);
			cube.position = new Vector3(0, 0, 2.75f);


			//add the cube first (so it can draw first, potentially occluding the sphere)
			//if the cube was added second, it would have no effect, as it would draw after the sphere
			drawToScreen.Add(cube);


			//create the predicate, passing in the sphere and bounding box
			var predicate = new Xen.Ex.Scene.DrawPredicate(sphere, sphereBoundingBox);

			//add the DrawPredicate (the DrawPredicate draws it's children)
			drawToScreen.Add(predicate);


			//statistic overlay
			statOverlay = new Xen.Ex.Graphics2D.Statistics.DrawStatisticsDisplay(this.UpdateManager);
			drawToScreen.Add(statOverlay);
		}
		protected override void Initialise()
		{
			//setup ambient lighting
			this.ambientLight = new MaterialLightCollection();
			ambientLight.LightingEnabled = true;
			ambientLight.AmbientLightColour = new Vector3(0.4f, 0.2f, 0.1f);
			ambientLight.CreateDirectionalLight(new Vector3(-1, -1, 0), new Vector3(3,2,1)); // add some backlighting
			ambientLight.SphericalHarmonic.AddLight(new Vector3(2, 0.5f, 0.25f), new Vector3(0, 0, 1), 0.2f);

			//the camera for the shadows point of view, represents the direction of the light.
			Camera3D shadowCamera = new Camera3D();
			shadowCamera.LookAt(new Vector3(1, 1, 3), new Vector3(-15, 20, 20), new Vector3(0, 0, 1));

			//set the clip plane distances
			shadowCamera.Projection.FarClip = 40;
			shadowCamera.Projection.NearClip = 20;
			shadowCamera.Projection.FieldOfView *= 0.25f;


			//8bit is actually enough accuracy for this sample (given the limited range of the shadow)
			var textureFormat = SurfaceFormat.Color;
			const int resolution = 256;

			//create the shadow map texture:
			drawShadowDepth = new DrawTargetTexture2D(shadowCamera, resolution, resolution, textureFormat, DepthFormat.Depth24);
			drawShadowDepth.ClearBuffer.ClearColour = Color.White;

			//for the shadow technique used, the shadow buffer is blurred.
			//this requires an intermediate render target on the PC
			DrawTargetTexture2D blurIntermediate = null;

			//technically not required on the xbox if the render target is small enough to fit in EDRAM in one tile, but xna insists
			blurIntermediate = new DrawTargetTexture2D(shadowCamera, resolution, resolution, textureFormat, DepthFormat.None);

			//create a blur filter
			shadowDepthBlurFilter = new Xen.Ex.Filters.BlurFilter(Xen.Ex.Filters.BlurFilterFormat.SevenSampleBlur,1.0f, drawShadowDepth, blurIntermediate);

			//create the scene camera
			var camera = new Camera3D();
			camera.LookAt(new Vector3(0, 0, 3), new Vector3(10, 10, 6), new Vector3(0, 0, 1));
			camera.Projection.FieldOfView *= 0.55f;

			//create the draw target.
			drawToScreen = new DrawTargetScreen(camera);
			drawToScreen.ClearBuffer.ClearColour = Color.Black;

			//the 'scene'
			//A DrawList from Tutorial 23 is used here, this stores the 'scene', 
			//which is just a set of actors and the ground
			Tutorials.Tutorial_23.DrawList scene = new Tutorials.Tutorial_23.DrawList();

			for (int x = 0; x < 2; x++)
			for (int y = 0; y < 2; y++)
			{
				//create the actor instances
				if (x != 0 || y != 0)
					scene.Add(new Actor(this.Content, new Vector3(x*6-3, y*6-3, 0), (x + y*2 + 1) * 0.2f, 4-x*2-y));
			}

			//add the ground
			var ground = new GroundDisk(this.Content, 10, ambientLight);
			scene.Add(ground);


			//setup the draw targets...


			//create the shader provider
			var shadowOutputShaderProvider = new ShadowOutputShaderProvider();

			//add a ShadowMapDrawer to the shadow map texture
			drawShadowDepth.Add(new ShadowMapDrawer(scene, shadowOutputShaderProvider));

			//setup the scene to be drawn to the screen
			//draw the scene normally (no shadow, just ambient)
			drawToScreen.Add(scene);

			Vector3 lightColour = new Vector3(2, 1.5f, 1);

			//then draw the scene with a shadow (blended on top)
			drawToScreen.Add(new ShadowedSceneDrawer(scene, shadowOutputShaderProvider, drawShadowDepth, lightColour));

			//add a nice faded background
			Tutorial_20.BackgroundGradient background = new Tutorial_20.BackgroundGradient(new Color(1, 0.5f, 0.3f), new Color(0.2f, 0.1f, 0.2f));
			background.DrawAtMaxZDepth = true;
			drawToScreen.Add(background);


			//create a textured element that will display the shadow map texture
			var shadowDepthDisplay = new TexturedElement(drawShadowDepth, new Vector2(256, 256));
			shadowDepthDisplay.VerticalAlignment = VerticalAlignment.Top;
			this.drawToScreen.Add(shadowDepthDisplay);
		}
		public GeometryDrawer(Vector3 position)
		{
			//NEW CODE
			//create the quad
			this.geometry = new QuadGeometry();

			//setup the world matrix
			this.worldMatrix = Matrix.CreateTranslation(position);

			//create a lighting shader with some average looking lighting :-)
			var material = new MaterialShader();
			material.SpecularColour = Color.LightYellow.ToVector3();//with a nice sheen

			var lightDirection = new Vector3(0.5f,1,-0.5f); //a less dramatic direction

			var lights = new MaterialLightCollection();
			lights.AmbientLightColour = Color.DarkGoldenrod.ToVector3() * 0.5f;
			lights.CreateDirectionalLight(-lightDirection, Color.WhiteSmoke);

			material.LightCollection = lights;

			this.shader = material;
		}
		public GeometryDrawer(Vector3 position)
		{
			//create the quad
			geometry = new DynamicQuadGeometry();

			//setup the world matrix
			worldMatrix = Matrix.CreateTranslation(position);

			//create a basic lighting shader with some average looking lighting :-)
			MaterialShader material = new MaterialShader();
			material.SpecularColour = Color.LightYellow.ToVector3() * 0.5f;

			Vector3 lightDirection = new Vector3(-1, -1, -1); //a dramatic direction

			//Note: To use vertex colours with a MaterialShader, UseVertexColour has to be set to true
			material.UseVertexColour = true;

			//create a directional light
			MaterialLightCollection lights = new MaterialLightCollection();
			lights.CreateDirectionalLight(-lightDirection, Color.WhiteSmoke);

			material.LightCollection = lights;

			this.shader = material;
		}
		//constructor
		public SphereDrawer(Vector3 position)
		{
			//setup the sphere
			var size = new Vector3(1,1,1);
			//use a prebuilt sphere geometry class
			sphereGeometry = new Sphere(size, 32);

			//setup the world matrix
			worldMatrix = Matrix.CreateTranslation(position);

			//create a lighting shader with some nice looking lighting
			var material = new MaterialShader();
			material.SpecularColour = Color.LightYellow.ToVector3();//with a nice sheen

			var lightDirection = new Vector3(0.5f,1,-0.5f); //a dramatic direction

			var lights = new MaterialLightCollection();
			lights.AmbientLightColour = Color.CornflowerBlue.ToVector3() * 0.5f;
			lights.CreateDirectionalLight(lightDirection, Color.Gray);//two light sources
			lights.CreateDirectionalLight(-lightDirection, Color.DarkSlateBlue);

			material.LightCollection = lights;

			this.shader = material;
		}