Axiom.Graphics.VertexData.AllocateHardwareAnimationElements C# (CSharp) Method

AllocateHardwareAnimationElements() public method

Allocate elements to serve a holder of morph / pose target data for hardware morphing / pose blending.
This method will allocate the given number of 3D texture coordinate sets for use as a morph target or target pose offset (3D position). These elements will be saved in hwAnimationDataList. It will also assume that the source of these new elements will be new buffers which are not bound at this time, so will start the sources to 1 higher than the current highest binding source. The caller is expected to bind these new buffers when appropriate. For morph animation the original position buffer will be the 'from' keyframe data, whilst for pose animation it will be the original vertex data.
public AllocateHardwareAnimationElements ( ushort count ) : void
count ushort
return void
		public void AllocateHardwareAnimationElements( ushort count )
		{
			// Find first free texture coord set
			short texCoord = 0;
			for ( int i = 0; i < vertexDeclaration.ElementCount; i++ )
			{
				VertexElement element = vertexDeclaration.GetElement( i );
				if ( element.Semantic == VertexElementSemantic.TexCoords )
					++texCoord;
			}
			Debug.Assert( texCoord <= Config.MaxTextureCoordSets );

			// Increase to correct size
			for ( int c = HWAnimationDataList.Count; c < count; ++c )
			{
				// Create a new 3D texture coordinate set
				HardwareAnimationData data = new HardwareAnimationData();
				data.TargetVertexElement = vertexDeclaration.AddElement( vertexBufferBinding.NextIndex, 0, VertexElementType.Float3, VertexElementSemantic.TexCoords, texCoord++ );

				HWAnimationDataList.Add( data );
				// Vertex buffer will not be bound yet, we expect this to be done by the
				// caller when it becomes appropriate (e.g. through a VertexAnimationTrack)
			}
		}

Usage Example

Example #1
0
		/// <summary>
		///     Initialize the hardware animation elements for given vertex data
		/// </summary>
		private void InitHardwareAnimationElements( VertexData vdata, ushort numberOfElements )
		{
			if ( vdata.HWAnimationDataList.Count < numberOfElements )
			{
				vdata.AllocateHardwareAnimationElements( numberOfElements );
			}
			// Initialize parametrics incase we don't use all of them
			for ( var i = 0; i < vdata.HWAnimationDataList.Count; i++ )
			{
				vdata.HWAnimationDataList[ i ].Parametric = 0.0f;
			}
			// reset used count
			vdata.HWAnimDataItemsUsed = 0;
		}