'Blinking , Smiling , etc Face Animation in Augmented Face AR
I am try to put animation like smiling ,eyes blinking and talking on Augmented Face Ar with GLB file . Here I Attach GLB file.
I have done set the Ar file on face here its output
.
Here My code i try with alots effect but its not working . But in IOS its have every animation and its working perfect Help me out to solve this in android.Thanks
private var modelRenderable: ModelRenderable? = null
private var isAdd = false
private var customArFragment: CustomArFragment? = null
@RequiresApi(Build.VERSION_CODES.N)
private fun setAvatarOnFace() {
customArFragment = childFragmentManager.findFragmentById(R.id.arImageFragment) as
CustomArFragment?
ModelRenderable.builder()
.setSource(context,/* Uri.parse("rpm.sfb"))*/
RenderableSource.builder().setSource(
context,
Uri.parse("rp.glb"),
RenderableSource.SourceType.GLB)
.setRecenterMode(RenderableSource.RecenterMode.CENTER)
.setScale(1.2f)
.build())
.build()
.thenAccept { rendarable: ModelRenderable? ->
modelRenderable = rendarable
modelRenderable!!.isShadowCaster = false
modelRenderable?.isShadowReceiver = false
}
.exceptionally { throwable: Throwable? ->
val toast = Toast.makeText(
requireContext(), "Unable to load renderable " +
GLTF_ASSET, Toast.LENGTH_LONG
)
toast.setGravity(Gravity.CENTER, 0, 0)
toast.show()
null
}
assert(customArFragment != null)
customArFragment?.arSceneView?.cameraStreamRenderPriority =
Renderable.RENDER_PRIORITY_FIRST
customArFragment?.arSceneView?.scene?.addOnUpdateListener { frameTime: FrameTime?
->
if (modelRenderable == null) {
return@addOnUpdateListener
}
val frame = customArFragment?.arSceneView?.arFrame
val augmentedFaces = frame?.getUpdatedTrackables(AugmentedFace::class.java)!!
for (augmentedFace in augmentedFaces) {
if (isAdd) return@addOnUpdateListener
val augmentedFaceMode = AugmentedFaceNode(augmentedFace)
augmentedFaceMode.setParent(customArFragment!!.arSceneView.scene)
augmentedFaceMode.faceRegionsRenderable = modelRenderable
faceNodeMap[augmentedFace!!] = augmentedFaceMode
isAdd = true
val iterator: MutableIterator<Map.Entry<AugmentedFace,
AugmentedFaceNode>> =
faceNodeMap.entries.iterator()
val entry = iterator.next()
val face = entry.key
while (face.trackingState == TrackingState.STOPPED) {
val node = entry.value
node.setParent(null)
iterator.remove()
}
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
