Esempio n. 1
0
        protected override void Remove(ModelDisplayObjectBase displayObject)
        {
            ModelDisplayObjectBatch batch = displayObject.BatchInformation.Batch;

            batch.Remove(displayObject, this);
            //If it's an empty batch, just throw it away.
            if (batch.DisplayObjects.Count == 0)
            {
                batches.Remove(batch);
            }
        }
 /// <summary>
 /// Collects the local space vertex data of the model.
 /// </summary>
 /// <param name="vertices">List of vertices to be filled with the model vertices.</param>
 /// <param name="indices">List of indices to be filled with the model indices.</param>
 /// <param name="batch">Batch that the display object is being added to.</param>
 /// <param name="baseVertexBufferIndex">Index in the batch's vertex buffer where this display object's vertices start.</param>
 /// <param name="baseIndexBufferIndex">Index in the batch's index buffer where this display object's vertices start.</param>
 /// <param name="batchListIndex">Index in the batch's display object list where this display object will be inserted.</param>
 public void GetVertexData(List <VertexPositionNormalTexture> vertices, List <ushort> indices,
                           ModelDisplayObjectBatch batch, ushort baseVertexBufferIndex, int baseIndexBufferIndex, int batchListIndex)
 {
     BatchInformation.Batch = batch;
     BatchInformation.BaseVertexBufferIndex = baseVertexBufferIndex;
     BatchInformation.BaseIndexBufferIndex  = baseIndexBufferIndex;
     BatchInformation.BatchListIndex        = batchListIndex;
     GetMeshData(vertices, indices);
     //Modify the indices.
     for (int i = 0; i < indices.Count; i++)
     {
         indices[i] += baseVertexBufferIndex;
     }
     BatchInformation.VertexCount = vertices.Count;
     BatchInformation.IndexCount  = indices.Count;
 }
 /// <summary>
 /// Collects the local space vertex data of the model.
 /// </summary>
 /// <param name="vertices">List of vertices to be filled with the model vertices.</param>
 /// <param name="indices">List of indices to be filled with the model indices.</param>
 /// <param name="batch">Batch that the display object is being added to.</param>
 /// <param name="baseVertexBufferIndex">Index in the batch's vertex buffer where this display object's vertices start.</param>
 /// <param name="baseIndexBufferIndex">Index in the batch's index buffer where this display object's vertices start.</param>
 /// <param name="batchListIndex">Index in the batch's display object list where this display object will be inserted.</param>
 public void GetVertexData(List<VertexPositionNormalTexture> vertices, List<ushort> indices,
                           ModelDisplayObjectBatch batch, ushort baseVertexBufferIndex, int baseIndexBufferIndex, int batchListIndex)
 {
     BatchInformation.Batch = batch;
     BatchInformation.BaseVertexBufferIndex = baseVertexBufferIndex;
     BatchInformation.BaseIndexBufferIndex = baseIndexBufferIndex;
     BatchInformation.BatchListIndex = batchListIndex;
     GetMeshData(vertices, indices);
     //Modify the indices.
     for (int i = 0; i < indices.Count; i++)
     {
         indices[i] += baseVertexBufferIndex;
     }
     BatchInformation.VertexCount = vertices.Count;
     BatchInformation.IndexCount = indices.Count;
 }
        protected override void Add(ModelDisplayObjectBase displayObject)
        {
            foreach (ModelDisplayObjectBatch batch in batches)
            {
                if (batch.Add(displayObject, this))
                    return;
            }
            //If we made it here, that means there was no batch that could handle the display object.
            //This could be because the batches were full, or it could be that this
            //display object is just really large (like a terrain) and violated the 
            //primitive count limit.

            //So throw the object in a new batch.
            //This will also allow a display object that is too large (like a 512x512 terrain) to be added to a batch,
            //so long as it is alone.

            var batchToAdd = new ModelDisplayObjectBatch(Game.GraphicsDevice);
            batches.Add(batchToAdd);
            batchToAdd.Add(displayObject, this);
        }
Esempio n. 5
0
        protected override void Add(ModelDisplayObjectBase displayObject)
        {
            foreach (ModelDisplayObjectBatch batch in batches)
            {
                if (batch.Add(displayObject, this))
                {
                    return;
                }
            }
            //If we made it here, that means there was no batch that could handle the display object.
            //This could be because the batches were full, or it could be that this
            //display object is just really large (like a terrain) and violated the
            //primitive count limit.

            //So throw the object in a new batch.
            //This will also allow a display object that is too large (like a 512x512 terrain) to be added to a batch,
            //so long as it is alone.

            var batchToAdd = new ModelDisplayObjectBatch(Game.GraphicsDevice);

            batches.Add(batchToAdd);
            batchToAdd.Add(displayObject, this);
        }