/// <summary> /// Draws a wireframe cube with position, rotation and scale /// </summary> public static void WireCube(DebugDrawLine drawLine, Vector3 position, Quaternion rotation, Vector3 scale, Color color, float duration, bool depthTest) { Vector3 right = rotation * Vector3.right * scale.x; Vector3 up = rotation * Vector3.up * scale.y; Vector3 forward = rotation * Vector3.forward * scale.z; Vector3 a1 = position + right * 0.5f + up * 0.5f + forward * 0.5f; Vector3 b1 = a1 - up; Vector3 c1 = b1 - right; Vector3 d1 = a1 - right; Vector3 a2 = a1 - forward; Vector3 b2 = b1 - forward; Vector3 c2 = c1 - forward; Vector3 d2 = d1 - forward; drawLine(a1, b1, color, duration, depthTest); drawLine(b1, c1, color, duration, depthTest); drawLine(c1, d1, color, duration, depthTest); drawLine(d1, a1, color, duration, depthTest); drawLine(a2, b2, color, duration, depthTest); drawLine(b2, c2, color, duration, depthTest); drawLine(c2, d2, color, duration, depthTest); drawLine(d2, a2, color, duration, depthTest); drawLine(a1, a2, color, duration, depthTest); drawLine(b1, b2, color, duration, depthTest); drawLine(c1, c2, color, duration, depthTest); drawLine(d1, d2, color, duration, depthTest); }
/// <summary> /// Draws a wireframe circular arc with position, rotation and radius /// </summary> public static void WireArc(Func <float, float, Vector3> pointOnCircle, DebugDrawLine drawLine, Vector3 position, Quaternion rotation, float radius, float fromAngle, float toAngle, Color color, float duration, bool depthTest) { GetSegmentsAndSegmentAngle(fromAngle, toAngle, out int segments, out float segmentAngle); WireArc(pointOnCircle, drawLine, position, rotation, radius, fromAngle, segments, segmentAngle, color, duration, depthTest); }
/// <summary> /// Draws a wireframe hemisphere with position, rotation and radius /// </summary> public static void WireHemisphere(DebugDrawLine drawLine, Vector3 position, Quaternion rotation, float radius, Color color, float duration, bool depthTest) { WireArcXY(drawLine, position, rotation, radius, -90, 90, color, duration, depthTest); WireCircleXZ(drawLine, position, rotation, radius, color, duration, depthTest); WireArcYZ(drawLine, position, rotation, radius, 0, 180, color, duration, depthTest); }
/// <summary> /// Draws a wireframe cone with position and rotation /// </summary> public static void WireCone(DebugDrawLine drawLine, Vector3 position, Quaternion rotation, float apexRadius, float angle, float length, Color color, float duration, bool depthTest) { Vector3 upperCenter = position + rotation * Vector3.up * length; float upperRadius = Mathf.Tan(angle * Mathf.Deg2Rad) * length + apexRadius; WireCircleXZ(drawLine, upperCenter, rotation, upperRadius, color, duration, depthTest); Vector3 a2 = upperCenter + rotation * Geometry.PointOnCircle3XZ(upperRadius, 0); Vector3 b2 = upperCenter + rotation * Geometry.PointOnCircle3XZ(upperRadius, 90); Vector3 c2 = upperCenter + rotation * Geometry.PointOnCircle3XZ(upperRadius, 180); Vector3 d2 = upperCenter + rotation * Geometry.PointOnCircle3XZ(upperRadius, 270); if (apexRadius == 0) { drawLine(position, a2, color, duration, depthTest); drawLine(position, b2, color, duration, depthTest); drawLine(position, c2, color, duration, depthTest); drawLine(position, d2, color, duration, depthTest); } else { WireCircleXZ(drawLine, position, rotation, apexRadius, color, duration, depthTest); Vector3 a1 = position + rotation * Geometry.PointOnCircle3XZ(apexRadius, 0); Vector3 b1 = position + rotation * Geometry.PointOnCircle3XZ(apexRadius, 90); Vector3 c1 = position + rotation * Geometry.PointOnCircle3XZ(apexRadius, 180); Vector3 d1 = position + rotation * Geometry.PointOnCircle3XZ(apexRadius, 270); drawLine(a1, a2, color, duration, depthTest); drawLine(b1, b2, color, duration, depthTest); drawLine(c1, c2, color, duration, depthTest); drawLine(d1, d2, color, duration, depthTest); } }
public static void WireRay( DebugDrawLine drawLine, Ray ray, Color color, float duration, bool depthTest) { drawLine(ray.origin, ray.origin + ray.direction, color, duration, depthTest); }
public static void WireCircleYZ( DebugDrawLine drawLine, Vector3 position, float radius, Color color, float duration, bool depthTest) { WireCircle(pointOnCircleYZ, drawLine, position, radius, color, duration, depthTest); }
public static void WireQuadXZ( DebugDrawLine drawLine, Vector3 position, Quaternion rotation, Vector2 scale, Color color, float duration, bool depthTest) { WireQuad(drawLine, position, rotation, scale, Vector3.right, Vector3.forward, color, duration, depthTest); }
public static void WireArcYZ( DebugDrawLine drawLine, Vector3 position, float radius, float fromAngle, float toAngle, Color color, float duration, bool depthTest) { WireArc(pointOnCircleYZ, drawLine, position, radius, fromAngle, toAngle, color, duration, depthTest); }
public static void WireCircle( Func<float, float, Vector3> pointOnCircle, DebugDrawLine drawLine, Vector3 position, float radius, Color color, float duration, bool depthTest) { WireArc(pointOnCircle, drawLine, position, radius, 0, circleSegments, circleSegmentAngle, color, duration, depthTest); }
/// <summary> /// Draws a wireframe circular arc with position, rotation and radius /// </summary> public static void WireArc(Func <float, float, Vector3> pointOnCircle, DebugDrawLine drawLine, Vector3 position, Quaternion rotation, float radius, float fromAngle, int segments, float segmentAngle, Color color, float duration, bool depthTest) { float currentAngle = fromAngle; for (var i = 0; i < segments; i++) { Vector3 a = position + rotation * pointOnCircle(radius, currentAngle); currentAngle += segmentAngle; Vector3 b = position + rotation * pointOnCircle(radius, currentAngle); drawLine(a, b, color, duration, depthTest); } }
/// <summary> /// Draws a wireframe quad with position, rotation and scale /// </summary> public static void WireQuad(DebugDrawLine drawLine, Vector3 position, Quaternion rotation, Vector2 scale, Vector3 planeRight, Vector3 planeForward, Color color, float duration, bool depthTest) { Vector3 right = rotation * planeRight * scale.x; Vector3 forward = rotation * planeForward * scale.y; Vector3 forwardRight = position + right * 0.5f + forward * 0.5f; Vector3 backRight = forwardRight - forward; Vector3 backLeft = backRight - right; Vector3 forwardLeft = forwardRight - right; drawLine(forwardRight, backRight, color, duration, depthTest); drawLine(backRight, backLeft, color, duration, depthTest); drawLine(backLeft, forwardLeft, color, duration, depthTest); drawLine(forwardLeft, forwardRight, color, duration, depthTest); }
public static void WireCircle( Func<float, float, Vector3> pointOnCircle, DebugDrawLine drawLine, Vector3 position, Quaternion rotation, float radius, Color color, float duration, bool depthTest) { WireArc(pointOnCircle, drawLine, position, rotation, radius, 0, circleSegments, circleSegmentAngle, color, duration, depthTest); }
public static void WireCircleYZ( DebugDrawLine drawLine, Vector3 position, Quaternion rotation, float radius, Color color, float duration, bool depthTest) { WireCircle(pointOnCircleYZ, drawLine, position, rotation, radius, color, duration, depthTest); }
/// <summary> /// Draws a segment /// </summary> public static void Segment3(DebugDrawLine drawLine, Segment3 segment, Color color, float duration, bool depthTest) { drawLine(segment.a, segment.b, color, duration, depthTest); }
/// <summary> /// Draws a segment /// </summary> public static void Segment2(DebugDrawLine drawLine, Segment2 segment, Color color, float duration, bool depthTest) { drawLine((Vector3)segment.a, (Vector3)segment.b, color, duration, depthTest); }
public static void WireHemisphere( DebugDrawLine drawLine, Vector3 position, Quaternion rotation, float radius, Color color, float duration, bool depthTest) { WireArcXY(drawLine, position, rotation, radius, -90, 90, color, duration, depthTest); WireCircleXZ(drawLine, position, rotation, radius, color, duration, depthTest); WireArcYZ(drawLine, position, rotation, radius, 0, 180, color, duration, depthTest); }
public static void WireArc( Func<float, float, Vector3> pointOnCircle, DebugDrawLine drawLine, Vector3 position, Quaternion rotation, float radius, float fromAngle, int segments, float segmentAngle, Color color, float duration, bool depthTest) { float currentAngle = fromAngle; for (var i = 0; i < segments; i++) { Vector3 a = position + rotation*pointOnCircle(radius, currentAngle); currentAngle += segmentAngle; Vector3 b = position + rotation*pointOnCircle(radius, currentAngle); drawLine(a, b, color, duration, depthTest); } }
public static void WireCone( DebugDrawLine drawLine, Vector3 position, Quaternion rotation, float radius, float angle, float length, Color color, float duration, bool depthTest) { Vector3 upperCenter = position + rotation*Vector3.up*length; float upperRadius = Mathf.Tan(angle*Mathf.Deg2Rad)*length + radius; WireCircleXZ(drawLine, upperCenter, rotation, upperRadius, color, duration, depthTest); Vector3 a2 = upperCenter + rotation*PTUtils.PointOnCircle3XZ(upperRadius, 0); Vector3 b2 = upperCenter + rotation*PTUtils.PointOnCircle3XZ(upperRadius, 90); Vector3 c2 = upperCenter + rotation*PTUtils.PointOnCircle3XZ(upperRadius, 180); Vector3 d2 = upperCenter + rotation*PTUtils.PointOnCircle3XZ(upperRadius, 270); if (radius == 0) { drawLine(position, a2, color, duration, depthTest); drawLine(position, b2, color, duration, depthTest); drawLine(position, c2, color, duration, depthTest); drawLine(position, d2, color, duration, depthTest); } else { WireCircleXZ(drawLine, position, rotation, radius, color, duration, depthTest); Vector3 a1 = rotation*PTUtils.PointOnCircle3XZ(radius, 0); Vector3 b1 = rotation*PTUtils.PointOnCircle3XZ(radius, 90); Vector3 c1 = rotation*PTUtils.PointOnCircle3XZ(radius, 180); Vector3 d1 = rotation*PTUtils.PointOnCircle3XZ(radius, 270); drawLine(a1, a2, color, duration, depthTest); drawLine(b1, b2, color, duration, depthTest); drawLine(c1, c2, color, duration, depthTest); drawLine(d1, d2, color, duration, depthTest); } }
public DebugRenderable(ref DebugDrawLine l, DebugRenderableFlags renderFlags) : this() { Type = DebugRenderableType.Line; Flags = renderFlags; LineData = l; }
public static void WireQuadYZ( DebugDrawLine drawLine, Vector3 position, Quaternion rotation, Vector2 scale, Color color, float duration, bool depthTest) { WireQuad(drawLine, position, rotation, scale, Vector3.up, Vector3.forward, color, duration, depthTest); }
public static void WireQuad( DebugDrawLine drawLine, Vector3 position, Quaternion rotation, Vector2 scale, Vector3 planeRight, Vector3 planeForward, Color color, float duration, bool depthTest) { Vector3 right = rotation*planeRight*scale.x; Vector3 forward = rotation*planeForward*scale.y; Vector3 forwardRight = position + right*0.5f + forward*0.5f; Vector3 backRight = forwardRight - forward; Vector3 backLeft = backRight - right; Vector3 forwardLeft = forwardRight - right; drawLine(forwardRight, backRight, color, duration, depthTest); drawLine(backRight, backLeft, color, duration, depthTest); drawLine(backLeft, forwardLeft, color, duration, depthTest); drawLine(forwardLeft, forwardRight, color, duration, depthTest); }
public static void WireArc( Func<float, float, Vector3> pointOnCircle, DebugDrawLine drawLine, Vector3 position, Quaternion rotation, float radius, float fromAngle, float toAngle, Color color, float duration, bool depthTest) { int segments; float segmentAngle; GetSegmentsAndSegmentAngle(fromAngle, toAngle, out segments, out segmentAngle); WireArc(pointOnCircle, drawLine, position, rotation, radius, fromAngle, segments, segmentAngle, color, duration, depthTest); }
public static void WireCube( DebugDrawLine drawLine, Vector3 position, Quaternion rotation, Vector3 scale, Color color, float duration, bool depthTest) { Vector3 right = rotation*Vector3.right*scale.x; Vector3 up = rotation*Vector3.up*scale.y; Vector3 forward = rotation*Vector3.forward*scale.z; Vector3 a1 = position + right*0.5f + up*0.5f + forward*0.5f; Vector3 b1 = a1 - up; Vector3 c1 = b1 - right; Vector3 d1 = a1 - right; Vector3 a2 = a1 - forward; Vector3 b2 = b1 - forward; Vector3 c2 = c1 - forward; Vector3 d2 = d1 - forward; drawLine(a1, b1, color, duration, depthTest); drawLine(b1, c1, color, duration, depthTest); drawLine(c1, d1, color, duration, depthTest); drawLine(d1, a1, color, duration, depthTest); drawLine(a2, b2, color, duration, depthTest); drawLine(b2, c2, color, duration, depthTest); drawLine(c2, d2, color, duration, depthTest); drawLine(d2, a2, color, duration, depthTest); drawLine(a1, a2, color, duration, depthTest); drawLine(b1, b2, color, duration, depthTest); drawLine(c1, c2, color, duration, depthTest); drawLine(d1, d2, color, duration, depthTest); }