Пример #1
0
        /// <summary>
        /// Initialize buffers
        /// </summary>
        /// <param name="name">Buffer name</param>
        /// <param name="textured">Use a textured buffer</param>
        private void InitializeBuffers(string name, bool textured, Vector4?uvMap)
        {
            Vector3[] vData;
            Vector2[] uvs;
            uint[]    iData;
            if (textured)
            {
                if (uvMap.HasValue)
                {
                    GeometryUtil.CreateSprite(Vector2.Zero, 1, 1, 0, 0, uvMap.Value, out vData, out uvs, out iData);
                }
                else
                {
                    GeometryUtil.CreateSprite(Vector2.Zero, 1, 1, 0, 0, out vData, out uvs, out iData);
                }

                var vertices = VertexPositionTexture.Generate(vData, uvs);
                this.vertexBuffer = this.BufferManager.Add(name, vertices, false, 0);
            }
            else
            {
                GeometryUtil.CreateSprite(Vector2.Zero, 1, 1, 0, 0, out vData, out uvs, out iData);

                var vertices = VertexPositionColor.Generate(vData, Color4.White);
                this.vertexBuffer = this.BufferManager.Add(name, vertices, false, 0);
            }

            this.indexBuffer = this.BufferManager.Add(name, iData, false);
        }