Make Your First Augmented Reality App | Part 2 | Sceneform | ARCore

heyletscode
5 Nov 201817:12

Summary

TLDRIn this tutorial, we guide you through the process of creating a Hello AR app using Sceneform on Android. The video covers setting up the app, importing 3D models, and rendering them in the AR environment. It demonstrates how to handle user interaction, such as tapping on AR planes, to place and manipulate models. Key concepts like anchors, anchor nodes, and transformable nodes are explained, giving viewers the tools to overlay 3D content in real-world settings. This video is perfect for beginners looking to dive into AR development with Sceneform.

Takeaways

  • ๐Ÿ˜€ If you haven't watched the previous video, itโ€™s recommended to watch it first as it covers setting up the Hello AR app.
  • ๐Ÿ“ฆ Sceneform is used for rendering 3D scenes in AR and non-AR apps without needing to learn OpenGL.
  • ๐Ÿป To use a 3D model in the app, you need to download it from a source like Poly (e.g., Arctic Fox), and place it inside the `sample_data` directory.
  • ๐Ÿ“ Files required for rendering include the `.obj` and `.mtl` files. These should be copied to the `sample_data` folder in the project.
  • โš™๏ธ Sceneform requires importing the 3D model and converting it from `.obj` format to Sceneform's SFB or SSB format using the 'Import Sceneform Asset' option.
  • ๐Ÿ”จ After importing, you can tweak the model properties (e.g., roughness, size) before saving it.
  • ๐ŸŒ The app renders the 3D model on top of an AR plane created by detecting horizontal or vertical planes in the real world.
  • ๐Ÿ‘† User taps on a detected AR plane, which triggers the creation of an anchor at the tap location to hold the 3D model.
  • ๐Ÿ“ An anchor defines a fixed position and orientation in the real world, which serves as a base for rendering 3D models.
  • ๐ŸŽฎ To interact with the model, a `transformableNode` is created. This node allows users to manipulate the size and position of the model in AR.
  • ๐Ÿ“ฒ The final model is placed in the AR scene by setting its parent node to the anchor node, allowing the model to be rendered at the userโ€™s selected location.
  • ๐Ÿ”„ In the end, the model is added to the scene, and the user can select it for further interaction in the AR environment.

Q & A

  • What is Sceneform and why is it important for AR app development?

    -Sceneform is an SDK that simplifies the process of creating augmented reality (AR) apps on Android devices. It allows developers to render 3D models in AR without needing to learn complex OpenGL. This is particularly useful for building AR experiences quickly and with ease.

  • What type of 3D file is used in the script, and why is it important to convert it for Sceneform?

    -The script uses the `.obj` file format for the 3D model, which must be converted to Sceneform's `.sfb` format to be properly rendered in the AR scene. Sceneform does not directly support `.obj` files, so conversion is necessary for compatibility.

  • What is the purpose of the `sampledata` directory in the app's structure?

    -The `sampledata` directory is used to store assets like 3D models. These files are not included in the final APK, meaning they are only used during development and testing of the AR features.

  • How do you create an anchor in the AR scene, and why is it necessary?

    -An anchor is created using the `hitResult.createAnchor()` method, which fixes a location and orientation in the real world based on where the user taps on a detected AR plane. The anchor is necessary to position 3D models accurately in the AR environment.

  • What is the difference between an `AnchorNode` and a `TransformableNode` in Sceneform?

    -An `AnchorNode` is used to attach 3D models to a fixed location in the real world (the anchor). However, it cannot be interacted with (e.g., moved, scaled). A `TransformableNode` allows for interaction, enabling the user to move, scale, or rotate the model in the AR scene.

  • Why do you need to use the `ModelRenderable` class in Sceneform?

    -The `ModelRenderable` class is used to load and render 3D models in Sceneform. It is necessary to build and accept the model before adding it to the AR scene so that the model can be placed at the correct anchor point.

  • What role does the `OnTapArPlaneListener` play in the app?

    -The `OnTapArPlaneListener` listens for tap events on detected AR planes. When a user taps on the plane, it triggers the creation of an anchor, which is then used to place the 3D model in the real-world scene.

  • How do you ensure the 3D model is correctly positioned and visible in the AR environment?

    -To ensure correct positioning, the 3D model is attached to an `AnchorNode` that is created using the anchor. Then, the model is attached to a `TransformableNode` which is added to the AR scene. This setup guarantees the model is rendered at the exact location of the anchor.

  • What happens if you don't use a `TransformableNode` when displaying a 3D model?

    -If you don't use a `TransformableNode`, the 3D model will be placed at the anchor, but the user will not be able to interact with it (i.e., scale or move it). The model will remain fixed in the AR space.

  • What does the script suggest doing if there is an error in rendering the 3D model?

    -If an error occurs while rendering the 3D model, the script suggests using the `exceptionally` method to catch the error and display an alert dialog with the error message, allowing the user to understand what went wrong.

Outlines

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Mindmap

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Keywords

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Highlights

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Transcripts

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now
Rate This
โ˜…
โ˜…
โ˜…
โ˜…
โ˜…

5.0 / 5 (0 votes)

Related Tags
AR DevelopmentSceneform3D ModelsAndroid AppAR TutorialMobile ARBeginner GuideProgrammingJavaTech TutorialInteractive AR