Class LineTracer3D
There is no true 3d line plotting primitive available for a CubeSurface, so we have to do it by hand. To get the Z-stacking right it is necessary to plot non-tiny lines using a number of pixels or segments, each placed at the relevant Z coordinate (depth). This is not done very accurately, but it's hopefully good enough to look OK. It may also not be very efficient if there are lots of long lines criss-crossing the visible cube, but in that case even if it was done fast it would almost certainly be impossible to see anything useful.
Line segments may still be visible if the points they join are outside the visible cube. In general therefore non-visible points should still be submitted to this tracer for drawing. The code attempts to deal with them efficiently, avoiding painting where it is not required, and coping with points that are far from the visible region.
- Since:
- 19 Jul 2018
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
LineTracer3D
(PaperType3D paperType, Paper paper, CubeSurface surf) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Submits a point for drawing.static LineTracer3D
createTracer
(PaperType3D paperType, Paper paper, CubeSurface surf, int thickness, int pixgap) Creates a line tracer from a given line thickness and pixel gap.static LineTracer3D
createTracer
(PaperType3D paperType, Paper paper, CubeSurface surf, Stroke stroke) Creats a line segment tracer from a given stroke.
-
Constructor Details
-
LineTracer3D
Constructor.- Parameters:
paperType
- paper typepaper
- papersurf
- target surface
-
-
Method Details
-
addPoint
Submits a point for drawing. Except for the first invocation, this will notionally result in drawing a line segment to the previous point.- Parameters:
dpos
- 3-element array giving the vertex position in data coordinatescolor
- colour of line segment
-
createTracer
public static LineTracer3D createTracer(PaperType3D paperType, Paper paper, CubeSurface surf, Stroke stroke) Creats a line segment tracer from a given stroke.- Parameters:
paperType
- paper typepaper
- papersurf
- target surfacestroke
- line stroke - probably only line width is honoured- Returns:
- new tracer
-
createTracer
public static LineTracer3D createTracer(PaperType3D paperType, Paper paper, CubeSurface surf, int thickness, int pixgap) Creates a line tracer from a given line thickness and pixel gap. If pixgap is non-zero, a tracer that draws points rather than line segments is returned. At present, the points are not very cleverly separated, so it doesn't look that good.- Parameters:
paperType
- paper typepaper
- papersurf
- target surfacethickness
- line thickness/marker size (minimum 1)pixgap
- nominal gap in pixels between markers- Returns:
- new tracer
-