示例#1
0
        //constructor
        public SphereDrawer(Vector3 position)
        {
            //setup the sphere geometry
            Vector3 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
            //This is a prebuilt class in Xen.Ex. It is similar to the XNA BasicEffect
            //This class implements IShader. All shaders implement IShader.
            MaterialShader material = new MaterialShader();

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

            //create a light collection and add a couple of lights to it
            material.Lights = new MaterialLightCollection();
            material.UsePerPixelSpecular       = true;
            material.Lights.AmbientLightColour = Color.CornflowerBlue.ToVector3() * 0.5f;               //set the ambient
            material.Lights.AddDirectionalLight(true, lightDirection, Color.Gray);                      //add the first of two light sources
            material.Lights.AddDirectionalLight(true, -lightDirection, Color.DarkSlateBlue);
            material.SpecularColour = Color.LightYellow.ToVector3();                                    //give the material a nice sheen

            //store the shader
            this.shader = material;
        }
		//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;
		}
示例#3
0
        public SphereDrawer(Vector3 position)
        {
            //setup the sphere
            Vector3 size = new Vector3(1, 1, 1);

            sphereGeometry = new Sphere(size, 32);

            //setup the world matrix
            worldMatrix = Matrix.CreateTranslation(position);
        }
		public SphereDrawer(Vector3 position)
		{
			//setup the sphere
			Vector3 size = new Vector3(1,1,1);
			this.sphereGeometry = new Sphere(size, 32);

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

			//NEW CODE
			//create an instance of the shader:
			this.shader = new Shader.Tutorial03Technique();

			//Note: All shaders implement the 'IShader' interface
		}
示例#5
0
        //constructor
        public SphereDrawer(Vector3 position)
        {
            //setup the sphere
            Vector3 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
            MaterialShader material       = new MaterialShader();
            Vector3        lightDirection = new Vector3(0.5f, 1, -0.5f);    //a dramatic direction

            material.Lights = new MaterialLightCollection();
            material.Lights.AmbientLightColour = Color.CornflowerBlue.ToVector3() * 0.5f;
            material.Lights.AddDirectionalLight(false, lightDirection, Color.Gray); //two light sources
            material.Lights.AddDirectionalLight(false, -lightDirection, Color.DarkSlateBlue);
            material.SpecularColour = Color.LightYellow.ToVector3();                //with a nice sheen

            this.shader = material;
        }
		/// <summary>
		/// Static method to generate the geometry data used by the sphere
		/// </summary>
		public static void GenerateGeometry(Vector3 size, int tesselation, bool storePositionOnly, bool hemisphere, bool sizeToInternalSphere, out IVertices vertices, out IIndices indices)
		{
			Sphere sphere = new Sphere(size, tesselation, storePositionOnly, hemisphere, sizeToInternalSphere);
			vertices = sphere.verts;
			indices = sphere.inds;
		}
		//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;
		}