Examples of Mesh3D


Examples of org.jwildfire.transform.Mesh3D

  public static SimpleImage renderMesh(Mesh pMesh, int pWidth, int pHeight, double pPositionX, double pPositionY,
      double pSize, double pScaleZ, double pRotateAlpha, double pRotateBeta) {
    if (pMesh.getFaces().size() == 0)
      return new SimpleImage(pWidth, pHeight);

    Mesh3D mesh3d = new Mesh3D();
    mesh3d.setImageWidth(pWidth);
    mesh3d.setImageHeight(pHeight);

    int pCount = pMesh.getVertices().size();
    mesh3d.setPCount(pCount);
    double[] x = new double[pCount];
    double[] y = new double[pCount];
    double[] z = new double[pCount];
    double cx = pWidth / 2;
    double cy = pHeight / 2;
    int idx = 0;
    double xmin = pMesh.getPMin().x;
    double ymin = pMesh.getPMin().y;
    double zmin = pMesh.getPMin().z;
    double xmax = pMesh.getPMax().x;
    double ymax = pMesh.getPMax().y;
    double zmax = pMesh.getPMax().z;
    double size = (xmax - xmin + ymax - ymin + zmax - zmin) / 3.0;

    for (Point point : pMesh.getVertices()) {
      double currX = (point.x - xmin) / size * pWidth - cx;
      double currY = (point.y - ymin) / size * pHeight - cy;
      double currZ = pScaleZ * (point.z - zmin) / size * pHeight;
      x[idx] = currX;
      y[idx] = currY;
      z[idx] = currZ;
      idx++;
    }
    mesh3d.setX(x);
    mesh3d.setY(y);
    mesh3d.setZ(z);

    int fCount = pMesh.getFaces().size();
    mesh3d.setFCount(fCount);
    mesh3d.setU(null);
    mesh3d.setV(null);
    mesh3d.setTexture(null);

    int[] pp1 = new int[fCount];
    int[] pp2 = new int[fCount];
    int[] pp3 = new int[fCount];
    idx = 0;
    for (Face face : pMesh.getFaces()) {
      pp1[idx] = face.a;
      pp2[idx] = face.b;
      pp3[idx] = face.c;
      idx++;
    }
    mesh3d.setPP1(pp1);
    mesh3d.setPP2(pp2);
    mesh3d.setPP3(pp3);

    int color[] = new int[fCount];
    Pixel toolPixel = new Pixel();
    toolPixel.setRGB(225, 185, 160);
    int argb = toolPixel.getARGBValue();
    for (int c = 0; c < fCount; c++) {
      color[c] = argb;
    }
    mesh3d.setColor(color);

    PerspectiveTransformer trans = new PerspectiveTransformer();
    trans.setInputMesh3D(mesh3d);
    trans.setDoCam(true);
    trans.setCentreX(trans.getCentreX() * (1.0 + pPositionX));
View Full Code Here

Examples of org.jwildfire.transform.Mesh3D

      newHDRImg = inBuffer.getHDRImage().clone();
      transformer.transformImage(newHDRImg);
    }
    else if (inBuffer.getBufferType() == BufferType.MESH3D) {
      transformer.setStoreMesh3D(pStoreMesh3D);
      Mesh3D mesh3D = inBuffer.getMesh3D();
      newImg = new SimpleImage(mesh3D.getImageWidth(), mesh3D.getImageHeight());
      transformer.setInputMesh3D(mesh3D);
      transformer.transformImage(newImg);
    }
    Buffer outBuffer = null;
    if (newImg != null) {
View Full Code Here

Examples of toxi.geom.mesh.Mesh3D

    public final void box(AABB box) {
        mesh(box.toMesh(), false, 0);
    }

    public final void box(AABB box, boolean smooth) {
        Mesh3D mesh = box.toMesh();
        if (smooth) {
            mesh.computeVertexNormals();
        }
        mesh(mesh, smooth, 0);
    }
View Full Code Here

Examples of toxi.geom.mesh.Mesh3D

        cone(cone, res, true, true, smooth);
    }

    public final void cone(Cone cone, int res, boolean topClosed,
            boolean bottomClosed, boolean smooth) {
        Mesh3D mesh = cone.toMesh(res);
        if (smooth) {
            mesh.computeVertexNormals();
        }
        mesh(mesh, smooth, 0);
    }
View Full Code Here

Examples of toxi.geom.mesh.Mesh3D

        mesh(cylinder.toMesh(), false, 0);
    }

    public final void cylinder(AxisAlignedCylinder cylinder, int res,
            boolean smooth) {
        Mesh3D mesh = cylinder.toMesh(res, 0);
        if (smooth) {
            mesh.computeVertexNormals();
        }
        mesh(mesh, smooth, 0);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.