CreateVertexTrack() public method

Creates an VertexAnimationTrack.
public CreateVertexTrack ( ushort handle, VertexAnimationType animType ) : VertexAnimationTrack
handle ushort Handle to give the track, used for accessing the track later.
animType VertexAnimationType
return VertexAnimationTrack
Exemplo n.º 1
0
		protected void ReadAnimationTrack( BinaryReader reader, Animation anim )
		{
			var type = ReadUShort( reader );
			var target = ReadUShort( reader );

			var track = anim.CreateVertexTrack( target, this.mesh.GetVertexDataByTrackHandle( target ), (VertexAnimationType)type );
			// Now read the key frames for this track
			if ( !IsEOF( reader ) )
			{
				var chunkID = ReadChunk( reader );
				while ( !IsEOF( reader ) &&
				        ( chunkID == MeshChunkID.AnimationMorphKeyframe || chunkID == MeshChunkID.AnimationPoseKeyframe ) )
				{
					switch ( chunkID )
					{
						case MeshChunkID.AnimationMorphKeyframe:
							ReadMorphKeyframe( reader, track );
							break;
						case MeshChunkID.AnimationPoseKeyframe:
							ReadPoseKeyframe( reader, track );
							break;
					}
					if ( !IsEOF( reader ) )
					{
						chunkID = ReadChunk( reader );
					}
				}
				if ( !IsEOF( reader ) )
				{
					// backpedal to the start of chunk
					Seek( reader, -ChunkOverheadSize );
				}
			}
		}
 protected void BuildInitialPoseInfo( Dictionary<MeshGeometry, List<PoseRef>> initialPoses,
                                     Dictionary<MeshGeometry, VertexAnimationTrack> tracks,
                                     Animation anim, MorphController morphController )
 {
     InputSource morphTargetSource = morphController.GetInputSourceBySemantic( "MORPH_TARGET" );
     InputSource morphWeightSource = morphController.GetInputSourceBySemantic( "MORPH_WEIGHT" );
     List<MeshGeometry> initialGeometries = morphController.Target;
     for( int geoIndex = 0; geoIndex < initialGeometries.Count; ++geoIndex )
     {
         MeshGeometry geometry = initialGeometries[ geoIndex ];
         // These geometry.Id are the submesh names (e.g. head01-mesh.0)
         for( ushort i = 0; i < m_AxiomMesh.SubMeshCount; ++i )
         {
             SubMesh subMesh = m_AxiomMesh.GetSubMesh( i );
             if( subMesh.Name != geometry.Id )
                 continue;
             VertexData vData = null;
             ushort target;
             if( subMesh.useSharedVertices )
             {
                 target = 0;
                 vData = m_AxiomMesh.SharedVertexData;
             }
             else
             {
                 target = (ushort) (i + 1);
                 vData = subMesh.vertexData;
             }
             VertexAnimationTrack track =
                 anim.CreateVertexTrack( target, vData, VertexAnimationType.Pose );
             tracks[ geometry ] = track;
             // This is the initial set of influences on the geometry
             List<PoseRef> initialPoseInfo = new List<PoseRef>();
             initialPoses[ geometry ] = initialPoseInfo;
             for( int k = 0; k < morphTargetSource.Accessor.Count; ++k )
             {
                 // morphTargetName is the id of the mesh we are blending in (e.g. head02-mesh)
                 string morphTargetName = (string) morphTargetSource.Accessor.GetParam( "MORPH_TARGET", k );
                 float influence = (float) morphWeightSource.Accessor.GetParam( "MORPH_WEIGHT", k );
                 GeometrySet morphDest = Geometries[ morphTargetName ];
                 // Get the pose index for the target submesh
                 // First find the PoseInfo object that is about this combination
                 PoseInfo poseInfo = GetPoseInfo( morphController.Target, morphDest );
                 // Now that I have the pose info for this combination,
                 // I still need to find the pose index for the portion
                 // that is associated with my MeshGeometry (instead of
                 // the GeometrySet).  Since I added these in order, I
                 // should be able to retrieve it in order as well.
                 ushort poseIndex = (ushort) poseInfo.poseIndices[ geoIndex ];
                 initialPoseInfo.Add( new PoseRef( poseIndex, influence ) );
             }
         }
     }
 }