/*
         * Draws the scene view helpers for Constraints
         * */
        public static void AddScene(Constraints constraints, Color color, bool modifiable)
        {
            if (!constraints.IsValid()) return;

            Handles.color = color;
            GUI.color = color;

            // Transform
            Handles.SphereCap(0, constraints.transform.position, Quaternion.identity, jointSize);

            // Target
            Handles.color = new Color(color.r, color.g, color.b, color.a * constraints.positionConstraint.weight);
            Handles.DrawLine(constraints.transform.position, constraints.positionConstraint.position);
            Handles.color = color;

            if (Application.isPlaying && modifiable && (constraints.positionConstraint.weight > 0 || constraints.rotationConstraint.weight > 0)) {
                Handles.CubeCap(0, constraints.positionConstraint.position, constraints.rotationConstraint.rotation, selectedSize);

                // Manipulating position and rotation
                switch(Tools.current) {
                case Tool.Move:
                    constraints.positionConstraint.position = Handles.PositionHandle(constraints.positionConstraint.position, constraints.rotationConstraint.rotation);
                    break;
                case Tool.Rotate:
                    constraints.rotationConstraint.rotation = Handles.RotationHandle(constraints.rotationConstraint.rotation, constraints.positionConstraint.position);
                    break;
                }
            }

            Handles.color = Color.white;
            GUI.color = Color.white;
        }
Exemple #2
0
        /*
         * Draws the scene view helpers for Constraints
         * */
        public static void AddScene(Constraints constraints, Color color, bool modifiable)
        {
            if (!constraints.IsValid())
            {
                return;
            }

            Handles.color = color;
            GUI.color     = color;

            // Transform
            Handles.SphereHandleCap(0, constraints.transform.position, Quaternion.identity, GetHandleSize(constraints.transform.position), EventType.Repaint);

            // Target
            Handles.color = new Color(color.r, color.g, color.b, color.a * constraints.positionWeight);
            Handles.DrawLine(constraints.transform.position, constraints.position);
            Handles.color = color;

            if (Application.isPlaying && modifiable && (constraints.positionWeight > 0 || constraints.rotationWeight > 0))
            {
                Handles.CubeHandleCap(0, constraints.position, Quaternion.Euler(constraints.rotation), GetHandleSize(constraints.transform.position), EventType.Repaint);

                // Manipulating position and rotation
                switch (Tools.current)
                {
                case Tool.Move:
                    constraints.position = Handles.PositionHandle(constraints.position, Quaternion.Euler(constraints.rotation));
                    break;

                case Tool.Rotate:
                    constraints.rotation = Handles.RotationHandle(Quaternion.Euler(constraints.rotation), constraints.position).eulerAngles;
                    break;
                }
            }

            Handles.color = Color.white;
            GUI.color     = Color.white;
        }
 public override void Execute()
 {
     var bipedIK = EntityView.GetComponent<BipedIK>();
     Constraints = bipedIK.solvers.pelvis;
 }