示例#1
0
        protected override void ProcessNextFrame(MVGraphAPI.Frame frame)
        {
            if (!frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.AUDIO_DATA_LAYER))
            {
                return;
            }

            lock (m_framesQueue)
                m_framesQueue.Enqueue(frame);

            StartAudioDataProcessingThread();
        }
示例#2
0
        private bool CollectTextureDataFromFrame(MVGraphAPI.Frame frame)
        {
            TextureFormat textureFormat;
            ushort        textureWidth, textureHeight;
            UInt32        textureSizeInBytes;

            if (m_textureFormat == MvxTextureFormat.DEPTH_MAP && frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.DEPTHMAP_TEXTURE_DATA_LAYER))
            {
                textureFormat = TextureFormat.R8;
                MVGraphAPI.FrameTextureExtractor.GetTextureResolution(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_DEPTH, out textureWidth, out textureHeight);
                textureSizeInBytes = MVGraphAPI.FrameTextureExtractor.GetTextureDataSizeInBytes(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_DEPTH) / 2;
            }
            else if (m_textureFormat == MvxTextureFormat.ASTC && frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.ASTC_TEXTURE_DATA_LAYER))
            {
                textureFormat = TextureFormat.ASTC_RGB_8x8;
                MVGraphAPI.FrameTextureExtractor.GetTextureResolution(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_ASTC, out textureWidth, out textureHeight);
                textureSizeInBytes = MVGraphAPI.FrameTextureExtractor.GetTextureDataSizeInBytes(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_ASTC);
            }
            else if (m_textureFormat == MvxTextureFormat.DXT1 && frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.DXT1_TEXTURE_DATA_LAYER))
            {
                textureFormat = TextureFormat.DXT1;
                MVGraphAPI.FrameTextureExtractor.GetTextureResolution(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_DXT1, out textureWidth, out textureHeight);
                textureSizeInBytes = MVGraphAPI.FrameTextureExtractor.GetTextureDataSizeInBytes(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_DXT1);
            }
            else if (m_textureFormat == MvxTextureFormat.ETC2 && frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.ETC2_TEXTURE_DATA_LAYER))
            {
                textureFormat = TextureFormat.ETC2_RGB;
                MVGraphAPI.FrameTextureExtractor.GetTextureResolution(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_ETC2, out textureWidth, out textureHeight);
                textureSizeInBytes = MVGraphAPI.FrameTextureExtractor.GetTextureDataSizeInBytes(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_ETC2);
            }
            else if (m_textureFormat == MvxTextureFormat.RGB && frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.RGB_TEXTURE_DATA_LAYER))
            {
                textureFormat = TextureFormat.RGB24;
                MVGraphAPI.FrameTextureExtractor.GetTextureResolution(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_RGB, out textureWidth, out textureHeight);
                textureSizeInBytes = MVGraphAPI.FrameTextureExtractor.GetTextureDataSizeInBytes(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_RGB);
            }
            else if (m_textureFormat == MvxTextureFormat.IR && frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.IR_TEXTURE_DATA_LAYER))
            {
                textureFormat = TextureFormat.R8;
                MVGraphAPI.FrameTextureExtractor.GetTextureResolution(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_IR, out textureWidth, out textureHeight);
                textureSizeInBytes = MVGraphAPI.FrameTextureExtractor.GetTextureDataSizeInBytes(frame, MVGraphAPI.FrameTextureExtractor.TextureType.TT_IR);
            }
            else
            {
                return(false);
            }

            m_activeTextureIndex = (m_activeTextureIndex + 1) % m_textures.Length;
            Texture2D newActiveTexture = m_textures[m_activeTextureIndex];

            EnsureTextureProperties(ref newActiveTexture, textureFormat, textureWidth, textureHeight);
            m_textures[m_activeTextureIndex] = newActiveTexture;

            LoadTexture(frame, newActiveTexture, m_textureFormat, textureWidth, textureHeight, textureSizeInBytes);

            return(true);
        }
示例#3
0
        private void CollectTextureDataFromFrame(MVGraphAPI.Frame frame)
        {
            if (materialInstances == null || materialInstances.Length == 0)
            {
                return;
            }

            int           textureType;
            TextureFormat textureFormat;

            MVGraphAPI.FrameTextureExtractor.TextureType mvxTextureType;

            if (frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.ASTC_TEXTURE_DATA_LAYER))
            {
                textureType    = (int)TextureTypeCodes.TTC_ASTC;
                textureFormat  = TextureFormat.ASTC_RGB_8x8;
                mvxTextureType = MVGraphAPI.FrameTextureExtractor.TextureType.TT_ASTC;
            }
            else if (frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.DXT1_TEXTURE_DATA_LAYER))
            {
                textureType    = (int)TextureTypeCodes.TTC_DXT1;
                textureFormat  = TextureFormat.DXT1;
                mvxTextureType = MVGraphAPI.FrameTextureExtractor.TextureType.TT_DXT1;
            }
            else if (frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.ETC2_TEXTURE_DATA_LAYER))
            {
                textureType    = (int)TextureTypeCodes.TTC_ETC2;
                textureFormat  = TextureFormat.ETC2_RGB;
                mvxTextureType = MVGraphAPI.FrameTextureExtractor.TextureType.TT_ETC2;
            }
            else if (frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.NVX_TEXTURE_DATA_LAYER))
            {
                textureType    = (int)TextureTypeCodes.TTC_NVX;
                textureFormat  = TextureFormat.Alpha8;
                mvxTextureType = MVGraphAPI.FrameTextureExtractor.TextureType.TT_NVX;
            }
            else if (frame.StreamContainsDataLayer(MVGraphAPI.SimpleDataLayersGuids.RGB_TEXTURE_DATA_LAYER))
            {
                textureType    = (int)TextureTypeCodes.TTC_RGB;
                textureFormat  = TextureFormat.RGB24;
                mvxTextureType = MVGraphAPI.FrameTextureExtractor.TextureType.TT_RGB;
            }
            else
            {
                foreach (Material materialInstance in materialInstances)
                {
                    materialInstance.SetTexture(TEXTURE_SHADER_PROPERTY_NAME, null);
                }
                return;
            }

            ushort textureWidth, textureHeight;

            MVGraphAPI.FrameTextureExtractor.GetTextureResolution(frame, mvxTextureType, out textureWidth, out textureHeight);
            UInt32 textureSizeInBytes = MVGraphAPI.FrameTextureExtractor.GetTextureDataSizeInBytes(frame, mvxTextureType);
            IntPtr textureData        = MVGraphAPI.FrameTextureExtractor.GetTextureData(frame, mvxTextureType);

            m_activeTextureIndex = (m_activeTextureIndex + 1) % m_textures.Length;
            Texture2D newActiveTexture = m_textures[m_activeTextureIndex];

            EnsureTextureProperties(ref newActiveTexture, textureFormat, textureWidth, textureHeight);
            m_textures[m_activeTextureIndex] = newActiveTexture;

            newActiveTexture.LoadRawTextureData(textureData, (Int32)textureSizeInBytes);
            newActiveTexture.Apply(true, false);

            foreach (Material materialInstance in materialInstances)
            {
                materialInstance.SetInt(TEXTURE_TYPE_SHADER_PROPERTY_NAME, textureType);
                materialInstance.SetTexture(TEXTURE_SHADER_PROPERTY_NAME, newActiveTexture);
            }
        }