public final class Primitives
- Object
- Primitives
Factory helpers that build common
Mesh primitives. Every primitive uses the
VertexFormat.POSITION_NORMAL_TEXCOORD layout so it can be drawn with any of
the built in materials, lit or unlit, textured or not.Methods
public static Mesh cube(GraphicsDevice device, float size) | Builds a unit-normal axis aligned cube centered at the origin with the supplied edge length. |
public static Mesh quad(GraphicsDevice device, float size) | Builds a flat quad in the XY plane centered at the origin facing +Z. |
public static Mesh sphere(GraphicsDevice device, float radius, int latBands, int lonBands, boolean insideOut) | Builds a UV sphere centered at the origin with equirectangular texture coordinates: u wraps the longitude from 0 to 1 and v runs from 0 at the north pole (+Y) to 1 at the south pole. |
public static Mesh sphere(float radius, int latBands, int lonBands, boolean insideOut) | Builds a UV sphere without a GraphicsDevice, allocating the buffers directly. |
Inherited methods
Method details
cube
public static Mesh cube(GraphicsDevice device, float size)Builds a unit-normal axis aligned cube centered at the origin with the
supplied edge length. Each face has its own normals and a full 0..1
texture coordinate quad.
Parameters
deviceGraphicsDevice- the device that allocates the buffers
sizefloat- the edge length of the cube
Returns
an indexed triangle mesh
quad
public static Mesh quad(GraphicsDevice device, float size)Builds a flat quad in the XY plane centered at the origin facing +Z.
Parameters
deviceGraphicsDevice- the device that allocates the buffers
sizefloat- the edge length of the quad
Returns
an indexed triangle mesh
sphere
public static Mesh sphere(GraphicsDevice device, float radius, int latBands, int lonBands, boolean insideOut)Builds a UV sphere centered at the origin with equirectangular texture
coordinates:
u wraps the longitude from 0 to 1 and v runs from 0 at
the north pole (+Y) to 1 at the south pole. This is the mapping used by
360 degree panorama images. The seam column and the pole rows duplicate
vertices so texture coordinates stay continuous. For an inside-out
sphere the u direction is reversed so a panorama viewed from the
center reads correctly instead of mirror-imaged.Parameters
deviceGraphicsDevice- the device that allocates the buffers
radiusfloat- the sphere radius
latBandsint- the number of latitude subdivisions, at least 2
lonBandsint- the number of longitude subdivisions, at least 3
insideOutboolean- when true the normals point toward the center and the winding is flipped so the inner surface faces the viewer, as needed when rendering a panorama from inside the sphere
Returns
an indexed triangle mesh
sphere
public static Mesh sphere(float radius, int latBands, int lonBands, boolean insideOut)Builds a UV sphere without a
GraphicsDevice, allocating the buffers
directly. Behaves exactly like
sphere(GraphicsDevice, float, int, int, boolean); useful for preparing
geometry off the render thread or handing meshes to non GPU consumers
such as the AR content pipeline.Parameters
radiusfloat- the sphere radius
latBandsint- the number of latitude subdivisions, at least 2
lonBandsint- the number of longitude subdivisions, at least 3
insideOutboolean- when true the normals point toward the center and the winding is flipped
Returns
an indexed triangle mesh