Search in sources :

Example 1 with AssetDescriptor

use of com.badlogic.gdx.assets.AssetDescriptor in project nhglib by VoidZombie.

the class NhgModelLoader 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) {
                String fName = modelTexture.fileName;
                if (fName.contains("/")) {
                    fName = fName.substring(fName.lastIndexOf("/") + 1);
                }
                deps.add(new AssetDescriptor(currentAsset.dependenciesPath + fName, Texture.class, textureParameter));
            }
        }
    }
    return deps;
}
Also used : ModelData(com.badlogic.gdx.graphics.g3d.model.data.ModelData) TextureLoader(com.badlogic.gdx.assets.loaders.TextureLoader) ModelTexture(com.badlogic.gdx.graphics.g3d.model.data.ModelTexture) Texture(com.badlogic.gdx.graphics.Texture) ModelTexture(com.badlogic.gdx.graphics.g3d.model.data.ModelTexture) Array(com.badlogic.gdx.utils.Array) ObjectMap(com.badlogic.gdx.utils.ObjectMap) ModelMaterial(com.badlogic.gdx.graphics.g3d.model.data.ModelMaterial) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 2 with AssetDescriptor

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

the class ParticleControllerInfluencer method load.

@Override
public void load(AssetManager manager, ResourceData resources) {
    SaveData data = resources.getSaveData();
    Array<IntArray> effectsIndices = data.load("indices");
    AssetDescriptor descriptor;
    Iterator<IntArray> iterator = effectsIndices.iterator();
    while ((descriptor = data.loadAsset()) != null) {
        ParticleEffect effect = (ParticleEffect) manager.get(descriptor);
        if (effect == null)
            throw new RuntimeException("Template is null");
        Array<ParticleController> effectControllers = effect.getControllers();
        IntArray effectIndices = iterator.next();
        for (int i = 0, n = effectIndices.size; i < n; i++) {
            templates.add(effectControllers.get(effectIndices.get(i)));
        }
    }
}
Also used : ParticleEffect(com.badlogic.gdx.graphics.g3d.particles.ParticleEffect) IntArray(com.badlogic.gdx.utils.IntArray) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController) SaveData(com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 3 with AssetDescriptor

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

the class MeshSpawnShapeValue method load.

@Override
public void load(AssetManager manager, ResourceData data) {
    SaveData saveData = data.getSaveData();
    AssetDescriptor descriptor = saveData.loadAsset();
    if (descriptor != null) {
        Model model = (Model) manager.get(descriptor);
        setMesh(model.meshes.get((Integer) saveData.load("index")), model);
    }
}
Also used : Model(com.badlogic.gdx.graphics.g3d.Model) SaveData(com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 4 with AssetDescriptor

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

the class ModelInfluencer method load.

@Override
public void load(AssetManager manager, ResourceData resources) {
    SaveData data = resources.getSaveData();
    AssetDescriptor descriptor;
    while ((descriptor = data.loadAsset()) != null) {
        Model model = (Model) manager.get(descriptor);
        if (model == null)
            throw new RuntimeException("Model is null");
        models.add(model);
    }
}
Also used : Model(com.badlogic.gdx.graphics.g3d.Model) SaveData(com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 5 with AssetDescriptor

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

the class PolygonRegionLoader method getDependencies.

/** If the PSH file contains a line starting with {@link PolygonRegionParameters#texturePrefix params.texturePrefix}, an
	 * {@link AssetDescriptor} for the file referenced on that line will be added to the returned Array. Otherwise a sibling of the
	 * given file with the same name and the first found extension in {@link PolygonRegionParameters#textureExtensions
	 * params.textureExtensions} will be used. If no suitable file is found, the returned Array will be empty. */
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, PolygonRegionParameters params) {
    if (params == null)
        params = defaultParameters;
    String image = null;
    try {
        BufferedReader reader = file.reader(params.readerBuffer);
        for (String line = reader.readLine(); line != null; line = reader.readLine()) if (line.startsWith(params.texturePrefix)) {
            image = line.substring(params.texturePrefix.length());
            break;
        }
        reader.close();
    } catch (IOException e) {
        throw new GdxRuntimeException("Error reading " + fileName, e);
    }
    if (image == null && params.textureExtensions != null)
        for (String extension : params.textureExtensions) {
            FileHandle sibling = file.sibling(file.nameWithoutExtension().concat("." + extension));
            if (sibling.exists())
                image = sibling.name();
        }
    if (image != null) {
        Array<AssetDescriptor> deps = new Array<AssetDescriptor>(1);
        deps.add(new AssetDescriptor<Texture>(file.sibling(image), Texture.class));
        return deps;
    }
    return null;
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) Array(com.badlogic.gdx.utils.Array) FileHandle(com.badlogic.gdx.files.FileHandle) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) Texture(com.badlogic.gdx.graphics.Texture) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Aggregations

AssetDescriptor (com.badlogic.gdx.assets.AssetDescriptor)18 Array (com.badlogic.gdx.utils.Array)10 FileHandle (com.badlogic.gdx.files.FileHandle)5 Texture (com.badlogic.gdx.graphics.Texture)4 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)4 FreeTypeFontLoaderParameter (com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader.FreeTypeFontLoaderParameter)4 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