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;
}
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)));
}
}
}
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);
}
}
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);
}
}
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;
}
Aggregations