Search in sources :

Example 6 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)

Example 7 with AssetDescriptor

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

the class BitmapFontLoader method getDependencies.

@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, BitmapFontParameter parameter) {
    Array<AssetDescriptor> deps = new Array();
    if (parameter != null && parameter.bitmapFontData != null) {
        data = parameter.bitmapFontData;
        return deps;
    }
    data = new BitmapFontData(file, parameter != null ? parameter.flip : false);
    if (parameter != null && parameter.atlasName != null) {
        deps.add(new AssetDescriptor(parameter.atlasName, TextureAtlas.class));
    } else {
        for (int i = 0; i < data.getImagePaths().length; i++) {
            String path = data.getImagePath(i);
            FileHandle resolved = resolve(path);
            TextureLoader.TextureParameter textureParams = new TextureLoader.TextureParameter();
            if (parameter != null) {
                textureParams.genMipMaps = parameter.genMipMaps;
                textureParams.minFilter = parameter.minFilter;
                textureParams.magFilter = parameter.magFilter;
            }
            AssetDescriptor descriptor = new AssetDescriptor(resolved, Texture.class, textureParams);
            deps.add(descriptor);
        }
    }
    return deps;
}
Also used : Array(com.badlogic.gdx.utils.Array) BitmapFontData(com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData) FileHandle(com.badlogic.gdx.files.FileHandle) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 8 with AssetDescriptor

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

the class ModelLoader method getDependencies.

@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, P parameters) {
    final Array<AssetDescriptor> deps = new Array();
    ModelData data = loadModelData(file, parameters);
    if (data == null)
        return deps;
    ObjectMap.Entry<String, ModelData> item = new ObjectMap.Entry<String, ModelData>();
    item.key = fileName;
    item.value = data;
    synchronized (items) {
        items.add(item);
    }
    TextureLoader.TextureParameter textureParameter = (parameters != null) ? parameters.textureParameter : defaultParameters.textureParameter;
    for (final ModelMaterial modelMaterial : data.materials) {
        if (modelMaterial.textures != null) {
            for (final ModelTexture modelTexture : modelMaterial.textures) deps.add(new AssetDescriptor(modelTexture.fileName, Texture.class, textureParameter));
        }
    }
    return deps;
}
Also used : Array(com.badlogic.gdx.utils.Array) ModelData(com.badlogic.gdx.graphics.g3d.model.data.ModelData) ObjectMap(com.badlogic.gdx.utils.ObjectMap) ModelMaterial(com.badlogic.gdx.graphics.g3d.model.data.ModelMaterial) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor) ModelTexture(com.badlogic.gdx.graphics.g3d.model.data.ModelTexture)

Example 9 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, ParticleEffectParameter param) {
    Array<AssetDescriptor> deps = null;
    if (param != null && param.atlasFile != null) {
        deps = new Array();
        deps.add(new AssetDescriptor<TextureAtlas>(param.atlasFile, TextureAtlas.class));
    }
    return deps;
}
Also used : Array(com.badlogic.gdx.utils.Array) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 10 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)

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