public static Animation Load(Stream stream, string path) { string extension = path.Substring(path.LastIndexOf('.') + 1); extension = extension.ToLower(); AnimationFormat format = 0; switch (extension) { case "smd": format = AnimationFormat.SMD; break; case "vmd": format = AnimationFormat.VMD; break; case "lmd": format = AnimationFormat.LMD; break; default: throw new Exception("cant recognize file format"); } return(Load(stream, path, format)); }
static STAnimation Read(FileReader reader) { AnimationFormat anim = new AnimationFormat(); Dictionary <uint, AnimationGroup> groupList = new Dictionary <uint, AnimationGroup>(); Header header = reader.ReadStruct <Header>(); List <Track> tracks = reader.ReadMultipleStructs <Track>(header.TrackCount); anim.FrameCount = header.FrameCount; anim.FrameRate = header.FrameCount / header.Duriation; for (int i = 0; i < header.TrackCount; i++) { //Add and combine tracks by hash. if (!groupList.ContainsKey(tracks[i].Hash)) { var newGroup = new AnimationGroup() { Name = Hashing.CreateHashString(tracks[i].Hash), }; anim.AnimGroups.Add(newGroup); groupList.Add(tracks[i].Hash, newGroup); } var group = groupList[tracks[i].Hash]; reader.SeekBegin(tracks[i].DataOffset); if (tracks[i].Type == 0) { ParseRotationTrack(reader, header, tracks[i], group); } else if (tracks[i].Type == 1) { ParseTranslationTrack(reader, header, tracks[i], group); } else if (tracks[i].Type == 2) { ParseScaleTrack(reader, header, tracks[i], group); } } PrintOpCodes(tracks); return(anim); }
public static Animation Load(Stream stream, string filename, AnimationFormat type) { IAnimationLoader modelLoader = null; switch (type) { case AnimationFormat.SMD: modelLoader = new AnimationSMD(stream, filename); break; case AnimationFormat.VMD: modelLoader = new AnimationVMD(stream, filename); break; case AnimationFormat.LMD: modelLoader = new AnimationLMD(stream, filename); break; } return(modelLoader.Load()); }