public static Circle3D operator -(Circle3D circle, Vector3 vector) { Circle3D clone = CloneUtil.CloneDeep(circle); clone.AddWorldOffset(-vector); return(clone); }
/// <summary> /// 画圆 /// 默认Matrix4x4.identity是向上 /// </summary> /// <param name="position"></param> /// <param name="radius"></param> /// <param name="mutiplyMatrix"></param> /// <param name="color"></param> /// <param name="duration">持续时间</param> /// <param name="isDepthTest"></param> public static void DebugCircle(Vector3 position, float radius, Matrix4x4 mutiplyMatrix, Color color, float duration = 0, bool isDepthTest = true) { if (!Is_Debug_Enable) { return; } var circle = new Circle3D(position, radius, mutiplyMatrix); circle.GetDrawLineList().ForEach(kv => { DebugLine(kv.Key, kv.Value, color, duration, isDepthTest); }); }
/// <summary> /// 画圆 /// 默认Matrix4x4.identity是向上 /// </summary> /// <param name="position"></param> /// <param name="radius"></param> /// <param name="mutiplyMatrix"></param> /// <param name="color"></param> public static void HandlesCircle(Vector3 position, float radius, Matrix4x4 mutiplyMatrix, Color color) { if (!Is_Handles_Enable) { return; } using (new HandlesColorScope(color)) { var circle = new Circle3D(position, radius, mutiplyMatrix); circle.GetDrawLineList().ForEach(kv => { HandlesLine(kv.Key, kv.Value, color); }); } }
public override List <KeyValuePair <Vector3, Vector3> > GetDrawLineList() { List <KeyValuePair <Vector3, Vector3> > result = new List <KeyValuePair <Vector3, Vector3> >(); result.AddRange(new Circle3D(worldOffset, radius).MultiplyMatrix(matrix) .MultiplyMatrix(Matrix4x4.Rotate(Quaternion.Euler(90, 0, 0))).GetDrawLineList()); result.AddRange(new Circle3D(worldOffset, radius).MultiplyMatrix(matrix) .MultiplyMatrix(Matrix4x4.Rotate(Quaternion.Euler(0, 90, 0))).GetDrawLineList()); result.AddRange(new Circle3D(worldOffset, radius).MultiplyMatrix(matrix) .MultiplyMatrix(Matrix4x4.Rotate(Quaternion.Euler(0, 0, 90))).GetDrawLineList()); float eachDegree = 4; int segmentNum = (int)Mathf.Ceil(360 / eachDegree); for (int i = 0; i <= segmentNum; i++) { Circle3D circle = (Circle3D)(new Circle3D(worldOffset, radius).MultiplyMatrix(matrix) .MultiplyMatrix(Matrix4x4.Rotate(Quaternion.Euler(0, 0, i * eachDegree)))); result.AddRange(circle.GetDrawLineList()); } return(result); }