//Sets the frustum dimensions and sends them to all connected devices
    /// <summary>
    ///
    /// </summary>
    /// <param name="camera"></param>
    private void setFrustumSize(Camera camera)
    {
        //From: https://github.com/myuwbclasses/CSS451/blob/master/ClassExamples/Week9/Week9_Examples/
        //1.DrawCameraFrustum/Assets/Source/UISupport/CameraManipulation_DrawFrustum.cs

        float tanFOV = Mathf.Tan(Mathf.Deg2Rad * 0.5f * camera.fieldOfView);

        // near plane dimension
        float n = camera.nearClipPlane + NEAR_DISTANCE;
        float nearPlaneHeight = 2f * n * tanFOV;
        float nearPlaneWidth  = camera.aspect * nearPlaneHeight;

        frustum.SetNearPlaneSize(nearPlaneWidth, nearPlaneHeight);

        // far plane dimension
        float f = camera.nearClipPlane + CLIP_DISTANCE;
        float farPlaneHeight = 2f * f * tanFOV;
        float farPlaneWidth  = camera.aspect * farPlaneHeight;

        frustum.SetFarPlaneSize(farPlaneWidth, farPlaneHeight);

        frustum.m_FarDist = f - n;

        //Todo: Separate this networked portion from the frustum resizing code

        //Send these dimensions as an array to the connected desktop
        float[] sendArray = { nearPlaneWidth, nearPlaneHeight, farPlaneWidth, farPlaneHeight, frustum.m_FarDist };

        ARCameraASLObject.SendAndSetClaim(() =>
        {
            ARCameraASLObject.SendFloatArray(sendArray);
        });
    }
    /// <summary>
    /// Sets the frustum's size and sends it to all connected devices.
    /// </summary>
    /// <param name="camera"></param>
    private void SetFrustumSize(Camera camera)
    {
        m_Frustum.SetFrustumSize(camera, m_NEAR_DISTANCE, m_CLIP_DISTANCE);

        float tanFOV = Mathf.Tan(Mathf.Deg2Rad * 0.5f * camera.fieldOfView);

        // near plane dimension
        float n = camera.nearClipPlane + m_NEAR_DISTANCE;
        float nearPlaneHeight = 2f * n * tanFOV;
        float nearPlaneWidth  = camera.aspect * nearPlaneHeight;

        // far plane dimension
        float f = camera.nearClipPlane + m_CLIP_DISTANCE;
        float farPlaneHeight = 2f * f * tanFOV;
        float farPlaneWidth  = camera.aspect * farPlaneHeight;


        //Send these dimensions as an array to the connected desktop
        float[] sendArray = { nearPlaneWidth, nearPlaneHeight, farPlaneWidth, farPlaneHeight, m_Frustum.m_FarDist };

        m_ARCameraASLObject.SendAndSetClaim(() =>
        {
            m_ARCameraASLObject.SendFloatArray(sendArray);
        });
    }
Beispiel #3
0
    //Sends all parameters to all peers via SendFloatArray()
    private void SynchronizePeers()
    {
        float[] floatArray = { FPS, ImageWidth, ImageHeight, GCCollectFreq, -1.0f };

        if (IsStreaming)
        {
            floatArray[4] = 1;
        }
        else
        {
            floatArray[4] = 0;
        }

        aslObject.SendAndSetClaim(() =>
        {
            aslObject.SendFloatArray(floatArray);
        });
    }
    /// <summary>
    ///
    /// </summary>
    private void updateFrustumPosition()
    {
        Transform cameraTransform = getARCamera().transform;

        frustumASLObject.SendAndSetClaim(() =>
        {
            frustumASLObject.SendAndSetWorldPosition(cameraTransform.position);
            frustumASLObject.SendAndSetWorldRotation(cameraTransform.rotation);
        });
    }
    /// <summary>
    /// Updates the frustum's position and rotation across all connected devices.
    /// </summary>
    private void UpdateFrustumPosition()
    {
        Transform cameraTransform = getARCamera().transform;

        //This happens sometimes as it takes a bit for the camera to initialize
        if (cameraTransform == null)
        {
            return;
        }

        m_FrustumASLObject.SendAndSetClaim(() =>
        {
            m_FrustumASLObject.SendAndSetLocalPosition(cameraTransform.position);
            m_FrustumASLObject.SendAndSetLocalRotation(cameraTransform.rotation);
        });
    }