Examples of AssetCache


Examples of com.jme3.asset.cache.AssetCache

        }
        return info;
    }
   
    public <T> T getFromCache(AssetKey<T> key) {
        AssetCache cache = handler.getCache(key.getCacheType());
        if (cache != null) {
            T asset = cache.getFromCache(key);
            if (asset != null) {
                // Since getFromCache fills the load stack, it has to be popped
                cache.notifyNoAssetClone();
            }
            return asset;
        } else {
            throw new IllegalArgumentException("Key " + key + " specifies no cache.");
        }
View Full Code Here

Examples of com.jme3.asset.cache.AssetCache

            throw new IllegalArgumentException("Key " + key + " specifies no cache.");
        }
    }
   
    public <T> void addToCache(AssetKey<T> key, T asset) {
        AssetCache cache = handler.getCache(key.getCacheType());
        if (cache != null) {
            cache.addToCache(key, asset);
            cache.notifyNoAssetClone();
        } else {
            throw new IllegalArgumentException("Key " + key + " specifies no cache.");
        }
    }
View Full Code Here

Examples of com.jme3.asset.cache.AssetCache

            throw new IllegalArgumentException("Key " + key + " specifies no cache.");
        }
    }
   
    public <T> boolean deleteFromCache(AssetKey<T> key) {
        AssetCache cache = handler.getCache(key.getCacheType());
        if (cache != null) {
            return cache.deleteFromCache(key);
        } else {
            throw new IllegalArgumentException("Key " + key + " specifies no cache.");
        }
    }
View Full Code Here

