WindowsPuzzleVisualizer.Game1.Initialize C# (CSharp) Method

Initialize() protected method

protected Initialize ( ) : void
return void
        protected override void Initialize()
        {
            Vector2 topLeft = new Vector2(0.0f, 0.0f);
            Vector2 topRight = new Vector2(1.0f, 0.0f);
            Vector2 bottomLeft = new Vector2(0.0f, 1.0f);
            Vector2 bottomRight = new Vector2(1.0f, 1.0f);

            VertexPositionNormalTexture[] boxData = new VertexPositionNormalTexture[]
            {
                // Back Surface
                new VertexPositionNormalTexture(new Vector3(-1.0f, -1.0f, 1.0f), Vector3.Backward, bottomLeft),
                new VertexPositionNormalTexture(new Vector3(-1.0f, 1.0f, 1.0f), Vector3.Backward, topLeft),
                new VertexPositionNormalTexture(new Vector3(1.0f, -1.0f, 1.0f), Vector3.Backward, bottomRight),
                new VertexPositionNormalTexture(new Vector3(1.0f, 1.0f, 1.0f), Vector3.Backward,topRight),

                // Front Surface
                new VertexPositionNormalTexture(new Vector3(1.0f, -1.0f, -1.0f), Vector3.Forward, bottomLeft),
                new VertexPositionNormalTexture(new Vector3(1.0f, 1.0f, -1.0f), Vector3.Forward, topLeft),
                new VertexPositionNormalTexture(new Vector3(-1.0f, -1.0f, -1.0f), Vector3.Forward, bottomRight),
                new VertexPositionNormalTexture(new Vector3(-1.0f, 1.0f, -1.0f), Vector3.Forward, topRight),

                // Left Surface
                new VertexPositionNormalTexture(new Vector3(-1.0f, -1.0f, -1.0f), Vector3.Left, bottomLeft),
                new VertexPositionNormalTexture(new Vector3(-1.0f, 1.0f, -1.0f), Vector3.Left, topLeft),
                new VertexPositionNormalTexture(new Vector3(-1.0f, -1.0f, 1.0f), Vector3.Left, bottomRight),
                new VertexPositionNormalTexture(new Vector3(-1.0f, 1.0f, 1.0f), Vector3.Left, topRight),

                // Right Surface
                new VertexPositionNormalTexture(new Vector3(1.0f, -1.0f, 1.0f), Vector3.Right, bottomLeft),
                new VertexPositionNormalTexture(new Vector3(1.0f, 1.0f, 1.0f), Vector3.Right, topLeft),
                new VertexPositionNormalTexture(new Vector3(1.0f, -1.0f, -1.0f), Vector3.Right, bottomRight),
                new VertexPositionNormalTexture(new Vector3(1.0f, 1.0f, -1.0f), Vector3.Right, topRight),

                // Top Surface
                new VertexPositionNormalTexture(new Vector3(-1.0f, 1.0f, 1.0f), Vector3.Up, bottomLeft),
                new VertexPositionNormalTexture(new Vector3(-1.0f, 1.0f, -1.0f), Vector3.Up, topLeft),
                new VertexPositionNormalTexture(new Vector3(1.0f, 1.0f, 1.0f), Vector3.Up, bottomRight),
                new VertexPositionNormalTexture(new Vector3(1.0f, 1.0f, -1.0f), Vector3.Up, topRight),

                // Bottom Surface
                new VertexPositionNormalTexture(new Vector3(-1.0f, -1.0f, -1.0f), Vector3.Down, bottomLeft),
                new VertexPositionNormalTexture(new Vector3(-1.0f, -1.0f, 1.0f), Vector3.Down, topLeft),
                new VertexPositionNormalTexture(new Vector3(1.0f, -1.0f, -1.0f), Vector3.Down, bottomRight),
                new VertexPositionNormalTexture(new Vector3(1.0f, -1.0f, 1.0f), Vector3.Down, topRight),
            };

            short[] boxIndices = new short[] {
                0, 1, 2, 2, 1, 3,
                4, 5, 6, 6, 5, 7,
                8, 9, 10, 10, 9, 11,
                12, 13, 14, 14, 13, 15,
                16, 17, 18, 18, 17, 19,
                20, 21, 22, 22, 21, 23
            };

            boxVB = new VertexBuffer(GraphicsDevice, VertexPositionNormalTexture.VertexDeclaration, 24, BufferUsage.WriteOnly);
            boxIB = new IndexBuffer(GraphicsDevice, IndexElementSize.SixteenBits, 36, BufferUsage.WriteOnly);

            boxVB.SetData(boxData);
            boxIB.SetData(boxIndices);
            //boxData = null;
            //boxIndices = null;
            TouchPanel.EnabledGestures = GestureType.FreeDrag | GestureType.Flick | GestureType.Tap | GestureType.DoubleTap;

            base.Initialize();
        }