Package org.gnome.graphene
Class Box
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.graphene.Box
- All Implemented Interfaces:
Proxy
A 3D box, described as the volume between a minimum and
a maximum vertices.
-
Constructor Summary
ConstructorDescriptionBox()
Allocate a new Box.Allocate a new Box.Box
(MemorySegment address) Create a Box proxy instance for the provided memory address.Allocate a new Box with the fields set to the provided values.Allocate a new Box with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionstatic Box
alloc()
Allocates a newgraphene_box_t
.boolean
containsBox
(Box b) Checks whether thegraphene_box_t
this Box contains the givengraphene_box_t
b
.boolean
containsPoint
(Point3D point) Checks whether this Box contains the givenpoint
.static Box
empty()
A degenerategraphene_box_t
that can only be expanded.boolean
Checks whether the two given boxes are equal.void
Expands the dimensions of this Box to include the coordinates atpoint
.void
expandScalar
(float scalar, Box res) Expands the dimensions of this Box by the givenscalar
value.void
expandVec3
(Vec3 vec, Box res) Expands the dimensions of this Box to include the coordinates of the given vector.void
free()
Frees the resources allocated by graphene_box_alloc().void
getBoundingSphere
(Sphere sphere) Computes the boundinggraphene_sphere_t
capable of containing the givengraphene_box_t
.void
Retrieves the coordinates of the center of agraphene_box_t
.float
getDepth()
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 givengraphene_box_t
.static MemoryLayout
The memory layout of the native struct.void
Retrieves the coordinates of the minimum point of the givengraphene_box_t
.void
Retrieves the size of the box on all three axes, and stores it into the givensize
vector.static Type
getType()
Get the GType of the Box classvoid
getVertices
(Vec3[] vertices) Computes the vertices of the givengraphene_box_t
.float
getWidth()
Retrieves the size of the this Box on the X axis.static Box
infinite()
A degenerategraphene_box_t
that cannot be expanded.Initializes the givengraphene_box_t
with two vertices.initFromBox
(Box src) Initializes the givengraphene_box_t
with the vertices of anothergraphene_box_t
.initFromPoints
(Point3D[] points) Initializes the givengraphene_box_t
with the given array of vertices.initFromVec3
(@Nullable Vec3 min, @Nullable Vec3 max) Initializes the givengraphene_box_t
with two vertices stored insidegraphene_vec3_t
.initFromVectors
(Vec3[] vectors) Initializes the givengraphene_box_t
with the given array of vertices.boolean
intersection
(Box b, @Nullable Box res) Intersects the two givengraphene_box_t
.static Box
minusOne()
Agraphene_box_t
with the minimum vertex set at (-1, -1, -1) and the maximum vertex set at (0, 0, 0).static Box
one()
Agraphene_box_t
with the minimum vertex set at (0, 0, 0) and the maximum vertex set at (1, 1, 1).static Box
Agraphene_box_t
with the minimum vertex set at (-1, -1, -1) and the maximum vertex set at (1, 1, 1).readMax()
Read the value of the fieldmax
.readMin()
Read the value of the fieldmin
.void
Unions the two givengraphene_box_t
.void
Write a value in the fieldmax
.void
Write a value in the fieldmin
.static Box
zero()
Agraphene_box_t
with both the minimum and maximum vertices set at (0, 0, 0).Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Box
Create a Box proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Box
Allocate a new Box.- Parameters:
arena
- to control the memory allocation scope
-
Box
public Box()Allocate a new Box. The memory is allocated withArena.ofAuto()
. -
Box
-
Box
Allocate a new Box with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
min
- value for the fieldmin
max
- value for the fieldmax
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readMin
-
writeMin
Write a value in the fieldmin
.- Parameters:
min
- The new value for the fieldmin
-
readMax
-
writeMax
Write a value in the fieldmax
.- Parameters:
max
- The new value for the fieldmax
-
alloc
Allocates a newgraphene_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
-
empty
A degenerategraphene_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
-
infinite
A degenerategraphene_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
-
minusOne
Agraphene_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
-
one
Agraphene_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
-
oneMinusOne
Agraphene_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
-
zero
Agraphene_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
-
containsBox
Checks whether thegraphene_box_t
this Box contains the givengraphene_box_t
b
.- Parameters:
b
- agraphene_box_t
- Returns:
true
if the box is contained in the given box
-
containsPoint
Checks whether this Box contains the givenpoint
.- Parameters:
point
- the coordinates to check- Returns:
true
if the point is contained in the given box
-
equal
Checks whether the two given boxes are equal.- Parameters:
b
- agraphene_box_t
- Returns:
true
if the boxes are equal
-
expand
-
expandScalar
Expands the dimensions of this Box by the givenscalar
value.If
scalar
is positive, thegraphene_box_t
will grow; ifscalar
is negative, thegraphene_box_t
will shrink.- Parameters:
scalar
- a scalar valueres
- return location for the expanded box
-
expandVec3
-
free
public void free()Frees the resources allocated by graphene_box_alloc(). -
getBoundingSphere
Computes the boundinggraphene_sphere_t
capable of containing the givengraphene_box_t
.- Parameters:
sphere
- return location for the bounding sphere
-
getCenter
Retrieves the coordinates of the center of agraphene_box_t
.- Parameters:
center
- return location for the coordinates of the center
-
getDepth
public float getDepth()Retrieves the size of the this Box on the Z axis.- Returns:
- the depth of the box
-
getHeight
public float getHeight()Retrieves the size of the this Box on the Y axis.- Returns:
- the height of the box
-
getMax
Retrieves the coordinates of the maximum point of the givengraphene_box_t
.- Parameters:
max
- return location for the maximum point
-
getMin
Retrieves the coordinates of the minimum point of the givengraphene_box_t
.- Parameters:
min
- return location for the minimum point
-
getSize
Retrieves the size of the box on all three axes, and stores it into the givensize
vector.- Parameters:
size
- return location for the size
-
getVertices
Computes the vertices of the givengraphene_box_t
.- Parameters:
vertices
- return location for an array of 8graphene_vec3_t
-
getWidth
public float getWidth()Retrieves the size of the this Box on the X axis.- Returns:
- the width of the box
-
init
-
initFromBox
-
initFromPoints
-
initFromVec3
Initializes the givengraphene_box_t
with two vertices stored insidegraphene_vec3_t
.- Parameters:
min
- the coordinates of the minimum vertexmax
- the coordinates of the maximum vertex- Returns:
- the initialized
graphene_box_t
-
initFromVectors
-
intersection
Intersects the two givengraphene_box_t
.If the two boxes do not intersect,
res
will contain a degenerate box initialized with graphene_box_empty().- Parameters:
b
- agraphene_box_t
res
- return location for the result- Returns:
- true if the two boxes intersect
-
union
-