Package edu.cnu.mdi.mdi3D.item3D
Class PolyLine3D
java.lang.Object
edu.cnu.mdi.mdi3D.item3D.Item3D
edu.cnu.mdi.mdi3D.item3D.PolyLine3D
- Direct Known Subclasses:
Trajectory3D
A 3D polyline item represented by an ordered list of vertices.
The coordinates are stored in the form:
[x1, y1, z1, x2, y2, z2, ..., xn, yn, zn]Consecutive points are connected by straight line segments, producing a single open polyline. This item is useful for drawing trajectories, orbit paths, field lines, and other connected 3D curves.
At least two points are required for visible output.
-
Field Summary
Fields inherited from class edu.cnu.mdi.mdi3D.item3D.Item3D
_panel3D, FILLALPHA, FILLCOLOR, FONT, LINE_WIDTH, LINEALPHA, LINECOLOR, TEXT_COLOR -
Constructor Summary
ConstructorsConstructorDescriptionPolyLine3D(Panel3D panel3D, float[] coords, Color color, float lineWidth) Creates a 3D polyline from an array of coordinates. -
Method Summary
Modifier and TypeMethodDescriptionvoiddraw(com.jogamp.opengl.GLAutoDrawable drawable) Draws the polyline.float[]Gets the centroid of the live polyline vertices.float[]Gets the current coordinate buffer.intReturns the number of live points currently held by this polyline.float[]Gets a representative point used for item sorting.voidsetCoords(float[] coords) Replaces the coordinates of this polyline.voidsetCoords(float[] buf, int livePoints) Points this polyline at a (possibly oversized) buffer, treating only the firstlivePointsentries as valid data.Methods inherited from class edu.cnu.mdi.mdi3D.item3D.Item3D
addChild, defaultProperties, dispose, disposeItem, drawItem, get, getChildren, getColor, getFillAlpha, getFillColor, getFloat, getFont, getFont, getInt, getLineAlpha, getLineColor, getLineWidth, getPanel3D, getParent, getString, getTextColor, isVisible, put, removeChild, setAlphaOfColor, setFillAlpha, setFillColor, setFont, setLineAlpha, setLineColor, setLineWidth, setTextColor, setVisible
-
Constructor Details
-
PolyLine3D
Creates a 3D polyline from an array of coordinates.- Parameters:
panel3D- the owning 3D panelcoords- the polyline coordinates as[x1, y1, z1, ..., xn, yn, zn]color- the line colorlineWidth- the line width
-
-
Method Details
-
draw
public void draw(com.jogamp.opengl.GLAutoDrawable drawable) Draws the polyline.If there are fewer than two live points, nothing is drawn.
-
setCoords
public void setCoords(float[] coords) Replaces the coordinates of this polyline.The entire array is treated as live data;
_livePointsis set tocoords.length / 3. Passnullor an empty array to produce no output.- Parameters:
coords- the new coordinates as[x1, y1, z1, ..., xn, yn, zn], ornullto clear
-
setCoords
public void setCoords(float[] buf, int livePoints) Points this polyline at a (possibly oversized) buffer, treating only the firstlivePointsentries as valid data.No copy is made. The caller must not modify indices at or beyond
3 * livePointswhile a draw is in progress.Trajectory3Dsatisfies this by writing new data only after advancing_pointCount.- Parameters:
buf- the coordinate buffer; must have length ≥3 * livePointslivePoints- number of valid points inbuf; must be ≥ 0- Throws:
IllegalArgumentException- iflivePointsis negative or the buffer is too small
-
getCoords
public float[] getCoords()Gets the current coordinate buffer.The buffer may be larger than the live data; use
getLivePoints()to determine how many points are valid.- Returns:
- the coordinate buffer, or
nullif none has been set
-
getLivePoints
public int getLivePoints()Returns the number of live points currently held by this polyline.- Returns:
- number of valid points in the coordinate buffer
-
getCentroid
public float[] getCentroid()Gets the centroid of the live polyline vertices.This is used as a representative point for sorting.
- Returns:
- the centroid of the live vertices, or the origin if there are none
-
getSortPoint
public float[] getSortPoint()Gets a representative point used for item sorting.- Overrides:
getSortPointin classItem3D- Returns:
- the centroid of the live polyline vertices
-