/// <summary> /// /// </summary> /// <param name="act"></param> /// <param name="tfNewBoneBase"></param> public void deepInit(SkinnedMeshRender smr, Transform tfNewBoneBase) { act = smr.GetComponentInParent <_Action3>(); replaceBone(smr, act, tfNewBoneBase); deepInit(smr); }
/// <summary> /// /// </summary> /// <param name="act"></param> public void deepInit(SkinnedMeshRender smr) { act = smr.GetComponentInParent <_Action3>(); tfBase = smr.bones[0]; rbs = tfBase.GetComponentsInChildren <Rigidbody>(); colliders = tfBase.GetComponentsInChildren <Collider>(); msClipPose = RagdollCliper.createState(act.tfBody.GetComponent <Animation>()); setMaxMoveForDepenetration(rbs); switchMode(false); }
/* * void switchObservedCenter() * {Debug.Log( this.tfObservedCenter.name ); * * var pre = act.tfObservedCenter; * * act.tfObservedCenter = this.tfObservedCenter; * * this.tfObservedCenter = pre; * * } */ public void setup(PlayerAction3 action) { act = action; smr = act.GetComponentInChildren <SkinnedMeshRender>(); setupRigidbodys(smr.bones); tfRagdollBase.parent = null; tfRagdollBase.gameObject.SetActive(false); tfRagdollBase.name = "base"; // msRagdoll = RagdollCliper.createState(act.tfBody.GetComponent <Animation>()); // msRagdoll.blendMode = AnimationBlendMode.Blend; msRagdoll.speed = 0.0f; }
Transform[] getTfBonesFromRenderSystem() { var mysmr = act.tfBody.GetComponentInChildren <SkinnedMeshRender>(); if (mysmr) { mysmr.enabled = false; drawer = mysmr; return(mysmr.bones); } var smr = act.tfBody.GetComponentInChildren <SkinnedMeshRenderer>(); if (smr) { return(smr.bones); } return(null); }
/// <summary> /// アニメーション/メッシュ用ボーン階層を、渡されたルートボーンから作成し置き換える。 /// ボーンは元ボーンと同名のものが取得され、SkinnedMeshRender にセットされる。 /// </summary> /// <param name="tfSkinMeshBones"></param> /// <param name="act"></param> /// <param name="tfNewBoneBase"></param> void replaceBone(SkinnedMeshRender smr, _Action3 act, Transform tfNewBoneBase) { var tfPreBones = smr.bones; var tfRagdollBones = new Transform[tfPreBones.Length]; tfRagdollBones[0] = tfNewBoneBase; var tfSrcBase = tfPreBones[0]; var tfDstBase = tfRagdollBones[0]; tfDstBase.name = tfSrcBase.name; for (var i = 1; i < tfPreBones.Length; i++) { var tfSrc = tfPreBones[i]; var tfDst = tfDstBase.Find(getPathName(tfSrc, tfSrcBase)); if (tfDst != null) { tfRagdollBones[i] = tfDst; } } // 観測対象中心位置を置き換える。 var tfObservedCenter = tfDstBase.Find(getPathName(act.tfObservedCenter, tfSrcBase)); if (tfObservedCenter) { act.tfObservedCenter = tfObservedCenter; } // プレイヤー用にショット位置を置き換える。 var pshoot = act.getComponentInDirectChildren <_PlayerShoot3>(); if (pshoot) { var tfHand = tfDstBase.Find(getPathName(pshoot.tfHand, tfSrcBase)); if (tfHand) { pshoot.tfHand = tfHand; } } tfPreBones[0].SetParent(null); GameObject.Destroy(tfPreBones[0].gameObject); tfNewBoneBase.SetParent(act.tfBody); smr.bones = tfRagdollBones; }