public Billboard CreateBillboard( Vector3 position, ColorEx color )
{
// see if we need to auto extend the free billboard pool
if ( this.freeBillboards.Count == 0 )
{
if ( this.autoExtendPool )
{
this.PoolSize = this.PoolSize * 2;
}
else
{
throw new AxiomException( "Could not create a billboard with AutoSize disabled and an empty pool." );
}
}
// get the next free billboard from the queue
Billboard newBillboard = this.freeBillboards[ 0 ];
this.freeBillboards.RemoveAt( 0 );
// add the billboard to the active list
this.activeBillboards.Add( newBillboard );
// initialize the billboard
newBillboard.Position = position;
newBillboard.Color = color;
newBillboard.Direction = Vector3.Zero;
newBillboard.Rotation = 0;
// newBillboard.TexCoordIndex = 0;
newBillboard.ResetDimensions();
newBillboard.NotifyOwner( this );
// Merge into bounds
float adjust = Utility.Max( this.defaultParticleWidth, this.defaultParticleHeight );
Vector3 adjustVec = new Vector3( adjust, adjust, adjust );
Vector3 newMin = position - adjustVec;
Vector3 newMax = position + adjustVec;
this.aab.Merge( new AxisAlignedBox( newMin, newMax ) );
float sqlen = (float)Utility.Max( newMin.LengthSquared, newMax.LengthSquared );
this.boundingRadius = (float)Utility.Max( this.boundingRadius, Utility.Sqrt( sqlen ) );
return newBillboard;
}