コード例 #1
0
 public static void ForDebug(Vector3 r1, Vector3 r2, Vector3 r3, Vector3 r4, Color color, float duration = 0)
 {
     Debug.DrawLine(r1, r2, color, duration);
     Debug.DrawLine(r2, r3, color, duration);
     Debug.DrawLine(r3, r4, color, duration);
     Debug.DrawLine(r4, r1, color, duration);
 }
コード例 #2
0
        private void DrawPatchBounds(Patch p)
        {
            var bounds = new Bounds();

            bounds.SetMinMax((Vector3)(p.SolidHullMin + p.Offset) * 0.5f, (Vector3)(p.SolidHullMax + p.Offset) * 0.5f);

            var extents = bounds.extents;
            var center  = bounds.center;

            var c0 = center - extents;
            var c1 = center + new Vector3(extents.x, -extents.y, -extents.z);
            var c2 = center + new Vector3(extents.x, extents.y, -extents.z);
            var c3 = center + new Vector3(-extents.x, extents.y, -extents.z);
            var c4 = center + new Vector3(-extents.x, extents.y, extents.z);
            var c5 = center + extents;
            var c6 = center + new Vector3(extents.x, -extents.y, extents.z);
            var c7 = center + new Vector3(-extents.x, -extents.y, extents.z);

            Debug.DrawLine(c0, c1, Color.magenta);
            Debug.DrawLine(c0, c3, Color.magenta);
            Debug.DrawLine(c0, c7, Color.magenta);
            Debug.DrawLine(c1, c2, Color.magenta);
            Debug.DrawLine(c1, c6, Color.magenta);
            Debug.DrawLine(c2, c3, Color.magenta);
            Debug.DrawLine(c2, c5, Color.magenta);
            Debug.DrawLine(c3, c4, Color.magenta);
            Debug.DrawLine(c4, c5, Color.magenta);
            Debug.DrawLine(c4, c7, Color.magenta);
            Debug.DrawLine(c5, c6, Color.magenta);
            Debug.DrawLine(c6, c7, Color.magenta);
        }
コード例 #3
0
    private void Update()
    {
        if (tTarget == null || onCollision)
        {
            return;
        }

        var point             = CenterPoint();
        var raycastHit        = new RaycastHit();
        var distance          = Vector3.Distance(point, targetPos); Debug.DrawLine(point, targetPos);
        var distanceNextFrame = effectSettings.MoveSpeed * Time.deltaTime;

        if (distanceNextFrame > distance)
        {
            distanceNextFrame = distance;
        }
        if (distance <= effectSettings.ColliderRadius)
        {
            DeactivateAttachedPoints(raycastHit);
        }

        var direction = (targetPos - point).normalized;

        if (Physics.Raycast(point, direction, out raycastHit, distanceNextFrame + effectSettings.ColliderRadius))
        {
            targetPos = raycastHit.point - direction * effectSettings.ColliderRadius;
            DeactivateAttachedPoints(raycastHit);
        }
    }
