Beispiel #1
0
        private FootTarget GetFootTarget(HandInput settings)
        {
            if (settings == null)
            {
                return(null);
            }
            FootTarget handTarget = settings.GetComponent <FootTarget>();

            if (handTarget == null)
            {
                handTarget = settings.transform.parent.GetComponent <FootTarget>();
            }
            return(handTarget);
        }
Beispiel #2
0
        private Quaternion NaturalLowerLegOrientation(FootTarget footTarget, Quaternion upperLegRotation, Vector3 footPosition)
        {
            float lowerLegAngle = CalculateKneeAngle(footTarget.upperLeg.bone.transform.position, footPosition, footTarget.upperLeg.bone.length, footTarget.lowerLeg.bone.length);

            if (footTarget.lowerLeg.bone.jointLimitations)
            {
                lowerLegAngle = LimitKneeAngle(footTarget.lowerLeg, lowerLegAngle);
            }

            Quaternion localLowerLegRotation = Quaternion.AngleAxis(lowerLegAngle, Vector3.right);
            Quaternion lowerLegRotation      = upperLegRotation * localLowerLegRotation;

            //lowerLegRotation = LimitRotationSpeed(oldLowerLegRotation, lowerLegRotation);
            return(lowerLegRotation);
        }
Beispiel #3
0
        private void ControllerInspectors(FootTarget footTarget)
        {
            showControllers = EditorGUILayout.Foldout(showControllers, "Controllers");
            if (showControllers)
            {
                EditorGUI.indentLevel++;

                foreach (TargetProps props in allProps)
                {
                    props.Inspector();
                }

                if (humanoid.animatorEnabled)
                {
                    footTarget.animator.enabled = EditorGUILayout.ToggleLeft("Procedural Animation", footTarget.animator.enabled, GUILayout.MinWidth(80));
                }
                EditorGUI.indentLevel--;
            }
        }
Beispiel #4
0
        private void SettingsInspector(FootTarget footTarget)
        {
            showSettings = EditorGUILayout.Foldout(showSettings, "Settings", true);
            if (showSettings)
            {
                EditorGUI.indentLevel++;
                //footTarget.jointLimitations = EditorGUILayout.Toggle("Joint Limitations", footTarget.jointLimitations);
                bool showRealObjects = EditorGUILayout.Toggle("Show Real Objects", footTarget.showRealObjects);
                if (showRealObjects != footTarget.showRealObjects)
                {
                    footTarget.ShowControllers(showRealObjects);
                    footTarget.showRealObjects = showRealObjects;
                }
                rotationSpeedLimitationProp.boolValue = EditorGUILayout.Toggle("Rotation Speed Limitation", rotationSpeedLimitationProp.boolValue);
                slidePreventionProp.boolValue         = EditorGUILayout.Toggle("Slide Prevention", slidePreventionProp.boolValue);

                EditorGUI.indentLevel--;
            }
        }
Beispiel #5
0
        private void ConfigurationInspector(FootTarget footTarget)
        {
            //if (!target.jointLimitations)
            //    return;

            footTarget.RetrieveBones();

            showConfiguration = EditorGUILayout.Foldout(showConfiguration, "Configuration", true);
            if (showConfiguration)
            {
                EditorGUI.indentLevel++;

                UpperLegConfigurationInspector(ref footTarget.upperLeg, footTarget.isLeft);
                LowerLegConfigurationInspector(ref footTarget.lowerLeg, footTarget.isLeft);
                FootConfigurationInspector(ref footTarget.foot, footTarget.isLeft);
                ToesConfigurationInspector(ref footTarget.toes, footTarget.isLeft);

                EditorGUI.indentLevel--;
            }
        }
