Package org.gnome.graphene
Class Ray
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.graphene.Ray
- All Implemented Interfaces:
Proxy
A ray emitted from an origin in a given direction.
The contents of the graphene_ray_t
structure are private, and should not
be modified directly.
-
Constructor Summary
ConstructorDescriptionRay()
Allocate a new Ray.Allocate a new Ray.Ray
(MemorySegment address) Create a Ray proxy instance for the provided memory address.Allocate a new Ray with the fields set to the provided values.Allocate a new Ray with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionstatic Ray
alloc()
Allocates a newgraphene_ray_t
structure.boolean
Checks whether the two givengraphene_ray_t
are equal.void
free()
Frees the resources allocated by graphene_ray_alloc().void
getClosestPointToPoint
(Point3D p, Point3D res) Computes the point on the givengraphene_ray_t
that is closest to the given pointp
.void
getDirection
(Vec3 direction) Retrieves the direction of the givengraphene_ray_t
.float
Computes the distance of the origin of the givengraphene_ray_t
from the given plane.float
Computes the distance of the closest approach between the givengraphene_ray_t
this Ray and the pointp
.static MemoryLayout
The memory layout of the native struct.void
Retrieves the origin of the givengraphene_ray_t
.void
getPositionAt
(float t, Point3D position) Retrieves the coordinates of a point at the distancet
along the givengraphene_ray_t
.static Type
getType()
Get the GType of the Ray classInitializes the givengraphene_ray_t
using the givenorigin
anddirection
values.initFromRay
(Ray src) Initializes the givengraphene_ray_t
using the origin and direction values of anothergraphene_ray_t
.initFromVec3
(@Nullable Vec3 origin, @Nullable Vec3 direction) Initializes the givengraphene_ray_t
using the given vectors.intersectBox
(Box b, Out<Float> tOut) Intersects the givengraphene_ray_t
this Ray with the givengraphene_box_t
b
.boolean
intersectsBox
(Box b) Checks whether the givengraphene_ray_t
this Ray intersects the givengraphene_box_t
b
.intersectSphere
(Sphere s, Out<Float> tOut) Intersects the givengraphene_ray_t
this Ray with the givengraphene_sphere_t
s
.boolean
Checks if the givengraphene_ray_t
this Ray intersects the givengraphene_sphere_t
s
.boolean
Checks whether the givengraphene_ray_t
this Ray intersects the givengraphene_triangle_t
b
.intersectTriangle
(Triangle t, Out<Float> tOut) Intersects the givengraphene_ray_t
this Ray with the givengraphene_triangle_t
t
.Read the value of the fielddirection
.Read the value of the fieldorigin
.void
writeDirection
(Vec3 direction) Write a value in the fielddirection
.void
writeOrigin
(Vec3 origin) Write a value in the fieldorigin
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Ray
Create a Ray proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Ray
Allocate a new Ray.- Parameters:
arena
- to control the memory allocation scope
-
Ray
public Ray()Allocate a new Ray. The memory is allocated withArena.ofAuto()
. -
Ray
-
Ray
Allocate a new Ray with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
origin
- value for the fieldorigin
direction
- value for the fielddirection
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readOrigin
-
writeOrigin
Write a value in the fieldorigin
.- Parameters:
origin
- The new value for the fieldorigin
-
readDirection
Read the value of the fielddirection
.- Returns:
- The value of the field
direction
-
writeDirection
Write a value in the fielddirection
.- Parameters:
direction
- The new value for the fielddirection
-
alloc
Allocates a newgraphene_ray_t
structure.The contents of the returned structure are undefined.
- Returns:
- the newly allocated
graphene_ray_t
. Use graphene_ray_free() to free the resources allocated by this function
-
equal
Checks whether the two givengraphene_ray_t
are equal.- Parameters:
b
- agraphene_ray_t
- Returns:
true
if the given rays are equal
-
free
public void free()Frees the resources allocated by graphene_ray_alloc(). -
getClosestPointToPoint
-
getDirection
Retrieves the direction of the givengraphene_ray_t
.- Parameters:
direction
- return location for the direction
-
getDistanceToPlane
Computes the distance of the origin of the givengraphene_ray_t
from the given plane.If the ray does not intersect the plane, this function returns
INFINITY
.- Parameters:
p
- agraphene_plane_t
- Returns:
- the distance of the origin of the ray from the plane
-
getDistanceToPoint
Computes the distance of the closest approach between the givengraphene_ray_t
this Ray and the pointp
.The closest approach to a ray from a point is the distance between the point and the projection of the point on the ray itself.
- Parameters:
p
- agraphene_point3d_t
- Returns:
- the distance of the point
-
getOrigin
Retrieves the origin of the givengraphene_ray_t
.- Parameters:
origin
- return location for the origin
-
getPositionAt
Retrieves the coordinates of a point at the distancet
along the givengraphene_ray_t
.- Parameters:
t
- the distance along the rayposition
- return location for the position
-
init
-
initFromRay
-
initFromVec3
-
intersectBox
Intersects the givengraphene_ray_t
this Ray with the givengraphene_box_t
b
.- Parameters:
b
- agraphene_box_t
tOut
- the distance of the point on the ray that intersects the box- Returns:
- the type of intersection
-
intersectSphere
Intersects the givengraphene_ray_t
this Ray with the givengraphene_sphere_t
s
.- Parameters:
s
- agraphene_sphere_t
tOut
- the distance of the point on the ray that intersects the sphere- Returns:
- the type of intersection
-
intersectTriangle
Intersects the givengraphene_ray_t
this Ray with the givengraphene_triangle_t
t
.- Parameters:
t
- agraphene_triangle_t
tOut
- the distance of the point on the ray that intersects the triangle- Returns:
- the type of intersection
-
intersectsBox
Checks whether the givengraphene_ray_t
this Ray intersects the givengraphene_box_t
b
.See also: graphene_ray_intersect_box()
- Parameters:
b
- agraphene_box_t
- Returns:
true
if the ray intersects the box
-
intersectsSphere
Checks if the givengraphene_ray_t
this Ray intersects the givengraphene_sphere_t
s
.See also: graphene_ray_intersect_sphere()
- Parameters:
s
- agraphene_sphere_t
- Returns:
true
if the ray intersects the sphere
-
intersectsTriangle
Checks whether the givengraphene_ray_t
this Ray intersects the givengraphene_triangle_t
b
.See also: graphene_ray_intersect_triangle()
- Parameters:
t
- agraphene_triangle_t
- Returns:
true
if the ray intersects the triangle
-