コード例 #4
0
    // Update is called once per frame
    private void Update()
    {
        float stepLength = 1.0f / Segments;
        float step;

        _animCounter += Time.deltaTime;
        // Animate the tangents to move around in cycles
        TangentOne.Translate(Mathf.Cos(_animCounter) * 0.1f, 0, 0, Space.Self);
        TangentTwo.Translate(Mathf.Sin(_animCounter) * 0.1f, 0, 0, Space.Self);
        // Turn GameObject positions into Vector2 objects
        _startPosition = new Vector2(StartPosition.position.x, StartPosition.position.y);
        _endPosition   = new Vector2(EndPosition.position.x, EndPosition.position.y);
        _tangentOne    = new Vector2(TangentOne.position.x, TangentOne.position.y);
        _tangentTwo    = new Vector2(TangentTwo.position.x, TangentTwo.position.y);
        // Build the line segments of the curve
        for (var i = 0; i < Segments; i++)
        {
            step = i * stepLength;
            var prevPosition = Hermite.GetVector2AtStep(_startPosition, _endPosition,
                                                        (_tangentOne - _startPosition) * TangentOneWeight,
                                                        -(_tangentTwo - _endPosition) * TangentTwoWeight,
                                                        step);
            var nextPosition = Hermite.GetVector2AtStep(_startPosition, _endPosition,
                                                        (_tangentOne - _startPosition) * TangentTwoWeight,
                                                        -(_tangentTwo - _endPosition) * TangentTwoWeight,
                                                        step + stepLength);
            _lines[i].transform.position = new Vector3(prevPosition.x, prevPosition.y, 0);
            _lines[i].transform.LookAt(new Vector3(nextPosition.x, nextPosition.y, 0), Vector3.up);
            _lines[i].transform.localScale = new Vector3(0.2f, 0.2f, (prevPosition - nextPosition).magnitude);
        }
        // Debug Draw methods only show up when Editor is playing and paused
        Hermite.DrawVector2(_startPosition, _endPosition, (_tangentOne - _startPosition), -(_tangentTwo - _endPosition), Segments);
        Debug.DrawLine(_startPosition, _tangentOne, Color.cyan);
        Debug.DrawLine(_endPosition, _tangentTwo, Color.magenta);
    }
コード例 #5
0
ファイル: DebugDrawer.cs プロジェクト: jeffhong21/ProjectBANG
        /// <summary>
        /// Draws a cube made with lines
        /// </summary>
        /// <param name="center">center of the code in world space</param>
        /// <param name="size">size of the cube (extents*2 or max-min)</param>
        /// <param name="color">the color of the cube lines</param>
        public static void DrawWireCube(Vector3 center, Vector3 size, Color color = default)
        {
            Vector3 lbb = center + ((-size) * 0.5f);
            Vector3 rbb = center + (new Vector3(size.x, -size.y, -size.z) * 0.5f);

            Vector3 lbf = center + (new Vector3(size.x, -size.y, size.z) * 0.5f);
            Vector3 rbf = center + (new Vector3(-size.x, -size.y, size.z) * 0.5f);

            Vector3 lub = center + (new Vector3(-size.x, size.y, -size.z) * 0.5f);
            Vector3 rub = center + (new Vector3(size.x, size.y, -size.z) * 0.5f);

            Vector3 luf = center + ((size) * 0.5f);
            Vector3 ruf = center + (new Vector3(-size.x, size.y, size.z) * 0.5f);

            color = color == default ? Color.white : color;

            Debug.DrawLine(lbb, rbb, color);
            Debug.DrawLine(rbb, lbf, color);
            Debug.DrawLine(lbf, rbf, color);
            Debug.DrawLine(rbf, lbb, color);

            Debug.DrawLine(lub, rub, color);
            Debug.DrawLine(rub, luf, color);
            Debug.DrawLine(luf, ruf, color);
            Debug.DrawLine(ruf, lub, color);

            Debug.DrawLine(lbb, lub, color);
            Debug.DrawLine(rbb, rub, color);
            Debug.DrawLine(lbf, luf, color);
            Debug.DrawLine(rbf, ruf, color);
        }
