use of io.github.voidzombie.nhglib.utils.data.Bundle in project nhglib by VoidZombie.
the class Assets method assetLoaded.
public void assetLoaded(Asset asset) {
Bundle bundle = new Bundle();
bundle.put(Strings.Defaults.assetKey, asset);
messaging.send(new Message(Strings.Events.assetLoaded, bundle));
}
use of io.github.voidzombie.nhglib.utils.data.Bundle in project nhglib by VoidZombie.
the class Assets method assetUnloaded.
public void assetUnloaded(Asset asset) {
Bundle bundle = new Bundle();
bundle.put(Strings.Defaults.assetKey, asset);
messaging.send(new Message(Strings.Events.assetUnloaded, bundle));
}
use of io.github.voidzombie.nhglib.utils.data.Bundle in project nhglib by VoidZombie.
the class SceneManager method loadAssets.
private void loadAssets(Integer entity) {
final ModelComponent modelComponent = modelMapper.get(entity);
// Group all assets
final Array<Asset> allAssets = new Array<>();
final Asset modelAsset = modelComponent.asset;
for (PbrMaterial mat : modelComponent.pbrMaterials) {
if (mat.albedoAsset != null) {
allAssets.add(mat.albedoAsset);
}
if (mat.metalnessAsset != null) {
allAssets.add(mat.metalnessAsset);
}
if (mat.roughnessAsset != null) {
allAssets.add(mat.roughnessAsset);
}
if (mat.normalAsset != null) {
allAssets.add(mat.normalAsset);
}
if (mat.ambientOcclusionAsset != null) {
allAssets.add(mat.ambientOcclusionAsset);
}
}
// Start loading them
assets.queueAsset(modelAsset);
// Wait for them
messaging.get(Strings.Events.assetLoaded).subscribe(new Consumer<Message>() {
@Override
public void accept(Message message) throws Exception {
Asset asset = (Asset) message.data.get(Strings.Defaults.assetKey);
if (asset != null) {
if (asset.is(modelAsset.alias)) {
Model model = assets.get(asset);
modelComponent.model = new ModelInstance(model);
if (modelComponent.model.animations.size > 0) {
modelComponent.animationController = new AnimationController(modelComponent.model);
}
assets.queueAssets(allAssets);
} else {
if (allAssets.contains(asset, false)) {
temporaryLoadedAssets.add(asset);
allAssets.removeValue(asset, false);
Bundle bundle = new Bundle();
bundle.put("size", allAssets.size);
bundle.put("modelComponent", modelComponent);
sizeSubject.onNext(bundle);
}
}
}
}
});
}
Aggregations