Class Ray

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Ray extends ProxyInstance

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.

Since:
1.4
  • Constructor Details

    • Ray

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

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

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

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

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

    • getType

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

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

      public @Nullable Vec3 readOrigin()
      Read the value of the field origin.
      Returns:
      The value of the field origin
    • writeOrigin

      public void writeOrigin(@Nullable Vec3 origin)
      Write a value in the field origin.
      Parameters:
      origin - The new value for the field origin
    • readDirection

      public @Nullable Vec3 readDirection()
      Read the value of the field direction.
      Returns:
      The value of the field direction
    • writeDirection

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

      public static Ray alloc()

      Allocates a new graphene_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
      Since:
      1.4
    • equal

      public boolean equal(Ray b)
      Checks whether the two given graphene_ray_t are equal.
      Parameters:
      b - a graphene_ray_t
      Returns:
      true if the given rays are equal
      Since:
      1.4
    • free

      public void free()
      Frees the resources allocated by graphene_ray_alloc().
      Since:
      1.4
    • getClosestPointToPoint

      public void getClosestPointToPoint(Point3D p, Point3D res)
      Computes the point on the given graphene_ray_t that is closest to the given point p.
      Parameters:
      p - a graphene_point3d_t
      res - return location for the closest point3d
      Since:
      1.4
    • getDirection

      public void getDirection(Vec3 direction)
      Retrieves the direction of the given graphene_ray_t.
      Parameters:
      direction - return location for the direction
      Since:
      1.4
    • getDistanceToPlane

      public float getDistanceToPlane(Plane p)

      Computes the distance of the origin of the given graphene_ray_t from the given plane.

      If the ray does not intersect the plane, this function returns INFINITY.

      Parameters:
      p - a graphene_plane_t
      Returns:
      the distance of the origin of the ray from the plane
      Since:
      1.4
    • getDistanceToPoint

      public float getDistanceToPoint(Point3D p)

      Computes the distance of the closest approach between the given graphene_ray_t this Ray and the point p.

      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 - a graphene_point3d_t
      Returns:
      the distance of the point
      Since:
      1.4
    • getOrigin

      public void getOrigin(Point3D origin)
      Retrieves the origin of the given graphene_ray_t.
      Parameters:
      origin - return location for the origin
      Since:
      1.4
    • getPositionAt

      public void getPositionAt(float t, Point3D position)
      Retrieves the coordinates of a point at the distance t along the given graphene_ray_t.
      Parameters:
      t - the distance along the ray
      position - return location for the position
      Since:
      1.4
    • init

      public Ray init(@Nullable Point3D origin, @Nullable Vec3 direction)
      Initializes the given graphene_ray_t using the given origin and direction values.
      Parameters:
      origin - the origin of the ray
      direction - the direction vector
      Returns:
      the initialized ray
      Since:
      1.4
    • initFromRay

      public Ray initFromRay(Ray src)
      Initializes the given graphene_ray_t using the origin and direction values of another graphene_ray_t.
      Parameters:
      src - a graphene_ray_t
      Returns:
      the initialized ray
      Since:
      1.4
    • initFromVec3

      public Ray initFromVec3(@Nullable Vec3 origin, @Nullable Vec3 direction)
      Initializes the given graphene_ray_t using the given vectors.
      Parameters:
      origin - a graphene_vec3_t
      direction - a graphene_vec3_t
      Returns:
      the initialized ray
      Since:
      1.4
    • intersectBox

      public RayIntersectionKind intersectBox(Box b, Out<Float> tOut)
      Intersects the given graphene_ray_t this Ray with the given graphene_box_t b.
      Parameters:
      b - a graphene_box_t
      tOut - the distance of the point on the ray that intersects the box
      Returns:
      the type of intersection
      Since:
      1.10
    • intersectSphere

      public RayIntersectionKind intersectSphere(Sphere s, Out<Float> tOut)
      Intersects the given graphene_ray_t this Ray with the given graphene_sphere_t s.
      Parameters:
      s - a graphene_sphere_t
      tOut - the distance of the point on the ray that intersects the sphere
      Returns:
      the type of intersection
      Since:
      1.10
    • intersectTriangle

      public RayIntersectionKind intersectTriangle(Triangle t, Out<Float> tOut)
      Intersects the given graphene_ray_t this Ray with the given graphene_triangle_t t.
      Parameters:
      t - a graphene_triangle_t
      tOut - the distance of the point on the ray that intersects the triangle
      Returns:
      the type of intersection
      Since:
      1.10
    • intersectsBox

      public boolean intersectsBox(Box b)

      Checks whether the given graphene_ray_t this Ray intersects the given graphene_box_t b.

      See also: graphene_ray_intersect_box()

      Parameters:
      b - a graphene_box_t
      Returns:
      true if the ray intersects the box
      Since:
      1.10
    • intersectsSphere

      public boolean intersectsSphere(Sphere s)

      Checks if the given graphene_ray_t this Ray intersects the given graphene_sphere_t s.

      See also: graphene_ray_intersect_sphere()

      Parameters:
      s - a graphene_sphere_t
      Returns:
      true if the ray intersects the sphere
      Since:
      1.10
    • intersectsTriangle

      public boolean intersectsTriangle(Triangle t)

      Checks whether the given graphene_ray_t this Ray intersects the given graphene_triangle_t b.

      See also: graphene_ray_intersect_triangle()

      Parameters:
      t - a graphene_triangle_t
      Returns:
      true if the ray intersects the triangle
      Since:
      1.10