コード例 #6
0
        /// <summary>
        /// Draws a cube at the specified position, and of the specified color and size
        /// </summary>
        /// <param name="position">Position.</param>
        /// <param name="color">Color.</param>
        /// <param name="size">Size.</param>
        public static void DrawCube(Vector3 position, Color color, Vector3 size)
        {
            if (!DebugDrawEnabled)
            {
                return;
            }

            Vector3 halfSize = size / 2f;

            Vector3[] points = new Vector3 []
            {
                position + new Vector3(halfSize.x, halfSize.y, halfSize.z),
                position + new Vector3(-halfSize.x, halfSize.y, halfSize.z),
                position + new Vector3(-halfSize.x, -halfSize.y, halfSize.z),
                position + new Vector3(halfSize.x, -halfSize.y, halfSize.z),
                position + new Vector3(halfSize.x, halfSize.y, -halfSize.z),
                position + new Vector3(-halfSize.x, halfSize.y, -halfSize.z),
                position + new Vector3(-halfSize.x, -halfSize.y, -halfSize.z),
                position + new Vector3(halfSize.x, -halfSize.y, -halfSize.z),
            };

            Debug.DrawLine(points[0], points[1], color);
            Debug.DrawLine(points[1], points[2], color);
            Debug.DrawLine(points[2], points[3], color);
            Debug.DrawLine(points[3], points[0], color);
        }
コード例 #7
0
ファイル: AnimGraph_Stand.cs プロジェクト: zy199711/FPSSample
        void DebugSceneView(PresentationState animState)
        {
            if (m_template.footIK.debugIdlePos)
            {
                var rotation     = Quaternion.Euler(0f, animState.rotation, 0f);
                var leftIdlePos  = rotation * m_template.footIK.leftToeStandPos + animState.position;
                var rightIdlePos = rotation * m_template.footIK.rightToeStandPos + animState.position;

                DebugDraw.Sphere(leftIdlePos, 0.01f, Color.green);
                DebugDraw.Sphere(leftIdlePos, 0.04f, Color.green);
                DebugDraw.Sphere(rightIdlePos, 0.01f, Color.red);
                DebugDraw.Sphere(rightIdlePos, 0.04f, Color.red);
            }

            if (m_template.footIK.debugRayCast)
            {
                DebugDraw.Sphere(m_LeftFootPos, 0.025f, Color.yellow);
                DebugDraw.Sphere(m_RightFootPos, 0.025f, Color.yellow);

                DebugDraw.Sphere(m_LeftHit.point, 0.015f);
                DebugDraw.Sphere(m_RightHit.point, 0.015f);

                Debug.DrawLine(m_LeftHit.point, m_LeftHit.point + m_LeftHit.normal, Color.green);
                Debug.DrawLine(m_RightHit.point, m_RightHit.point + m_RightHit.normal, Color.red);
            }
        }
コード例 #8
0
        /// <summary>
        /// Draws a point of the specified color and size at the specified position
        /// </summary>
        /// <param name="pos">Position.</param>
        /// <param name="col">Col.</param>
        /// <param name="scale">Scale.</param>
        public static void DrawPoint(Vector3 position, Color color, float size)
        {
            if (!DebugDrawEnabled)
            {
                return;
            }

            Vector3[] points = new Vector3[]
            {
                position + (Vector3.up * size),
                position - (Vector3.up * size),
                position + (Vector3.right * size),
                position - (Vector3.right * size),
                position + (Vector3.forward * size),
                position - (Vector3.forward * size)
            };

            Debug.DrawLine(points[0], points[1], color);
            Debug.DrawLine(points[2], points[3], color);
            Debug.DrawLine(points[4], points[5], color);
            Debug.DrawLine(points[0], points[2], color);
            Debug.DrawLine(points[0], points[3], color);
            Debug.DrawLine(points[0], points[4], color);
            Debug.DrawLine(points[0], points[5], color);
            Debug.DrawLine(points[1], points[2], color);
            Debug.DrawLine(points[1], points[3], color);
            Debug.DrawLine(points[1], points[4], color);
            Debug.DrawLine(points[1], points[5], color);
            Debug.DrawLine(points[4], points[2], color);
            Debug.DrawLine(points[4], points[3], color);
            Debug.DrawLine(points[5], points[2], color);
            Debug.DrawLine(points[5], points[3], color);
        }
