Class Vertex
A vertex represents a corner point of a polygon or polyhedron. In addition to the 3D coordinate, it stores the transformed position (relative to viewer) and the projected screen coordinates for rendering.
Coordinate spaces:
coordinate- Original position in local/model spacetransformedCoordinate(eu.svjatoslav.sixth.e3d.gui.RenderingContext)- Position relative to viewer (camera space)onScreenCoordinate(eu.svjatoslav.sixth.e3d.gui.RenderingContext)- 2D screen position after perspective projection
Example:
Vertex v = new Vertex(new Point3D(10, 20, 30));
v.calculateLocationRelativeToViewer(transformStack, renderContext);
if (v.transformedCoordinate.z > 0) {
// Vertex is in front of the camera
}
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionVertex coordinate in local/model 3D space.Normal vector for this vertex (optional).Texture coordinate for UV mapping (optional). -
Constructor Summary
ConstructorsConstructorDescriptionVertex()Creates a vertex at the origin (0, 0, 0) with no texture coordinate.Creates a vertex at the specified position with no texture coordinate.Creates a vertex at the specified position with an optional texture coordinate. -
Method Summary
Modifier and TypeMethodDescriptionvoidcalculateLocationRelativeToViewer(TransformStack transforms, RenderingContext renderContext) Transforms this vertex from model space to screen space.clone()Creates a deep copy of this vertex.voidflip()Flips the orientation of this vertex by negating the normal vector.interpolate(Vertex other, double t) Creates a new vertex between this vertex and another by linearly interpolating all properties using parameter t.onScreenCoordinate(RenderingContext renderContext) Returns the screen-space position for the rendering context's buffer slot.voidsetCameraSpaceCoordinate(double x, double y, double z, RenderingContext renderContext) Writes a camera-space position directly into this vertex's slot state and projects it to screen coordinates, bypassing the transform stack.transformedCoordinate(RenderingContext renderContext) Returns the camera-space coordinate for the rendering context's buffer slot.
-
Field Details
-
coordinate
Vertex coordinate in local/model 3D space. -
textureCoordinate
Texture coordinate for UV mapping (optional). -
normal
Normal vector for this vertex (optional). Used by CSG operations for smooth interpolation during polygon splitting. Null for non-CSG usage; existing rendering code ignores this field.
-
-
Constructor Details
-
Vertex
public Vertex()Creates a vertex at the origin (0, 0, 0) with no texture coordinate. -
Vertex
Creates a vertex at the specified position with no texture coordinate.- Parameters:
coordinate- the 3D position of this vertex
-
Vertex
Creates a vertex at the specified position with an optional texture coordinate.- Parameters:
coordinate- the 3D position of this vertextextureCoordinate- the UV texture coordinate, ornullfor none
-
-
Method Details
-
transformedCoordinate
Returns the camera-space coordinate for the rendering context's buffer slot. Valid only after this vertex was transformed for that slot's current frame.- Parameters:
renderContext- the rendering context (selects the buffer slot)- Returns:
- the transformed coordinate (camera space) for the active slot
-
onScreenCoordinate
Returns the screen-space position for the rendering context's buffer slot.- Parameters:
renderContext- the rendering context (selects the buffer slot)- Returns:
- the on-screen coordinate (pixels) for the active slot
-
calculateLocationRelativeToViewer
public void calculateLocationRelativeToViewer(TransformStack transforms, RenderingContext renderContext) Transforms this vertex from model space to screen space.This method applies the transform stack to compute the vertex position relative to the viewer, then projects it to 2D screen coordinates. Results are cached per-frame per-slot to avoid redundant calculations.
- Parameters:
transforms- the transform stack to apply (world-to-camera transforms)renderContext- the rendering context providing projection parameters
-
setCameraSpaceCoordinate
Writes a camera-space position directly into this vertex's slot state and projects it to screen coordinates, bypassing the transform stack.Used by near-plane clipping (
AbstractCoordinateShape), which creates intersection vertices that exist ONLY in camera space — there is no model-space coordinate to transform. The given z must be > 0 (clip against the near plane guarantees z == nearPlaneDistance).- Parameters:
x- camera-space Xy- camera-space Yz- camera-space Z (depth in front of viewer, > 0)renderContext- the rendering context (selects the buffer slot and provides projection parameters)
-
clone
Creates a deep copy of this vertex. Clones the coordinate, normal (if present), and texture coordinate (if present). The transformedCoordinate and onScreenCoordinate are not cloned (they are computed per-frame). -
flip
public void flip()Flips the orientation of this vertex by negating the normal vector. Called when the orientation of a polygon is flipped during CSG operations. If normal is null, this method does nothing. -
interpolate
Creates a new vertex between this vertex and another by linearly interpolating all properties using parameter t.Interpolates: position, normal (if present), and texture coordinate (if present).
- Parameters:
other- the other vertex to interpolate towardst- the interpolation parameter (0 = this vertex, 1 = other vertex)- Returns:
- a new Vertex representing the interpolated position
-