public static void DrawCircleThickness(ExtCircle circle, int thickness, DrawOutlineType drawOutlineType = DrawOutlineType.MIDDLE, float space = 0.01f) { int start = 0; int end = thickness; switch (drawOutlineType) { case DrawOutlineType.MIDDLE: start = -thickness / 2; end = thickness / 2; break; case DrawOutlineType.INSIDE: start = -thickness; end = 0; break; case DrawOutlineType.OUTSIDE: start = 0; end = thickness; break; } for (int i = start; i < end; i++) { Handles.DrawWireDisc(circle.Point, circle.Normal, circle.Radius + space * i); } }
/// <summary> /// draw a disc /// </summary> public static GravityOverrideDisc DrawDisc(ExtCircle circle, GravityOverrideDisc discGravity, Color color, bool allowBottom, out bool hasChanged) { hasChanged = false; Quaternion rotation = ExtRotation.QuaternionFromVectorDirector(circle.Normal, Vector3.up); bool topFace = discGravity.Face; bool topExtremity = discGravity.Borders; bool isCameraViewBehindFace = Vector3.Dot(ExtSceneView.GetSceneViewCameraTransform().forward, circle.Normal) > 0 && !allowBottom; Handles.color = color; if (!Event.current.alt && Event.current.button != 2 && Handles.Button(circle.Point, rotation, circle.Radius, circle.Radius, Handles.CircleHandleCap)) { Debug.Log("extremity pressed"); discGravity.Borders = !discGravity.Borders; hasChanged = true; Use(); } if (!topFace) { Handles.color = (isCameraViewBehindFace) ? new Color(color.r, color.g, color.b, color.a / 2) : color; Handles.DrawSolidDisc(circle.Point, circle.Normal, circle.Radius / 10 * 8); } if (!topExtremity) { Handles.color = (isCameraViewBehindFace) ? new Color(color.r, color.g, color.b, color.a / 2) : color; ExtHandle.DrawCircleThickness(circle, 50, ExtHandle.DrawOutlineType.INSIDE); } Handles.color = Color.red; if (!Event.current.alt && Event.current.button != 2 && Handles.Button(circle.Point, rotation, circle.Radius / 10 * 7, circle.Radius / 10 * 7, Handles.CircleHandleCap)) { if (isCameraViewBehindFace) { Debug.Log("not behind face"); } else { Debug.Log("Face pressed !"); discGravity.Face = !discGravity.Face; hasChanged = true; Use(); } } return(discGravity); }
public void DrawWithExtraSize(Color color, Vector3 extraSize) { if (extraSize.Maximum() <= 1f) { return; } Matrix4x4 cylinderMatrix = Matrix4x4.TRS(_position, _rotation, (_localScale + extraSize) * _radius); float realRadius = _radius * MaxXY(_localScale + extraSize); ExtCircle circle = new ExtCircle(_position, -cylinderMatrix.UpFast(), realRadius); circle.Draw(color, true, ""); }
public static GravityOverrideCylinder DrawCylinder(ExtCylinder cylinder, ExtCircle circle1, ExtCircle circle2, GravityOverrideCylinder cylinderGravity, Color color, out bool hasChanged) { float sizeLine = cylinder.LocalScale.magnitude / 20; hasChanged = false; bool changed = hasChanged; cylinderGravity.Disc1 = ExtGravityOverrideEditor.DrawDisc(circle1, cylinderGravity.Disc1, color, false, out changed); hasChanged = (changed) ? true : hasChanged; cylinderGravity.Disc2 = ExtGravityOverrideEditor.DrawDisc(circle2, cylinderGravity.Disc2, color, false, out changed); hasChanged = (changed) ? true : hasChanged; cylinderGravity.Trunk = ExtGravityOverrideEditor.DrawLineTrunk(cylinderGravity.Trunk, cylinder.P1, cylinder.P2, new Color(color.r, color.g, color.b, color.a * 0.8f), sizeLine, out changed); hasChanged = (changed) ? true : hasChanged; return(cylinderGravity); }