コード例 #9
0
 internal void DrawEdges()
 {
     Debug.DrawLine(EdgeA.Start, EdgeA.End, Color.green, 180);
     Debug.DrawLine(EdgeB.Start, EdgeB.End, Color.green, 180);
     Debug.DrawLine(EdgeC.Start, EdgeC.End, Color.green, 180);
     Debug.DrawLine(EdgeD.Start, EdgeD.End, Color.green, 180);
 }
コード例 #10
0
 private void TraceDisplacement(Vector3 delta, Color color)
 {
     if (_traceAdjustments)
     {
         Debug.DrawLine(Transform.position, Transform.position + delta, color);
     }
 }
コード例 #11
0
 public static void DebugPath(Vector3[] path)
 {
     for (int i = 0; i < path.Length - 1; i++)
     {
         Debug.DrawLine(path[i], path[i + 1], Color.yellow, 10.0f);
     }
 }
コード例 #12
0
    public Vector3 GetReEntryPosition(Vector3 position, Bounds bounds)
    {
        var pointOnBounds = _paddedBounds.ClosestPoint(position);

        var colliderOverlapPadding = 0.5f;

        var size = (_collider.bounds.extents * 2) + bounds.extents * colliderOverlapPadding;

        var result = new Vector3(pointOnBounds.x, position.y, pointOnBounds.z);

        if (position.z <= _collider.bounds.min.z)
        {
            result.z += size.z;
        }
        if (position.z > _collider.bounds.max.z)
        {
            result.z -= size.z;
        }
        if (position.x <= _collider.bounds.min.x)
        {
            result.x += size.x;
        }
        if (position.x > _collider.bounds.max.x)
        {
            result.x -= size.x;
        }

        Debug.DrawLine(pointOnBounds, result + Vector3.zero * 0.1f, Color.yellow);
        return(result);
    }
コード例 #13
0
    // Update is called once per frame
    private void Update()
    {
        float stepLength = 1.0f / Segments;
        float step;

        _animCounter += Time.deltaTime;
        // Animate the tangents to move around in cycles
        TangentOne.Translate(Mathf.Cos(_animCounter) * 0.1f, Mathf.Sin(_animCounter) * 0.05f, -Mathf.Sin(_animCounter) * 0.1f, Space.Self);
        TangentTwo.Translate(Mathf.Sin(_animCounter) * 0.1f, Mathf.Cos(_animCounter) * 0.03f, Mathf.Cos(_animCounter) * 0.1f, Space.Self);
        // Build the line segments of the curve
        for (var i = 0; i < Segments; i++)
        {
            step = i * stepLength;
            // Use the Hermite class to get the start and end points of the current segment
            var prevPosition = Hermite.GetVector3AtStep(StartPosition.position, EndPosition.position,
                                                        (TangentOne.position - StartPosition.position) * TangentOneWeight,
                                                        -(TangentTwo.position - EndPosition.position) * TangentTwoWeight,
                                                        step);
            var nextPosition = Hermite.GetVector3AtStep(StartPosition.position, EndPosition.position,
                                                        (TangentOne.position - StartPosition.position) * TangentTwoWeight,
                                                        -(TangentTwo.position - EndPosition.position) * TangentTwoWeight,
                                                        step + stepLength);
            // Move the segment to the starting point
            _lines[i].transform.position = prevPosition;
            // Rotate towards the endpoint
            _lines[i].transform.LookAt(nextPosition, Vector3.up);
            // Scale the cube to match length
            _lines[i].transform.localScale = new Vector3(0.2f, 0.2f, (prevPosition - nextPosition).magnitude);
        }
        // Debug Draw methods only show up when Editor is playing and paused
        Hermite.DrawVector3(StartPosition.position, EndPosition.position, TangentOne.position,
                            -TangentTwo.position, Segments);
        Debug.DrawLine(StartPosition.position, TangentOne.position, Color.cyan);
        Debug.DrawLine(EndPosition.position, TangentTwo.position, Color.magenta);
    }
