public GroundDisk(ContentRegister content, MaterialLightCollection lights, float radius)
		{
			this.radius = radius;

			int vertexCount = 256;
			var indices = new List<int>();

			//create the vertices. Note the DiskVertex() constructor takes an angle/size
			var verts = new DiskVertex[vertexCount];

			for (int i = 0; i < vertexCount; i++)
			{
				verts[i] = new DiskVertex((i / (float)(vertexCount - 1)) * MathHelper.TwoPi, radius, 0.05f);
				
				if (i != 0)	//add the tirangle indices
				{
					indices.Add(0);
					indices.Add(i - 1);
					indices.Add(i);
				}
			}

			//create the vertex buffer
			this.vertices = new Vertices<DiskVertex>(verts);
			this.indices = new Indices<int>(indices);


			//create the custom material for this geometry
			//the light collection has been passed into the constructor, although it
			//could easily be changed later (by changing material.Lights)
			this.Material = new MaterialShader(lights);
			
			//give the disk really bright specular for effect
			Material.SpecularColour = new Vector3(1,1,1);
			Material.DiffuseColour = new Vector3(0.6f, 0.6f, 0.6f);
			Material.SpecularPower = 64;

			//setup the texture samples to use high quality anisotropic filtering
			//the textures are assigned in LoadContent
			Material.Textures = new MaterialTextures();
			Material.Textures.TextureMapSampler = TextureSamplerState.AnisotropicHighFiltering;
			Material.Textures.NormalMapSampler = TextureSamplerState.AnisotropicLowFiltering;

			//load the textures for this material
			content.Add(this);
		}
Пример #2
0
        public GroundDisk(ContentRegister content, MaterialLightCollection lights, float radius)
        {
            this.radius = radius;

            int vertexCount = 256;

            //create the vertices. Note the DiskVertex() constructor takes an angle/size
            DiskVertex[] verts = new DiskVertex[vertexCount];
            for (int i = 0; i < vertexCount; i++)
            {
                verts[i] = new DiskVertex((i / (float)(vertexCount - 1)) * MathHelper.TwoPi, radius, 0.05f);
            }

            //create the vertex buffer
            this.vertices = new Vertices <DiskVertex>(verts);


            //create the custom material for this geometry
            //the light collection has been passed into the constructor, although it
            //could easily be changed later (by changing material.Lights)
            this.material = new MaterialShader(lights);

            //By default, per-pixel lighting in the material shader does not do
            //specular reflection. This is because specular nearly triples the
            //complexity of the lighting calculation - which makes rendering slower
            //and reduces the maximum number of per-pixel lights supported from 4 to 2.
            material.UsePerPixelSpecular = true;

            //give the disk really bright specular for effect
            material.SpecularColour = new Vector3(1, 1, 1);
            material.DiffuseColour  = new Vector3(0.6f, 0.6f, 0.6f);
            material.SpecularPower  = 64;

            //setup the texture samples to use high quality anisotropic filtering
            material.TextureMapSampler = TextureSamplerState.AnisotropicHighFiltering;
            material.NormalMapSampler  = TextureSamplerState.AnisotropicLowFiltering;

            //load the textures for this material
            content.Add(this);
        }