Examples of com.jme3.asset.cache.AssetCache

       
        for (AssetEventListener listener : eventListeners){
            listener.assetRequested(key);
        }
       
        AssetCache cache = handler.getCache(key.getCacheType());
        AssetProcessor proc = handler.getProcessor(key.getProcessorType());
       
        Object obj = cache != null ? cache.getFromCache(key) : null;
        if (obj == null){
            // Asset not in cache, load it from file system.
            AssetLoader loader = handler.aquireLoader(key);
            AssetInfo info = handler.tryLocate(key);
            if (info == null){
                if (handler.getParentKey() != null){
                    // Inform event listener that an asset has failed to load.
                    // If the parent AssetLoader chooses not to propagate
                    // the exception, this is the only means of finding
                    // that something went wrong.
                    for (AssetEventListener listener : eventListeners){
                        listener.assetDependencyNotFound(handler.getParentKey(), key);
                    }
                }
                throw new AssetNotFoundException(key.toString());
            }

            try {
                handler.establishParentKey(key);
                obj = loader.load(info);
            } catch (IOException ex) {
                throw new AssetLoadException("An exception has occured while loading asset: " + key, ex);
            } finally {
                handler.releaseParentKey(key);
            }
            if (obj == null){
                throw new AssetLoadException("Error occured while loading asset \"" + key + "\" using " + loader.getClass().getSimpleName());
            }else{
                if (logger.isLoggable(Level.FINER)){
                    logger.log(Level.FINER, "Loaded {0} with {1}",
                            new Object[]{key, loader.getClass().getSimpleName()});
                }
               
                if (proc != null){
                    // do processing on asset before caching
                    obj = proc.postProcess(key, obj);
                }
               
                if (cache != null){
                    // At this point, obj should be of type T
                    cache.addToCache(key, (T) obj);
                }
               
                for (AssetEventListener listener : eventListeners){
                    listener.assetLoaded(key);
                }
            }
        }

        // object obj is the original asset
        // create an instance for user
        T clone = (T) obj;
        if (clone instanceof CloneableSmartAsset){
            if (proc == null){
                throw new IllegalStateException("Asset implements "
                        + "CloneableSmartAsset but doesn't "
                        + "have processor to handle cloning");
            }else{
                clone = (T) proc.createClone(obj);
                if (cache != null && clone != obj){
                    cache.registerAssetClone(key, clone);
                } else{
                    throw new IllegalStateException("Asset implements "
                        + "CloneableSmartAsset but doesn't have cache or "
                        + "was not cloned");
                }
View Full Code Here

Examples of com.jme3.asset.cache.AssetCache

     * @return the loaded {@link Shader}
     */
    public Shader loadShader(ShaderKey key){
        // cache abuse in method
        // that doesn't use loaders/locators
        AssetCache cache = handler.getCache(SimpleAssetCache.class);
        Shader shader = (Shader) cache.getFromCache(key);
        if (shader == null){
            if (key.isUsesShaderNodes()) {
                if(shaderGenerator == null){
                    throw new UnsupportedOperationException("ShaderGenerator was not initialized, make sure assetManager.getGenerator(caps) has been called");
                }
                shader = shaderGenerator.generateShader();
            } else {
                String vertName = key.getVertName();
                String fragName = key.getFragName();

                String vertSource = (String) loadAsset(new AssetKey(vertName));
                String fragSource = (String) loadAsset(new AssetKey(fragName));

                shader = new Shader();
                shader.initialize();
                shader.addSource(Shader.ShaderType.Vertex, vertName, vertSource, key.getDefines().getCompiled(), key.getVertexShaderLanguage());
                shader.addSource(Shader.ShaderType.Fragment, fragName, fragSource, key.getDefines().getCompiled(), key.getFragmentShaderLanguage());
            }

            cache.addToCache(key, shader);
        }
        return shader;
    }
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.sim.cache.AssetCache

    /// </summary>
    /// <param name="client">A reference to the GridClient object</param>
    public AssetManager(GridClient client)
    {
        Client = client;
        Cache = new AssetCache(client);
        Texture = new TexturePipeline(client);
        HttpDownloads = new DownloadManager();

        //        // Transfer packets for downloading large assets
        //        // Client.network.RegisterCallback(PacketType.TransferInfo, TransferInfoHandler);
View Full Code Here

Examples of org.jdesktop.wonderland.client.assetmgr.AssetCache

    private String getChecksumFromDB(AssetURI assetURI) {
        // Query the asset database for an entry with this URI, looking for
        // the most recent checksum. This assumes that, although we are returned
        // a list of assets, there is only one asset, because it is the policy
        // to have only one wlhttp entry per cache.
        AssetCache assetCache = AssetManager.getAssetManager().getAssetCache();
        List<Asset> assetList = null;
        try {
            assetList = assetCache.getAssetList(assetURI);
        } catch (AssetCacheException excp) {
        }
       
        if (assetList.size() > 1) {
            logger.warning("Found more than one asset for " +
View Full Code Here

Examples of org.jdesktop.wonderland.client.assetmgr.AssetCache

    private String getChecksumFromDB(AssetURI assetURI) {
        // Query the asset database for an entry with this URI, looking for
        // the most recent checksum. This assumes that, although we are returned
        // a list of assets, there is only one asset, because it is the policy
        // to have only one wlhttp entry per cache.
        AssetCache assetCache = AssetManager.getAssetManager().getAssetCache();
        List<Asset> assetList = null;
        try {
            assetList = assetCache.getAssetList(assetURI);
        } catch (AssetCacheException excp) {
        }
       
        if (assetList.size() > 1) {
            logger.warning("Found more than one asset for " +
View Full Code Here

Examples of org.jdesktop.wonderland.client.assetmgr.AssetCache

     * false if not
     */
    private boolean isAssetCached(AssetID assetID) {
        // Using the asset URI and the desired checksum check whether the asset
        // is in the database (cached)
        AssetCache assetCache = AssetManager.getAssetManager().getAssetCache();
        try {
            return assetCache.isCached(assetID);
        } catch (AssetCacheException excp) {
            logger.log(Level.WARNING, "Unable to check cache for asset " +
                    assetID.toString(), excp);
            return false;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.