コード例 #14
0
        //private void DrawCells(KdTree<FloatWithSizeMath.FloatWithSize, Cell> cellTree)
        private void DrawCells(IEnumerable <Cell> cellTree)
        {
            foreach (var currentCell in cellTree)
            {
                try
                {
#if UNITY_EDITOR
                    Gizmos.color = currentCell.Color;
                    Gizmos.DrawCube(currentCell.Position, currentCell.Size);
                    if (!ShowReferences)
                    {
                        continue;
                    }
                    Gizmos.color = Color.blue;
                    foreach (var neighbour in currentCell.Neighbours)
                    {
                        //Gizmos.DrawLine(currentCell.Position, neighbour.Key.Position);
                        //Gizmos.DrawCube(currentCell.Position, Vector3.one * 0.075f);
                        Debug.DrawLine(currentCell.Position, neighbour.Key.Position, Color.blue);
                    }
#endif
                }
                catch (Exception e)
                {
                    Debug.Log(e);
                }
            }
        }
コード例 #15
0
 void OnDrawGizmos()
 {
     if (_path != null && _path.Count > 0)
     {
         int index = 1;
         foreach (Node node in _path)
         {
             if (index < _path.Count)
             {
                 SNode nextNode = _path[index];
                 Debug.DrawLine(node.position, nextNode.position, Color.green);
                 index++;
             }
         }
         ;
         int vecIndex = 1;
         if (actualPath.Count > 0)
         {
             foreach (Vector3 vec in actualPath)
             {
                 if (vecIndex < actualPath.Count)
                 {
                     Vector3 nextVec = actualPath[vecIndex];
                     Debug.DrawLine(vec, nextVec, Color.red);
                     vecIndex++;
                 }
             }
         }
     }
 }
コード例 #16
0
ファイル: FeetManager.cs プロジェクト: powerzaba/predictionIK
    private Vector3 GetGroundPoint(Vector3 predictedPosition, bool right)
    {
        RaycastHit hit;
        var        groundPoint = Vector3.zero;
        var        skyPosition = predictedPosition + Vector3.up * 1.2f;

        Debug.DrawLine(skyPosition, skyPosition + Vector3.down * 2f, Color.magenta);
        //test OMG
        var currentDirection = StateManager.currentDirection;
        var rot  = Quaternion.LookRotation(currentDirection);
        var a1   = predictedPosition + rot * new Vector3(0.05f, 0, 0.05f);
        var a2   = predictedPosition + rot * new Vector3(-0.05f, 0, 0.05f);
        var a3   = predictedPosition + rot * new Vector3(-0.05f, 0, -0.05f);
        var a4   = predictedPosition + rot * new Vector3(0.05f, 0, -0.05f);
        var sky1 = _predictor.GetSkyPosition(1.2f, a1);
        var sky2 = _predictor.GetSkyPosition(1.2f, a2);
        var sky3 = _predictor.GetSkyPosition(1.2f, a3);
        var sky4 = _predictor.GetSkyPosition(1.2f, a4);
        var hit1 = Physics.Raycast(sky1, Vector3.down, out var h1, 4f, environmentLayer);
        var hit2 = Physics.Raycast(sky2, Vector3.down, out var h2, 4f, environmentLayer);
        var hit3 = Physics.Raycast(sky3, Vector3.down, out var h3, 4f, environmentLayer);
        var hit4 = Physics.Raycast(sky4, Vector3.down, out var h4, 4f, environmentLayer);

        Debug.DrawLine(sky1, sky1 + Vector3.down * 1.2f, Color.yellow);
        Debug.DrawLine(sky2, sky2 + Vector3.down * 1.2f, Color.yellow);
        Debug.DrawLine(sky3, sky3 + Vector3.down * 1.2f, Color.yellow);
        Debug.DrawLine(sky4, sky4 + Vector3.down * 1.2f, Color.yellow);

        var test = new float[4];

        test[0] = h1.point.y;
        test[1] = h2.point.y;
        test[2] = h3.point.y;
        test[3] = h4.point.y;
        var res = _predictor.GetPopularElement(test);

        if (Physics.Raycast(skyPosition, Vector3.down, out hit, 2f, environmentLayer))
        {
            groundPoint    = hit.point;
            groundPoint.y += feetHeight;

            //test rotation all the time like old system
            var rotAxis  = Vector3.Cross(Vector3.up, hit.normal);
            var angle    = Vector3.Angle(Vector3.up, hit.normal);
            var rotation = Quaternion.AngleAxis(angle, rotAxis);
            if (right)
            {
                rightRotationIK = rotation;
            }
            else
            {
                leftRotationIK = rotation;
            }
        }

        return(new Vector3(predictedPosition.x, res, predictedPosition.z));

        return(groundPoint);
    }
