diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 45ac955a91..4802b9dbd8 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -3,6 +3,10 @@
This file contains one line summaries of commits that are worthy of mentioning in release notes.
A new header is inserted each time a *tag* is created.
+## Next release
+
+- Add Java / Kotlin bindings for gltfio::Animator.
+
## v1.4.1
- Added missing API documentation.
diff --git a/android/gltfio-android/CMakeLists.txt b/android/gltfio-android/CMakeLists.txt
index 77fef27c7d..c8ad30a405 100644
--- a/android/gltfio-android/CMakeLists.txt
+++ b/android/gltfio-android/CMakeLists.txt
@@ -66,6 +66,7 @@ set(CMAKE_SHARED_LINKER_FLAGS " ${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-func
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--version-script=${CMAKE_SOURCE_DIR}/libgltfio-jni.map")
add_library(gltfio-jni SHARED
+ src/main/cpp/Animator.cpp
src/main/cpp/AssetLoader.cpp
src/main/cpp/FilamentAsset.cpp
src/main/cpp/KtxLoader.cpp
diff --git a/android/gltfio-android/src/main/cpp/Animator.cpp b/android/gltfio-android/src/main/cpp/Animator.cpp
new file mode 100644
index 0000000000..e1e42a2514
--- /dev/null
+++ b/android/gltfio-android/src/main/cpp/Animator.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include Animator can be used for two things:
+ * animation and skin definitions.
+ *
+ *
+ *
+ * TransformManager components according to glTF animation definitions.RenderableManager components according to glTF skin definitions.
TransformManager.
+ *
+ * @param animationIndex Zero-based index for the animation of interest.
+ * @param time Elapsed time of interest in seconds.
+ *
+ * @see #getAnimationCount
+ */
+ public void applyAnimation(@IntRange(from = 0) int animationIndex, float time) {
+ nApplyAnimation(mNativeObject, animationIndex, time);
+ }
+
+ /**
+ * Computes root-to-node transforms for all bone nodes, then passes
+ * the results into {@see RenderableManager#setBones}.
+ * Uses TransformManager and RenderableManager.
+ *
+ * NOTE: this operation is independent of animation.
animation definitions in the glTF asset.
+ */
+ public int getAnimationCount() {
+ return nGetAnimationCount(mNativeObject);
+ }
+
+ /**
+ * Returns the duration of the specified glTF animation in seconds.
+ *
+ * @param animationIndex Zero-based index for the animation of interest.
+ *
+ * @see #getAnimationCount
+ * */
+ public float getAnimationDuration(@IntRange(from = 0) int animationIndex) {
+ return nGetAnimationDuration(mNativeObject, animationIndex);
+ }
+
+ /**
+ * Returns a weak reference to the string name of the specified animation, or an
+ * empty string if none was specified.
+ *
+ * @param animationIndex Zero-based index for the animation of interest.
+ *
+ * @see #getAnimationCount
+ */
+ public String getAnimationName(@IntRange(from = 0) int animationIndex) {
+ return nGetAnimationName(mNativeObject, animationIndex);
+ }
+
+ private static native void nApplyAnimation(long nativeAnimator, int index, float time);
+ private static native void nUpdateBoneMatrices(long nativeAnimator);
+ private static native int nGetAnimationCount(long nativeAnimator);
+ private static native float nGetAnimationDuration(long nativeAnimator, int index);
+ private static native String nGetAnimationName(long nativeAnimator, int index);
+}
diff --git a/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/AssetLoader.java b/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/AssetLoader.java
index 8a50d96cf2..41182db809 100644
--- a/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/AssetLoader.java
+++ b/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/AssetLoader.java
@@ -55,10 +55,13 @@ import java.nio.Buffer;
* }
*
* ResourceLoader(engine).loadResources(filamentAsset).destroy()
+ * animator = asset.getAnimator()
+ *
* scene.addEntities(filamentAsset.entities)
* }
*
*
+ * @see Animator
* @see FilamentAsset
* @see ResourceLoader
*/
diff --git a/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java b/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java
index e653994f14..b3abd71c43 100644
--- a/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java
+++ b/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java
@@ -37,16 +37,17 @@ import com.google.android.filament.Entity;
* Clients can use {@link ResourceLoader} to create textures, compute tangent quaternions, and * upload data into vertex buffers and index buffers.
* - *TODO: Animator is not yet exposed to Java / Kotlin clients.
NameComponentManager label for the given entity, if it exists.
+ * Gets the NameComponentManager label for the given entity, if it exists.
*/
public String getName(@Entity int entity) {
return nGetName(getNativeObject(), entity);
}
+ /**
+ * Creates or retrieves the Animator for this asset.
+ *
+ * When calling this for the first time, this must be called after
+ * {@see ResourceLoader#loadResources}.
+ */
+ public Animator getAnimator() {
+ if (mAnimator != null) {
+ return mAnimator;
+ }
+ mAnimator = new Animator(nGetAnimator(getNativeObject()));
+ return mAnimator;
+ }
+
void clearNativeObject() {
mNativeObject = 0;
}
@@ -97,4 +112,5 @@ public class FilamentAsset {
private static native void nGetEntities(long nativeAsset, int[] result);
private static native void nGetBoundingBox(long nativeAsset, float[] box);
private static native String nGetName(long nativeAsset, int entity);
+ private static native long nGetAnimator(long nativeAsset);
}