Пример #1
0
 virtual protected void HandleOnUpdateFrameInfo(SVFFrameInfo frameInfo)
 {
     if (null != OnUpdateFrameInfoNotify)
     {
         OnUpdateFrameInfoNotify(this, frameInfo);
     }
 }
Пример #2
0
 private void PauseOnFrame(HoloVideoObject sender, SVFFrameInfo frameInfo)
 {
     if (ShouldPauseAfterPlay && frameInfo.frameId >= PauseFrameID)
     {
         Pause();
         ShouldPauseAfterPlay = false;
     }
 }
Пример #3
0
 public bool GetHCapObjectFrameInfo(ref SVFFrameInfo frameInfo)
 {
     if (s_logstack)
     {
         logger.Log("[INTEROP]GetHCapObjectFrameInfo");
     }
     if (instanceId == InvalidID)
     {
         return(false);
     }
     return(InteropGetHCapObjectFrameInfo(instanceId, ref frameInfo));
 }
Пример #4
0
    public void Cleanup()
    {
        isInitialized = false;

        if (pluginInterop != null)
        {
            pluginInterop.Dispose();
            pluginInterop = null;

            Url           = "";
            fileInfo      = new SVFFileInfo();
            openInfo      = new SVFOpenInfo();
            lastFrameInfo = new SVFFrameInfo();
        }
    }
Пример #5
0
    public void Update()
    {
        if (!isInitialized || pluginInterop == null || !isPlaying)
        {
            return;
        }

        Update3DAudio();

        // pass a temp frame info struct here so we don't trash information in lastFrameInfo when GetHCapObjectFrameInfo returns a bunch of zeros.
        SVFFrameInfo frameInfo = new SVFFrameInfo();

        if (pluginInterop.GetHCapObjectFrameInfo(ref frameInfo))
        {
            // if we didn't get any useful frame info, don't overwrite our previous values (likely initial file-level values)
            if (frameInfo.textureWidth > 0 && frameInfo.textureHeight > 0)
            {
                lastFrameInfo = frameInfo;

                SVFFrameInfo adjustedFrameInfo = lastFrameInfo;

                if ((adjustedFrameInfo.maxX - adjustedFrameInfo.minX) > 0.0f ||
                    (adjustedFrameInfo.maxY - adjustedFrameInfo.minY) > 0.0f ||
                    (adjustedFrameInfo.maxZ - adjustedFrameInfo.minZ) > 0.0f)
                {
                    Vector3 min = new Vector3((float)adjustedFrameInfo.minX, (float)adjustedFrameInfo.minY, (float)adjustedFrameInfo.minZ);
                    Vector3 max = new Vector3((float)adjustedFrameInfo.maxX, (float)adjustedFrameInfo.maxY, (float)adjustedFrameInfo.maxZ);
                    localSpaceBounds.SetMinMax(min, max);

                    HVCollider.center      = localSpaceBounds.center;
                    HVCollider.size        = localSpaceBounds.size;
                    meshFilter.mesh.bounds = localSpaceBounds;
                }

#if UNITY_PS4 && !UNITY_EDITOR
                UpdateUnityBuffers(false, true);
#else
                UpdateUnityBuffers();
#endif
                HandleOnUpdateFrameInfo(adjustedFrameInfo);

                // here is the logic for checking for end of stream in a
                // portable way. CheckEOS is used on Android because there
                // are circumstances in which the android plugin can decode the
                // EOS frame, rewind, and decode a beginning frame, before Unity
                // asks for another frame, causing it to miss the EOS frame.
                // This behavior does not occur on Desktop.
#if UNITY_ANDROID && !UNITY_EDITOR
                if (pluginInterop.CheckEOS())
#else
                if (lastFrameInfo.isEOS)
#endif
                {
                    if (null != OnEndOfStreamNotify)
                    {
                        OnEndOfStreamNotify(this);
                    }
                }
            }
        }
        else
        {
            logger.Log("GetHCapObjectFrameInfo returned false");
        }
#if ENABLE_NATIVE_LOGGING
        string[] trace = pluginInterop.GetTrace();
        if (null != trace)
        {
            foreach (var line in trace)
            {
                logger.Log(line);
            }
        }
#endif
    }
Пример #6
0
 private static extern bool InteropGetHCapObjectFrameInfo(int instanceId, ref SVFFrameInfo info);
Пример #7
0
    public void Update()
    {
        if (isInitialized)
        {
            Update3DAudio();
            if (pluginInterop.GetHCapObjectFrameInfo(ref lastFrameInfo))
            {
                SVFFrameInfo adjustedFrameInfo = lastFrameInfo;
                if (renderingMode == RenderingMode.SVFDraw)
                {
                    var cam = Camera.current;
                    if (cam == null)
                    {
                        return;
                    }
                    CameraView camView = cameraViews.Find(cam, targetDevice, flipHandedness);
                    if ((null != camView) && camView.isFlipHand)
                    {
                        adjustedFrameInfo.maxX = -lastFrameInfo.minX;
                        adjustedFrameInfo.minX = -lastFrameInfo.maxX;
                    }
                }
                if ((adjustedFrameInfo.maxX - adjustedFrameInfo.minX) > 0.0f ||
                    (adjustedFrameInfo.maxY - adjustedFrameInfo.minY) > 0.0f ||
                    (adjustedFrameInfo.maxZ - adjustedFrameInfo.minZ) > 0.0f)
                {
                    Vector3 min = new Vector3((float)adjustedFrameInfo.minX, (float)adjustedFrameInfo.minY, (float)adjustedFrameInfo.minZ);
                    Vector3 max = new Vector3((float)adjustedFrameInfo.maxX, (float)adjustedFrameInfo.maxY, (float)adjustedFrameInfo.maxZ);
                    localSpaceBounds.SetMinMax(min, max);

                    // File info did not contain bounds, then use the first frame's bounding box
                    if ((fileInfo.maxX - fileInfo.minX) <= 0.0f &&
                        (fileInfo.maxY - fileInfo.minY) <= 0.0f &&
                        (fileInfo.maxZ - fileInfo.minZ) <= 0.0f &&
                        adjustedFrameInfo.frameId <= 1)
                    {
                        Debug.LogWarning("Capture did not contain bounding box info, using the first frame's bounding box");
                        Vector3 worldMin = transform.localToWorldMatrix * new Vector4(min.x, min.y, min.z, 1.0f);
                        Vector3 worldMax = transform.localToWorldMatrix * new Vector4(max.x, max.y, max.z, 1.0f);
                        maximalWCSBounds.SetMinMax(worldMin, worldMax);
                    }

                    HVCollider.center      = localSpaceBounds.center;
                    HVCollider.size        = localSpaceBounds.size;
                    meshFilter.mesh.bounds = localSpaceBounds;
                }

                UpdateUnityBuffers();
                HandleOnUpdateFrameInfo(adjustedFrameInfo);
            }
            else
            {
                logger.Log("GetHCapObjectFrameInfo returned false");
            }

            if (lastFrameInfo.isEOS)
            {
                if (null != OnEndOfStreamNotify)
                {
                    OnEndOfStreamNotify(this);
                }
            }
#if ENABLE_NATIVE_LOGGING
            string[] trace = pluginInterop.GetTrace();
            if (null != trace)
            {
                foreach (var line in trace)
                {
                    logger.Log(line);
                }
            }
#endif
        }
    }