Beispiel #6
0
        public void OnEnable()
        {
            footTarget = (FootTarget)target;

            if (footTarget.humanoid == null)
            {
                footTarget.humanoid = GetHumanoid(footTarget);
            }
            humanoid = footTarget.humanoid;
            if (humanoid == null)
            {
                return;
            }

            InitEditors();

            footTarget.InitSensors();
            InitConfiguration(footTarget);
            InitSettings();
        }
        // Do not remove this, this is dynamically called from Target_Editor!
        public static FootTarget CreateTarget(FootTarget oldTarget)
        {
            HumanoidControl humanoid = oldTarget.humanoid;

            GameObject targetObject = new GameObject();

            if (oldTarget.isLeft)
            {
                targetObject.name = "Left Foot Target";
            }
            else
            {
                targetObject.name = "Right Foot Target";
            }
            Transform targetTransform = targetObject.transform;

            targetTransform.parent   = humanoid.transform;
            targetTransform.position = oldTarget.transform.position;
            targetTransform.rotation = oldTarget.transform.rotation;

            FootTarget footTarget = Constructor(humanoid, oldTarget.isLeft, targetTransform);

            if (footTarget.isLeft)
            {
                humanoid.leftFootTarget = footTarget;
            }
            else
            {
                humanoid.rightFootTarget = footTarget;
            }

            footTarget.RetrieveBones();
            footTarget.InitAvatar();
            footTarget.MatchTargetsToAvatar();

            return(footTarget);
        }
Beispiel #8
0
        private void StartFootStep(FootTarget footTarget)
        {
            if (footTarget.animator.isMoving)
            {
                return;
            }

            basePointStart = footTarget.humanoid.transform.position;
            if (footTarget.humanoid.ground != null)
            {
                basePointStart -= footTarget.humanoid.ground.position;
            }

            footTarget.foot.target.transform.position = lastPosition;
            footTarget.foot.target.transform.rotation = lastOrientation;

            prevPrintPosition    = footTarget.foot.target.transform.position;
            prevPrintOrientation = footTarget.foot.target.transform.rotation;

            footTarget.animator.isMoving            = true;
            footTarget.animator.movedLast           = true;
            footTarget.animator.follow              = false;
            footTarget.otherFoot.animator.movedLast = false;
        }
Beispiel #9
0
 public FootTargetProps(SerializedObject serializedObject, FootTarget footTarget)
     : base(serializedObject, footTarget.optitrack, footTarget, "optitrack")
 {
     //trackerIdProp = serializedObject.FindProperty("optitrack.trackerId");
 }
 public TargetedToesBone(FootTarget footTarget)
 {
     this.footTarget = footTarget;
 }
 public TargetedFootBone(FootTarget footTarget) : base(footTarget.toes)
 {
     this.footTarget = footTarget;
 }
 public TargetedLowerLegBone(FootTarget footTarget) : base(footTarget.foot)
 {
     this.footTarget = footTarget;
 }
 public TargetedUpperLegBone(FootTarget footTarget) : base(footTarget.lowerLeg)
 {
     this.footTarget = footTarget;
 }
Beispiel #14
0
 public override void Init(FootTarget _footTarget)
 {
     base.Init(_footTarget);
     optitrackTracker = footTarget.humanoid.optitrack;
     tracker          = optitrackTracker;
 }
Beispiel #15
0
 public FootTargetProps(SerializedObject serializedObject, FootTarget footTarget)
     : base(serializedObject, footTarget.kinect, footTarget, "kinect")
 {
 }
Beispiel #16
0
 public FootTargetProps(SerializedObject serializedObject, FootTarget footTarget)
     : base(serializedObject, footTarget.viveTracker, footTarget, "viveTracker")
 {
 }
Beispiel #17
0
            public TargetProps(SerializedObject serializedObject, UnityLegSensor _sensor, FootTarget _footTarget, string unitySensorName)
            {
                enabledProp               = serializedObject.FindProperty(unitySensorName + ".enabled");
                sensorTransformProp       = serializedObject.FindProperty(unitySensorName + ".sensorTransform");
                sensor2TargetPositionProp = serializedObject.FindProperty(unitySensorName + ".sensor2TargetPosition");
                sensor2TargetRotationProp = serializedObject.FindProperty(unitySensorName + ".sensor2TargetRotation");

                footTarget = _footTarget;
                sensor     = _sensor;

                sensor.Init(footTarget);
            }
Beispiel #18
0
 private void SetEventInput(SerializedProperty inputProp, InputEvent input, string label, FootTarget footTarget)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUI.indentLevel--;
     EditorGUILayout.LabelField(label, GUILayout.Width(100));
     SetInput(inputProp, GetTargetGameObject, InputTypePopup, ref input, footTarget.gameObject);
     EditorGUI.indentLevel++;
     EditorGUILayout.EndHorizontal();
 }
 public virtual void Init(FootTarget footTarget)
 {
     target = footTarget;
 }
Beispiel #20
0
 private void Awake()
 {
     footTarget = GetComponent <FootTarget>();
 }