Пример #1
0
        private static void Gizmo(MoveenSkelSimplestTarget component, GizmoType gizmoType)
        {
            Gizmos.color = MoveenSkelWithBonesEditor.BONE_COLOR;
            Vector3 dir    = component.targetPos.sub(component.transform.position);
            Vector3 minPos = dir.normalized(component.minLen).add(component.transform.position);

            if (component.minLen > 0)
            {
                UnityEditorUtils.circle3d(minPos, Quaternion.FromToRotation(Vector3.up, dir), component.maxLen * 0.1f, 20);
            }
            Vector3 maxPos = dir.normalized(component.maxLen).add(component.transform.position);

            UnityEditorUtils.circle3d(maxPos, Quaternion.FromToRotation(Vector3.up, dir), component.maxLen * 0.1f, 20);
            Gizmos.DrawLine(minPos, maxPos);
        }
Пример #2
0
        private static void Gizmo(MoveenStep2 component, GizmoType gizmoType)
        {
            if (!component.isActiveAndEnabled)
            {
                return;
            }
            Step2 step = component.step;

            if (step.thisTransform == null)
            {
                return;                            //if not updated first time yet
            }
            Transform withStepper = MoveenStep2Editor.withStepper(component.transform);

            Gizmos.color = new Color(0.5f, 0.5f, 0.5f);
            UnityEditorUtils.circle3d(step.bestTargetConservativeAbs, Quaternion.AngleAxis(0, Vector3.up), step.comfortRadius, 20);
            if (!Application.isPlaying)
            {
                if (step.showTrajectory)
                {
                    Gizmos.color = new Color(0, 1, 0);
                    Gizmos.DrawRay(step.posAbs, new Vector3(0, 1, 0) * step.undockTime * step.undockInitialStrength);

                    Vector3 far = step.posAbs + withStepper.rotation.rotate(new Vector3(1, 0, 0)) * step.comfortRadius;
                    Gizmos.color = new Color(1, 0, 0);
                    Gizmos.DrawRay(far, new Vector3(0, 1, 0) * step.targetDockR);

                    Step2 example = new Step2();

                    example.posAbs    = step.posAbs;
                    example.oldPosAbs = step.posAbs;
//                        example.legPosFromStruct = example.legPosAbs;
                    example.undockPause           = step.undockPause;
                    example.targetDockR           = step.targetDockR;
                    example.undockInitialStrength = step.undockInitialStrength;
                    example.undockTime            = step.undockTime;
//                    example.targetUnderground = step.targetUnderground;

                    example.bestTargetProgressiveAbs        = far;
                    example.bestTargetConservativeAbs       = step.posAbs;
                    example.bestTargetConservativeUnprojAbs = step.posAbs;
                    example.legSpeed        = step.stepSpeedMin;
                    example.maxAcceleration = step.maxAcceleration;
                    example.basisAbs        = step.thisTransform.position;
                    example.maxLen          = step.maxLen;
                    example.beginStep(1);
                    example.isExample  = true;
                    example.undockHDif = 1;
                    Vector3 lastPos = step.posAbs;

                    for (int j = 0; j < 1000; j++)
                    {
                        example.tick(1f / 50);
                        Gizmos.color = new Color(0, 0, 1);
                        Gizmos.DrawLine(lastPos, example.posAbs);
                        lastPos = example.posAbs;
                        if (example.posAbs.dist(far) < example.targetDockR * 0.3f)
                        {
                            break;
                        }
                    }
                    Gizmos.color = new Color(0, 1, 0);
                    Gizmos.DrawLine(lastPos, far);
                }
            }

            if (Application.isPlaying)
            {
                Gizmos.color = new Color(0, 1, 0);
                Gizmos.DrawWireSphere(step.bestTargetConservativeAbs, 0.03f);
                Gizmos.color = new Color(1, 1, 0);
                Gizmos.DrawWireSphere(step.bestTargetConservativeUnprojAbs2, 0.08f);
                Gizmos.color = new Color(0, 1, 1);
                Gizmos.DrawWireSphere(step.airTarget, 0.08f);
                Gizmos.color = new Color(1, 0, 0);
                Gizmos.DrawWireSphere(step.bestTargetProgressiveAbs, 0.03f);
                Gizmos.color = new Color(1, 1, 1);
                Gizmos.DrawWireSphere(step.curTarget, 0.05f);

                Gizmos.color = Color.green;

                if (step.wasTooLong)
                {
                    Gizmos.color = Color.red;
                    Gizmos.DrawWireSphere(step.posAbs, 0.2f);
                }
                if (step.dockedState)
                {
                    Gizmos.color = Color.green;
                    Gizmos.DrawWireSphere(step.posAbs, 0.15f);
                }
            }
        }