This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun cloudAnchor(newAnchor: Anchor?) { | |
cloudAnchor?.detach() | |
cloudAnchor = newAnchor | |
appAnchorState = AppAnchorState.NONE | |
snackbarHelper.hide(this) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arFragment.setOnTapArPlaneListener { hitResult, plane, _ -> | |
if (plane.type != Plane.Type.HORIZONTAL_UPWARD_FACING || appAnchorState != AppAnchorState.NONE) { | |
return@setOnTapArPlaneListener | |
} | |
val anchor = arFragment.arSceneView.session?.hostCloudAnchor(hitResult.createAnchor()) | |
placeObject(arFragment, cloudAnchor!!, Uri.parse("model.sfb")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun cloudAnchor(newAnchor: Anchor?) { | |
cloudAnchor?.detach() | |
cloudAnchor = newAnchor | |
appAnchorState = AppAnchorState.NONE | |
snackbarHelper.hide(this) | |
} | |
private fun placeObject(fragment: ArFragment, anchor: Anchor, model: Uri) { | |
ModelRenderable.Builder() | |
.setSource(fragment.context, model) | |
.build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<fragment | |
android:id="@+id/ar_fragment" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CloudAnchorFragment : ArFragment() { | |
override fun getSessionConfiguration(session: Session?): Config { | |
planeDiscoveryController.setInstructionView(null) | |
val config: Config = super.getSessionConfiguration(session) | |
config.cloudAnchorMode = Config.CloudAnchorMode.ENABLED | |
return config | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation 'com.google.ar:core:1.10.0' | |
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.10.0' | |
implementation 'com.google.android.material:material:1.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<meta-data | |
android:name="com.google.ar.core" | |
android:value="required"/> | |
<meta-data | |
android:name="com.google.android.ar.API_KEY" | |
android:value="YOUR API KEY"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-permission android:name="android.permission.CAMERA"/> | |
<uses-permission android:name="android.permission.INTERNET"/> | |
<uses-feature android:name="android.hardware.camera.ar" android:required="true"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun processFaceResult(faces: MutableList<FirebaseVisionFace>) { | |
faces.forEach { | |
val bounds = it.boundingBox | |
val rectOverLay = RectOverlay(graphic_overlay, bounds) | |
graphic_overlay.add(rectOverLay) | |
} | |
alertDialog.dismiss() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<Button android:layout_width="match_parent" android:layout_height="wrap_content" | |
android:layout_alignParentBottom="true" | |
android:layout_centerHorizontal="true" |