Top Description Constructors Methods
org.lwjgl.util.par

public Class ParShapes

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

Bindings to par_shapes.h, a simple C library for creation and manipulation of triangle meshes.

The par_shapes API is divided into three sections:

For our purposes, a "mesh" is a list of points and a list of triangles; the former is a flattened list of three-tuples (32-bit floats) and the latter is also a flattened list of three-tuples (16-bit uints). Triangles are always oriented such that their front face winds counter-clockwise.

Depending on which generator function is used, meshes may or may not contain normals and texture coordinates (one per vertex).

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static native void
public static native void
npar_shapes__connect(long scene, long cylinder, int slices)

public static native long
npar_shapes_clone(long mesh, long target)

Unsafe version of: clone

public static native void
npar_shapes_compute_aabb(long mesh, long aabb)

Unsafe version of: compute_aabb

public static native void
npar_shapes_compute_aabb(long mesh, float[] aabb)

Array version of: npar_shapes_compute_aabb

public static native void
npar_shapes_compute_normals(long mesh)

Unsafe version of: compute_normals

public static native long
npar_shapes_create_cone(int slices, int stacks)

Unsafe version of: create_cone

public static native long
public static native long
npar_shapes_create_cylinder(int slices, int stacks)

Unsafe version of: create_cylinder

public static native long
npar_shapes_create_disk(float radius, int slices, long center, long normal)

Unsafe version of: create_disk

public static native long
npar_shapes_create_disk(float radius, int slices, float[] center, float[] normal)

Array version of: npar_shapes_create_disk

public static native long
public static native long
public static native long
npar_shapes_create_hemisphere(int slices, int stacks)

Unsafe version of: create_hemisphere

public static native long
public static native long
npar_shapes_create_klein_bottle(int slices, int stacks)

Unsafe version of: create_klein_bottle

public static native long
npar_shapes_create_lsystem(long program, int slices, int maxdepth, long rand_fn, long context)

Unsafe version of: create_lsystem

public static native long
public static native long
npar_shapes_create_parametric_disk(int slices, int stacks)

Unsafe version of: create_parametric_disk

public static native long
npar_shapes_create_parametric_sphere(int slices, int stacks)

Unsafe version of: create_parametric_sphere

public static native long
npar_shapes_create_plane(int slices, int stacks)

Unsafe version of: create_plane

public static native long
npar_shapes_create_rock(int seed, int nsubdivisions)

Unsafe version of: create_rock

public static native long
public static native long
public static native long
npar_shapes_create_torus(int slices, int stacks, float radius)

Unsafe version of: create_torus

public static native long
npar_shapes_create_trefoil_knot(int slices, int stacks, float radius)

Unsafe version of: create_trefoil_knot

public static native void
npar_shapes_export(long mesh, long objfile)

Unsafe version of: export

public static native void
npar_shapes_free_mesh(long mesh)

Unsafe version of: free_mesh

public static native void
npar_shapes_invert(long mesh, int startface, int nfaces)

Unsafe version of: invert

public static native void
npar_shapes_merge(long dst, long src)

Unsafe version of: merge

public static native void
npar_shapes_merge_and_free(long dst, long src)

Unsafe version of: merge_and_free

public static native void
npar_shapes_remove_degenerate(long mesh, float minarea)

Unsafe version of: remove_degenerate

public static native void
npar_shapes_rotate(long mesh, float radians, long axis)

Unsafe version of: rotate

public static native void
npar_shapes_rotate(long mesh, float radians, float[] axis)

Array version of: npar_shapes_rotate

public static native void
npar_shapes_scale(long mesh, float x, float y, float z)

Unsafe version of: scale

public static native void
npar_shapes_translate(long mesh, float x, float y, float z)

Unsafe version of: translate

public static native void
npar_shapes_unweld(long mesh, boolean create_indices)

Unsafe version of: unweld

public static native long
npar_shapes_weld(long mesh, float epsilon, long mapping)

Unsafe version of: weld

public static native long
npar_shapes_weld(long mesh, float epsilon, int[] mapping)

