Exemple #1
0
    //** Debug Methods **//
    private void drawDebug()
    {
        //Draw line from this cam to the observed object
        Debug.DrawLine(transform.position, observedObject.position, Color.gray);

        //Draw the hide obstruction Ray
        //hideRayCamToPlayer.draw(Color.black);

        //Draw the ZoomClip Ray, this isnt up to date since the cam has already lerped before this is called
        clipZoomRayPlayerToCam.draw(Color.white);
        DebugShapes.DrawRay(clipZoomRayPlayerToCam.getOrigin(), clipZoomRayPlayerToCam.getDirection(), clipZoomMinDistanceFactor * maxCameraDistance, Color.blue);
        DebugShapes.DrawRay(clipZoomRayPlayerToCam.getEnd(), -clipZoomRayPlayerToCam.getDirection(), clipZoomPaddingFactor * maxCameraDistance, Color.red);

        //Draw the angle restrictions
        Vector3 zeroOrientation = getHorizontalRotationAxis();
        Vector3 up   = Quaternion.AngleAxis(-camUpperAngleMargin, camTarget.right) * zeroOrientation;
        Vector3 down = Quaternion.AngleAxis(-camLowerAngleMargin, camTarget.right) * zeroOrientation;

#if UNITY_EDITOR
        if (!UnityEditor.EditorApplication.isPlaying)
        {
            UnityEditor.Handles.color = Color.white;
            UnityEditor.Handles.DrawSolidArc(observedObject.position, camTarget.right, down, Vector3.SignedAngle(down, up, camTarget.right), maxCameraDistance / 4);
        }
#endif

        //Draw Target Transform
        DebugShapes.DrawPoint(camTarget.position, Color.magenta, 0.1f);
        DebugShapes.DrawRay(camTarget.position, camTarget.forward, Color.blue);
        DebugShapes.DrawRay(camTarget.position, camTarget.right, Color.red);
        DebugShapes.DrawRay(camTarget.position, camTarget.up, Color.green);
    }
Exemple #2
0
    //** Debug Methods **//
    private void drawDebug()
    {
        //Draw the two Sphere Rays
        downRay.draw(Color.green);
        forwardRay.draw(Color.blue);

        //Draw the Gravity off distance
        Vector3 borderpoint = getColliderBottomPoint();

        Debug.DrawLine(borderpoint, borderpoint + getGravityOffDistance() * -transform.up, Color.magenta);

        //Draw the current transform.up and the bodys current Y orientation
        Debug.DrawLine(transform.position, transform.position + 2f * getColliderRadius() * transform.up, new Color(1, 0.5f, 0, 1));
        Debug.DrawLine(transform.position, transform.position + 2f * getColliderRadius() * body.TransformDirection(bodyY), Color.blue);

        //Draw the Centroids
        DebugShapes.DrawPoint(getDefaultCentroid(), Color.magenta, 0.1f);
        DebugShapes.DrawPoint(getLegsCentroid(), Color.red, 0.1f);
        DebugShapes.DrawPoint(getColliderBottomPoint(), Color.cyan, 0.1f);
    }
    /*
     * This function will perform debug drawing using Gizmos.
     */
    private void drawDebug(bool points = true, bool steppingProcess = true, bool rayCasts = true, bool DOFArc = true)
    {
        float scale = spider.getScale() * 0.0001f * debugIconScale;

        if (points)
        {
            // Default Position
            DebugShapes.DrawPoint(getDefault(), Color.magenta, scale);

            // Last Resort Position
            DebugShapes.DrawPoint(getLastResortTarget().position, Color.cyan, scale);


            //Draw the top and bottom ray points
            DebugShapes.DrawPoint(getTopFocalPoint(), Color.green, scale);
            DebugShapes.DrawPoint(getBottomFocalPoint(), Color.green, scale);

            //Target Point
            if (isStepping)
            {
                DebugShapes.DrawPoint(ikChain.getTarget().position, Color.cyan, scale, 0.2f);
            }
            else
            {
                DebugShapes.DrawPoint(ikChain.getTarget().position, Color.cyan, scale);
            }
        }

        if (steppingProcess)
        {
            //Draw the prediction process
            DebugShapes.DrawPoint(lastEndEffectorPos, Color.white, scale);
            DebugShapes.DrawPoint(projPrediction, Color.grey, scale);
            DebugShapes.DrawPoint(overshootPrediction, Color.green, scale);
            DebugShapes.DrawPoint(prediction, Color.yellow, scale);
            Debug.DrawLine(lastEndEffectorPos, projPrediction, Color.white);
            Debug.DrawLine(projPrediction, overshootPrediction, Color.grey);
            Debug.DrawLine(overshootPrediction, prediction, Color.green);
        }

        if (rayCasts)
        {
            Color col = Color.black;
            foreach (var cast in casts)
            {
                if (cast.Key.Contains("Default"))
                {
                    col = Color.magenta;
                }
                else if (cast.Key.Contains("Prediction"))
                {
                    col = Color.yellow;
                }

                if (cast.Key != lastHitRay)
                {
                    col = Color.Lerp(col, Color.white, 0.5f);
                }
                cast.Value.draw(col);
            }
        }

        if (DOFArc)
        {
            Vector3 v = spider.transform.TransformDirection(minOrient);
            Vector3 w = spider.transform.TransformDirection(maxOrient);
            Vector3 p = spider.transform.InverseTransformPoint(rootJoint.getRotationPoint());
            p.y = defaultPositionLocal.y;
            p   = spider.transform.TransformPoint(p);
            DebugShapes.DrawCircleSection(p, v, w, rootJoint.getRotationAxis(), minDistance, chainLength, Color.red);
        }
    }