Class Primitives

java.lang.Object
com.codename1.gpu.Primitives

public final class Primitives extends Object
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.
  • 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
      • device: the device that allocates the buffers

      • size: 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
      • device: the device that allocates the buffers

      • size: the edge length of the quad

      Returns

      an indexed triangle mesh