Package edu.cnu.mdi.mdi3D.item3D
Class LabelSet3D
java.lang.Object
edu.cnu.mdi.mdi3D.item3D.Item3D
edu.cnu.mdi.mdi3D.item3D.LabelSet3D
Draws screen-space text labels for a set of 3D points.
This item projects each 3D point into window coordinates using
Panel3D.project(GL2, float, float, float, float[]) and then renders
the corresponding label in pixel coordinates via JOGL's TextRenderer.
This keeps label size constant regardless of zoom and avoids any need for 3D
text geometry. Label visibility policy (e.g., globe front-hemisphere) is
optional and controlled by a pluggable LabelSet3D.LabelCull.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface for optional per-label visibility tests. -
Field Summary
Fields inherited from class edu.cnu.mdi.mdi3D.item3D.Item3D
_panel3D, FILLALPHA, FILLCOLOR, FONT, LINE_WIDTH, LINEALPHA, LINECOLOR, TEXT_COLOR -
Constructor Summary
ConstructorsConstructorDescriptionLabelSet3D(Panel3D panel3D, float[] coords, String[] labels) Create a label set for 3D points. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddispose(com.jogamp.opengl.GLAutoDrawable drawable) Releases the lazily-createdTextRendererand its GPU texture atlas.voiddraw(com.jogamp.opengl.GLAutoDrawable drawable) The custom drawing methodstatic LabelSet3D.LabelCullfrontHemisphereCull(float cx, float cy, float cz) Returns a culling policy that keeps labels on the visible hemisphere of a sphere.voidsetClipToViewport(boolean clip) If enabled, labels must project into the viewport and have depth in [0,1].voidsetCoords(float[] coords) Update coordinates (e.g., if points move).voidsetCull(LabelSet3D.LabelCull cull) Install (or clear) an optional culling strategy.voidUpdate labels.voidsetPixelOffset(int dx, int dy) Set pixel offsets applied to each label after projecting.Methods inherited from class edu.cnu.mdi.mdi3D.item3D.Item3D
addChild, defaultProperties, disposeItem, drawItem, get, getChildren, getColor, getFillAlpha, getFillColor, getFloat, getFont, getFont, getInt, getLineAlpha, getLineColor, getLineWidth, getPanel3D, getParent, getSortPoint, getString, getTextColor, isVisible, put, removeChild, setAlphaOfColor, setFillAlpha, setFillColor, setFont, setLineAlpha, setLineColor, setLineWidth, setTextColor, setVisible
-
Constructor Details
-
LabelSet3D
Create a label set for 3D points.- Parameters:
panel3D- owner panelcoords- point coords as [x1,y1,z1,...]labels- per-point labels (same count as points)
-
-
Method Details
-
setCull
Install (or clear) an optional culling strategy.- Parameters:
cull- strategy, or null to disable extra culling
-
setPixelOffset
public void setPixelOffset(int dx, int dy) Set pixel offsets applied to each label after projecting.- Parameters:
dx- pixels rightdy- pixels up
-
setClipToViewport
public void setClipToViewport(boolean clip) If enabled, labels must project into the viewport and have depth in [0,1].- Parameters:
clip- true to clip labels to viewport
-
setCoords
public void setCoords(float[] coords) Update coordinates (e.g., if points move).- Parameters:
coords- [x1,y1,z1,...]
-
setLabels
Update labels.- Parameters:
labels- per-point labels
-
dispose
protected void dispose(com.jogamp.opengl.GLAutoDrawable drawable) Releases the lazily-createdTextRendererand its GPU texture atlas. -
draw
public void draw(com.jogamp.opengl.GLAutoDrawable drawable) Description copied from class:Item3DThe custom drawing method -
frontHemisphereCull
Returns a culling policy that keeps labels on the visible hemisphere of a sphere.This is a geometric hemisphere test for a sphere whose center is given in world coordinates. It does not require the sphere to be centered at (0,0,0).
Implementation details:
- Transforms the sphere center C and the point P into eye space using the provided modelview.
- Computes N = P - C (outward normal direction).
- Computes V = -C (vector from center to camera at origin in eye space).
- Accepts if N ยท V > 0.
- Parameters:
cx- sphere center world xcy- sphere center world ycz- sphere center world z- Returns:
- a culling strategy for the front hemisphere of that sphere
-