@Override
  public void addMesh(double[][][] vertices, double[][][] normals, AppearanceState appearance) {

    if (vertices.length == 0) return;
    int l = vertices[0].length;
    for (int i = 0; i < vertices.length; ++i)
      if (vertices[i].length == 0 || vertices[i].length != l) return;

    SceneGraphComponent sgc = SceneGraphUtility.createFullSceneGraphComponent();
    QuadMeshFactory qmf = new QuadMeshFactory();

    qmf.setVLineCount(vertices.length);
    qmf.setULineCount(l);

    qmf.setClosedInUDirection(false);
    qmf.setClosedInVDirection(false);
    qmf.setVertexCoordinates(vertices);
    if (normals == null) {
      qmf.setGenerateFaceNormals(true);
      // qmf.setGenerateVertexNormals(true);
    } else {
      qmf.setVertexNormals(normals);
    }
    qmf.setGenerateTextureCoordinates(false);
    qmf.setGenerateEdgesFromFaces(true);
    qmf.setEdgeFromQuadMesh(true);

    Color[] colors = new Color[vertices.length * l];
    for (int i = 0; i < vertices.length * l; ++i) {
      colors[i] = appearance.getColor();
    }

    qmf.setVertexColors(colors);

    qmf.update();
    sgc.setGeometry(qmf.getGeometry());

    DefaultGeometryShader dgs =
        ShaderUtility.createDefaultGeometryShader(sgc.getAppearance(), true);

    dgs.setShowLines(true);
    dgs.setShowPoints(true);
    dgs.setShowFaces(true);

    dgs.createPointShader("my");

    MyLineShader ls = (MyLineShader) dgs.createLineShader("my");
    ls.setDiffuseColor(appearance.getColor());
    ls.setLineType(0);

    DefaultPolygonShader dps = (DefaultPolygonShader) dgs.getPolygonShader();

    dps.setTransparency(1 - appearance.getOpacity());

    sceneMeshes.addChild(sgc);
  }
 private void addLineObject(
     double x1,
     double y1,
     double z1,
     double x2,
     double y2,
     double z2,
     AppearanceState appearance,
     int type) {
   lineCoordinates.add(new double[] {x1, y1, z1});
   lineCoordinates.add(new double[] {x2, y2, z2});
   lineColors.add(appearance.getColor());
   lineIndices.add(lineCoordinates.size() - 2);
   lineIndices.add(lineCoordinates.size() - 1);
   lineSizes.add(appearance.getSize());
   lineTypes.add(type);
 }
 @Override
 public void addCircle(
     double cx,
     double cy,
     double cz,
     double nx,
     double ny,
     double nz,
     double radius,
     AppearanceState appearance) {
   circleCenters.add(new double[] {cx, cy, cz});
   circleNormals.add(new double[] {nx, ny, nz});
   circleColors.add(appearance.getColor());
   circleRadii.add(radius);
 }
 @Override
 public void addPolygon(double[][] vertices, AppearanceState appearance) {
   polygonVertices.add(vertices);
   polygonColors.add(appearance.getColor());
   polygonTotalVertexCount += vertices.length;
 }
 /* (non-Javadoc)
  * @see de.tum.in.jrealityplugin.Cindy3DViewer#addPoint(double, double, double)
  */
 @Override
 public void addPoint(double x, double y, double z, AppearanceState appearance) {
   pointCoordinates.add(new double[] {x, y, z});
   pointColors.add(appearance.getColor());
   pointSizes.add(appearance.getSize());
 }