How to make the plane renderer have a single non-repeating texture on it's material? #300
-
Something along the lines of the image below: The idea is that every time the user moves the phone, the texture's center should be focused on the focus point (like this does for spotlight) of the frame, and this should ideally be the same height / width of the current model that is downloaded. Questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 16 replies
-
Hi! |
Beta Was this translation helpful? Give feedback.
-
A very basic implementation of what @grassydragon suggested Layout.xml <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/linearLayout">
<ImageView
android:id="@+id/image_view_ar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_tracking_plane"
tools:layout_conversion_absoluteHeight="50dp"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_conversion_absoluteWidth="50dp" />
</LinearLayout> ic_tracking_plane <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="60dp"
android:height="60dp"
android:viewportWidth="60"
android:viewportHeight="60">
<path
android:pathData="M2.575659303251037,2.306419295191382 L57.829926365885946,2.296878830805386 L57.90754413020447,57.40356772363032 L2.488460406775956,57.248990756189016 L2.575659303251037,2.306419295191382 z"
android:strokeWidth="2"
android:strokeColor="@color/colorTrackingPlane" />
</vector> Create a ViewRenderable View view = ((LayoutInflater) context
.getSystemService(Service.LAYOUT_INFLATER_SERVICE))
.inflate(configuration.getLayoutId(), null);
CompletableFuture<ViewRenderable> viewRenderable = ViewRenderable
.builder()
.setView(context, view)
.build(); handle the first HitResult to create a Anchor viewRenderable.thenAccept(renderable -> {
anchor = session.createAnchor(hit.getHitPose());
tackingAnchorNode = new AnchorNode(anchor);
fragment.getArSceneView().getScene().addChild(trackingAnchorNode);
node = new Node();
node.setRenderable(renderable);
node.setParent(tackingAnchorNode);
} update position of the view based on a HitResult if (!node.isEnabled())
return;
Pose hitPose = hit.getHitPose();
Vector3 oldPosition = node.getWorldPosition();
Vector3 desiredPosition = new Vector3(
hitPose.tx(),
hitPose.ty(),
hitPose.tz());
node.setWorldPosition(desiredPosition);
Quaternion rotation1 = Quaternion.axisAngle(new Vector3(1.0f, 0.0f, 0.0f), 90);
node.setWorldRotation(rotation1); The posted code might not work by simple copy & paste, but it gives you a general idea how to implement what you want. |
Beta Was this translation helpful? Give feedback.
-
May I suggest moving to sceneView-android? https://github.com/SceneView/sceneview-android/blob/0a1d36c8a097f1e1fd9e43c59226789147544836/arsceneview/src/main/kotlin/io/github/sceneview/ar/node/CursorNode.kt#L17-L71 |
Beta Was this translation helpful? Give feedback.
-
Is it possible to implement the same thing as above in scenview-android? |
Beta Was this translation helpful? Give feedback.
A very basic implementation of what @grassydragon suggested
Layout.xml