Top Description Fields Constructors Methods
org.lwjgl.util.par

public Class ParOctasphere

extends Object
Class Inheritance
Imports
java.nio.*, org.lwjgl.system.*

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

Modifier and TypeField and Description
public static final int
par_octasphere_NORMALS_SMOOTH

par_octasphere_normals_mode

public static final int
public static final int
par_octasphere_UV_LATLONG

par_octasphere_uv_mode

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static native void
npar_octasphere_get_counts(long config, long num_indices, long num_vertices)

Unsafe version of: get_counts

public static native void
npar_octasphere_get_counts(long config, int[] num_indices, int[] num_vertices)

Array version of: npar_octasphere_get_counts

public static native void
npar_octasphere_populate(long config, long mesh)

Unsafe version of: populate

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.

public static void
par_octasphere_get_counts(ParOctasphereConfig config, int[] num_indices, int[] num_vertices)

Array version of: get_counts

public static void
par_octasphere_populate(ParOctasphereConfig config, ParOctasphereMesh mesh)

Populates a pre-allocated mesh structure with indices and vertices.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

par_octasphere_NORMALS_SMOOTHback to summary
public static final int par_octasphere_NORMALS_SMOOTH

par_octasphere_normals_mode

par_octasphere_PAR_OCTASPHERE_MAX_SUBDIVISIONSback to summary
public static final int par_octasphere_PAR_OCTASPHERE_MAX_SUBDIVISIONS
par_octasphere_UV_LATLONGback to summary
public static final int par_octasphere_UV_LATLONG

par_octasphere_uv_mode

Constructor Detail

ParOctasphereback to summary
protected ParOctasphere()

Method Detail

npar_octasphere_get_countsback to summary
public static native void npar_octasphere_get_counts(long config, long num_indices, long num_vertices)

Unsafe version of: get_counts

npar_octasphere_get_countsback to summary
public static native void npar_octasphere_get_counts(long config, int[] num_indices, int[] num_vertices)

Array version of: npar_octasphere_get_counts

npar_octasphere_populateback to summary
public static native void npar_octasphere_populate(long config, long mesh)

Unsafe version of: populate

par_octasphere_get_countsback to summary
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.

par_octasphere_get_countsback to summary
public static void par_octasphere_get_counts(ParOctasphereConfig config, int[] num_indices, int[] num_vertices)

Array version of: get_counts

par_octasphere_populateback to summary
public static void par_octasphere_populate(ParOctasphereConfig config, ParOctasphereMesh mesh)

Populates a pre-allocated mesh structure with indices and vertices.