Class MeshBuilder

java.lang.Object
com.here.NativeBase
com.here.sdk.mapview.MeshBuilder
Direct Known Subclasses:
QuadMeshBuilder, TriangleMeshBuilder

public class MeshBuilder extends NativeBase

Builder for meshes. Such meshes can contain different kinds of primitives, like quads or triangles. Both primitives support adding texture coordinates that are mapped to the corners of the primitives. See TriangleMeshBuilder and QuadMeshBuilder for more details.

Note: Normals cannot be set as they are not necessary when using the MeshBuilder.

Example how to build a cube using QuadMeshBuilder

    Mesh cube = new MeshBuilder()
         .quad(new Point3D(0.5, 0.5, 0.5),
             new Point3D(-0.5, 0.5, 0.5),
             new Point3D(0.5, -0.5, 0.5),
             new Point3D(-0.5, -0.5, 0.5))
         .quad(new Point3D(-0.5, 0.5, -0.5),
             new Point3D(0.5, 0.5, -0.5),
             new Point3D(-0.5, -0.5, -0.5),
             new Point3D(0.5, -0.5, -0.5))
         .quad(new Point3D(0.5, 0.5, -0.5),
             new Point3D(0.5, 0.5, 0.5),
             new Point3D(0.5, -0.5, -0.5),
             new Point3D(0.5, -0.5, 0.5))
         .quad(new Point3D(-0.5, 0.5, 0.5),
             new Point3D(-0.5, 0.5, -0.5),
             new Point3D(-0.5, -0.5, 0.5),
             new Point3D(-0.5, -0.5, -0.5))
         .quad(new Point3D(-0.5, 0.5, 0.5),
             new Point3D(0.5, 0.5, 0.5),
             new Point3D(-0.5, 0.5, -0.5),
             new Point3D(0.5, 0.5, -0.5))
         .quad(new Point3D(0.5, -0.5, 0.5),
             new Point3D(-0.5, -0.5, 0.5),
             new Point3D(0.5, -0.5, -0.5),
             new Point3D(-0.5, -0.5, -0.5))
         .build();
 
  • Constructor Details

    • MeshBuilder

      public MeshBuilder()

      Constructs an instance of MeshBuilder.

  • Method Details

    • triangle

      @NonNull public TriangleMeshBuilder triangle(@NonNull Point3D a, @NonNull Point3D b, @NonNull Point3D c)

      Adds a triangle.

      Triangle visibility is determined via back-face culling. Front-facing triangles are expected to have counter-clockwise winding.

      Parameters:
      a -

      First vertex of the triangle.

      b -

      Second vertex of the triangle.

      c -

      Third vertex of the triangle.

      Returns:

      A TriangleMeshBuilder instance.

    • quad

      @NonNull public QuadMeshBuilder quad(@NonNull Point3D a, @NonNull Point3D b, @NonNull Point3D c, @NonNull Point3D d)

      Adds a quad. Internally, this will be transformed into triangles abc and bdc.

      Triangle visibility is determined via back-face culling. Front-facing triangles are expected to have counter-clockwise winding.

      Parameters:
      a -

      First vertex of quad.

      b -

      Second vertex of the quad.

      c -

      Third vertex of the quad.

      d -

      Fourth vertex of the quad.

      Returns:

      A QuadMeshBuilder instance.

    • build

      @Nullable public Mesh build()
      Returns:

      mesh containing added geometry or 'null' if no geometry was added.