public MotionIK(ChaControl info, bool isHscene = false, MotionIKData data = null) { this.info = info; this.data = data ?? new MotionIKData(); Animator animBody = info.animBody; this.ik = (FullBodyBipedIK)((Component)animBody).GetComponent <FullBodyBipedIK>(); if (Object.op_Inequality((Object)this.ik, (Object)null)) { this.frameCorrect = (FrameCorrect)((Component)animBody).GetComponent <FrameCorrect>(); this.ikCorrect = (IKCorrect)((Component)animBody).GetComponent <IKCorrect>(); } this.SetPartners((MotionIK[])Array.Empty <MotionIK>()); this.Reset(); if (isHscene) { return; } this.tmpBones = new List <GameObject>(); ((Component)animBody).get_transform().FindLoopPrefix(this.tmpBones, "f_pv_"); this.DefBone[0] = this.ListFindBone(this.tmpBones, "f_pv_arm_L"); this.DefBone[1] = this.ListFindBone(this.tmpBones, "f_pv_elbo_L"); this.DefBone[2] = this.ListFindBone(this.tmpBones, "f_pv_arm_R"); this.DefBone[3] = this.ListFindBone(this.tmpBones, "f_pv_elbo_R"); this.DefBone[4] = this.ListFindBone(this.tmpBones, "f_pv_leg_L"); this.DefBone[5] = this.ListFindBone(this.tmpBones, "f_pv_knee_L"); this.DefBone[6] = this.ListFindBone(this.tmpBones, "f_pv_leg_R"); this.DefBone[7] = this.ListFindBone(this.tmpBones, "f_pv_knee_R"); }
public MotionIKData.State InitState(string stateName, int sex) { int index1 = -1; if (this.states != null) { int index2 = -1; do { ; }while (++index2 < this.states.Length && !(this.states[index2].name == stateName)); index1 = index2 < this.states.Length ? index2 : -1; } if (index1 == -1) { MotionIKData.State[] stateArray = new MotionIKData.State[1] { new MotionIKData.State() { name = stateName } }; this.states = this.states != null ? ((IEnumerable <MotionIKData.State>) this.states).Concat <MotionIKData.State>((IEnumerable <MotionIKData.State>)stateArray).ToArray <MotionIKData.State>() : stateArray; index1 = this.states.Length - 1; } MotionIKData.State state = this.states[index1]; MotionIKData.InitFrame(state, sex); return(state); }
public void SetMapIK(string AnimatorName) { if (!Singleton <Resources> .Instance.MapIKData.TryGetValue(AnimatorName, out this.tmpMapData)) { this.tmpMapData = (MotionIKData)null; } this.data = this.tmpMapData != null?this.tmpMapData.Copy() : (MotionIKData)null; }
public static void InitFrame(MotionIKData.State state, int sex) { int ikLen = MotionIK.IKTargetPair.IKTargetLength; IEnumerable <MotionIKData.Frame> source = Enumerable.Range(0, ikLen).Select <int, MotionIKData.Frame>((Func <int, MotionIKData.Frame>)(i => new MotionIKData.Frame() { frameNo = i })).Concat <MotionIKData.Frame>(Enumerable.Range(0, FrameCorrect.FrameNames.Length).Select <int, MotionIKData.Frame>((Func <int, MotionIKData.Frame>)(i => new MotionIKData.Frame() { frameNo = i + ikLen }))); state.frames = source.ToArray <MotionIKData.Frame>(); for (int index = 0; index < state.frames.Length; ++index) { MotionIKData.InitShape(ref state.frames[index]); } }
public static void dumpassets() { print("Dumping all text serializable assets"); var dumpdir = Dir.mod + "!base/"; var mainass = AppDomain.CurrentDomain.GetAssemblies().First(a => a.GetName().Name == "Assembly-CSharp"); var dumpables = mainass.GetExportedTypes().Where(t => typeof(IDumpable).IsAssignableFrom(t)); var basedir = Dir.abdata; print($"Found {dumpables.Count()} types."); LoadedAssetBundle.GCBundles(); foreach (var bpath in Directory.GetFiles(Dir.abdata + subdir, "*.unity3d", SearchOption.AllDirectories)) { var bundle = bpath.Replace("\\", "/"); var abname = bundle.Substring(Dir.abdata.Length); if (abname.Contains("--")) { continue; } var lab = AssetBundle.LoadFromFile(bundle); if (lab == null) { continue; } foreach (var longname in lab.GetAllAssetNames()) { var dir = bundle.Remove(bundle.LastIndexOf('.')).Substring(Dir.abdata.Length); byte[] bytes = null; var name = Path.GetFileName(longname).ToLower(); var bname = Path.GetFileNameWithoutExtension(name); string ext = name.Substring(bname.Length).ToLower(); if (ext != ".asset" && ext != ".txt" && ext != ".bytes" && ext != "") { //print("skip"); continue; } var ass = lab.LoadAsset(bname); if (ass == null) { print("Failed to load ", ass); continue; } var ta = ass as UnityEngine.TextAsset; var da = ass as IDumpable; //print(ass.GetType()); if (ta != null) { if (bname.StartsWith("cf_anmshape")) { print(name); var si = new AnimationKeyInfo(); si.LoadInfo(new MemoryStream(ta.bytes)); bytes = si.Marshal().ToBytes(); ext = ".csv"; } else if (abname.Contains("list/characustom/")) { var chd = MessagePackSerializer.Deserialize <ChaListData>(ta.bytes); bytes = chd.Marshal().ToBytes(); bname = chd.categoryNo + "_" + bname; var disa = $"{chd.distributionNo:00}"; var disb = Path.GetFileName(dir); dir = dir.Remove(dir.LastIndexOf('/') + 1) + disa + ((disa != disb)?("_" + disb):""); ext = ".csv"; } else if (name.ToLower().EndsWith(".txt")) { bytes = ta.text.StripBOM().ToBytes(); ext = ".lst"; } else { var test = ta.text.Replace("\r", "").Split('\n'); if (test.Length > 2 && (test[0].Split('\t').Length == test[1].Split('\t').Length) && test[0].Split('\t').Length >= 2) { bytes = ta.text.StripBOM().ToBytes(); ext = ".lst"; } else { if (abname.Contains("h/list") && bname.StartsWith("kh") && ext == ".bytes") { var ikd = new MotionIKData(); ikd.Read(new MemoryStream(ta.bytes)); bytes = ikd.Marshal().ToBytes(); ext = "." + ikd.GetFileExt(); } else { print("Uknown " + bname); } } } } else if (ass is IDumpable) { ext = "." + da.GetFileExt(); try { bytes = da.Marshal().ToBytes(); } catch (Exception ex) { print("Something went wrong"); print(bpath); print(bname); print(ex); } } if (bytes != null) { var ddir = dumpdir + dir; Directory.CreateDirectory(ddir); var dst = ddir + "/" + bname + ext; File.WriteAllBytes(dst, bytes); //print("Dumping " + dst.Substring(Dir.root.Length) + " of type " + ass.GetType().Name); } } lab.Unload(true); } }
public MotionIKData Copy() { MotionIKData motionIkData = new MotionIKData(); int length1 = this.states.Length; motionIkData.states = new MotionIKData.State[length1]; for (int index1 = 0; index1 < length1; ++index1) { MotionIKData.State state1 = new MotionIKData.State(); MotionIKData.State state2 = this.states[index1]; state1.name = state2.name; int length2 = state1.parts.Length; for (int index2 = 0; index2 < length2; ++index2) { MotionIKData.Parts part1 = state1.parts[index2]; MotionIKData.Parts part2 = state2.parts[index2]; part1.param2.sex = part2.param2.sex; part1.param2.target = part2.param2.target; part1.param2.weightPos = part2.param2.weightPos; part1.param2.weightAng = part2.param2.weightAng; part1.param2.blendInfos[0] = new List <MotionIKData.BlendWeightInfo>((IEnumerable <MotionIKData.BlendWeightInfo>)part2.param2.blendInfos[0]); part1.param2.blendInfos[1] = new List <MotionIKData.BlendWeightInfo>((IEnumerable <MotionIKData.BlendWeightInfo>)part2.param2.blendInfos[1]); part1.param3.chein = part2.param3.chein; part1.param3.weight = part2.param3.weight; part1.param3.blendInfos = new List <MotionIKData.BlendWeightInfo>((IEnumerable <MotionIKData.BlendWeightInfo>)part2.param3.blendInfos); } int length3 = state2.frames.Length; state1.frames = new MotionIKData.Frame[length3]; for (int index2 = 0; index2 < length3; ++index2) { MotionIKData.Frame frame1 = new MotionIKData.Frame(); MotionIKData.Frame frame2 = state2.frames[index2]; frame1.frameNo = frame2.frameNo; frame1.editNo = frame2.editNo; int length4 = frame2.shapes.Length; frame1.shapes = new MotionIKData.Shape[length4]; for (int index3 = 0; index3 < length4; ++index3) { MotionIKData.Shape shape1 = new MotionIKData.Shape(); MotionIKData.Shape shape2 = frame2.shapes[index3]; shape1.shapeNo = shape2.shapeNo; for (int index4 = 0; index4 < 3; ++index4) { shape1[index4] = new MotionIKData.PosAng?(new MotionIKData.PosAng()); MotionIKData.PosAng posAng = shape1[index4].Value; for (int index5 = 0; index5 < 3; ++index5) { ((Vector3) ref posAng.pos).set_Item(index5, ((Vector3) ref shape2[index4].Value.pos).get_Item(index5)); } for (int index5 = 0; index5 < 3; ++index5) { ((Vector3) ref posAng.ang).set_Item(index5, ((Vector3) ref shape2[index4].Value.ang).get_Item(index5)); } shape1[index4] = new MotionIKData.PosAng?(posAng); } frame1.shapes[index3] = shape1; } state1.frames[index2] = frame1; } motionIkData.states[index1] = state1; } return(motionIkData); }