コード例 #17
0
 public static void DrawLine(Vector3 from, Vector3 to, Color c, float duration = 0f)
 {
     if (!showDebugging)
     {
         return;
     }
     Debug.DrawLine(from, to, c, duration);
 }
コード例 #18
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && AssignedTeam == Team.Red)
        {
            Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            moveTarget = new Vector2(pos.x, pos.y);
            isMoving   = true;
        }

        if (isMoving)
        {
            if (Manager.Debugging)
            {
                Debug.DrawLine(transform.position, moveTarget, Color.green);
            }
        }

        ////////////////////////////////////////////
        /// AI Update

        calculateNearestEnemies();
        calculateNearestFriendlies();

        SelectState();

        switch (aiState)
        {
        case (AIState.Flee):
            RunAway();
            break;

        case (AIState.Fight):
            Fight();
            break;

        case (AIState.Find):
            Debug.LogException(new NotImplementedException());
            break;

        case (AIState.HealFriend):
            HealFriendly();
            Debug.LogException(new NotImplementedException());
            break;

        case (AIState.Patrol):
            Patrol();
            Debug.LogException(new NotImplementedException());
            break;

        case (AIState.None):
            break;

        default:
            Debug.LogException(new ArgumentException());
            break;
        }
    }
コード例 #19
0
        private RaycastHit[] CalculateBothRayCastHits(Transform transform)
        {
            var point        = PositionWithinArea(transform);
            var startingCast = CreateRandomRay(point);
            var hits         = Physics.RaycastAll(startingCast.origin, startingCast.direction);

            Debug.DrawLine(startingCast.origin, startingCast.direction, Color.cyan, 1000f);
            return(hits);
        }
コード例 #20
0
 private void OnDrawGizmosSelected()
 {
     if (corners == null)
     {
         return;
     }
     foreach (var p in corners.Buffer(2, 1).Where(p => p.Count == 2))
     {
         Debug.DrawLine(p.First(), p.Last(), Color.green);
     }
 }
コード例 #21
0
ファイル: DebugDraw.cs プロジェクト: yika-aixi/tlplib
        public static void bounds2D(Bounds bounds, Color color, float duration = 0)
        {
            var c  = bounds.center;
            var e  = bounds.extents;
            var e2 = new Vector3(e.x, -e.y, e.z);

            Debug.DrawLine(c + e, c + e2, color, duration);
            Debug.DrawLine(c - e, c + e2, color, duration);
            Debug.DrawLine(c - e, c - e2, color, duration);
            Debug.DrawLine(c + e, c - e2, color, duration);
        }
コード例 #22
0
        public static void ForDebug(Bounds2i rectangle, Color color, float duration = 0)
        {
            var corner1 = new Vector3(rectangle.Min.X, 0, rectangle.Min.Z);
            var corner2 = new Vector3(rectangle.Min.X, 0, rectangle.Max.Z + 1);
            var corner3 = new Vector3(rectangle.Max.X + 1, 0, rectangle.Max.Z + 1);
            var corner4 = new Vector3(rectangle.Max.X + 1, 0, rectangle.Min.Z);

            Debug.DrawLine(corner1, corner2, color, duration);
            Debug.DrawLine(corner2, corner3, color, duration);
            Debug.DrawLine(corner3, corner4, color, duration);
            Debug.DrawLine(corner4, corner1, color, duration);
        }
