示例#1
0
    void Start()
    {
        mgr = (HPV_Manager)mainCamEye.GetComponent("HPV_Manager");

        trackedObj = GetComponent <SteamVR_TrackedObject>();
        contr      = GetComponent <SteamVR_TrackedController>();
        arr[0]     = sphere1;
        arr[1]     = sphere2;
        arr[2]     = sphere3;
    }
示例#2
0
    /* Startup the node, opens the file */
    void Start()
    {
        m_event_processor = SingletonService <EventProcessor> .GetSingleton();

        m_manager = SingletonService <HPV_Manager> .GetSingleton();

        if (!m_event_processor)
        {
            Debug.LogError("Make sure there is exactly ONE EventProcessor.cs script in the scene.");
            return;
        }

        if (!m_manager)
        {
            Debug.LogError("Make sure there is exactly ONE HPV_Manager.cs script present in the scene.");
            return;
        }

        // init the player
        int node_id = m_manager.initPlayer(new HPVEventDelegate(onHPVEvent));

        if (node_id >= 0)
        {
            m_node_id = (byte)node_id;
            //string filepath = Application.streamingAssetsPath + "/../../" + filename;
            string filepath = filename;
            int    ret      = m_manager.openVideo(m_node_id, filepath);
            if (ret == 1)
            {
                // store parameters of the file
                int fps = m_manager.getFrameRate(m_node_id);
                width  = m_manager.getWidth(m_node_id);
                height = m_manager.getHeight(m_node_id);
                int number_of_frames = m_manager.getNumberOfFrames(m_node_id);
                hpv_type = m_manager.getCompressionType(m_node_id);

                /* If state == internal, video will play using internal clock. This call also sets loop mode to LOOP */
                m_manager.setSyncState(m_node_id, HPV_Unity_Bridge.HPVSyncState.HPV_SYNC_INTERNAL);
                /* ... else, wait for external sync, using one of the seek methods */
                //m_manager.setSyncState(m_node_id, HPV_Unity_Bridge.HPVSyncState.HPV_SYNC_EXTERNAL);

                //Debug.Log("Opened video " + filename + " with total of " + number_of_frames + " of frames and dimensions " + width + "x" + height + " @ " + fps + "fps [TYPE: " + HPV_Unity_Bridge.HPVCompressionTypeStrings[(int)hpv_type] + "]");
                b_needs_init = true;
            }
        }
        else
        {
            Debug.LogError("Couldn't create new HPV_Video node!");
        }
    }
示例#3
0
    /* Startup the node, opens the file */
    void Start()
    {
        m_event_processor = SingletonService <EventProcessor> .GetSingleton();

        m_manager = SingletonService <HPV_Manager> .GetSingleton();

        if (!m_event_processor)
        {
            Debug.LogError("Make sure there is exactly ONE EventProcessor.cs script in the scene.");
            return;
        }

        if (!m_manager)
        {
            Debug.LogError("Make sure there is exactly ONE HPV_Manager.cs script present in the scene.");
            return;
        }

        // init the player
        int node_id = m_manager.initPlayer(new HPVEventDelegate(onHPVEvent));

        if (node_id >= 0)
        {
            m_node_id = (byte)node_id;
            string filepath = Application.streamingAssetsPath + "/../../" + filename;
            int    ret      = m_manager.openVideo(m_node_id, filepath);

            if (ret == 1)
            {
                // store parameters of the file
                int fps = m_manager.getFrameRate(m_node_id);
                width  = m_manager.getWidth(m_node_id);
                height = m_manager.getHeight(m_node_id);
                int number_of_frames = m_manager.getNumberOfFrames(m_node_id);
                hpv_type = m_manager.getCompressionType(m_node_id);

                ret = m_manager.startVideo(m_node_id);
                ret = m_manager.setLoopState(m_node_id, 1);

                Debug.Log("Opened video " + filename + " with total of " + number_of_frames + " of frames and dimensions " + width + "x" + height + " @ " + fps + "fps [TYPE: " + HPV_Unity_Bridge.HPVCompressionTypeStrings[(int)hpv_type] + "]");
                b_needs_init = true;
            }
        }
        else
        {
            Debug.LogError("Couldn't create new HPV_Video node!");
        }
    }
