コード例 #1
0
 public static void drawSimpleSpiderGizmo(JunctionSimpleSpider junctionSimpleSpider, float size, Vector3 posAbs, Vector3 targetAbs)
 {
     UnityEditorUtils.cylinder(posAbs, MUtil.qToAxesXZ(junctionSimpleSpider.axisAbs, targetAbs), 1, 10, 0, 1 * size, 0.1f * size, 0.1f * size);
     UnityEditorUtils.cylinder(posAbs,
                               MUtil.qToAxesXZ(junctionSimpleSpider.secondaryAxisAbs, junctionSimpleSpider.axisAbs),
                               1, 10, 0, 1 * size * 0.3f, 0.1f * size * 0.5f, 0.1f * size * 0.5f);
 }
コード例 #2
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>))
                {
                }
            }
        }
コード例 #3
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);
        }
コード例 #4
0
 static DelayedEntryPoint()
 {
     SearchEverywhereWindow.Settings      = SearchWindowSettings.instance;
     RecentFilesCacheController.Cache     = RecentFilesCache.instance;
     ProgressManagerOwner.ProgressManager = new ProgressManager();
     UnityEditorUtils.ExecuteOnceOnUpdateCall(OnEnable);
     SceneIntegrationSettings.IsClassicToolboxEnabled = false;
 }
コード例 #5
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);
        }
コード例 #6
0
//        [DrawGizmo(GizmoType.InSelectionHierarchy | GizmoType.Active)]
//        [DrawGizmo(GizmoType.InSelectionHierarchy | GizmoType.NonSelected | GizmoType.Active)]
        public static void OnDrawGizmos(MoveenSkelWithBones component)
        {
            if (!component.isActiveAndEnabled)
            {
                return;
            }
            Gizmos.color = BONE_COLOR;
            for (int i = 0; i < component.bones.Count; i++)
            {
                Bone bone = component.bones[i];
                bone.origin.tick(); //TODO ensure tick in root
                if (bone.origin.getRot().magnitude() < 0.3f)
                {
                    MUtil.log(component, "wrong quaternion: " + bone.origin.getRot());
                    //Debug.Log("  " + i);
                    continue;
                }
                UnityEditorUtils.diamond(bone.origin.getPos(), bone.origin.getRot().normalized(), bone.r);
            }

            Type type = component.GetType();

            Gizmos.color = Color.green;
            for (int index = 0; index < type.GetFields().Length; index++)
            {
                FieldInfo field = type.GetFields()[index];
                if (field.FieldType == typeof(Vector3))
                {
                    if (field.GetCustomAttributes(typeof(CustomSkelResultAttribute), true).Length != 0)
                    {
                        Vector3 cur = (Vector3)field.GetValue(component);
                        Gizmos.DrawWireSphere(cur, 0.04f);
                    }
                }
                if (field.FieldType == typeof(P <Vector3>))
                {
                    if (field.GetCustomAttributes(typeof(CustomSkelResultAttribute), true).Length != 0)
                    {
                        P <Vector3> cur = (P <Vector3>)field.GetValue(component);
                        Gizmos.DrawWireSphere(cur.v, 0.04f);
                    }
                }
            }
        }
コード例 #7
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);
            }
        }
コード例 #8
0
        private static void drawNeedle(float a2, Vector2 dialCenter, float r1, float r2)
        {
            Vector2 aa = new Vector2(MyMath.cos(a2), MyMath.sin(a2));

            UnityEditorUtils.line2D(dialCenter + aa * (r1 + 2), dialCenter + aa * (r2 - 2), 3);
        }
コード例 #9
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);
        }
コード例 #10
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);
                }
            }
        }
コード例 #11
0
 static DelayedEntryPoint()
 {
     SearchEverywhereWindow.Settings      = new SearchWindowSettings();
     ProgressManagerOwner.ProgressManager = new LogProgressManager();
     UnityEditorUtils.ExecuteOnceOnUpdateCall(OnEnable);
 }