Ejemplo n.º 1
0
    /// <summary>
    /// Shifts the info window to the display on the given index
    /// </summary>
    /// <param name="selectedIndex">index of the display to set display on</param>
    private void InfoDisplayShift(int selectedIndex)
    {
        PhysicalDisplayCalibration currentDisplay = this.allOptions[selectedIndex].calibration;

        if (currentDisplay == null || this.infoDisplayInstance == null)
        {
            return;
        }

        if (currentDisplay.GetDisplayWarpsValues().Count() > 0)
        {
            this.SetInfoDisplay(infoDisplayInstance.gameObject, currentDisplay.GetDisplayWarpsValues().First().GetDewarpGameObject().transform);
            this.infoDisplayInstance.SetText(this.calibrationType.ToString());
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Moves a vertex by index in a direction (-1, +1 or 0) by a factor delta.
    /// A direction can be Vector2(-1,0); move the display in a negative X direction.
    /// The factor delta sets the "speed/distance" of the movement.
    /// </summary>
    /// <param name="direction">the direction to move in</param>
    /// <param name="delta">movement factor</param>
    /// <param name="selectedIndex">the display to move vertex on</param>
    /// <param name="vertexIndex">the vertex to move</param>
    private void LocalShift(Vector2 direction, float delta, int selectedIndex, int vertexIndex)
    {
        PhysicalDisplayCalibration lastCalibration = allOptions[lastSelectedIndex].calibration;

        lastCalibration.HideVisualMarker();
        PhysicalDisplayCalibration calibration = allOptions[selectedIndex].calibration;

        calibration.SetVisualMarkerVertextPoint(vertexIndex);

        Debug.Log("RealtimeCalibration: LocalShift called " + delta + ", " + selectedIndex + ", " + vertexIndex);

        MeshFilter lastWarpedFilter = null;

        foreach (Dewarp dewarp in calibration.GetDisplayWarpsValues())
        {
            MeshFilter meshFilter = dewarp.GetDewarpMeshFilter();
            lastWarpedFilter = meshFilter;
            Vector3[] verts = meshFilter.sharedMesh.vertices;
            // verts[vertexIndex] = new Vector3(verts[vertexIndex].x + direction.x * delta, verts[vertexIndex].y + direction.y * delta, verts[vertexIndex].z);

            Dictionary <int, float> vertsToShift = this.getIndexesSurrounding(dewarp.xSize, vertexIndex);
            foreach (var ind in vertsToShift)
            {
                verts[ind.Key] = new Vector3(verts[ind.Key].x + (direction.x * delta * ind.Value), verts[ind.Key].y + (direction.y * delta * ind.Value), verts[ind.Key].z);
            }

            meshFilter.sharedMesh.vertices = verts;
            meshFilter.sharedMesh.UploadMeshData(false);
            meshFilter.mesh.RecalculateBounds();
            meshFilter.mesh.RecalculateTangents();
        }

        calibration.UpdateMeshPositions(lastWarpedFilter?.sharedMesh.vertices);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Assign all point positions based on positions of the four corner points;
    /// positions are linearly interpolated
    /// </summary>
    public void LocalInterpolateFromCorners(int selectedIndex)
    {
        PhysicalDisplayCalibration lastCalibration = allOptions[lastSelectedIndex].calibration;

        lastCalibration.HideVisualMarker();
        PhysicalDisplayCalibration calibration = allOptions[selectedIndex].calibration;

        calibration.SetVisualMarkerVertextPoint(vertexIndex);

        Debug.Log("RealtimeCalibration: InterpolateFromCorners called, selectedIndex " + selectedIndex);

        MeshFilter lastWarpedFilter = null;

        foreach (Dewarp dewarp in calibration.GetDisplayWarpsValues())
        {
            MeshFilter meshFilter = dewarp.GetDewarpMeshFilter();
            lastWarpedFilter = meshFilter;
            Vector3[] verts = meshFilter.sharedMesh.vertices;
            // verts[vertexIndex] = new Vector3(verts[vertexIndex].x + direction.x * delta, verts[vertexIndex].y + direction.y * delta, verts[vertexIndex].z);

            Vector3 corner_0 = verts[0];
            Vector3 corner_1 = verts[7];
            Vector3 corner_2 = verts[63];
            Vector3 corner_3 = verts[56];
            for (int x = 0; x < 8; x++)
            {
                float   xfac   = x / 7.0f;
                Vector3 xmix_0 = corner_0 * (1.0f - xfac) + corner_1 * xfac;
                Vector3 xmix_1 = corner_3 * (1.0f - xfac) + corner_2 * xfac;
                for (int y = 0; y < 8; y++)
                {
                    float yfac = y / 7.0f;
                    verts[y * 8 + x] = xmix_0 * (1.0f - yfac) + xmix_1 * yfac;
                }
            }

            meshFilter.sharedMesh.vertices = verts;
            meshFilter.sharedMesh.UploadMeshData(false);
            meshFilter.mesh.RecalculateBounds();
            meshFilter.mesh.RecalculateTangents();
        }

        calibration.UpdateMeshPositions(lastWarpedFilter?.sharedMesh.vertices);
    }