コード例 #1
0
ファイル: QuadTree.cs プロジェクト: razvanalex/XNAEnvironment
        /// <summary>
        /// <para>Second stepin quad tree update.</para>
        /// <para>This method get all enabled vertices for all sub quad node and build two lists of vertices and and indices.</para>
        /// </summary>
        private void BuildQuadVerticesList()
        {
            this.Vertices.Clear(1000);
            this.Indices.Clear(1000);

            for (int i = 0; i < this.Childs.Length; i++)
                this.Childs[i].GetEnabledVertices();

            /*if (Indices.Count == 0)
                return;*/

            if (!this.Device.IsDisposed)
            {
                IndexBuffer indexBuffer;
                VertexBuffer vertexBuffer;

                vertexBuffer = new VertexBuffer(this.Device, typeof(VertexPositionNormalTextureTangentBinormal), Vertices.Count, BufferUsage.WriteOnly);
                vertexBuffer.SetData<VertexPositionNormalTextureTangentBinormal>(Vertices.ToArray());

                indexBuffer = new IndexBuffer(this.Device, typeof(int), Indices.Count, BufferUsage.WriteOnly);
                indexBuffer.SetData<int>(Indices.ToArray());

                BuffersData data = new BuffersData();
                data.IndexBuffer = indexBuffer;
                data.VertexBuffer = vertexBuffer;
                data.NumberOfIndices = Indices.Count / 3;
                data.NumberOfVertices = Vertices.Count;

                this._lastLoadedDatas.Add(data);
            }
        }
コード例 #2
0
ファイル: QuadTree.cs プロジェクト: razvanalex/XNAEnvironment
 private void SetVertecesIndices()
 {
     if (_lastLoadedDatas.Count > 0)
     {
         this._disposeDatas.Add(this._currentBufferData);
         this._currentBufferData = _lastLoadedDatas[0];
         this.Device.SetVertexBuffer(this._currentBufferData.VertexBuffer);
         this.Device.Indices = this._currentBufferData.IndexBuffer;
         _lastLoadedDatas.RemoveAt(0);
     }
     else
     {
         this.Device.SetVertexBuffer(this._currentBufferData.VertexBuffer);
         this.Device.Indices = this._currentBufferData.IndexBuffer;
     }
 }
コード例 #3
0
ファイル: QuadTree.cs プロジェクト: razvanalex/XNAEnvironment
        public void Load(GraphicsDevice device)
        {
            this._device = device;

            this._minimalDepth = 4;

            for (int i = 0; i < this._loadUpdateOccurences; i++)
                UpdateQuadVertices();

            this._minimalDepth = 1;

            this.BuildQuadVerticesList();

            this._currentBufferData = this._lastLoadedDatas[0];

            //this._vertexDeclaration = new VertexDeclaration(null);
            //this.Device.VertexDeclaration = this._vertexDeclaration;
            //this.Device.Vertices[0].SetSource(this._currentBufferData.VertexBuffer, 0, VertexPositionNormalTexture.SizeInBytes);
            this.Device.SetVertexBuffer(this._currentBufferData.VertexBuffer);

            this.Device.Indices = this._currentBufferData.IndexBuffer;
        }