Пример #1
0
        /// <summary>
        /// Schedule asynchronous texture loading.
        /// </summary>
        private void LoadAsync()
        {
            TextureQueue.CompletionCallback callback = (file, image, actualLocation, result) =>
            {
                Debug.Assert(_file == file);
                SetImage(image, result);

                _actualLocation = actualLocation;

                if (_callback != null)
                {
                    _callback(_file, _image, actualLocation, result);
                }
            };

            lock (_lock)
            {
                State = TextureState.LoadingPending;
                if (_dataSource != null)
                {
                    TextureQueue.Enqueue(_dataSource, _file, callback);
                    return;
                }

                TextureQueue.Enqueue(_file, _baseDir, callback);
            }
        }
Пример #2
0
        /// <summary>
        /// Start loading a texture from a given embedded texture
        /// </summary>
        /// <param name="dataSource">Source texture from assimp</param>
        /// <param name="refName">Sentinel name of the texture. This is the name
        ///    that is set as FileName.</param>
        /// <param name="callback">Optional callback to be invoked
        ///   when loading to memory is either complete or is definitely
        ///   failed.)</param>
        public Texture(Assimp.EmbeddedTexture dataSource, string refName, CompletionCallback callback)
        {
            _file       = refName;
            _dataSource = dataSource;
            _callback   = (s, image, actualLocation, status) => callback(this);

            if (CoreSettings.CoreSettings.Default.LoadTextures)
            {
                LoadAsync();
            }
            else
            {
                SetImage(null, TextureLoader.LoadResult.FileNotFound);
            }
        }
Пример #3
0
        /// <summary>
        /// Start loading a texture from a given file path
        /// </summary>
        /// <param name="file">File to load from</param>
        /// <param name="baseDir">Scene root folder </param>
        /// <param name="callback">Optional callback to be invoked
        ///   when loading to memory is either complete or is definitely
        ///   failed.)</param>
        public Texture(string file, string baseDir, CompletionCallback callback)
        {
            _file     = file;
            _baseDir  = baseDir;
            _callback = (s, image, actualLocation, status) => callback(this);

            if (CoreSettings.CoreSettings.Default.LoadTextures)
            {
                LoadAsync();
            }
            else
            {
                SetImage(null, TextureLoader.LoadResult.FileNotFound);
            }
        }
Пример #4
0
        /// <summary>
        /// Start loading a texture from a given embedded texture
        /// </summary>
        /// <param name="dataSource">Source texture from assimp</param>
        /// <param name="refName">Sentinel name of the texture. This is the name
        ///    that is set as FileName.</param>
        /// <param name="callback">Optional callback to be invoked
        ///   when loading to memory is either complete or is definitely
        ///   failed.)</param>
        public Texture(Assimp.EmbeddedTexture dataSource, string refName, CompletionCallback callback)
        {
            _originalFile = refName;
            _dataSource = dataSource;
            _callback = (s, image, actualLocation, status) => callback(this);

            if (CoreSettings.CoreSettings.Default.LoadTextures)
            {
                LoadAsync();
            }
            else
            {
                SetImage(null, TextureLoader.LoadResult.FileNotFound);
            }
        }
Пример #5
0
        /// <summary>
        /// Start loading a texture from a given file path
        /// </summary>
        /// <param name="originalFile">File to load from, this is the unique id of the texture.</param>
        /// <param name="baseDir">Scene root folder </param>
        /// <param name="callback">Optional callback to be invoked
        ///   when loading to memory is either complete or is definitely
        ///   failed.)</param>
        public Texture(string originalFile, string baseDir, CompletionCallback callback)
        {
            _originalFile = originalFile;
            _baseDir = baseDir;
            _callback = (s, image, actualLocation, status) => callback(this);

            if (CoreSettings.CoreSettings.Default.LoadTextures)
            {
                LoadAsync();
            }
            else
            {
                SetImage(null, TextureLoader.LoadResult.FileNotFound);
            }
        }