Change image search of surfaces in sceneform with arcore

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Change image search of surfaces in sceneform with arcore



where I change the sceneform_hand_phone.png image to a custom one?. This is the image of the hand that is used in the library sceneform for Android with ARCore.



Thank you




1 Answer
1



HelloSceneformActivity.java:


public class HelloSceneformActivity extends AppCompatActivity
private ArFragment arFragment;
private View phoneImage;

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_ux);

// Get AR fragment from layout
arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.ux_fragment);

// Disable plane discovery hand motion animation
arFragment.getPlaneDiscoveryController().hide();

ViewGroup container = findViewById(R.id.sceneform_hand_layout);
container.removeAllViews();

// Create the new plane discovery animation and add it to the hand layout.
phoneImage = getLayoutInflater().inflate(R.layout.hand_layout, container, true);

// Set the instructions view in the plane discovery controller.
arFragment.getPlaneDiscoveryController().setInstructionView(phoneImage);




activity_ux.xml:


<FrameLayout 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"
android:id="@+id/sceneform_hand_layout"
android:clipChildren="false"
tools:context=".HelloSceneformActivity">

<fragment class="com.google.ar.sceneform.ux.ArFragment"
android:id="@+id/ux_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</FrameLayout>



Put the custom hand animation in it's own layout file (it must be created dynamically), hand_layout.xml:


<FrameLayout 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">

<com.google.ar.sceneform.ux.HandMotionView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="center"
android:scaleType="center"
android:src="@drawable/YOURIMAGE" />

</FrameLayout>



build.gradle:


buildscript
repositories
google()
jcenter()
mavenLocal()

dependencies
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.ar.sceneform:plugin:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files



allprojects
repositories
google()
jcenter()
mavenLocal()



task clean(type: Delete)
delete rootProject.buildDir





Hello I did what you indicate, the new image appears but the camera does not appear. Only the image with white background is seen.
– Atlas Keel
Aug 19 at 12:06





@AtlasKeel sorry for delay, but ti show is not related with this code. I'm on another country now far away from my laptop, but you need to render the frame.
– Canato
Aug 22 at 10:53






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard