Commit 7dc13540 authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Resolve "Fix heatmap rendering without shaders"

parent bb75a1d0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ import java.util.stream.Collectors;
public class DatasetStats {

    private static final String DATA_DIR = "../analyst-data-antropologie/_ECA";
    private static final int MAX_SAMPLES = 100;
    private static final int MAX_SAMPLES = 1000;

    public static void main(String[] args) throws IOException {
        List<Path> faces = Files.list(new File(DATA_DIR).toPath())
+13 −9
Original line number Diff line number Diff line
@@ -10,6 +10,10 @@ import java.awt.*;
import java.util.List;
import java.util.Map;

import static com.jogamp.opengl.GL.GL_FRONT_AND_BACK;
import static com.jogamp.opengl.GL.GL_TRIANGLES;
import static com.jogamp.opengl.fixedfunc.GLLightingFunc.GL_DIFFUSE;

/**
 * Heatmap rendering.
 * 
@@ -79,24 +83,22 @@ public class HeatmapRenderer {
                            minValue,
                            distanceList.parallelStream()
                                    .mapToDouble(Double::doubleValue)
                                    .filter(v -> Double.isFinite(v))
                                    .filter(Double::isFinite)
                                    .min()
                                    .getAsDouble()
                                    .orElse(minValue)
                    );
                    maxValue = Math.max(
                            maxValue,
                            distanceList.parallelStream()
                                    .mapToDouble(Double::doubleValue)
                                    .filter(v -> Double.isFinite(v))
                                    .filter(Double::isFinite)
                                    .max()
                                    .getAsDouble()
                                    .orElse(maxValue)
                    );
                }
            }
        }
        
        //System.out.println(minDistance + "/" + maxDistance);
        
        for (MeshFacet f: model.getFacets()) {
            if (distances.containsKey(f)) {
                renderMeshFacet(gl, f, distances.get(f), saturation.get(f), minValue, maxValue, transparency);
@@ -122,9 +124,9 @@ public class HeatmapRenderer {
            double maxValue,
            float transparency) {

        gl.glBegin(GL2.GL_TRIANGLES); //vertices are rendered as triangles
        gl.glBegin(GL_TRIANGLES); //vertices are rendered as triangles

        // get the normal and tex coords indicies for face i
        // get the normal and tex coord. indices for face i
        for (int v = 0; v < facet.getCornerTable().getSize(); v++) {
            int vertexIndex = facet.getCornerTable().getRow(v).getVertexIndex();
            
@@ -145,7 +147,9 @@ public class HeatmapRenderer {
                    Color.BLACK;
            float[] ca = c.getComponents(null);
            ca[3] = transparency;
            gl.glColor4f(ca[0], ca[1], ca[2], ca[3]);

            gl.glColor4f(ca[0], ca[1], ca[2], ca[3]); // needed if SceneRenderer uses shaders
            gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, ca, 0); // needed if SceneRenderer doesn't use shaders

            gl.glVertex3d(vert.x, vert.y, vert.z);
        }