private DebugScopeCode(DebugStyle setup) : base() #endif { this.setup = setup; #if ACTIVE_CODE ScopeRegistry.Add(this); #endif }
public static void Arrow(DebugPlace place, DebugStyle setup) { var prim = new DebugPrimitiveSetup(DebugPrimitiveType.Arrow, setup); prim.pos = place.Start; prim.rot = place.Rotation; prim.extents = vec3(place.Extents.x, place.Extents.y, place.Size.z); DebugDisplayRegistry.Add(prim); }
public static void Point(DebugPlace place, DebugStyle setup) { var prim = new DebugPrimitiveSetup(DebugPrimitiveType.Point, setup); prim.pos = place.Position; prim.rot = Quaternion.identity; prim.extents = place.Extents; DebugDisplayRegistry.Add(prim); }
public static void Box(DebugPlace place, DebugStyle setup) { var prim = new DebugPrimitiveSetup(DebugPrimitiveType.Box, setup); prim.pos = place.Position; prim.rot = place.Rotation; prim.extents = place.Extents; DebugDisplayRegistry.Add(prim); }
public static DebugScopeCode Open(DebugStyle setup) #endif { #if PRATEEK_DEBUG && ACTIVE_CODE return(new DebugScope(setup)); #else return(null); #endif }
public static void Line(DebugPlace place, DebugStyle setup) { var prim = new DebugPrimitiveSetup(DebugPrimitiveType.Line, setup); prim.pos = place.Start; prim.rot = place.Rotation; prim.extents = place.Size; DebugDisplayRegistry.Add(prim); }
///--------------------------------------------------------------------- //Point: Three line to mark each axis private static void Line(Vector3 start, Vector3 end, DebugStyle setup) { var dir = end - start; var prim = new DebugPrimitiveSetup(DebugPrimitiveType.Line, setup); prim.pos = start; prim.rot = Quaternion.LookRotation(dir.normalized); prim.extents = vec3(0, 0, dir.magnitude); DebugDisplayRegistry.Add(prim); }
public static void SphereCast(Ray ray, float radius, float distance, DebugStyle setup) { var place = DebugPlace.AToB(ray.origin, ray.origin + ray.direction * distance); var prim = new DebugPrimitiveSetup(DebugPrimitiveType.SphereCast, setup); prim.pos = place.Position; prim.rot = place.Rotation; prim.extents = vec3(radius, radius, place.Extents.z); DebugDisplayRegistry.Add(prim); }
///----------------------------------------------------------------- public DebugPrimitiveSetup(DebugPrimitiveType type, DebugStyle setup) { this.type = type; this.setup = setup; endDebugSpace = DebugSpace.World; pos = Vector3.zero; rot = Quaternion.identity; extents = Vector3.one; range = Statics.vec2(0, 1); }
public static void Pie(DebugPlace place, Vector2 degrees, DebugStyle setup) { var prim = new DebugPrimitiveSetup(DebugPrimitiveType.Pie, setup); prim.pos = place.Position; prim.rot = place.Rotation; prim.extents = place.Extents; prim.range = degrees; DebugDisplayRegistry.Add(prim); }
public static void LineCastList(Ray[] rays, float radius, float distance, DebugStyle setup, bool doLoop = false) { for (int h = 0; h < rays.Length; h++) { LineCast(rays[h], radius, distance, setup); if (doLoop || h < rays.Length - 1) { var h1 = (h + 1) % rays.Length; Line(DebugPlace.AToB(rays[h].origin + rays[h].direction * distance, rays[h1].origin + rays[h1].direction * distance), setup); } } }
///--------------------------------------------------------------------- public void RenderLine(DebugStyle setup, Vector3 start, Vector3 end) { //todo var manager = TickableRegistry.GetManager<DebugDisplayManager>(); //if (manager != null) //{ // if (!manager.IsActive(setup.Flag)) // return; //} //var line = GetLine(setup.DepthTest); //line.SetLine(start, end); //line.SetColor(setup.Color, setup.Color); }
private static Bitmap GenerateBitmap(DiagramArguments arguments, ISequenceDiagram sequenceDiagram) { IStyle style; switch (arguments.Style) { case DiagramStyle.Sketchy: style = new SketchyStyle(); break; case DiagramStyle.Classic: style = new ClassicStyle(); break; default: throw new ArgumentOutOfRangeException("style"); } if (arguments.Debug) { style = new DebugStyle(style); } var sequenceDiagramVisual = new SequenceDiagramVisual(style, sequenceDiagram); using (var measureBitmap = new Bitmap(1, 1)) using (var measureGraphics = System.Drawing.Graphics.FromImage(measureBitmap)) { var graphicContext = new GdiPlusGraphicContext(measureGraphics); sequenceDiagramVisual.Layout(graphicContext); var renderBitmap = new Bitmap( (int)Math.Ceiling(sequenceDiagramVisual.Width + 1), (int)Math.Ceiling(sequenceDiagramVisual.Height + 1)); using (var renderGraphics = System.Drawing.Graphics.FromImage(renderBitmap)) { renderGraphics.Clear(Color.White); renderGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; renderGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; renderGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graphicContext = new GdiPlusGraphicContext(renderGraphics); sequenceDiagramVisual.Draw(graphicContext); } return(renderBitmap); } }
public static void Light(Light light, DebugStyle setup) { var tr = light.transform; if (light.type == LightType.Point) { Sphere(DebugPlace.At(tr.position, tr.rotation, light.range), setup); } else if (light.type == LightType.Spot) { var t = Mathf.Tan(light.spotAngle) * light.range; Cone(DebugPlace.AToB(tr.position, tr.rotation * vec3(0, 0, light.range), vec3(t, t, 0), tr.rotation * Vector3.up), setup); } }
public static void Plane(Plane plane, DebugPlace place, DebugStyle setup) { var q = place.Rotation; var x = place.Right; var y = place.Up; var p = (plane.normal * -plane.distance) + (x * place.Position.x) + (y * place.Position.y); var prim = new DebugPrimitiveSetup(DebugPrimitiveType.Plane, setup); prim.pos = p; prim.rot = q; prim.extents = place.Size; DebugDisplayRegistry.Add(prim); Arrow(place, setup); }
public static void Box(Vector3[] points, DebugStyle setup) { if (points.Length != 8) { return; } Line(points[0], points[1], setup); Line(points[1], points[2], setup); Line(points[2], points[3], setup); Line(points[3], points[0], setup); Line(points[4], points[5], setup); Line(points[5], points[6], setup); Line(points[6], points[7], setup); Line(points[7], points[4], setup); Line(points[0], points[7], setup); Line(points[1], points[6], setup); Line(points[2], points[5], setup); Line(points[3], points[4], setup); }
public static void SphereCast(RaycastHit hit, Ray ray, float radius, float distance, DebugStyle setup) { { var prim = new DebugPrimitiveSetup(DebugPrimitiveType.Point, setup); prim.pos = hit.point; prim.rot = Quaternion.LookRotation(hit.normal); prim.extents = vec3(radius * 0.4f); DebugDisplayRegistry.Add(prim); } var place0 = DebugPlace.AToB(ray.origin, ray.origin + ray.direction * (hit.distance + radius)); { var prim = new DebugPrimitiveSetup(DebugPrimitiveType.SphereCast, setup); prim.pos = place0.Position; prim.rot = place0.Rotation; prim.extents = vec3(radius, radius, place0.Extents.z); DebugDisplayRegistry.Add(prim); } var place1 = DebugPlace.AToB(place0.End - ray.direction * radius * 1.9f, ray.origin + ray.direction * distance); { setup.Color = Color.grey; var prim = new DebugPrimitiveSetup(DebugPrimitiveType.SphereCast, setup); prim.pos = place1.Position; prim.rot = place1.Rotation; prim.extents = vec3(radius * 0.9f, radius * 0.9f, place1.Extents.z); DebugDisplayRegistry.Add(prim); } }
public static DebugScope Open(DebugStyle setup)
///----------------------------------------------------------------- #region Scope #if ACTIVE_CODE private DebugScope(DebugStyle setup) : base()
public static void LineCastList(RaycastHit[] hits, Ray[] rays, float radius, float distance, DebugStyle setup, bool doLoop = false) { bool hasHit = false; for (int h = 0; h < hits.Length; h++) { if (hits[h].transform != null) { hasHit = true; break; } } if (!hasHit) { LineCastList(rays, radius, distance, setup, doLoop); return; } var greySetup = setup; greySetup.Color = Color.grey; for (int h = 0; h < hits.Length; h++) { LineCast(hits[h], rays[h], radius, distance, setup); if (doLoop || h < hits.Length - 1) { var h1 = (h + 1) % hits.Length; var d0 = hits[h].transform != null ? hits[h].distance : distance; var d1 = hits[h1].transform != null ? hits[h1].distance : distance; Line(DebugPlace.AToB(rays[h].origin + rays[h].direction * d0, rays[h1].origin + rays[h1].direction * d1), setup); if (hits[h].transform != null || hits[h1].transform != null) { Line(DebugPlace.AToB(rays[h].origin + rays[h].direction * distance, rays[h1].origin + rays[h1].direction * distance), greySetup); } } } }
public static void LineCast(RaycastHit hit, Ray ray, float radius, float distance, DebugStyle setup) { if (hit.transform == null) { LineCast(ray, radius, distance, setup); return; } { var prim = new DebugPrimitiveSetup(DebugPrimitiveType.Point, setup); prim.pos = hit.point; prim.rot = Quaternion.LookRotation(hit.normal); prim.extents = vec3(radius * 2); DebugDisplayRegistry.Add(prim); } var place0 = DebugPlace.AToB(ray.origin, ray.origin + ray.direction * hit.distance); { var prim = new DebugPrimitiveSetup(DebugPrimitiveType.LineCast, setup); prim.pos = place0.Position; prim.rot = place0.Rotation; prim.extents = vec3(radius, radius, place0.Extents.z); DebugDisplayRegistry.Add(prim); } var place1 = DebugPlace.AToB(place0.End, ray.origin + ray.direction * distance); { setup.Color = Color.grey; var prim = new DebugPrimitiveSetup(DebugPrimitiveType.LineCast, setup); prim.pos = place1.Position; prim.rot = place1.Rotation; prim.extents = vec3(radius * 0.9f, radius * 0.9f, place1.Extents.z); DebugDisplayRegistry.Add(prim); } }