Search in sources :

Example 1 with PointCloudPLYWriter

use of org.jwildfire.create.tina.base.raster.PointCloudPLYWriter in project JWildfire by thargor6.

the class FlameRenderer method renderPointCloud.

public void renderPointCloud(PointCloudRenderInfo pPointCloudRenderInfo, String pFilename) {
    if (!flame.isRenderable())
        throw new RuntimeException("Point clouds can not be created of empty flames");
    renderInfo = pPointCloudRenderInfo.createRenderInfo();
    progressDisplayPhaseCount = 1;
    progressDisplayPhase = 0;
    double zmin = pPointCloudRenderInfo.getZmin() < pPointCloudRenderInfo.getZmax() ? pPointCloudRenderInfo.getZmin() : pPointCloudRenderInfo.getZmax();
    double zmax = pPointCloudRenderInfo.getZmin() < pPointCloudRenderInfo.getZmax() ? pPointCloudRenderInfo.getZmax() : pPointCloudRenderInfo.getZmin();
    Flame currFlame = flame.makeCopy();
    prepareFlameForPointCloudRendering(currFlame);
    initRasterSizes(pPointCloudRenderInfo.getImageWidth(), pPointCloudRenderInfo.getImageHeight());
    RasterPointCloud pcraster = new RasterPointCloud(zmin, zmax, pPointCloudRenderInfo.getMaxOctreeCellSize());
    raster = pcraster;
    raster.allocRaster(flame, rasterWidth, rasterHeight, flame.getSpatialOversampling(), flame.getSampleDensity());
    List<List<RenderPacket>> renderFlames = new ArrayList<List<RenderPacket>>();
    for (int t = 0; t < prefs.getTinaRenderThreads(); t++) {
        renderFlames.add(createRenderPackets(flame, flame.getFrame()));
    }
    iterate(0, 1, renderFlames, null);
    raster.finalizeRaster();
    List<PCPoint> points = pcraster.getGeneratedPoints();
    if (points != null && !points.isEmpty()) {
        if (Tools.getFileExt(pFilename).isEmpty()) {
            pFilename = pFilename + "." + Tools.FILEEXT_PLY;
        }
        if (Tools.FILEEXT_PLY.equalsIgnoreCase(Tools.getFileExt(pFilename))) {
            new PointCloudPLYWriter().writePLY(points, pFilename);
        } else if (Tools.FILEEXT_OBJ.equalsIgnoreCase(Tools.getFileExt(pFilename))) {
            new PointCloudOBJWriter().writeOBJ(points, pFilename);
        } else {
            throw new RuntimeException("Unvalid file extension <" + Tools.getFileExt(pFilename) + ">");
        }
    }
}
Also used : PointCloudPLYWriter(org.jwildfire.create.tina.base.raster.PointCloudPLYWriter) ArrayList(java.util.ArrayList) RasterPointCloud(org.jwildfire.create.tina.base.raster.RasterPointCloud) PCPoint(org.jwildfire.create.tina.base.raster.RasterPointCloud.PCPoint) ArrayList(java.util.ArrayList) List(java.util.List) Flame(org.jwildfire.create.tina.base.Flame) PCPoint(org.jwildfire.create.tina.base.raster.RasterPointCloud.PCPoint) PointCloudOBJWriter(org.jwildfire.create.tina.base.raster.PointCloudOBJWriter)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Flame (org.jwildfire.create.tina.base.Flame)1 PointCloudOBJWriter (org.jwildfire.create.tina.base.raster.PointCloudOBJWriter)1 PointCloudPLYWriter (org.jwildfire.create.tina.base.raster.PointCloudPLYWriter)1 RasterPointCloud (org.jwildfire.create.tina.base.raster.RasterPointCloud)1 PCPoint (org.jwildfire.create.tina.base.raster.RasterPointCloud.PCPoint)1