// IKの登録 // IKは基本的にスクリプトを利用 CCDIKSolver[] EntryIKSolver(GameObject[] bones) { PMD.PMDFormat.IKList ik_list = format_.ik_list; CCDIKSolver[] iksolvers = new CCDIKSolver[ik_list.ik_data_count]; for (int i = 0; i < ik_list.ik_data_count; i++) { PMD.PMDFormat.IK ik = ik_list.ik_data[i]; bones[ik.ik_bone_index].AddComponent <CCDIKSolver>(); CCDIKSolver solver = bones[ik.ik_bone_index].GetComponent <CCDIKSolver>(); solver.target = bones[ik.ik_target_bone_index].transform; solver.controll_weight = ik.control_weight * 4; // PMDファイルは4倍らしい solver.iterations = ik.iterations; solver.chains = new Transform[ik.ik_chain_length]; for (int j = 0; j < ik.ik_chain_length; j++) { solver.chains[j] = bones[ik.ik_child_bone_index[j]].transform; } if (!(bones[ik.ik_bone_index].name.Contains("足") || bones[ik.ik_bone_index].name.Contains("つま先"))) { solver.enabled = false; } iksolvers[i] = solver; } return(iksolvers); }
/// <summary> /// 初回更新前処理 /// </summary> void Start() { if (null != ik_solver) { ik_solver = transform.GetComponent<CCDIKSolver>(); if (0 == ik_solver_targets.Length) { ik_solver_targets = Enumerable.Repeat(ik_solver.target, 1) .Concat(ik_solver.chains) .Select(x=>x.GetComponent<BoneController>()) .ToArray(); } } UpdatePrevTransform(); }
private void Start() { if (null != ik_solver) { ik_solver = this.transform.GetComponent <CCDIKSolver>(); if (ik_solver_targets.Length == 0) { ik_solver_targets = (from x in Enumerable.Repeat <Transform>(ik_solver.target, 1).Concat(ik_solver.chains) select x.GetComponent <BoneController>()).ToArray(); } } UpdatePrevTransform(); }
/// <summary> /// 初回更新前処理 /// </summary> void Start() { if (null != ik_solver) { ik_solver = transform.GetComponent <CCDIKSolver>(); if (0 == ik_solver_targets.Length) { ik_solver_targets = Enumerable.Repeat(ik_solver.target, 1) .Concat(ik_solver.chains) .Select(x => x.GetComponent <BoneController>()) .ToArray(); } } UpdatePrevTransform(); }
// IKの登録 // IKは基本的にスクリプトを利用 CCDIKSolver[] EntryIKSolver(GameObject[] bones) { PMD.PMDFormat.IKList ik_list = format_.ik_list; CCDIKSolver[] iksolvers = new CCDIKSolver[ik_list.ik_data_count]; for (int i = 0; i < ik_list.ik_data_count; i++) { PMD.PMDFormat.IK ik = ik_list.ik_data[i]; bones[ik.ik_bone_index].AddComponent<CCDIKSolver>(); CCDIKSolver solver = bones[ik.ik_bone_index].GetComponent<CCDIKSolver>(); solver.target = bones[ik.ik_target_bone_index].transform; solver.controll_weight = ik.control_weight * 4; // PMDファイルは4倍らしい solver.iterations = ik.iterations; solver.chains = new Transform[ik.ik_chain_length]; for (int j = 0; j < ik.ik_chain_length; j++) solver.chains[j] = bones[ik.ik_child_bone_index[j]].transform; if (!(bones[ik.ik_bone_index].name.Contains("足") || bones[ik.ik_bone_index].name.Contains("つま先"))) { solver.enabled = false; } iksolvers[i] = solver; } return iksolvers; }