use of com.badlogic.gdx.graphics.g3d.utils.AnimationController in project libgdx by libgdx.
the class ModelTest method switchAnimation.
protected void switchAnimation() {
for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) {
int animIndex = 0;
if (e.value.current != null) {
for (int i = 0; i < e.key.animations.size; i++) {
final Animation animation = e.key.animations.get(i);
if (e.value.current.animation == animation) {
animIndex = i;
break;
}
}
}
animIndex = (animIndex + 1) % (e.key.animations.size + 1);
e.value.animate((animIndex == e.key.animations.size) ? null : e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f);
}
}
use of com.badlogic.gdx.graphics.g3d.utils.AnimationController in project libgdx by libgdx.
the class SkeletonTest method onLoaded.
@Override
protected void onLoaded() {
if (currentlyLoading == null || currentlyLoading.isEmpty())
return;
instances.clear();
animationControllers.clear();
final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class));
for (Material m : instance.materials) m.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.8f));
instances.add(instance);
if (instance.animations.size > 0)
animationControllers.put(instance, new AnimationController(instance));
currentlyLoading = null;
}
use of com.badlogic.gdx.graphics.g3d.utils.AnimationController 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);
}
}
}
}
});
}
use of com.badlogic.gdx.graphics.g3d.utils.AnimationController in project bladecoder-adventure-engine by bladecoder.
the class Sprite3DRenderer method retrieveSource.
private void retrieveSource(String source) {
ModelCacheEntry entry = (ModelCacheEntry) sourceCache.get(source);
if (entry == null || entry.refCounter < 1) {
loadSource(source);
EngineAssetManager.getInstance().finishLoading();
entry = (ModelCacheEntry) sourceCache.get(source);
}
if (entry.modelInstance == null) {
Model model3d = EngineAssetManager.getInstance().getModel3D(source);
entry.modelInstance = new ModelInstance(model3d);
entry.controller = new AnimationController(entry.modelInstance);
entry.camera3d = getCamera(entry.modelInstance);
}
}
Aggregations