Axiom.Core.BillboardSet.BeginBillboards C# (CSharp) Method

BeginBillboards() private method

Generate the vertices for all the billboards relative to the camera Also take the opportunity to update the vertex colours May as well do it here to save on loops elsewhere
private BeginBillboards ( ) : void
return void
		internal void BeginBillboards()
		{
			// Make sure we aren't calling this more than once
			Debug.Assert( this.lockPtr == IntPtr.Zero );

			/* NOTE: most engines generate world coordinates for the billboards
			   directly, taking the world axes of the camera as offsets to the
			   center points. I take a different approach, reverse-transforming
			   the camera world axes into local billboard space.
			   Why?
			   Well, it's actually more efficient this way, because I only have to
			   reverse-transform using the billboardset world matrix (inverse)
			   once, from then on it's simple additions (assuming identically
			   sized billboards). If I transformed every billboard center by it's
			   world transform, that's a matrix multiplication per billboard
			   instead.
			   I leave the final transform to the render pipeline since that can
			   use hardware TnL if it is available.
			*/

			// create vertex and index buffers if they haven't already been
			if ( !this.buffersCreated )
			{
				this.CreateBuffers();
			}

			// Only calculate vertex offets et al if we're not point rendering
			if ( !this.pointRendering )
			{
				// Get offsets for origin type
				this.GetParametricOffsets( out this.leftOff, out this.rightOff, out this.topOff, out this.bottomOff );

				// Generate axes etc up-front if not oriented per-billboard
				if ( this.billboardType != BillboardType.OrientedSelf &&
					 this.billboardType != BillboardType.PerpendicularSelf &&
					 !( this.accurateFacing && this.billboardType != BillboardType.PerpendicularCommon ) )
				{
					this.GenerateBillboardAxes( ref this.camX, ref this.camY );

					/* If all billboards are the same size we can precalculate the
					   offsets and just use '+' instead of '*' for each billboard,
					   and it should be faster.
					*/
					this.GenerateVertexOffsets( this.leftOff,
												this.rightOff,
												this.topOff,
												this.bottomOff,
												this.defaultParticleWidth,
												this.defaultParticleHeight,
												ref this.camX,
												ref this.camY,
												this.vOffset );
				}
			}

			// Init num visible
			this.numVisibleBillboards = 0;

			// Lock the buffer
			this.lockPtr = this.mainBuffer.Lock( BufferLocking.Discard );
			this.ptrOffset = 0;
		}