Fusion.Engine.Graphics.SkySphere.GetVertices C# (CSharp) Method

GetVertices() public static method

Gets sphere vertices.
public static GetVertices ( int iterations = 4 ) : System.Vector4[]
iterations int
return System.Vector4[]
		public static Vector4[] GetVertices ( int iterations = 4 )
		{
			var shape = CreateOctahedron();
			
			for ( int i=0; i<iterations; i++ ) {
				shape = Refine( shape );
			}

			var result = new Vector4[ shape.Length * 3 ];

			for ( int i=0; i<shape.Length; i++ ) {
				result[ i*3+0 ] = new Vector4( shape[i].A, 1 );
				result[ i*3+1 ] = new Vector4( shape[i].B, 1 );
				result[ i*3+2 ] = new Vector4( shape[i].C, 1 );
			}

			return result;
		}

Usage Example

Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        public override void Initialize()
        {
            skyCube     = new RenderTargetCube(device, ColorFormat.Rgba16F, 128, true);
            skyConstsCB = new ConstantBuffer(device, typeof(SkyConsts));

            LoadContent();

            Game.Reloading += (s, e) => LoadContent();


            var skySphere = SkySphere.GetVertices(4).Select(v => new SkyVertex {
                Vertex = v
            }).ToArray();

            skyVB = new VertexBuffer(Game.GraphicsDevice, typeof(SkyVertex), skySphere.Length);
            skyVB.SetData(skySphere);


            randVectors = new Vector3[64];

            for (int i = 0; i < randVectors.Length; i++)
            {
                Vector3 randV;
                do
                {
                    randV = rand.NextVector3(-Vector3.One, Vector3.One);
                } while (randV.Length() > 1 && randV.Y < 0);

                randVectors[i] = randV.Normalized();
            }
        }