Class Support3D
All methods are static and accept a GLAutoDrawable (or a
raw GL2 context for lower-level helpers) plus the geometry and colour
parameters needed to produce output. No instance is required.
Coordinate conventions
All geometry is expressed in the caller's current model-view coordinate system. Packed coordinate arrays always follow the layout:
[x₀, y₀, z₀, x₁, y₁, z₁, ...]so every three consecutive floats describe one point and
coords.length / 3 gives the point count.
Colour and alpha
Every drawing method accepts Color values whose alpha
component is honoured: a fully-opaque colour has alpha 255 and a fully
transparent colour has alpha 0. Pass null where a colour is
documented as optional to suppress that drawing pass.
Line width
Methods that accept a lineWidth parameter set glLineWidth
before drawing and restore it to 1f afterwards. The caller's current
line width is therefore clobbered; this is consistent with the rest of the
framework.
Thread safety
All methods must be called from the JOGL GL thread (typically inside a
GLEventListener callback). The shared
glut field and the internal GLU / GLUquadric
singletons are not thread-safe; do not call these methods concurrently from
multiple GL contexts.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic com.jogamp.opengl.util.gl2.GLUTShared GLUT utility instance used for stroke fonts, solid/wire primitives, and other GLUT geometry helpers. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddrawCone(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float x2, float y2, float z2, float radius, Color color) Draws a solid cone with its base centred at(x1, y1, z1)and its tip at(x2, y2, z2).static voiddrawLine(com.jogamp.opengl.GLAutoDrawable drawable, double x1, double y1, double z1, double x2, double y2, double z2, Color color, float lineWidth) Draws a line segment between two explicit double endpoints.static voiddrawLine(com.jogamp.opengl.GLAutoDrawable drawable, float[] p0, float[] p1, Color color, float lineWidth) Draws a line segment between two endpoints supplied asfloat[3]arrays.static voidDraws a line segment from a packed six-element coordinate array.static voiddrawLine(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float ux, float uy, float uz, float length, Color color, float lineWidth) Draws a line segment from a start point along a unit-vector direction for a given length.static voiddrawLine(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float x2, float y2, float z2, Color color, float lineWidth) Draws a line segment between two explicit float endpoints.static voiddrawLine(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float x2, float y2, float z2, Color color1, Color color2, float lineWidth) Draws a line segment rendered in two alternating stipple colours.static voiddrawMarker(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, Color markerColor, float markerSize, boolean circular, String label, float fontSize, Color fontColor) Draws a labelled marker: a point accompanied by a text label rendered in screen space below it.static voiddrawPoint(com.jogamp.opengl.GLAutoDrawable drawable, double x, double y, double z, Color color, float size, boolean circular) Draws a single point at double-precision coordinates.static voiddrawPoint(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, Color color, float size) Draws a single point rendered as a point sprite.static voiddrawPoint(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, Color color, float size, boolean circular) Draws a single point at float coordinates.static voiddrawPoints(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, float size, boolean circular) Draws a set of points from a packed coordinate array.static voiddrawPoints(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color fill, Color frame, float size, boolean circular) Draws a set of points with an optional contrasting frame ring.static voiddrawPolyLine(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, int livePoints, Color color, float lineWidth) Draws an open polyline using only the firstlivePointsvertices of a (possibly oversized) coordinate buffer.static voiddrawPolyLine(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, float lineWidth) Draws an open polyline connecting all vertices in a packed coordinate array.static voiddrawPolyLine(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color1, Color color2, float lineWidth) Draws an open polyline rendered in two alternating stipple colours.static voiddrawQuad(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, int index1, int index2, int index3, int index4, Color color, float lineWidth, boolean frame) Draws a single quad addressed by four vertex indices into a shared coordinate array, with an optional frame in a darker shade.static voiddrawQuads(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, float lineWidth, boolean frame) Draws a batch of quads from a packed coordinate array, with an optional frame drawn in a darker shade of the fill colour.static voiddrawQuads(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, Color lineColor, float lineWidth) Draws a batch of quads from a packed coordinate array with an independent frame colour.static voiddrawRectangularSolid(com.jogamp.opengl.GLAutoDrawable drawable, float xc, float yc, float zc, float xw, float yw, float zw, Color fc, float lineWidth, boolean frame) Draws a solid axis-aligned rectangular box centred at(xc, yc, zc)with a frame in a darker shade of the fill colour.static voiddrawRectangularSolid(com.jogamp.opengl.GLAutoDrawable drawable, float xc, float yc, float zc, float xw, float yw, float zw, Color fc, Color lc, float lineWidth, boolean frame) Draws a solid axis-aligned rectangular box centred at(xc, yc, zc)with an independent frame colour.static voiddrawShadedQuad(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color fillColor, Color lineColor, float lineWidth, boolean enableLighting) Draws a batch of quads from a packed coordinate array with optional Phong-style lighting.static voiddrawShadedRectangularSolid(com.jogamp.opengl.GLAutoDrawable drawable, float xc, float yc, float zc, float xw, float yw, float zw, Color fc, Color lc, float lineWidth, boolean frame, boolean enableLighting) Draws a solid axis-aligned rectangular box with optional Phong-style lighting.static voiddrawShadedTube(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float x2, float y2, float z2, float radius, Color color, boolean enableLighting) Draws an open-ended cylindrical tube between two points, with optional Phong-style lighting.static voiddrawSphericalPolygon(com.jogamp.opengl.GLAutoDrawable drawable, float radius, float[] coords, Color lineColor, Color fillColor, float lineWidth) Draws a filled and/or outlined spherical polygon defined by vertices in spherical coordinates.static voiddrawTriangle(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, int index1, int index2, int index3, Color color, float lineWidth, boolean frame) Draws a single triangle addressed by three vertex indices into a shared coordinate array, with an optional frame in a darker shade.static voiddrawTriangles(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, float lineWidth, boolean frame) Draws a batch of triangles from a packed coordinate array.static voiddrawTube(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float x2, float y2, float z2, float radius, Color color) Draws a solid cylindrical tube between two endpoints.static float[]oneToFourTriangle(float[] coords) Splits a triangle given as a self-contained 9-element array into four smaller triangles by connecting its three edge midpoints.static float[]oneToFourTriangle(float[] coords, int index) Splits one triangle — addressed by a triple index into a packed array — into four by connecting its three edge midpoints.static voidSets the current OpenGL drawing colour from an AWTColor.static voidsolidShadedSphere(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, float radius, int slices, int stacks, Color color, boolean enableLighting) Draws a solid sphere with optional Phong-style lighting.static voidsolidSphere(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, float radius, int slices, int stacks, Color color) Draws a solid (filled) sphere centred at(x, y, z).static voidsolidSphereShell(com.jogamp.opengl.GLAutoDrawable drawable, float cx, float cy, float cz, float innerRadius, float outerRadius, int slices, int stacks, Color color) Draws a solid spherical shell — a sphere with a hollow interior — by rendering an outer surface, an inner surface with inverted normals, and a connecting band of quads along each horizontal latitude strip.static float[]toArray(float... v) Convenience factory that converts a varargs list offloatvalues into afloat[].static float[]triangulateTriangle(float[] coords, int level) Subdivides a triangle into4^levelsmaller triangles by recursively connecting edge midpoints.static voidwireSphere(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, float radius, int slices, int stacks, Color color) Draws a wireframe sphere centred at(x, y, z).
-
Field Details
-
glut
public static com.jogamp.opengl.util.gl2.GLUT glutShared GLUT utility instance used for stroke fonts, solid/wire primitives, and other GLUT geometry helpers.This field is
publicso that callers can invoke GLUT methods not directly wrapped by this class (e.g.glut.glutBitmapCharacter(...)). It must only be used from the GL thread.
-
-
Constructor Details
-
Support3D
public Support3D()
-
-
Method Details
-
drawPoints
public static void drawPoints(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, float size, boolean circular) Draws a set of points from a packed coordinate array.All points are drawn with the same colour and pixel size. Pass
circular = trueto enableGL_POINT_SMOOTH, which asks the driver to rasterise each point as a circle rather than a square; support is driver-dependent.- Parameters:
drawable- the OpenGL drawablecoords- packed point coordinates as[x, y, z, x, y, z, ...];nullor empty arrays are silently ignoredcolor- the point coloursize- the point diameter in pixelscircular-trueto request round (smooth) points;falsefor square points
-
drawPoints
public static void drawPoints(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color fill, Color frame, float size, boolean circular) Draws a set of points with an optional contrasting frame ring.When
frameis non-null, each point is drawn twice: first at fullsizein the frame colour to create an outline, then atsize - 2pixels in the fill colour on top. Whenframeisnullthis is equivalent todrawPoints(GLAutoDrawable, float[], Color, float, boolean).- Parameters:
drawable- the OpenGL drawablecoords- packed point coordinates as[x, y, z, x, y, z, ...];nullor empty arrays are silently ignoredfill- the inner fill colourframe- the outer frame colour, ornullfor no framesize- the outer point diameter in pixels; the inner fill is drawn atsize - 2circular-trueto request round (smooth) points
-
drawPoint
public static void drawPoint(com.jogamp.opengl.GLAutoDrawable drawable, double x, double y, double z, Color color, float size, boolean circular) Draws a single point at double-precision coordinates.The coordinates are cast to
floatbefore submission to OpenGL.- Parameters:
drawable- the OpenGL drawablex- the x coordinatey- the y coordinatez- the z coordinatecolor- the point coloursize- the point diameter in pixelscircular-trueto request round (smooth) points
-
drawPoint
public static void drawPoint(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, Color color, float size, boolean circular) Draws a single point at float coordinates.- Parameters:
drawable- the OpenGL drawablex- the x coordinatey- the y coordinatez- the z coordinatecolor- the point coloursize- the point diameter in pixelscircular-trueto request round (smooth) points
-
drawMarker
public static void drawMarker(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, Color markerColor, float markerSize, boolean circular, String label, float fontSize, Color fontColor) Draws a labelled marker: a point accompanied by a text label rendered in screen space below it.The label is drawn using GLUT's
STROKE_ROMANvector font, projected into a temporary 2D orthographic overlay so its pixel size remains constant regardless of zoom. The text is centred horizontally on the marker's screen x and positionedmarkerSize/2 + 3pixels below its screen y.Note: depth testing is temporarily disabled while the label is drawn so that it is never occluded by scene geometry.
- Parameters:
drawable- the OpenGL drawablex- the x coordinate of the marker in world spacey- the y coordinate of the marker in world spacez- the z coordinate of the marker in world spacemarkerColor- the colour of the point marker (the point itself is not drawn by this method; pass todrawPoint(GLAutoDrawable, float, float, float, Color, float, boolean)separately if required)markerSize- the pixel diameter of the marker, used only for computing the label offsetcircular-trueto request round (smooth) point renderinglabel- the text string to display; must not benullfontSize- scaling factor applied to the GLUT stroke font; values around0.07f–0.15fproduce readable results in typical scenesfontColor- the colour of the rendered text
-
drawPoint
public static void drawPoint(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, Color color, float size) Draws a single point rendered as a point sprite.Point sprites (
GL_POINT_SPRITE) allow a texture to be mapped onto a point primitive. This overload enables the sprite state, draws the point, then leaves sprite state enabled for the caller to manage. If no texture is bound, the point will appear as a solid-coloured square.- Parameters:
drawable- the OpenGL drawablex- the x coordinatey- the y coordinatez- the z coordinatecolor- the point coloursize- the point sprite size in pixels
-
wireSphere
public static void wireSphere(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, float radius, int slices, int stacks, Color color) Draws a wireframe sphere centred at(x, y, z).The sphere is rendered using GLUT's
glutWireSphere, which approximates the surface with longitude/latitude line strips.- Parameters:
drawable- the OpenGL drawablex- x coordinate of the centrey- y coordinate of the centrez- z coordinate of the centreradius- radius in model-space unitsslices- number of subdivisions around the Z axis (longitude lines); higher values produce a smoother appearancestacks- number of subdivisions along the Z axis (latitude bands); higher values produce a smoother appearancecolor- the wire colour
-
solidSphere
public static void solidSphere(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, float radius, int slices, int stacks, Color color) Draws a solid (filled) sphere centred at(x, y, z).The sphere is rendered using GLUT's
glutSolidSpherewith flat shading and no lighting. For a shaded appearance seesolidShadedSphere(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, int, int, java.awt.Color, boolean).- Parameters:
drawable- the OpenGL drawablex- x coordinate of the centrey- y coordinate of the centrez- z coordinate of the centreradius- radius in model-space unitsslices- number of subdivisions around the Z axisstacks- number of subdivisions along the Z axiscolor- the fill colour
-
solidShadedSphere
public static void solidShadedSphere(com.jogamp.opengl.GLAutoDrawable drawable, float x, float y, float z, float radius, int slices, int stacks, Color color, boolean enableLighting) Draws a solid sphere with optional Phong-style lighting.When
enableLightingistrue,GL_LIGHT0is configured as a directional light at(1, 1, 1)with white diffuse and specular components, and a material with shininess 50 is applied. The lighting and material state are restored (lighting disabled) after drawing. WhenenableLightingisfalsethe sphere is drawn with flat colour, identical tosolidSphere(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, int, int, java.awt.Color).- Parameters:
drawable- the OpenGL drawablex- x coordinate of the centrey- y coordinate of the centrez- z coordinate of the centreradius- radius in model-space unitsslices- number of subdivisions around the Z axisstacks- number of subdivisions along the Z axiscolor- the sphere colour; also used as the material diffuse colour when lighting is enabledenableLighting-trueto enable a directional GL_LIGHT0 and Phong materials;falsefor flat colour
-
solidSphereShell
public static void solidSphereShell(com.jogamp.opengl.GLAutoDrawable drawable, float cx, float cy, float cz, float innerRadius, float outerRadius, int slices, int stacks, Color color) Draws a solid spherical shell — a sphere with a hollow interior — by rendering an outer surface, an inner surface with inverted normals, and a connecting band of quads along each horizontal latitude strip.- Parameters:
drawable- the OpenGL drawablecx- x coordinate of the centrecy- y coordinate of the centrecz- z coordinate of the centreinnerRadius- the radius of the hollow interior; must be less thanouterRadiusouterRadius- the outer surface radiusslices- number of subdivisions around the Z axis (longitude); higher values give a smoother silhouettestacks- number of subdivisions along the Z axis (latitude); higher values give a smoother silhouettecolor- the shell colour
-
drawRectangularSolid
public static void drawRectangularSolid(com.jogamp.opengl.GLAutoDrawable drawable, float xc, float yc, float zc, float xw, float yw, float zw, Color fc, float lineWidth, boolean frame) Draws a solid axis-aligned rectangular box centred at(xc, yc, zc)with a frame in a darker shade of the fill colour.Equivalent to calling
drawRectangularSolid(GLAutoDrawable, float, float, float, float, float, float, Color, Color, float, boolean)withlc = null(the frame colour defaults tofc.darker()).- Parameters:
drawable- the OpenGL drawablexc- x coordinate of the box centreyc- y coordinate of the box centrezc- z coordinate of the box centrexw- total width along the X axisyw- total width along the Y axiszw- total width along the Z axisfc- the fill colour for all six faceslineWidth- the frame line width in pixelsframe-trueto draw a wireframe outline over the filled faces
-
drawRectangularSolid
public static void drawRectangularSolid(com.jogamp.opengl.GLAutoDrawable drawable, float xc, float yc, float zc, float xw, float yw, float zw, Color fc, Color lc, float lineWidth, boolean frame) Draws a solid axis-aligned rectangular box centred at(xc, yc, zc)with an independent frame colour.All six faces are filled with
fc. Whenframeistruea wireframe outline is superimposed usinglc; iflcisnullthe frame is drawn infc.darker().- Parameters:
drawable- the OpenGL drawablexc- x coordinate of the box centreyc- y coordinate of the box centrezc- z coordinate of the box centrexw- total width along the X axisyw- total width along the Y axiszw- total width along the Z axisfc- the fill colour for all six faceslc- the frame (outline) colour, ornullto usefc.darker()lineWidth- the frame line width in pixelsframe-trueto draw a wireframe outline over the filled faces
-
drawShadedRectangularSolid
public static void drawShadedRectangularSolid(com.jogamp.opengl.GLAutoDrawable drawable, float xc, float yc, float zc, float xw, float yw, float zw, Color fc, Color lc, float lineWidth, boolean frame, boolean enableLighting) Draws a solid axis-aligned rectangular box with optional Phong-style lighting.When
enableLightingistrue,GL_LIGHT0is configured the same way as insolidShadedSphere(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, int, int, java.awt.Color, boolean): a directional light at(1, 1, 1)with white diffuse/specular components, and a material with shininess 50. Each of the six faces is submitted with its own axis-aligned face normal (viaglNormal3f) so the fixed-function lighting pipeline shades each face independently as the box rotates. The lighting and material state are restored (lighting disabled) after drawing. WhenenableLightingisfalse, the box is drawn with flat colour, identical todrawRectangularSolid(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, float, float, java.awt.Color, float, boolean).- Parameters:
drawable- the OpenGL drawablexc- x coordinate of the box centreyc- y coordinate of the box centrezc- z coordinate of the box centrexw- total width along the X axisyw- total width along the Y axiszw- total width along the Z axisfc- the fill colour for all six faces; also used as the material diffuse colour when lighting is enabledlc- the frame (outline) colour, ornullto usefc.darker()lineWidth- the frame line width in pixelsframe-trueto draw a wireframe outline over the filled facesenableLighting-trueto enable a directional GL_LIGHT0 and Phong materials;falsefor flat colour
-
drawQuads
public static void drawQuads(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, float lineWidth, boolean frame) Draws a batch of quads from a packed coordinate array, with an optional frame drawn in a darker shade of the fill colour.Equivalent to
drawQuads(GLAutoDrawable, float[], Color, Color, float)withlineColor = frame ? color.darker() : null.- Parameters:
drawable- the OpenGL drawablecoords- packed quad vertices as[x, y, z, ...]; every 12 floats (4 vertices × 3 coordinates) describe one quadcolor- the fill colourlineWidth- the frame line width in pixelsframe-trueto draw a wireframe outline around each quad
-
drawQuads
public static void drawQuads(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, Color lineColor, float lineWidth) Draws a batch of quads from a packed coordinate array with an independent frame colour.All vertices in
coordsare submitted as a singleGL_QUADSprimitive. WhenlineColoris non-null, each group of four vertices is additionally drawn as a closedGL_LINE_STRIPto produce a per-quad outline.- Parameters:
drawable- the OpenGL drawablecoords- packed quad vertices as[x, y, z, ...]; every 12 floats describe one quadcolor- the fill colourlineColor- the frame colour, ornullfor no framelineWidth- the frame line width in pixels
-
drawShadedQuad
public static void drawShadedQuad(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color fillColor, Color lineColor, float lineWidth, boolean enableLighting) Draws a batch of quads from a packed coordinate array with optional Phong-style lighting.Each group of four vertices (one quad) is submitted as its own
GL_QUADScall with a single face normal computed via the cross product of its first two edges, so flat quads at arbitrary orientations — not just axis-aligned ones — shade correctly as the scene rotates. This is the batch counterpart todrawRectangularSolid(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, float, float, java.awt.Color, float, boolean)'s per-face normals, generalized to a quad of any orientation.When
enableLightingistrue, lighting is set up exactly as insolidShadedSphere(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, int, int, java.awt.Color, boolean). Whenfalse, this behaves likedrawQuads(GLAutoDrawable, float[], Color, Color, float).- Parameters:
drawable- the OpenGL drawablecoords- packed quad vertices as[x, y, z, ...]; every 12 floats describe one quadfillColor- the fill colour; also used as the material diffuse colour when lighting is enabledlineColor- the frame (outline) colour, ornullfor no framelineWidth- the frame line width in pixelsenableLighting-trueto enable a directional GL_LIGHT0 and Phong materials;falsefor flat colour
-
drawQuad
public static void drawQuad(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, int index1, int index2, int index3, int index4, Color color, float lineWidth, boolean frame) Draws a single quad addressed by four vertex indices into a shared coordinate array, with an optional frame in a darker shade.The indices are "triple indices": index
krefers to the point atcoords[3k], coords[3k+1], coords[3k+2].- Parameters:
drawable- the OpenGL drawablecoords- the shared coordinate pool as[x, y, z, ...]index1- triple index of the first vertexindex2- triple index of the second vertexindex3- triple index of the third vertexindex4- triple index of the fourth vertexcolor- the fill colourlineWidth- the frame line width in pixelsframe-trueto outline the quad incolor.darker()
-
drawTriangles
public static void drawTriangles(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, float lineWidth, boolean frame) Draws a batch of triangles from a packed coordinate array.Every 9 floats in
coordsdescribe one triangle ([x1,y1,z1, x2,y2,z2, x3,y3,z3]). Each triangle is drawn by delegating todrawTriangle(GLAutoDrawable, float[], int, int, int, Color, float, boolean).- Parameters:
drawable- the OpenGL drawablecoords- packed triangle vertices as[x, y, z, ...]; length must be a multiple of 9color- the fill colourlineWidth- the frame line width in pixelsframe-trueto outline each triangle incolor.darker()
-
drawTriangle
public static void drawTriangle(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, int index1, int index2, int index3, Color color, float lineWidth, boolean frame) Draws a single triangle addressed by three vertex indices into a shared coordinate array, with an optional frame in a darker shade.The indices are "triple indices": index
krefers to the point atcoords[3k], coords[3k+1], coords[3k+2].- Parameters:
drawable- the OpenGL drawablecoords- the shared coordinate pool as[x, y, z, ...]index1- triple index of the first vertexindex2- triple index of the second vertexindex3- triple index of the third vertexcolor- the fill colourlineWidth- the frame line width in pixelsframe-trueto outline the triangle incolor.darker()
-
triangulateTriangle
public static float[] triangulateTriangle(float[] coords, int level) Subdivides a triangle into4^levelsmaller triangles by recursively connecting edge midpoints.At
level = 1the input triangle is split into 4. Atlevel = 2each of those 4 is split again, yielding 16, and so on. The resulting triangles lie in the same plane as the original (no projection onto a sphere is applied); for spherical subdivision, normalise the vertices after calling this method.- Parameters:
coords- the input triangle as[x1, y1, z1, x2, y2, z2, x3, y3, z3]level- subdivision depth; values less than 1 returncoordsunchanged; each level multiplies the triangle count by 4- Returns:
- a packed coordinate array containing all output triangles in the
same
[x, y, z, ...]layout; length is9 * 4^max(level,0)
-
oneToFourTriangle
public static float[] oneToFourTriangle(float[] coords, int index) Splits one triangle — addressed by a triple index into a packed array — into four by connecting its three edge midpoints.The result is returned as a new packed array of 36 floats (4 triangles × 3 vertices × 3 coordinates). The winding order of the four output triangles matches the winding order of the input.
- Parameters:
coords- the packed coordinate array containing at least3 * (index + 3)floatsindex- triple index of the first vertex of the triangle to split; vertices are at triple indicesindex,index+1,index+2- Returns:
- a 36-element array containing the four output triangles
-
oneToFourTriangle
public static float[] oneToFourTriangle(float[] coords) Splits a triangle given as a self-contained 9-element array into four smaller triangles by connecting its three edge midpoints.Equivalent to
oneToFourTriangle(float[], int)withindex = 0.- Parameters:
coords- the triangle as[x1, y1, z1, x2, y2, z2, x3, y3, z3]; must have length ≥ 9- Returns:
- a 36-element array containing the four output triangles
-
drawLine
public static void drawLine(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float ux, float uy, float uz, float length, Color color, float lineWidth) Draws a line segment from a start point along a unit-vector direction for a given length.The endpoint is computed as
(x1 + length*ux, y1 + length*uy, z1 + length*uz)and the call delegates todrawLine(GLAutoDrawable, float, float, float, float, float, float, Color, float).- Parameters:
drawable- the OpenGL drawablex1- x coordinate of the start pointy1- y coordinate of the start pointz1- z coordinate of the start pointux- x component of the unit direction vectoruy- y component of the unit direction vectoruz- z component of the unit direction vectorlength- the length of the line segment in model-space unitscolor- the line colourlineWidth- the line width in pixels
-
drawLine
public static void drawLine(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float x2, float y2, float z2, Color color, float lineWidth) Draws a line segment between two explicit float endpoints.- Parameters:
drawable- the OpenGL drawablex1- x coordinate of the first endpointy1- y coordinate of the first endpointz1- z coordinate of the first endpointx2- x coordinate of the second endpointy2- y coordinate of the second endpointz2- z coordinate of the second endpointcolor- the line colourlineWidth- the line width in pixels
-
drawLine
public static void drawLine(com.jogamp.opengl.GLAutoDrawable drawable, double x1, double y1, double z1, double x2, double y2, double z2, Color color, float lineWidth) Draws a line segment between two explicit double endpoints.The coordinates are cast to
floatbefore submission to OpenGL.- Parameters:
drawable- the OpenGL drawablex1- x coordinate of the first endpointy1- y coordinate of the first endpointz1- z coordinate of the first endpointx2- x coordinate of the second endpointy2- y coordinate of the second endpointz2- z coordinate of the second endpointcolor- the line colourlineWidth- the line width in pixels
-
drawLine
public static void drawLine(com.jogamp.opengl.GLAutoDrawable drawable, float[] p0, float[] p1, Color color, float lineWidth) Draws a line segment between two endpoints supplied asfloat[3]arrays.- Parameters:
drawable- the OpenGL drawablep0- first endpoint as[x, y, z]; must have length ≥ 3p1- second endpoint as[x, y, z]; must have length ≥ 3color- the line colourlineWidth- the line width in pixels
-
drawLine
public static void drawLine(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, float lineWidth) Draws a line segment from a packed six-element coordinate array.- Parameters:
drawable- the OpenGL drawablecoords- the line as[x1, y1, z1, x2, y2, z2]; must have length ≥ 6color- the line colourlineWidth- the line width in pixels
-
drawLine
public static void drawLine(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float x2, float y2, float z2, Color color1, Color color2, float lineWidth) Draws a line segment rendered in two alternating stipple colours.The segment is drawn twice using
GL_LINE_STIPPLE: once with pattern0x00FF(first half solid) incolor1, and once with pattern0xFF00(second half solid) incolor2. Either colour may benullto suppress that pass. The combined effect produces a two-colour dashed appearance.- Parameters:
drawable- the OpenGL drawablex1- x coordinate of the first endpointy1- y coordinate of the first endpointz1- z coordinate of the first endpointx2- x coordinate of the second endpointy2- y coordinate of the second endpointz2- z coordinate of the second endpointcolor1- the first stipple colour, ornullto skipcolor2- the second stipple colour, ornullto skiplineWidth- the line width in pixels
-
drawPolyLine
public static void drawPolyLine(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color, float lineWidth) Draws an open polyline connecting all vertices in a packed coordinate array.Every three consecutive floats describe one vertex. At least two vertices are required for visible output; the method does not guard against fewer.
- Parameters:
drawable- the OpenGL drawablecoords- packed vertex coordinates as[x, y, z, ...]color- the line colourlineWidth- the line width in pixels
-
drawPolyLine
public static void drawPolyLine(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, int livePoints, Color color, float lineWidth) Draws an open polyline using only the firstlivePointsvertices of a (possibly oversized) coordinate buffer.This overload exists to avoid trimming a backing buffer to its live length before drawing — the caller supplies the count explicitly. It is used by
Trajectory3Dto achieve zero-copy append semantics. IflivePointsis less than 2, nothing is drawn.- Parameters:
drawable- the OpenGL drawablecoords- the coordinate buffer as[x, y, z, ...]; may be larger than3 * livePoints; only indices[0, 3 * livePoints)are readlivePoints- the number of valid vertices to draw; values less than 2 produce no outputcolor- the line colourlineWidth- the line width in pixels
-
drawPolyLine
public static void drawPolyLine(com.jogamp.opengl.GLAutoDrawable drawable, float[] coords, Color color1, Color color2, float lineWidth) Draws an open polyline rendered in two alternating stipple colours.The polyline is drawn twice using
GL_LINE_STIPPLE: once with pattern0x00FFincolor1and once with pattern0xFF00incolor2. Either colour may benullto suppress that pass.- Parameters:
drawable- the OpenGL drawablecoords- packed vertex coordinates as[x, y, z, ...]color1- the first stipple colour, ornullto skipcolor2- the second stipple colour, ornullto skiplineWidth- the line width in pixels
-
drawCone
public static void drawCone(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float x2, float y2, float z2, float radius, Color color) Draws a solid cone with its base centred at(x1, y1, z1)and its tip at(x2, y2, z2).The cone is oriented along the vector from base to tip using a single
glRotatefcall. The rotation axis degenerates when the direction vector is exactly parallel to the Z axis; a small epsilon (1e-5) is applied to the Z component to avoid this in practice.- Parameters:
drawable- the OpenGL drawablex1- x coordinate of the base centrey1- y coordinate of the base centrez1- z coordinate of the base centrex2- x coordinate of the tipy2- y coordinate of the tipz2- z coordinate of the tipradius- radius of the base circle in model-space unitscolor- the cone colour
-
drawTube
public static void drawTube(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float x2, float y2, float z2, float radius, Color color) Draws a solid cylindrical tube between two endpoints.The tube is rendered as a GLU cylinder oriented along the vector from
(x1,y1,z1)to(x2,y2,z2)with 50 radial subdivisions and no end caps. The same axis-alignment approach asdrawCone(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, float, float, float, java.awt.Color)is used; the same Z-axis epsilon applies.- Parameters:
drawable- the OpenGL drawablex1- x coordinate of the first endy1- y coordinate of the first endz1- z coordinate of the first endx2- x coordinate of the second endy2- y coordinate of the second endz2- z coordinate of the second endradius- the tube radius in model-space unitscolor- the tube colour
-
drawShadedTube
public static void drawShadedTube(com.jogamp.opengl.GLAutoDrawable drawable, float x1, float y1, float z1, float x2, float y2, float z2, float radius, Color color, boolean enableLighting) Draws an open-ended cylindrical tube between two points, with optional Phong-style lighting.Behaves exactly like
drawTube(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, float, float, float, java.awt.Color)except that whenenableLightingistrue, the shared GLU quadric is told to generate smooth per-vertex normals (GLU_SMOOTH) viagluQuadricNormals, and lighting/material state is applied around thegluCylindercall the same waysolidShadedSphere(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, int, int, java.awt.Color, boolean)does. The quadric's normal mode is restored toGLU_NONEafterward so unlit callers ofdrawTube(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, float, float, float, java.awt.Color)are unaffected.No end caps are drawn, matching
drawTube(com.jogamp.opengl.GLAutoDrawable, float, float, float, float, float, float, float, java.awt.Color).- Parameters:
drawable- the OpenGL drawablex1- x coordinate of the first endpointy1- y coordinate of the first endpointz1- z coordinate of the first endpointx2- x coordinate of the second endpointy2- y coordinate of the second endpointz2- z coordinate of the second endpointradius- tube radiuscolor- the tube colour; also used as the material diffuse colour when lighting is enabledenableLighting-trueto enable a directional GL_LIGHT0 and Phong materials;falsefor flat colour
-
drawSphericalPolygon
public static void drawSphericalPolygon(com.jogamp.opengl.GLAutoDrawable drawable, float radius, float[] coords, Color lineColor, Color fillColor, float lineWidth) Draws a filled and/or outlined spherical polygon defined by vertices in spherical coordinates.The polygon vertices are supplied in spherical coordinates as alternating
(theta, phi)pairs in radians, wherethetais the polar angle from the positive Z axis ([0, π]) andphiis the azimuthal angle in the XY plane ([-π, π]). They are converted internally to Cartesian coordinates on the surface of a sphere of the givenradius.The fill is drawn as a
GL_POLYGONprimitive; the outline is drawn as aGL_LINE_LOOP. Either pass may be suppressed by passingnullfor the corresponding colour.- Parameters:
drawable- the OpenGL drawableradius- the sphere radius on whose surface the polygon is drawncoords- spherical coordinate pairs as[theta0, phi0, theta1, phi1, ...]; length must be evenlineColor- the outline colour, ornullfor no outlinefillColor- the fill colour, ornullfor no filllineWidth- the outline line width in pixels
-
setColor
Sets the current OpenGL drawing colour from an AWTColor.All four components (red, green, blue, alpha) are normalised from the AWT range
[0, 255]to the OpenGL range[0.0, 1.0]and submitted viaglColor4f.- Parameters:
gl- the GL2 contextcolor- the AWT colour to apply; must not benull
-
toArray
public static float[] toArray(float... v) Convenience factory that converts a varargs list offloatvalues into afloat[].This is syntactic sugar for building inline coordinate arrays:
Support3D.drawPolyLine(drawable, Support3D.toArray(0f, 0f, 0f, 1f, 0f, 0f, 1f, 1f, 0f), Color.WHITE, 1f);- Parameters:
v- the float values; may be empty- Returns:
- the same values as a
float[]; the array is the varargs array itself, so no copy is made
-