Package org.lwjgl.util.par
Class ParOctasphere
java.lang.Object
org.lwjgl.util.par.ParOctasphere
Bindings to par_octasphere.h, a tiny malloc-free library that generates triangle meshes for spheres,
rounded boxes, and capsules.
Usage example:
// Specify a 100x100x20 rounded box.
const par_octasphere_config cfg = {
.corner_radius = 5,
.width = 100,
.height = 100,
.depth = 20,
.num_subdivisions = 3,
};
// Allocate memory for the mesh and opt-out of normals.
uint32_t num_indices;
uint32_t num_vertices;
par_octasphere_get_counts(&cfg, &num_indices, &num_vertices);
par_octasphere_mesh mesh = {
.positions = malloc(sizeof(float) * 3 * num_vertices),
.normals = NULL,
.texcoords = malloc(sizeof(float) * 2 * num_vertices),
.indices = malloc(sizeof(uint16_t) * num_indices),
};
// Generate vertex coordinates, UV's, and triangle indices.
par_octasphere_populate(&cfg, &mesh);
To generate a sphere: set width, height, and depth to 0 in your configuration. To generate a capsule shape: set only two of these dimensions to 0.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intpar_octasphere_normals_modestatic final intstatic final intpar_octasphere_uv_mode -
Method Summary
Modifier and TypeMethodDescriptionstatic voidnpar_octasphere_get_counts(long config, int[] num_indices, int[] num_vertices) Array version of:npar_octasphere_get_counts(long, long, long)static voidnpar_octasphere_get_counts(long config, long num_indices, long num_vertices) Unsafe version of:get_countsstatic voidnpar_octasphere_populate(long config, long mesh) Unsafe version of:populatestatic voidpar_octasphere_get_counts(ParOctasphereConfig config, int[] num_indices, int[] num_vertices) Array version of:get_countsstatic voidpar_octasphere_get_counts(ParOctasphereConfig config, IntBuffer num_indices, IntBuffer num_vertices) Computes the maximum possible number of indices and vertices for the given octasphere config.static voidpar_octasphere_populate(ParOctasphereConfig config, ParOctasphereMesh mesh) Populates a pre-allocated mesh structure with indices and vertices.
-
Field Details
-
par_octasphere_PAR_OCTASPHERE_MAX_SUBDIVISIONS
public static final int par_octasphere_PAR_OCTASPHERE_MAX_SUBDIVISIONS- See Also:
-
par_octasphere_UV_LATLONG
public static final int par_octasphere_UV_LATLONGpar_octasphere_uv_mode- See Also:
-
par_octasphere_NORMALS_SMOOTH
public static final int par_octasphere_NORMALS_SMOOTHpar_octasphere_normals_mode- See Also:
-
-
Method Details
-
npar_octasphere_get_counts
public static void npar_octasphere_get_counts(long config, long num_indices, long num_vertices) Unsafe version of:get_counts -
par_octasphere_get_counts
public static void par_octasphere_get_counts(ParOctasphereConfig config, IntBuffer num_indices, IntBuffer num_vertices) Computes the maximum possible number of indices and vertices for the given octasphere config. -
npar_octasphere_populate
public static void npar_octasphere_populate(long config, long mesh) Unsafe version of:populate -
par_octasphere_populate
Populates a pre-allocated mesh structure with indices and vertices. -
npar_octasphere_get_counts
public static void npar_octasphere_get_counts(long config, int[] num_indices, int[] num_vertices) Array version of:npar_octasphere_get_counts(long, long, long) -
par_octasphere_get_counts
public static void par_octasphere_get_counts(ParOctasphereConfig config, int[] num_indices, int[] num_vertices) Array version of:get_counts
-