Array version of: npar_shapes_weld

public static void
public static void
par_shapes__connect(ParShapesMesh scene, ParShapesMesh cylinder, int slices)

public static ParShapesMesh
par_shapes_clone(ParShapesMesh
the mesh to copy
mesh
,
ParShapesMesh
the target mesh
target
)

Makes a deep copy of a mesh.

public static void
par_shapes_compute_aabb(ParShapesMesh
the mesh to query
mesh
,
FloatBuffer
a pointer to an array of 6 floats in which the AABB will be written
aabb
)

Takes a pointer to 6 floats and sets them to min xyz, max xyz.

public static void
par_shapes_compute_aabb(ParShapesMesh mesh, float[] aabb)

Array version of: compute_aabb

public static void
par_shapes_compute_normals(ParShapesMesh
the mesh
mesh
)

Computes smooth normals by averaging adjacent facet normals.

public static ParShapesMesh
par_shapes_create_cone(int
the number of slices
slices
,
int
the number of stacks
stacks
)

Creates a cone similar to create_cylinder but the radius diminishes to zero as Z increases.

public static ParShapesMesh
par_shapes_create_cube()

Generates points for a cube that fits in the unit sphere.

public static ParShapesMesh
par_shapes_create_cylinder(int
the number of slices
slices
,
int
the number of stacks
stacks
)

Creates a cylinder that sits on the Z=0 plane using the given tessellation levels across the UV domain.

public static ParShapesMesh
par_shapes_create_disk(float
the disk radius
radius
,
int
the number of slices
slices
,
FloatBuffer
the disk center
center
,
FloatBuffer
the disk normal
normal
)

Generates an orientable disk shape in 3-space.

public static ParShapesMesh
par_shapes_create_disk(float radius, int slices, float[] center, float[] normal)

Array version of: create_disk

public static ParShapesMesh
par_shapes_create_dodecahedron()

Generates points for a 12-sided polyhedron that fits in the unit sphere.

public static ParShapesMesh
par_shapes_create_empty()

Creates an empty shape.

public static ParShapesMesh
par_shapes_create_hemisphere(int
the number of slices
slices
,
int
the number of stacks
stacks
)

Creates a hemisphere mesh.

public static ParShapesMesh
par_shapes_create_icosahedron()

Generates points for a 20-sided polyhedron that fits in the unit sphere.

public static ParShapesMesh
par_shapes_create_klein_bottle(int
the number of slices
slices
,
int
the number of stacks
stacks
)

Creates a klein bottle mesh.

public static ParShapesMesh
par_shapes_create_lsystem(ByteBuffer
the list of command-argument pairs
program
,
int
the number of slices
slices
,
int
the maximum depth
maxdepth
,
ParShapesRandFnI
is expected to return a value between 0 and 1, or can be NULL (in which case (float) rand() / RAND_MAX will be used)
rand_fn
,
long
passed unmodified to rand_fn
context
)

Creates trees or vegetation by executing a recursive turtle graphics program.

public static ParShapesMesh
par_shapes_create_lsystem(CharSequence
the list of command-argument pairs
program
,
int
the number of slices
slices
,
int
the maximum depth
maxdepth
,
ParShapesRandFnI
is expected to return a value between 0 and 1, or can be NULL (in which case (float) rand() / RAND_MAX will be used)
rand_fn
,
long
passed unmodified to rand_fn
context
)

Creates trees or vegetation by executing a recursive turtle graphics program.

public static ParShapesMesh
par_shapes_create_octahedron()

Generates points for an 8-sided polyhedron that fits in the unit sphere.

public static ParShapesMesh
par_shapes_create_parametric_disk(int
the number of slices
slices
,
int
the number of stacks
stacks
)

Creates a disk of radius 1.0 with texture coordinates and normals by squashing a cone flat on the Z=0 plane.

public static ParShapesMesh
par_shapes_create_parametric_sphere(int
the number of slices
slices
,
int
the number of stacks
stacks
)

Creates a sphere with texture coordinates and small triangles near the poles.

