Class Box

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Box extends ProxyInstance
A 3D box, described as the volume between a minimum and a maximum vertices.
Since:
1.2
  • Constructor Summary

    Constructors
    Constructor
    Description
    Box()
    Allocate a new Box.
    Box(Arena arena)
    Allocate a new Box.
    Box(MemorySegment address)
    Create a Box proxy instance for the provided memory address.
    Box(Vec3 min, Vec3 max)
    Allocate a new Box with the fields set to the provided values.
    Box(Vec3 min, Vec3 max, Arena arena)
    Allocate a new Box with the fields set to the provided values.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Box
    Allocates a new graphene_box_t.
    boolean
    Checks whether the graphene_box_t this Box contains the given graphene_box_t b.
    boolean
    Checks whether this Box contains the given point.
    static Box
    A degenerate graphene_box_t that can only be expanded.
    boolean
    Checks whether the two given boxes are equal.
    void
    expand(Point3D point, Box res)
    Expands the dimensions of this Box to include the coordinates at point.
    void
    expandScalar(float scalar, Box res)
    Expands the dimensions of this Box by the given scalar value.
    void
    expandVec3(Vec3 vec, Box res)
    Expands the dimensions of this Box to include the coordinates of the given vector.
    void
    Frees the resources allocated by graphene_box_alloc().
    void
    Computes the bounding graphene_sphere_t capable of containing the given graphene_box_t.
    void
    Retrieves the coordinates of the center of a graphene_box_t.
    float
    Retrieves the size of the this Box on the Z axis.
    float
    Retrieves the size of the this Box on the Y axis.
    void
    Retrieves the coordinates of the maximum point of the given graphene_box_t.
    The memory layout of the native struct.
    void
    Retrieves the coordinates of the minimum point of the given graphene_box_t.
    void
    getSize(Vec3 size)
    Retrieves the size of the box on all three axes, and stores it into the given size vector.
    static @Nullable Type
    Get the GType of the Box class.
    void
    getVertices(@Nullable Out<Vec3[]> vertices)
    Computes the vertices of the given graphene_box_t.
    float
    Retrieves the size of the this Box on the X axis.
    static Box
    A degenerate graphene_box_t that cannot be expanded.
    init(@Nullable Point3D min, @Nullable Point3D max)
    Initializes the given graphene_box_t with two vertices.
    Initializes the given graphene_box_t with the vertices of another graphene_box_t.
    initFromPoints(@Nullable Point3D @Nullable [] points)
    Initializes the given graphene_box_t with the given array of vertices.
    initFromVec3(@Nullable Vec3 min, @Nullable Vec3 max)
    Initializes the given graphene_box_t with two vertices stored inside graphene_vec3_t.
    initFromVectors(@Nullable Vec3 @Nullable [] vectors)
    Initializes the given graphene_box_t with the given array of vertices.
    boolean
    intersection(Box b, @Nullable Box res)
    Intersects the two given graphene_box_t.
    static Box
    A graphene_box_t with the minimum vertex set at (-1, -1, -1) and the maximum vertex set at (0, 0, 0).
    static Box
    one()
    A graphene_box_t with the minimum vertex set at (0, 0, 0) and the maximum vertex set at (1, 1, 1).
    static Box
    A graphene_box_t with the minimum vertex set at (-1, -1, -1) and the maximum vertex set at (1, 1, 1).
    @Nullable Vec3
    Read the value of the field max.
    @Nullable Vec3
    Read the value of the field min.
    void
    union(Box b, Box res)
    Unions the two given graphene_box_t.
    void
    writeMax(@Nullable Vec3 max)
    Write a value in the field max.
    void
    writeMin(@Nullable Vec3 min)
    Write a value in the field min.
    static Box
    A graphene_box_t with both the minimum and maximum vertices set at (0, 0, 0).

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

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

    • Box

      public Box(MemorySegment address)
      Create a Box proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Box

      public Box(Arena arena)
      Allocate a new Box.
      Parameters:
      arena - to control the memory allocation scope
    • Box

      public Box()
      Allocate a new Box. The memory is allocated with Arena.ofAuto().
    • Box

      public Box(Vec3 min, Vec3 max, Arena arena)
      Allocate a new Box with the fields set to the provided values.
      Parameters:
      min - value for the field min
      max - value for the field max
      arena - to control the memory allocation scope
    • Box

      public Box(Vec3 min, Vec3 max)
      Allocate a new Box with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      min - value for the field min
      max - value for the field max
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Box class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readMin

      public @Nullable Vec3 readMin()
      Read the value of the field min.
      Returns:
      The value of the field min
    • writeMin

      public void writeMin(@Nullable Vec3 min)
      Write a value in the field min.
      Parameters:
      min - The new value for the field min
    • readMax

      public @Nullable Vec3 readMax()
      Read the value of the field max.
      Returns:
      The value of the field max
    • writeMax

      public void writeMax(@Nullable Vec3 max)
      Write a value in the field max.
      Parameters:
      max - The new value for the field max
    • alloc

      public static Box alloc()

      Allocates a new graphene_box_t.

      The contents of the returned structure are undefined.

      Returns:
      the newly allocated graphene_box_t structure. Use graphene_box_free() to free the resources allocated by this function
      Since:
      1.2
    • empty

      public static Box empty()

      A degenerate graphene_box_t that can only be expanded.

      The returned value is owned by Graphene and should not be modified or freed.

      Returns:
      a graphene_box_t
      Since:
      1.2
    • infinite

      public static Box infinite()

      A degenerate graphene_box_t that cannot be expanded.

      The returned value is owned by Graphene and should not be modified or freed.

      Returns:
      a graphene_box_t
      Since:
      1.2
    • minusOne

      public static Box minusOne()

      A graphene_box_t with the minimum vertex set at (-1, -1, -1) and the maximum vertex set at (0, 0, 0).

      The returned value is owned by Graphene and should not be modified or freed.

      Returns:
      a graphene_box_t
      Since:
      1.2
    • one

      public static Box one()

      A graphene_box_t with the minimum vertex set at (0, 0, 0) and the maximum vertex set at (1, 1, 1).

      The returned value is owned by Graphene and should not be modified or freed.

      Returns:
      a graphene_box_t
      Since:
      1.2
    • oneMinusOne

      public static Box oneMinusOne()

      A graphene_box_t with the minimum vertex set at (-1, -1, -1) and the maximum vertex set at (1, 1, 1).

      The returned value is owned by Graphene and should not be modified or freed.

      Returns:
      a graphene_box_t
      Since:
      1.2
    • zero

      public static Box zero()

      A graphene_box_t with both the minimum and maximum vertices set at (0, 0, 0).

      The returned value is owned by Graphene and should not be modified or freed.

      Returns:
      a graphene_box_t
      Since:
      1.2
    • containsBox

      public boolean containsBox(Box b)
      Checks whether the graphene_box_t this Box contains the given graphene_box_t b.
      Parameters:
      b - a graphene_box_t
      Returns:
      true if the box is contained in the given box
      Since:
      1.2
    • containsPoint

      public boolean containsPoint(Point3D point)
      Checks whether this Box contains the given point.
      Parameters:
      point - the coordinates to check
      Returns:
      true if the point is contained in the given box
      Since:
      1.2
    • equal

      public boolean equal(Box b)
      Checks whether the two given boxes are equal.
      Parameters:
      b - a graphene_box_t
      Returns:
      true if the boxes are equal
      Since:
      1.2
    • expand

      public void expand(Point3D point, Box res)
      Expands the dimensions of this Box to include the coordinates at point.
      Parameters:
      point - the coordinates of the point to include
      res - return location for the expanded box
      Since:
      1.2
    • expandScalar

      public void expandScalar(float scalar, Box res)

      Expands the dimensions of this Box by the given scalar value.

      If scalar is positive, the graphene_box_t will grow; if scalar is negative, the graphene_box_t will shrink.

      Parameters:
      scalar - a scalar value
      res - return location for the expanded box
      Since:
      1.2
    • expandVec3

      public void expandVec3(Vec3 vec, Box res)
      Expands the dimensions of this Box to include the coordinates of the given vector.
      Parameters:
      vec - the coordinates of the point to include, as a graphene_vec3_t
      res - return location for the expanded box
      Since:
      1.2
    • free

      public void free()
      Frees the resources allocated by graphene_box_alloc().
      Since:
      1.2
    • getBoundingSphere

      public void getBoundingSphere(Sphere sphere)
      Computes the bounding graphene_sphere_t capable of containing the given graphene_box_t.
      Parameters:
      sphere - return location for the bounding sphere
      Since:
      1.2
    • getCenter

      public void getCenter(Point3D center)
      Retrieves the coordinates of the center of a graphene_box_t.
      Parameters:
      center - return location for the coordinates of the center
      Since:
      1.2
    • getDepth

      public float getDepth()
      Retrieves the size of the this Box on the Z axis.
      Returns:
      the depth of the box
      Since:
      1.2
    • getHeight

      public float getHeight()
      Retrieves the size of the this Box on the Y axis.
      Returns:
      the height of the box
      Since:
      1.2
    • getMax

      public void getMax(Point3D max)
      Retrieves the coordinates of the maximum point of the given graphene_box_t.
      Parameters:
      max - return location for the maximum point
      Since:
      1.2
    • getMin

      public void getMin(Point3D min)
      Retrieves the coordinates of the minimum point of the given graphene_box_t.
      Parameters:
      min - return location for the minimum point
      Since:
      1.2
    • getSize

      public void getSize(Vec3 size)
      Retrieves the size of the box on all three axes, and stores it into the given size vector.
      Parameters:
      size - return location for the size
      Since:
      1.2
    • getVertices

      public void getVertices(@Nullable Out<Vec3[]> vertices)
      Computes the vertices of the given graphene_box_t.
      Parameters:
      vertices - return location for an array of 8 graphene_vec3_t
      Since:
      1.2
    • getWidth

      public float getWidth()
      Retrieves the size of the this Box on the X axis.
      Returns:
      the width of the box
      Since:
      1.2
    • init

      public Box init(@Nullable Point3D min, @Nullable Point3D max)
      Initializes the given graphene_box_t with two vertices.
      Parameters:
      min - the coordinates of the minimum vertex
      max - the coordinates of the maximum vertex
      Returns:
      the initialized graphene_box_t
      Since:
      1.2
    • initFromBox

      public Box initFromBox(Box src)
      Initializes the given graphene_box_t with the vertices of another graphene_box_t.
      Parameters:
      src - a graphene_box_t
      Returns:
      the initialized graphene_box_t
      Since:
      1.2
    • initFromPoints

      public Box initFromPoints(@Nullable Point3D @Nullable [] points)

      Initializes the given graphene_box_t with the given array of vertices.

      If nPoints is 0, the returned box is initialized with graphene_box_empty().

      Parameters:
      points - an array of graphene_point3d_t
      Returns:
      the initialized graphene_box_t
      Since:
      1.2
    • initFromVec3

      public Box initFromVec3(@Nullable Vec3 min, @Nullable Vec3 max)
      Initializes the given graphene_box_t with two vertices stored inside graphene_vec3_t.
      Parameters:
      min - the coordinates of the minimum vertex
      max - the coordinates of the maximum vertex
      Returns:
      the initialized graphene_box_t
      Since:
      1.2
    • initFromVectors

      public Box initFromVectors(@Nullable Vec3 @Nullable [] vectors)

      Initializes the given graphene_box_t with the given array of vertices.

      If nVectors is 0, the returned box is initialized with graphene_box_empty().

      Parameters:
      vectors - an array of graphene_vec3_t
      Returns:
      the initialized graphene_box_t
      Since:
      1.2
    • intersection

      public boolean intersection(Box b, @Nullable Box res)

      Intersects the two given graphene_box_t.

      If the two boxes do not intersect, res will contain a degenerate box initialized with graphene_box_empty().

      Parameters:
      b - a graphene_box_t
      res - return location for the result
      Returns:
      true if the two boxes intersect
      Since:
      1.2
    • union

      public void union(Box b, Box res)
      Unions the two given graphene_box_t.
      Parameters:
      b - the box to union to this Box
      res - return location for the result
      Since:
      1.2