Search in sources :

Example 11 with AssetDescriptor

use of com.badlogic.gdx.assets.AssetDescriptor in project libgdx by libgdx.

the class TextureAtlasLoader method getDependencies.

@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle atlasFile, TextureAtlasParameter parameter) {
    FileHandle imgDir = atlasFile.parent();
    if (parameter != null)
        data = new TextureAtlasData(atlasFile, imgDir, parameter.flip);
    else {
        data = new TextureAtlasData(atlasFile, imgDir, false);
    }
    Array<AssetDescriptor> dependencies = new Array();
    for (Page page : data.getPages()) {
        TextureParameter params = new TextureParameter();
        params.format = page.format;
        params.genMipMaps = page.useMipMaps;
        params.minFilter = page.minFilter;
        params.magFilter = page.magFilter;
        dependencies.add(new AssetDescriptor(page.textureFile, Texture.class, params));
    }
    return dependencies;
}
Also used : Array(com.badlogic.gdx.utils.Array) TextureAtlasData(com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData) FileHandle(com.badlogic.gdx.files.FileHandle) Page(com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Page) TextureParameter(com.badlogic.gdx.assets.loaders.TextureLoader.TextureParameter) Texture(com.badlogic.gdx.graphics.Texture) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 12 with AssetDescriptor

use of com.badlogic.gdx.assets.AssetDescriptor in project libgdx by libgdx.

the class ParticleEffectLoader method getDependencies.

@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, ParticleEffectLoadParameter parameter) {
    Json json = new Json();
    ResourceData<ParticleEffect> data = json.fromJson(ResourceData.class, file);
    Array<AssetData> assets = null;
    synchronized (items) {
        ObjectMap.Entry<String, ResourceData<ParticleEffect>> entry = new ObjectMap.Entry<String, ResourceData<ParticleEffect>>();
        entry.key = fileName;
        entry.value = data;
        items.add(entry);
        assets = data.getAssets();
    }
    Array<AssetDescriptor> descriptors = new Array<AssetDescriptor>();
    for (AssetData<?> assetData : assets) {
        // If the asset doesn't exist try to load it from loading effect directory
        if (!resolve(assetData.filename).exists()) {
            assetData.filename = file.parent().child(Gdx.files.internal(assetData.filename).name()).path();
        }
        if (assetData.type == ParticleEffect.class) {
            descriptors.add(new AssetDescriptor(assetData.filename, assetData.type, parameter));
        } else
            descriptors.add(new AssetDescriptor(assetData.filename, assetData.type));
    }
    return descriptors;
}
Also used : AssetData(com.badlogic.gdx.graphics.g3d.particles.ResourceData.AssetData) Json(com.badlogic.gdx.utils.Json) Array(com.badlogic.gdx.utils.Array) ObjectMap(com.badlogic.gdx.utils.ObjectMap) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 13 with AssetDescriptor

use of com.badlogic.gdx.assets.AssetDescriptor in project libgdx by libgdx.

the class TiledMapAtlasAssetManagerTest method create.

@Override
public void create() {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, (w / h) * 10, 10);
    camera.zoom = 2;
    camera.update();
    cameraController = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(cameraController);
    font = new BitmapFont();
    batch = new SpriteBatch();
    AtlasTiledMapLoaderParameters params = new AtlasTiledMapLoaderParameters();
    params.forceTextureFilters = true;
    params.textureMinFilter = TextureFilter.Linear;
    params.textureMagFilter = TextureFilter.Linear;
    assetManager = new AssetManager();
    assetManager.setErrorListener(new AssetErrorListener() {

        @Override
        public void error(AssetDescriptor asset, Throwable throwable) {
            errorMessage = throwable.getMessage();
        }
    });
    assetManager.setLoader(TiledMap.class, new AtlasTmxMapLoader(new InternalFileHandleResolver()));
    assetManager.load(fileName, TiledMap.class);
}
Also used : AtlasTiledMapLoaderParameters(com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters) AssetManager(com.badlogic.gdx.assets.AssetManager) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) AssetErrorListener(com.badlogic.gdx.assets.AssetErrorListener) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) AtlasTmxMapLoader(com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Aggregations

AssetDescriptor (com.badlogic.gdx.assets.AssetDescriptor)13 Array (com.badlogic.gdx.utils.Array)9 FileHandle (com.badlogic.gdx.files.FileHandle)5 Texture (com.badlogic.gdx.graphics.Texture)4 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)3 SaveData (com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData)3 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)3 IntArray (com.badlogic.gdx.utils.IntArray)3 ObjectMap (com.badlogic.gdx.utils.ObjectMap)3 IOException (java.io.IOException)3 TextureLoader (com.badlogic.gdx.assets.loaders.TextureLoader)2 TextureParameter (com.badlogic.gdx.assets.loaders.TextureLoader.TextureParameter)2 Model (com.badlogic.gdx.graphics.g3d.Model)2 ModelData (com.badlogic.gdx.graphics.g3d.model.data.ModelData)2 ModelMaterial (com.badlogic.gdx.graphics.g3d.model.data.ModelMaterial)2 ModelTexture (com.badlogic.gdx.graphics.g3d.model.data.ModelTexture)2 AssetErrorListener (com.badlogic.gdx.assets.AssetErrorListener)1 AssetManager (com.badlogic.gdx.assets.AssetManager)1 InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)1 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1