示例#4
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        HPV_Manager manager = SingletonService <HPV_Manager> .GetSingleton();

        if (!manager)
        {
            return;
        }

        byte m_node_id = ((HPV_Node)target).getID();

        GUILayoutOption[] options = { GUILayout.Width(250), GUILayout.Height(100) };

        // global vertical
        EditorGUILayout.BeginVertical(options);

        EditorGUILayout.Separator();
        // play controls horizontal
        EditorGUILayout.LabelField("Play Controls");
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button(playState_str, GUILayout.MinWidth(75), GUILayout.ExpandWidth(true), GUILayout.MinHeight(40), GUILayout.ExpandHeight(true)))
        {
            playState = !playState;
            if (playState)
            {
                playState_str = "Stop";
                loop_in       = 0;
                loop_out      = manager.getNumberOfFrames(m_node_id);
                rangeMin      = 0.0f;
                rangeMax      = 1.0f;
                speed         = 1.0f;
                prev_speed    = 1.0f;
                seek          = 0.0f;
                prev_seek     = 0.0f;
                manager.startVideo(m_node_id);
            }
            else
            {
                playState_str = "Play";
                manager.stopVideo(m_node_id);
            }
        }
        if (playState)
        {
            if (GUILayout.Button(pauzeState_str, GUILayout.MinWidth(75), GUILayout.ExpandWidth(true), GUILayout.MinHeight(40), GUILayout.ExpandHeight(true)))
            {
                pauzeState = !pauzeState;
                if (pauzeState)
                {
                    pauzeState_str = "Resume";
                    manager.pauseVideo(m_node_id);
                }
                else
                {
                    pauzeState_str = "Pauze";
                    manager.resumeVideo(m_node_id);
                }
            }
        }

        // end play controls horizontal
        EditorGUILayout.EndHorizontal();

        // start pauze controls horizontal
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("<< BWD", GUILayout.MinWidth(75), GUILayout.ExpandWidth(true), GUILayout.MinHeight(40), GUILayout.ExpandHeight(true)))
        {
            manager.setDirection(m_node_id, false);
        }
        if (GUILayout.Button("FWD >>", GUILayout.MinWidth(75), GUILayout.ExpandWidth(true), GUILayout.MinHeight(40), GUILayout.ExpandHeight(true)))
        {
            manager.setDirection(m_node_id, true);
        }

        // end pauze controls horizontal
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Speed");
        speed = EditorGUILayout.Slider(speed, -10, 10);
        if (!isNearlyEqual(speed, prev_speed))
        {
            prev_speed = speed;
            manager.setSpeed(m_node_id, speed);
        }

        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Loop");
        loop_index = EditorGUILayout.Popup(loop_index, loop_options);
        if (loop_index != prev_loop_index)
        {
            manager.setLoopState(m_node_id, loop_index);
            prev_loop_index = loop_index;
        }

        EditorGUILayout.IntField(loop_in);
        EditorGUILayout.IntField(loop_out);

        EditorGUILayout.MinMaxSlider(ref rangeMin, ref rangeMax, 0.0f, 1.0f);
        if (GUILayout.Button("Update loop points"))
        {
            loop_in  = (int)(rangeMin * (manager.getNumberOfFrames(m_node_id) - 1));
            loop_out = (int)(rangeMax * (manager.getNumberOfFrames(m_node_id) - 1));

            manager.setLoopIn(m_node_id, loop_in);
            manager.setLoopOut(m_node_id, loop_out);
        }

        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Seek");
        seek = EditorGUILayout.Slider(seek, 0.0f, 1.0f);
        if (!isNearlyEqual(seek, prev_seek))
        {
            manager.seekToPos(m_node_id, seek);
            prev_seek = seek;
        }

        bShowStats = EditorGUILayout.Foldout(bShowStats, "Decode stats");
        if (bShowStats)
        {
            if (bShowStats != prevShowStats)
            {
                manager.enableStats(m_node_id, bShowStats);
                prevShowStats = bShowStats;
            }

            IntPtr ptr = manager.getDecodeStatsPtr(m_node_id);
            HPV_Unity_Bridge.HPVDecodeStats decode_stats = (HPV_Unity_Bridge.HPVDecodeStats)Marshal.PtrToStructure(ptr, typeof(HPV_Unity_Bridge.HPVDecodeStats));

            string stats = "HDD: " + (decode_stats.hdd_read_time / (float)1e6).ToString("F") + "ms";
            stats += "\nL4Z: " + (decode_stats.l4z_decompress_time / (float)1e6).ToString("F") + "ms";
            stats += "\nGPU: " + (decode_stats.gpu_upload_time / (float)1e6).ToString("F") + "ms";
            EditorGUILayout.HelpBox(stats, MessageType.Info);
            Repaint();
        }
        else if (!bShowStats && prevShowStats)
        {
            manager.enableStats(m_node_id, bShowStats);
            prevShowStats = bShowStats;
        }

        // end global vertical
        EditorGUILayout.EndVertical();
    }