コード例 #23
0
ファイル: DebugDraw.cs プロジェクト: yika-aixi/tlplib
        public static void circle(Vector3 pos, float radius, Color color, float duration, int segments = 20)
        {
            var current      = pos + new Vector3(radius, 0);
            var segmentAngle = 2 * Mathf.PI / segments;

            for (var i = 1; i <= segments; i++)
            {
                var next = pos + radius * new Vector3(Mathf.Cos(segmentAngle * i), Mathf.Sin(segmentAngle * i));
                Debug.DrawLine(current, next, color, duration);
                current = next;
            }
        }
コード例 #24
0
 private void VisualizerTest()
 {
     float[] spectrum = new float[256];
     source.GetSpectrumData(spectrum, 0, FFTWindow.Rectangular);
     for (int i = 1; i < spectrum.Length - 1; i++)
     {
         Debug.DrawLine(new Vector3(i - 1, spectrum[i] + 10, 0), new Vector3(i, spectrum[i + 1] + 10, 0), Color.red);
         Debug.DrawLine(new Vector3(i - 1, Mathf.Log(spectrum[i - 1]) + 10, 2), new Vector3(i, Mathf.Log(spectrum[i]) + 10, 2), Color.cyan);
         Debug.DrawLine(new Vector3(Mathf.Log(i - 1), spectrum[i - 1] - 10, 1), new Vector3(Mathf.Log(i), spectrum[i] - 10, 1), Color.green);
         Debug.DrawLine(new Vector3(Mathf.Log(i - 1), Mathf.Log(spectrum[i - 1]), 3), new Vector3(Mathf.Log(i), Mathf.Log(spectrum[i]), 3), Color.blue);
     }
 }
コード例 #25
0
        void DrawEdges(float duration)
        {
            var tri       = NavMesh.CalculateTriangulation();
            var edge_list = CreateEdges(tri);

            foreach (var edge in edge_list)
            {
                edge.ComputeDerivedData();
                Debug.DrawLine(edge.m_StartPos, edge.m_EndPos, Color.magenta, duration);
                var mid = edge.GetMidpoint();
                Debug.DrawLine(mid, mid + edge.m_Normal, Color.blue, duration);
            }
        }
コード例 #26
0
    public static void DebugDrawQuadrant(float3 pos)
    {
        Color   color     = Color.black;
        Vector3 lowerLeft = new Vector3((math.floor(pos.x / quadrantCellSize)) * quadrantCellSize, 0,
                                        math.floor(pos.z / quadrantCellSize) * quadrantCellSize);

        Debug.DrawLine(lowerLeft, lowerLeft + new Vector3(1, 0, 0) * quadrantCellSize, color);
        Debug.DrawLine(lowerLeft, lowerLeft + new Vector3(0, 0, 1) * quadrantCellSize, color);
        Debug.DrawLine(lowerLeft + new Vector3(1, 0, 0) * quadrantCellSize,
                       lowerLeft + new Vector3(1, 0, 1) * quadrantCellSize, color);
        Debug.DrawLine(lowerLeft + new Vector3(0, 0, 1) * quadrantCellSize,
                       lowerLeft + new Vector3(1, 0, 1) * quadrantCellSize, color);
    }
コード例 #27
0
    public bool checkVisible(Vector3 point)
    {
        var campos = _Player.camera.transform.position;
        var wp     = _Player.camera.WorldToViewportPoint(point);

        var vis = new Rect(0, 0, 1, 1).Contains(wp) && wp.z > 0 && !Physics.Linecast(campos, point, Layer.levelMask) || Vector3.Distance(campos, point) < 50;

        if (vis)
        {
            Debug.DrawLine(campos, point);
        }
        return(vis);
    }