public static ParShapesMesh
par_shapes_create_plane(int
the number of slices
slices
,
int
the number of stacks
stacks
)

Creates a plane mesh.

public static ParShapesMesh
par_shapes_create_rock(int
a seed value
seed
,
int
the number of subdivisions
nsubdivisions
)

Generates a rock shape that sits on the Y=0 plane, and sinks into it a bit.

public static ParShapesMesh
par_shapes_create_subdivided_sphere(int
the number of subdivisions
nsubdivisions
)

Approximates a sphere with a subdivided icosahedron, which produces a nice distribution of triangles, but no texture coordinates.

public static ParShapesMesh
par_shapes_create_tetrahedron()

Generates points for a 4-sided polyhedron that fits in the unit sphere.

public static ParShapesMesh
par_shapes_create_torus(int
the number of slices
slices
,
int
the number of stacks
stacks
,
float
the torus radius
radius
)

Creates a donut that sits on the Z=0 plane with the specified inner radius.

public static ParShapesMesh
par_shapes_create_trefoil_knot(int
the number of slices
slices
,
int
the number of stacks
stacks
,
float radius)

Creates a trefoil knot mesh.

public static void
par_shapes_export(ParShapesMesh
the mesh to export
mesh
,
ByteBuffer
the OBJ file path
objfile
)

Dumps out a text file conforming to the venerable OBJ format.

public static void
par_shapes_export(ParShapesMesh
the mesh to export
mesh
,
CharSequence
the OBJ file path
objfile
)

Dumps out a text file conforming to the venerable OBJ format.

public static void
par_shapes_free_mesh(ParShapesMesh
the mesh to free
mesh
)

Frees the specified ParShapesMesh structure.

public static void
par_shapes_invert(ParShapesMesh
the mesh to reverse
mesh
,
int
the index of the first face to reverse
startface
,
int
the number of faces to reverse
nfaces
)

Reverses the winding of a run of faces.

public static void
par_shapes_merge(ParShapesMesh
the destination mesh
dst
,
ParShapesMesh
the source mesh
src
)

Merges two shapes.

public static void
par_shapes_merge_and_free(ParShapesMesh
the destination mesh
dst
,
ParShapesMesh
the source mesh
src
)

Merges two shapes and frees the source shape.

public static void
par_shapes_remove_degenerate(ParShapesMesh
the mesh to cleanup
mesh
,
float
triangles with an area below this value will be removed
minarea
)

Removes all triangles whose area is less than minarea.

public static void
par_shapes_rotate(ParShapesMesh
the mesh to rotate
mesh
,
float
the rotation angle, in radians
radians
,
FloatBuffer
the rotation axis
axis
)

Rotates the specified mesh.

public static void
par_shapes_rotate(ParShapesMesh mesh, float radians, float[] axis)

Array version of: rotate

public static void
par_shapes_scale(ParShapesMesh
the mesh to scale
mesh
,
float
the X axis scale factor
x
,
float
the Y axis scale factor
y
,
float
the Z axis scale factor
z
)

Scales the specified mesh.

public static native void
public static native void
public static void
par_shapes_translate(ParShapesMesh
the mesh to translate
mesh
,
float
the X axis translation amount
x
,
float
the Y axis translation amount
y
,
float
the Z axis translation amount
z
)

Translates the specified mesh.

public static void
par_shapes_unweld(ParShapesMesh
the mesh to unweld
mesh
,
boolean
if an index buffer should be generated
create_indices
)

Dereferences the entire index buffer and replaces the point list.

public static ParShapesMesh
par_shapes_weld(ParShapesMesh
the mesh to weld
mesh
,
float
the maximum distance to consider when welding vertices
epsilon
,
IntBuffer
null, or a pointer to npoints 32-bit integers, which gets filled with the mapping from old vertex indices to new indices
mapping
)

Merges colocated verts, builds a new index buffer, and returns the optimized mesh.

public static ParShapesMesh
par_shapes_weld(ParShapesMesh mesh, float epsilon, int[] mapping)

Array version of: weld

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait