Exemple #1
0
    IEnumerator ProcessRecording()
    {
        yield return(new WaitForEndOfFrame());

        if (!m_recording)
        {
            yield break;
        }

        ProcessCapture();

        // wait maximumDeltaTime if timeSamplingType is uniform
        if (m_conf.timeSamplingType == AbcAPI.aeTypeSamplingType.Uniform)
        {
            AbcAPI.aeWaitMaxDeltaTime();
        }
    }
        /// <summary>
        /// Writes the current frame to the Alembic archive. Recording should have been previously started.
        /// </summary>

        public void ProcessRecording()
        {
            if (!m_recording)
            {
                return;
            }

            float begin_time = Time.realtimeSinceStartup;

            // check if there are new GameObjects to capture
            UpdateCaptureNodes();
            if (m_frameCount > 0 && m_newNodes.Count > 0)
            {
                // add invisible sample
                m_ctx.MarkFrameBegin();
                foreach (var node in m_newNodes)
                {
                    node.MarkForceInvisible();
                    node.Capture();
                }
                m_ctx.MarkFrameEnd();
            }
            m_newNodes.Clear();

            // do capture
            m_ctx.MarkFrameBegin();
            m_ctx.AddTime(m_time);
            foreach (var kvp in m_nodes)
            {
                var node = kvp.Value;
                node.Capture();
                if (node.transform == null)
                {
                    m_iidToRemove.Add(node.instanceID);
                }
            }
            m_ctx.MarkFrameEnd();

            // remove deleted GameObjects
            foreach (int iid in m_iidToRemove)
            {
                m_nodes.Remove(iid);
            }
            m_iidToRemove.Clear();

            // advance time
            ++m_frameCount;
            m_timePrev = m_time;
            switch (m_settings.ExportOptions.TimeSamplingType)
            {
            case TimeSamplingType.Uniform:
                m_time = (1.0f / m_settings.ExportOptions.FrameRate) * m_frameCount;
                break;

            case TimeSamplingType.Acyclic:
                m_time += Time.deltaTime;
                break;
            }
            m_elapsed = Time.realtimeSinceStartup - begin_time;

            // wait maximumDeltaTime if timeSamplingType is uniform
            if (m_settings.ExportOptions.TimeSamplingType == TimeSamplingType.Uniform && m_settings.FixDeltaTime)
            {
                AbcAPI.aeWaitMaxDeltaTime();
            }

            if (m_settings.DetailedLog)
            {
                Debug.Log("AlembicRecorder: frame " + m_frameCount + " (" + (m_elapsed * 1000.0f) + " ms)");
            }
        }