/// <summary> /// Constructor /// </summary> /// <param name="game">Game</param> /// <param name="bufferManager">Buffer manager</param> /// <param name="name">Name</param> public FoliageBuffer(Game game, BufferManager bufferManager, string name) { this.Game = game; this.BufferManager = bufferManager; this.Id = GetID(); this.Attached = false; this.CurrentPatch = null; this.VertexBuffer = bufferManager.Add(string.Format("{1}.{0}", this.Id, name), new VertexBillboard[FoliagePatch.MAX], true, 0); }
/// <summary> /// Attachs the specified patch to buffer /// </summary> /// <param name="gameTime">Game time</param> /// <param name="eyePosition">Eye position</param> /// <param name="transparent">The billboards were transparent</param> /// <param name="patch">Patch</param> /// <param name="bufferManager">Buffer manager</param> public void AttachFoliage(GameTime gameTime, Vector3 eyePosition, bool transparent, FoliagePatch patch, BufferManager bufferManager) { this.vertexDrawCount = 0; this.Attached = false; this.CurrentPatch = null; if (patch.HasData) { var data = patch.GetData(gameTime, eyePosition, transparent); //Attach data bufferManager.WriteBuffer( this.VertexBuffer.Slot, this.VertexBuffer.Offset, data.ToArray()); this.vertexDrawCount = data.Count(); this.Attached = true; this.CurrentPatch = patch; } }