示例#1
0
        public void GeneratePath(List <MazePoint> path)
        {
            if (vertexBufferPath != null)
            {
                vertexBufferPath.Dispose();
            }
            if (indexBufferPath != null)
            {
                indexBufferPath.Dispose();
            }


            VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[path.Count * 4];
            int[] indices = new int[path.Count * 6];

            int curVertice = 0;
            int curIndice  = 0;



            foreach (var pathNode in path)
            {
                //int factorHeight = 10;
                //int factorWidth = 10;

                VierkantjeModel model = new VierkantjeModel();

                model.GoGenerateVertices(pathNode.X, pathNode.Y, vertices, indices, ref curVertice, ref curIndice);
            }

            pathCount = path.Count;

            vertexBufferPath = new VertexBuffer(GraphicsDevice, VertexPositionNormalTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
            indexBufferPath  = new IndexBuffer(GraphicsDevice, IndexElementSize.ThirtyTwoBits, indices.Length, BufferUsage.WriteOnly);

            vertexBufferPath.SetData(vertices);
            indexBufferPath.SetData(indices);
        }
示例#2
0
        public void GeneratePath(List<MazePoint> path)
        {
            if (vertexBufferPath != null)
                vertexBufferPath.Dispose();
            if (indexBufferPath != null)
                indexBufferPath.Dispose();

            VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[path.Count * 4];
            int[] indices = new int[path.Count * 6];

            int curVertice = 0;
            int curIndice = 0;

            foreach (var pathNode in path)
            {
                //int factorHeight = 10;
                //int factorWidth = 10;

                VierkantjeModel model = new VierkantjeModel();

                model.GoGenerateVertices(pathNode.X, pathNode.Y, vertices, indices, ref curVertice, ref curIndice);

            }

            pathCount = path.Count;

            vertexBufferPath = new VertexBuffer(GraphicsDevice, VertexPositionNormalTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
            indexBufferPath = new IndexBuffer(GraphicsDevice, IndexElementSize.ThirtyTwoBits, indices.Length, BufferUsage.WriteOnly);

            vertexBufferPath.SetData(vertices);
            indexBufferPath.SetData(indices);
        }