private GameObject SetupEffector(ref FullBodyIKJob.EffectorHandle handle, string name) { var go = CreateEffector(name); if (go != null) { go.AddComponent <Effector>(); handle.effector = animator.BindSceneTransform(go.transform); handle.positionWeight = animator.BindSceneProperty(go.transform, typeof(Effector), "positionWeight"); handle.rotationWeight = animator.BindSceneProperty(go.transform, typeof(Effector), "rotationWeight"); } return(go); }
public void Setup(Animator animator, Transform[] bones, Transform target) { this.bones = new NativeArray <UnityEngine.Animations.TransformStreamHandle>(bones.Length, Allocator.Persistent); this.boneWeights = new NativeArray <UnityEngine.Animations.PropertySceneHandle>(bones.Length - 1, Allocator.Persistent); this.boneSqrMags = new NativeArray <float>(bones.Length - 1, Allocator.Persistent); for (int i = 0; i < this.bones.Length; i++) { this.bones[i] = animator.BindStreamTransform(bones[i]); } for (int i = 0; i < this.bones.Length - 1; i++) { var boneParams = bones[i].gameObject.GetComponent <IKJBoneParams>(); if (boneParams == null) { boneParams = bones[i].gameObject.AddComponent <IKJBoneParams>(); } this.boneWeights[i] = animator.BindSceneProperty(bones[i].transform, typeof(IKJBoneParams), "weight"); } // Rotation Limits SetUpRotationLimits(animator, bones); _target = animator.BindSceneTransform(target); _IKPositionWeight = animator.BindSceneProperty(animator.transform, typeof(CCDIKJ), "weight"); _maxIterations = animator.BindSceneProperty(animator.transform, typeof(CCDIKJ), "maxIterations"); _tolerance = animator.BindSceneProperty(animator.transform, typeof(CCDIKJ), "tolerance"); _XY = animator.BindSceneProperty(animator.transform, typeof(CCDIKJ), "XY"); _useRotationLimits = animator.BindSceneProperty(animator.transform, typeof(CCDIKJ), "useRotationLimits"); }
public void Setup(Animator animator, Transform topX, Transform midX, Transform lowX, Transform effectorX) { top = animator.BindStreamTransform(topX); mid = animator.BindStreamTransform(midX); low = animator.BindStreamTransform(lowX); effector = animator.BindSceneTransform(effectorX); }
public void Setup(Animator animator, Transform[] bones, Transform target, Transform poleTarget, Transform aimTransform) { this.bones = new NativeArray <UnityEngine.Animations.TransformStreamHandle>(bones.Length, Allocator.Persistent); this.boneWeights = new NativeArray <UnityEngine.Animations.PropertySceneHandle>(bones.Length, Allocator.Persistent); for (int i = 0; i < this.bones.Length; i++) { this.bones[i] = animator.BindStreamTransform(bones[i]); } for (int i = 0; i < this.bones.Length; i++) { var boneParams = bones[i].gameObject.GetComponent <IKJBoneParams>(); if (boneParams == null) { boneParams = bones[i].gameObject.AddComponent <IKJBoneParams>(); } this.boneWeights[i] = animator.BindSceneProperty(bones[i].transform, typeof(IKJBoneParams), "weight"); } // Rotation Limits SetUpRotationLimits(animator, bones); _target = animator.BindSceneTransform(target); _poleTarget = animator.BindSceneTransform(poleTarget); _transform = animator.BindStreamTransform(aimTransform); _IKPositionWeight = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "weight"); _poleWeight = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "poleWeight"); _axisX = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "axisX"); _axisY = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "axisY"); _axisZ = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "axisZ"); _poleAxisX = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "poleAxisX"); _poleAxisY = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "poleAxisY"); _poleAxisZ = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "poleAxisZ"); _clampWeight = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "clampWeight"); _clampSmoothing = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "clampSmoothing"); _maxIterations = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "maxIterations"); _tolerance = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "tolerance"); _XY = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "XY"); _useRotationLimits = animator.BindSceneProperty(animator.transform, typeof(AimIKJ), "useRotationLimits"); step = 1f / (float)bones.Length; }
public bool Setup(Animator animator, IkChain chain, Type componentType, string weightProperty, string weightOffsetProperty, string targetOffsetProperty) { if (!chain.HasValidData()) { return(false); } // Target m_TargetOffset = chain.target.offset; if (chain.target.readFrom == TargetType.Stream) { m_EffectorStreamHandle = animator.BindStreamTransform(chain.target.target); m_UseStreamEffector = true; } else { m_EffectorSceneHandle = animator.BindSceneTransform(chain.target.target); m_UseStreamEffector = false; } // Weight if (chain.weight.useAnimatorProperty && chain.weight.propertyName != "") { m_AnimatorWeight = animator.BindStreamProperty(animator.transform, typeof(Animator), chain.weight.propertyName); m_UseAnimatorProperty = true; } m_WeightHandle = animator.BindSceneProperty(animator.transform, componentType, weightProperty); m_AnimatorWeightOffset = animator.BindSceneProperty(animator.transform, componentType, weightOffsetProperty); // Driven m_IkType = chain.driven.type; if (m_IkType == IkType.Generic) { var end = chain.driven.genericEndJoint; var mid = end.parent; var start = mid.parent; m_StartHandle = animator.BindStreamTransform(start); m_MidHandle = animator.BindStreamTransform(mid); m_EndHandle = animator.BindStreamTransform(end); } else { m_HumanLimb = chain.driven.humanoidLimb; } return(true); }
public bool Setup(Animator animator, EditorSettings editorSettings, float deltaTime, NativeQueue <Quaternion> dragHistory) { if (!editorSettings.HasValidData()) { return(false); } settings = editorSettings.settings; m_Effectorhandle = animator.BindStreamTransform(editorSettings.weaponHandBone); m_WeaponPivot = animator.BindStreamTransform(editorSettings.weaponBone); m_WeaponHandResult = animator.BindSceneTransform(editorSettings.applyResultOn); m_DragHistory = dragHistory; return(true); }
private void CollectAndBindAnimationTransforms() { List <Transform> transforms = new List <Transform>(60); if (m_animator.isHuman) { for (int i = 0; i < (int)HumanBodyBones.LastBone; ++i) { var boneTransform = m_animator.GetBoneTransform((HumanBodyBones)i); if (boneTransform != null) { transforms.Add(boneTransform); } } } if (m_avatarMask != null) { //All non human bones for (int i = 0; i < m_avatarMask.transformCount; ++i) { var jointTransformPath = m_avatarMask.GetTransformPath(i); var jointTransform = m_animator.transform.Find(jointTransformPath); if (jointTransform != null) { transforms.Add(jointTransform); } } } m_transforms = transforms.ToArray(); m_targetAnimationTransforms = new NativeArray <TransformStreamHandle>(m_transforms.Length, Allocator.Persistent); m_currentAnimationTransforms = new NativeArray <TransformSceneHandle>(m_transforms.Length, Allocator.Persistent); m_previousAnimationTransforms = new NativeArray <TransformData>(m_transforms.Length, Allocator.Persistent); for (int i = 0; i < m_transforms.Length; ++i) { Transform tform = m_transforms[i]; m_targetAnimationTransforms[i] = m_animator.BindStreamTransform(tform); m_currentAnimationTransforms[i] = m_animator.BindSceneTransform(tform); m_previousAnimationTransforms[i] = new TransformData(tform.position, tform.rotation); } }
public override SyncSceneToStreamJob Create(Animator animator, ref T data) { var job = new SyncSceneToStreamJob(); var objects = data.objects; var sync = data.sync; job.sceneHandles = new NativeArray<TransformSceneHandle>(objects.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); job.streamHandles = new NativeArray<TransformStreamHandle>(objects.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); job.syncSceneToStream = new BitArray(data.sync); for (int i = 0; i < objects.Length; ++i) { job.sceneHandles[i] = animator.BindSceneTransform(objects[i]); job.streamHandles[i] = animator.BindStreamTransform(objects[i]); } return job; }
/// <summary> /// Create a ReadOnlyTransformHandle representing the new binding between the Animator and a Transform already bound to the Animator. /// </summary> /// <param name="animator">The Animator on which to bind the new handle.</param> /// <param name="transform">The Transform to bind.</param> /// <returns>Returns the ReadOnlyTransformHandle that represents the new binding.</returns> public static ReadOnlyTransformHandle Bind(Animator animator, Transform transform) { ReadOnlyTransformHandle handle = new ReadOnlyTransformHandle(); if (transform == null) { return(handle); } handle.m_InStream = (byte)(transform.IsChildOf(animator.transform) ? 1 : 0); if (handle.m_InStream == 1) { handle.m_StreamHandle = animator.BindStreamTransform(transform); } else { handle.m_SceneHandle = animator.BindSceneTransform(transform); } return(handle); }
public void Setup(Animator animator, Transform boneToFollow, Transform slavedTransform) { m_BoneToFollow = animator.BindStreamTransform(boneToFollow); m_SlavedTransform = animator.BindSceneTransform(slavedTransform); }
public void BindAt(int index, Animator animator, Transform transform) { sceneHandles[index] = animator.BindSceneTransform(transform); streamHandles[index] = animator.BindStreamTransform(transform); }