コード例 #28
0
    void Draw(ref BlobArray <int> parentIndexes, ref DynamicBuffer <float4x4> localToWorldBuffer, Color color)
    {
        for (int i = 1; i != parentIndexes.Length; ++i)
        {
            var localToWorld = localToWorldBuffer[i];

            var pIdx = parentIndexes[i];
            var parentLocalToWorld = localToWorldBuffer[pIdx];

            Vector3 p1 = localToWorld.c3.xyz;
            Vector3 p2 = parentLocalToWorld.c3.xyz;
//            DebugOverlay.DrawLine3D(p1, p2, color);
            Debug.DrawLine(p1, p2, color);
        }
    }
コード例 #29
0
    private void _DrawAll()
    {
        for (int i = 0; i < Left.Length - 1; i++)
        {
            var pos1 = transform.position + new Vector3(Left[i].x, 0, Left[i].y);
            var pos2 = transform.position + new Vector3(Left[i + 1].x, 0, Left[i + 1].y);
            Debug.DrawLine(pos1, pos2, AllLineColor);
        }

        for (int i = 0; i < Right.Length - 1; i++)
        {
            var pos1 = transform.position + new Vector3(Right[i].x, 0, Right[i].y);
            var pos2 = transform.position + new Vector3(Right[i + 1].x, 0, Right[i + 1].y);
            Debug.DrawLine(pos1, pos2, AllLineColor);
        }
    }
コード例 #30
0
    public static bool PositionIsInFan(Vector3d basePosi, long radius, int angle, FixedQuaternion baseQuaternion, Vector3d posi)
    {
#if UNITY_EDITOR
        var p1_sin  = FixedMath.Trig.Sin(FixedMath.One.Div(180).Mul(FixedMath.Pi).Mul(angle / 2));
        var p1_cos  = FixedMath.Trig.Cos(FixedMath.One.Div(180).Mul(FixedMath.Pi).Mul(angle / 2));
        var p1      = new Vector3d(p1_sin.Mul(radius), 0, p1_cos.Mul(radius));
        var worldP1 = baseQuaternion * p1 + basePosi;

        var p2_sin  = FixedMath.Trig.Sin(FixedMath.One.Div(180).Mul(FixedMath.Pi).Mul(-angle / 2));
        var p2_cos  = FixedMath.Trig.Cos(FixedMath.One.Div(180).Mul(FixedMath.Pi).Mul(-angle / 2));
        var p2      = new Vector3d(p2_sin.Mul(radius), 0, p2_cos.Mul(radius));
        var worldP2 = baseQuaternion * p2 + basePosi;
        Debug.DrawLine(basePosi.ToVector3(), worldP1.ToVector3(), Color.red, 3);
        Debug.DrawLine(basePosi.ToVector3(), worldP2.ToVector3(), Color.red, 3);
#endif
        var radiusSqr = radius.Mul(radius);
        var relativeP = posi - basePosi;
        if (radiusSqr > relativeP.sqrMagnitude)
        {
            var rotateRelativeP = FixedQuaternion.Inverse(baseQuaternion) * relativeP;
            var cos             = Vector3d.Dot(rotateRelativeP.Normalize(), new Vector3d(0, 0, FixedMath.One));
            var realCos         = FixedMath.Trig.Cos(FixedMath.One.Div(180).Mul(FixedMath.Pi).Mul(angle / 2));
            if (relativeP.z > 0)
            {
                if (angle > 180)
                {
                    return(true);
                }
                return(realCos < cos);
            }
            else
            {
                if (angle < 180)
                {
                    return(false);
                }
                else
                {
                    return(realCos > cos);
                }
            }
        }
        else
        {
            return(false);
        }
    }