Commit 774790d7 authored by Mario Chromik's avatar Mario Chromik
Browse files

reworking screenPointToRay, testing projection using screenpointtoray

parent 41e2322b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ public class InteractiveMaskAction extends ControlPanelAction<InteractiveMaskPan
    private void project() {
        SurfaceMask2D mask = getControlPanel().getSurfaceMask();
        MaskProjector mp = new MaskProjector(mask);
        InteractiveMaskTaskNoParallel task = new InteractiveMaskTaskNoParallel(getCanvas(), mask.getPointsToProject(), getControlPanel().getSurfaceMaskPanel1().getPanelWidth(), getControlPanel().getSurfaceMaskPanel1().getPanelHeight());
        task.project();
        //getPrimaryFace().getMeshModel().getFacets().forEach(mp::visitMeshFacet);
    }

+5 −3
Original line number Diff line number Diff line
package cz.fidentis.analyst.gui.task.interactivemask;

import cz.fidentis.analyst.canvas.Canvas;
import cz.fidentis.analyst.canvas.ScreenPointToRay;
import cz.fidentis.analyst.data.face.HumanFace;
import cz.fidentis.analyst.data.mesh.MeshTriangle;
import cz.fidentis.analyst.data.ray.Ray;
@@ -66,10 +67,11 @@ public class InteractiveMaskTaskNoParallel {
    private HumanFace projectPoint(Point point) {
        Point normalizedPoint = new Point((int) point.getX() - (panelWidth/2) ,(int) point.getY() - (panelHeight/2));

        Ray ray = canvas.getSceneRenderer().castRayThroughPixel( normalizedPoint.x + canvas.getWidth() / 2,
                normalizedPoint.y + canvas.getHeight() / 2,
                canvas.getCamera());
        //Ray ray = canvas.getSceneRenderer().castRayThroughPixel( normalizedPoint.x + canvas.getWidth() / 2,
             //   normalizedPoint.y + canvas.getHeight() / 2,
             //   canvas.getCamera());

        Ray ray = ScreenPointToRay.convert(normalizedPoint.x + canvas.getWidth() / 2, normalizedPoint.y + canvas.getHeight() / 2, canvas.getWidth(), canvas.getHeight(),   canvas.getCamera());
        Pair<HumanFace, RayIntersection> closestFace = canvas.getScene()
                .getDrawableFaces()
                .stream()
+2 −2
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ public class ScreenPointToRay {
    private static Point3d calculatePositionOnNearPlane(int screenX, int screenY, int width, int height) {
        double x = (2.0 * screenX) / width - 1.0;
        double y = 1.0 - (2.0 * screenY) / height;
        double z = Camera.Z_NEAR;
        double z = 1.0;
        
        return new Point3d(x, y, z);
    }
@@ -87,7 +87,7 @@ public class ScreenPointToRay {
        camPos.add(center);
        Vector3d camDir = new Vector3d();
        camDir.normalize(camPos);
        camDir.scale(5);
        camDir.scale(1);
        
        return camDir;
    }