gltfio Java: add getMorphTargetNames for consistency with other methods.
Tested by hacking ModelViewer.
This commit is contained in:
@@ -5,6 +5,9 @@ A new header is inserted each time a *tag* is created.
|
||||
|
||||
## v1.20.6 (currently main branch)
|
||||
|
||||
- gltfio: add support for KHR_materials_variants
|
||||
- gltfio: Java now exposes morph target names as an array for consistency [⚠️ **API Change**].
|
||||
|
||||
## v1.20.5
|
||||
|
||||
- New behavior for MASKED to work with translucent views. [⚠️ **Recompile Materials** to get the fix]
|
||||
|
||||
@@ -215,15 +215,6 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nGetResourceUriCount(JNIEn
|
||||
return (jint) asset->getResourceUriCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jstring JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetMorphTargetNameAt(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jint entityId, jint targetIndex) {
|
||||
Entity entity = Entity::import(entityId);
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
const char* val = asset->getMorphTargetNameAt(entity, (size_t) targetIndex);
|
||||
return val ? env->NewStringUTF(val) : nullptr;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetResourceUris(JNIEnv* env, jclass,
|
||||
jlong nativeAsset,
|
||||
@@ -235,6 +226,25 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nGetResourceUris(JNIEnv* e
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetMorphTargetCount(JNIEnv*, jclass,
|
||||
jlong nativeAsset, jint entityId) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
Entity entity = Entity::import(entityId);
|
||||
return (jint) asset->getMorphTargetCountAt(entity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetMorphTargetNames(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jint entityId, jobjectArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
Entity entity = Entity::import(entityId);
|
||||
for (int i = 0, n = asset->getMorphTargetCountAt(entity); i < n; ++i) {
|
||||
const char* name = asset->getMorphTargetNameAt(entity, i);
|
||||
env->SetObjectArrayElement(result, (jsize) i, env->NewStringUTF(name));
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetMaterialVariantCount(JNIEnv*, jclass,
|
||||
jlong nativeAsset) {
|
||||
|
||||
@@ -217,12 +217,12 @@ public class FilamentAsset {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the morph target name at the given index in the given entity.
|
||||
*
|
||||
* TODO(prideout): This should be "getMorphTargetNames"
|
||||
* Gets the names of all morph targets in the given entity.
|
||||
*/
|
||||
public String getMorphTargetNameAt(@Entity int entity, @IntRange(from = 0) int targetIndex) {
|
||||
return nGetMorphTargetNameAt(getNativeObject(), entity, targetIndex);
|
||||
public @NonNull String[] getMorphTargetNames(@Entity int entity) {
|
||||
String[] names = new String[nGetMorphTargetCount(mNativeObject, entity)];
|
||||
nGetMorphTargetNames(mNativeObject, entity, names);
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,11 +297,13 @@ public class FilamentAsset {
|
||||
private static native int nGetMaterialVariantCount(long nativeAsset);
|
||||
private static native void nGetMaterialVariantNames(long nativeAsset, String[] result);
|
||||
|
||||
private static native int nGetMorphTargetCount(long nativeAsset, int entity);
|
||||
private static native void nGetMorphTargetNames(long nativeAsset, int entity, String[] result);
|
||||
|
||||
private static native void nGetBoundingBox(long nativeAsset, float[] box);
|
||||
private static native String nGetName(long nativeAsset, int entity);
|
||||
private static native String nGetExtras(long nativeAsset, int entity);
|
||||
private static native long nGetAnimator(long nativeAsset);
|
||||
private static native String nGetMorphTargetNameAt(long nativeAsset, int entity, int targetIndex);
|
||||
private static native void nApplyMaterialVariant(long nativeAsset, int variantIndex);
|
||||
private static native int nGetResourceUriCount(long nativeAsset);
|
||||
private static native void nGetResourceUris(long nativeAsset, String[] result);
|
||||
|
||||
Reference in New Issue
Block a user