Record Class MeshShape

java.lang.Object
java.lang.Record
io.github.toxicity188.javamesh.MeshShape
Record Components:
points - polygon points in winding order
texture - optional texture name referenced by the source mesh material

public record MeshShape(@NotNull @Unmodifiable List<MeshPoint> points, @Nullable String texture) extends Record
Polygon data extracted from a mesh source before conversion into Minecraft triangle models.

A shape contains at least three points and an optional texture reference. During conversion it is triangulated and each triangle becomes one or more Minecraft model elements.


 MeshShape quad = new MeshShape(List.of(p0, p1, p2, p3), "blade.png");
 
Since:
0.0.1
  • Constructor Summary

    Constructors
    Constructor
    Description
    MeshShape(@NotNull @Unmodifiable List<MeshPoint> points, @Nullable String texture)
    Validates polygon data for mesh conversion.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    static @NotNull MeshShape
    of(@NotNull MeshPoint... points)
    Creates an untextured polygon from the provided points.
    @NotNull @Unmodifiable List<MeshPoint>
    Returns the value of the points record component.
    @Nullable String
    Returns the value of the texture record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MeshShape

      public MeshShape(@NotNull @NotNull @Unmodifiable List<MeshPoint> points, @Nullable @Nullable String texture)
      Validates polygon data for mesh conversion.
      Throws:
      IllegalArgumentException - if fewer than three points are supplied
      Since:
      0.0.1
  • Method Details

    • of

      @NotNull public static @NotNull MeshShape of(@NotNull @NotNull MeshPoint... points)
      Creates an untextured polygon from the provided points.
      Parameters:
      points - polygon points in winding order
      Returns:
      a new shape without a texture reference
      Throws:
      NullPointerException - if points is null
      IllegalArgumentException - if fewer than three points are supplied
      Since:
      0.0.1
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • points

      @NotNull public @NotNull @Unmodifiable List<MeshPoint> points()
      Returns the value of the points record component.
      Returns:
      the value of the points record component
    • texture

      @Nullable public @Nullable String texture()
      Returns the value of the texture record component.
      Returns:
      the value of the texture record component