m3g04.mesh
Class MeshFactory3D

java.lang.Object
  extended by m3g04.mesh.MeshFactory3D

public class MeshFactory3D
extends java.lang.Object

Factory methods for 3D meshes.

Author:
Claus Hoefele

Constructor Summary
private MeshFactory3D()
          Constructor has private access because class contains static methods exclusively.
 
Method Summary
static javax.microedition.m3g.Mesh createCube(boolean addColors, boolean addNormals, boolean addTexCoords)
          Creates a cube with three separate vertices for each corner.
static javax.microedition.m3g.Mesh createCylinder(int slices, boolean addNormals, boolean addTexCoords)
          Creates a cylinder with a radius of one unit and a height of two units.
static javax.microedition.m3g.Mesh createMinimalCube()
          Creates a cube with one vertex per corner.
static javax.microedition.m3g.Mesh createSphere(int slices, int stacks, boolean addNormals, boolean addTexCoords)
          Creates a sphere that's subdivided with the given number of slices and stacks.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MeshFactory3D

private MeshFactory3D()
Constructor has private access because class contains static methods exclusively.

Method Detail

createMinimalCube

public static javax.microedition.m3g.Mesh createMinimalCube()
Creates a cube with one vertex per corner. The edge length is two units, the center of the cube is at the origin.

Returns:
cube mesh.

createCube

public static javax.microedition.m3g.Mesh createCube(boolean addColors,
                                                     boolean addNormals,
                                                     boolean addTexCoords)
Creates a cube with three separate vertices for each corner. The edge length is two units; the center of the cube is at the origin.

Parameters:
addColors - true to give each side a fixed color.
addNormals - true to generate normals, false otherwise.
addTexCoords - true to generate texture coordinates, false otherwise.
Returns:
cube mesh.

createCylinder

public static javax.microedition.m3g.Mesh createCylinder(int slices,
                                                         boolean addNormals,
                                                         boolean addTexCoords)
Creates a cylinder with a radius of one unit and a height of two units. The cylinder's center is at the origin; the top and bottom caps are parallel to the x-z plane. The minimum number of slices is two.

Parameters:
slices - subdivisions along the longitude.
addNormals - true to generate normals, false otherwise.
addTexCoords - true to generate texture coordinates, false otherwise.
Returns:
cylinder.

createSphere

public static javax.microedition.m3g.Mesh createSphere(int slices,
                                                       int stacks,
                                                       boolean addNormals,
                                                       boolean addTexCoords)
Creates a sphere that's subdivided with the given number of slices and stacks. The minimum number is two and three for slices and stacks respectively. The sphere has a radius of one unit and the sphere's center is at the origin.

Parameters:
slices - subdivisions along the longitude.
stacks - subdivisions along the latitude.
addNormals - true to generate normals, false otherwise.
addTexCoords - true to generate texture coordinates, false otherwise.
Returns:
sphere.