public static CraClip Import(string bankName, uint animNameCRC, string clipNaming = null) { CraClip clip; uint animID = HashUtils.GetCRC(bankName) * animNameCRC; if (ClipDB.TryGetValue(animID, out clip)) { return(clip); } AnimationBank bank = Con.Get <AnimationBank>(bankName); if (bank == null) { Debug.LogError($"Cannot find AnimationBank '{bankName}'!"); return(null); } if (!bank.GetAnimationMetadata(animNameCRC, out int numFrames, out int numBones)) { //Debug.LogError($"Cannot find Animation '{animNameCRC}' in AnimationBank '{bankName}'!"); return(null); } clip = new CraClip(); clip.Name = string.IsNullOrEmpty(clipNaming) ? animNameCRC.ToString() : clipNaming; uint dummyroot = HashUtils.GetCRC("dummyroot"); uint[] boneCRCs = bank.GetBoneCRCs(); List <CraBone> bones = new List <CraBone>(); for (int i = 0; i < boneCRCs.Length; ++i) { // no root motion if (boneCRCs[i] == dummyroot) { continue; } CraBone bone = new CraBone(); bone.BoneHash = (int)boneCRCs[i]; bone.Curve = new CraTransformCurve(); for (uint j = 0; j < 7; ++j) { if (!bank.GetCurve(animNameCRC, boneCRCs[i], j, out ushort[] indices, out float[] values))
static int Main(string[] args) { if (args.Length < 3) { return(-1); } TestBench.StartLogging(ELogType.Warning); Level level = TestBench.LoadAndTrackLVL(args[0]); if (level == null) { TestBench.StopLogging(); return(-1); } string animSetName = args[1]; string animationName = args[2]; List <uint> boneCRCs = new List <uint>(); for (int i = 0; i < args.Length - 3; i++) { boneCRCs.Add(HashUtils.GetCRC(args[3 + i])); } AnimationBank bank = level.GetAnimationBank(animSetName); if (bank == null) { Console.WriteLine("Animation bank not found!"); TestBench.StopLogging(); return(-1); } uint[] animHashes = bank.GetAnimationCRCs(); foreach (uint hash in animHashes) { if (hash == HashUtils.GetCRC(animationName)) { bank.GetAnimationMetadata(hash, out int numFrames, out int numBones); Console.WriteLine("Printing bone curves for {0}(0x{1:X})", animationName, hash); Console.WriteLine("{0} transforms {1} bones over {2} frames...", animationName, numBones, numFrames); for (int i = 0; i < boneCRCs.Count; i++) { string boneName = args[3 + i]; uint boneHash = boneCRCs[i]; Console.WriteLine("\tBone #{0}: {1} (0x{2:X})", i, boneName, boneHash); bool status = bank.GetCurve(hash, boneHash, 0, out ushort[] inds, out float[] values); if (!status) { Console.WriteLine("\t\tFailed to fetch curve!"); TestBench.StopLogging(); return(-1); } Console.WriteLine("\t\tRotation X component: "); for (int j = 0; j < inds.Length && j < 5; j++) { Console.WriteLine("\t\t\t{0}: {1}", inds[j], values[j]); } } TestBench.StopLogging(); return(0); } } Console.WriteLine("Animation not found!"); TestBench.StopLogging(); return(-1); }