コード例 #1
0
        public static void drawIkHelp(Transform main, object skel)
        {
            foreach (FieldInfo field in skel.GetType().GetFields())
            {
                if (field.GetCustomAttributes(typeof(CustomSkelResultAttribute), true).Length == 0)
                {
                    continue;
                }
                object value     = field.GetValue(skel);
                Type   fieldType = field.FieldType;
                drawIkHelp(main, value);

                if (fieldType == typeof(Vector3))
                {
                    Vector3 w2s = Camera.current.WorldToScreenPoint((Vector3)value);
                    if (w2s.z < 0)
                    {
                        continue;
                    }
                    UnityEditorUtils.fillStripe2D(w2s.getXy(), IK_DISK_R1, IK_DISK_R2, 20);
                }
                if (fieldType == typeof(P <Vector3>))
                {
                }
            }
        }
コード例 #2
0
        private static void Gizmo(MoveenSkelLimb2 h, GizmoType gizmoType)
        {
            if (!h.isActiveAndEnabled)
            {
                return;
            }
            OnDrawGizmos(h);
            Gizmos.color = new Color(0, 1, 0, 0.4f);
            drawSimpleSpiderGizmo(h.rotJoint, h.maxLen * 0.2f, h.transform.position, h.targetPosRel);

            if (((int)gizmoType & (int)GizmoType.InSelectionHierarchy) != 0 && solveIk)
            {
                Gizmos.color = IK_GIZMO_COLOR;
                Vector3 w2s = Camera.current.WorldToScreenPoint(h.targetPos);
                if (w2s.z > 0)
                {
                    UnityEditorUtils.fillStripe2D(w2s.getXy(), IK_DISK_R1, IK_DISK_R2, 20);
                }
//                UnityEditorUtils.fillStripe2D(Camera.current.WorldToScreenPoint(h.transform.TransformPoint(h.rotJoint.axisRel)).getXy(), MoveenGizmos_Limb1.IK_DISK_R1, MoveenGizmos_Limb1.IK_DISK_R2, 20);
                MoveenSkelLimb1Editor.drawIkHelp(h.transform, h);
            }

            Gizmos.color = new Color(0, 0.5f, 0, 0.8f);

//            Gizmos.DrawLine(rotationJoint.basisAbs.v, rotationJoint.targetAbs.v);
            Gizmos.DrawLine(h.invisibleElbowJoint.basisAbs.v, h.invisibleElbowJoint.resultAbs.v);
            Gizmos.DrawLine(h.invisibleElbowJoint.resultAbs.v, h.invisibleElbowJoint.targetAbs.v);
        }
コード例 #3
0
        private static void Gizmo(MoveenSkelLimb1 h, GizmoType gizmoType)
        {
            if (!h.isActiveAndEnabled)
            {
                return;
            }
            OnDrawGizmos(h);
            Gizmos.color = new Color(0, 1, 0, 0.4f);
            MoveenSkelLimb2Editor.drawSimpleSpiderGizmo(h.rotJoint, h.maxLen * 0.2f, h.transform.position, h.targetPosRel);

            if (((int)gizmoType & (int)GizmoType.InSelectionHierarchy) != 0 && solveIk)
            {
                Gizmos.color = IK_GIZMO_COLOR;
                Vector3 w2s = Camera.current.WorldToScreenPoint(h.targetPos);
                if (w2s.z > 0)
                {
                    UnityEditorUtils.fillStripe2D(w2s.getXy(), IK_DISK_R1, IK_DISK_R2, 20);
                }
                drawIkHelp(h.transform, h);
            }
        }
コード例 #4
0
        private static void OnDrawGizmos(MoveenStepper5 component, GizmoType gizmoType)
        {
            if (!component.isActiveAndEnabled)
            {
                return;
            }
            Vector3 distSum = new Vector3();

            for (var i = 0; i < component.engine.steps.Count; i++)
            {
                var step = component.engine.steps[i];

                //step dial
                float r1 = 10;
                float r2 = 20;

                float airTime     = step.lastStepLen / step.legSpeed * 1.5f;
                float earthTime   = step.lastStepLen / step.bodySpeed.length();
                float dockedAngle = MyMath.PI * 2 * earthTime / (airTime + earthTime);
//                float angle = MyMath.PI;

                if (component.engine.showPhaseDials)
                {
                    Vector2 dialCenter = new Vector2(r2 * 2 + i * (r2 * 2.5f), r2 * 2);
                    Gizmos.color = Color.green;
                    UnityEditorUtils.fillStripe2D(dialCenter, r1, r2, 20);
                    Gizmos.color = Color.red;
                    UnityEditorUtils.fillArcStripe2D(dialCenter, r1, r2, 20, MyMath.PI * 2 * 3 / 4 - dockedAngle / 2, MyMath.PI * 2 * 3 / 4 + dockedAngle / 2);

                    float a2;
                    if (step.dockedState)
                    {
                        a2 = MyMath.PI * 2 * 3 / 4 - dockedAngle / 2 + dockedAngle * step.progress;
                    }
                    else
                    {
                        a2 = MyMath.PI * 2 * 3 / 4 + dockedAngle / 2 + (MyMath.PI * 2 - dockedAngle) * step.progress;
                    }
                    Gizmos.color = new Color(0.8f, 0.8f, 0.8f, 1);
                    UnityEditorUtils.fillArcStripe2D(dialCenter, r2 - 5, r2 + 2, 5, a2, a2 + step.beFaster);
                    Gizmos.color = step.dockedState ? Color.white : Color.black;
                    drawNeedle(a2, dialCenter, r1, r2);
                }

                Gizmos.color = Color.green;

                if (component.engine.collectSteppingHistory && Application.isPlaying)
                {
                    CounterStacksCollection history = step.paramHistory;
                    drawHistory(history, historyBeans, i);
                }
            }
            distSum       = MyMath.max(distSum, new Vector3(0.5f, 0.5f, 0.5f));
            Gizmos.color  = Color.yellow;
            Gizmos.matrix = Matrix4x4.TRS(component.targetPos, component.targetRot, new Vector3(1, 1, 1));
            Gizmos.DrawWireCube(Vector3.zero, distSum * 0.2f);
            Gizmos.matrix = Matrix4x4.identity;
            Gizmos.color  = Color.green;

            if (component.hip != null)
            {
                Gizmos.matrix = Matrix4x4.TRS(component.engine.hipPosAbs, component.engine.hipRotAbs, new Vector3(1, 1, 1));
                Gizmos.DrawWireCube(Vector3.zero, distSum / 2);
                Gizmos.matrix = Matrix4x4.identity;
            }

            Gizmos.matrix = Matrix4x4.TRS(component.transform.position, component.transform.rotation, new Vector3(1, 1, 1));
            UnityEditorUtils.arrow();
            Gizmos.DrawWireCube(Vector3.zero, distSum);
            Gizmos.matrix = Matrix4x4.identity;

            if (Application.isPlaying)
            {
                Gizmos.color = Color.cyan;
                Gizmos.DrawWireSphere(component.engine.imBody, 0.2f);
                Gizmos.color = new Color(0, 0, 1);
                Gizmos.DrawWireSphere(component.engine.imCenter, 0.4f);
                Gizmos.color = Color.green;
                Gizmos.DrawWireSphere(component.engine.virtualForLegs, 0.35f);
            }

            Gizmos.color = new Color(1, 0.0f, 1);
            Gizmos.DrawWireSphere(component.engine.calculatedCOG, 0.1f);
        }