Package org.lwjgl.util.par
Class ParOctasphere
- java.lang.Object
-
- org.lwjgl.util.par.ParOctasphere
-
public class ParOctasphere extends java.lang.ObjectBindings 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
Fields Modifier and Type Field Description static intpar_octasphere_NORMALS_SMOOTHpar_octasphere_normals_modestatic intpar_octasphere_PAR_OCTASPHERE_MAX_SUBDIVISIONSstatic intpar_octasphere_UV_LATLONGpar_octasphere_uv_mode
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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, java.nio.IntBuffer num_indices, java.nio.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 Detail
-
par_octasphere_PAR_OCTASPHERE_MAX_SUBDIVISIONS
public static final int par_octasphere_PAR_OCTASPHERE_MAX_SUBDIVISIONS
- See Also:
- Constant Field Values
-
par_octasphere_UV_LATLONG
public static final int par_octasphere_UV_LATLONG
par_octasphere_uv_mode- See Also:
- Constant Field Values
-
par_octasphere_NORMALS_SMOOTH
public static final int par_octasphere_NORMALS_SMOOTH
par_octasphere_normals_mode- See Also:
- Constant Field Values
-
-
Method Detail
-
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, java.nio.IntBuffer num_indices, java.nio.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
public static void par_octasphere_populate(ParOctasphereConfig config, ParOctasphereMesh mesh)
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
-
-