Beispiel #1
0
 void UpdateMasterBoneRot(MasterBoneModel masterBone, AbstractTsf inputData, float maxSpeed)
 {
     if (inputData.space == Space.World)
     {
         if (maxSpeed > 0.0f)
         {
             masterBone.transformRef.localRotation = BasicHelpers.ClampQuaternion(masterBone.transformRef.localRotation, Quaternion.Inverse(masterBone.transformRef.parent.rotation) * inputData.rotation, maxSpeed * Time.deltaTime);
         }
         else
         {
             masterBone.transformRef.rotation = inputData.rotation;
         }
     }
     else
     {
         if (maxSpeed > 0.0f)
         {
             masterBone.transformRef.localRotation = BasicHelpers.ClampQuaternion(masterBone.transformRef.localRotation, inputData.rotation, maxSpeed * Time.deltaTime);
         }
         else
         {
             masterBone.transformRef.localRotation = inputData.rotation;
         }
     }
 }
Beispiel #2
0
        void UpdateBoneTsfRot(ReprModel repr, Transform applyToThis, AbstractTsf inputData, float maxSpeed, Transform referenceTsf, Transform replicatedTsf)
        {
            AvatarController avatarCtrl = repr.point.bone.part.body.avatar.controller;

            Quaternion desiredWorldRot;

            if (inputData.space == Space.World)
            {
                desiredWorldRot = inputData.rotation;
            }
            else
            {
                desiredWorldRot = avatarCtrl.GetWorldFromLocalRotation(inputData.rotation, repr);
            }

            if (referenceTsf && replicatedTsf)
            {
                Quaternion relRot = Quaternion.Inverse(referenceTsf.rotation) * desiredWorldRot;
                desiredWorldRot = replicatedTsf.rotation * relRot;
            }

            if (maxSpeed > 0.0f)
            {
                applyToThis.rotation = BasicHelpers.ClampQuaternion(applyToThis.rotation, desiredWorldRot, maxSpeed * Time.deltaTime);
            }
            else
            {
                applyToThis.rotation = desiredWorldRot;
            }
        }