google-ar / arcore-android-sdk

ARCore SDK for Android Studio
https://developers.google.com/ar
Other
4.95k stars 1.22k forks source link

How to create a PointCloud from a list of Vector3f ? #1139

Closed agGitHub closed 3 years ago

agGitHub commented 3 years ago

Hi,

I have a list of Vector3f representing points in world space coordinates. Now, I would like to render these points thanks to the hello_ar_java PointCloudRenderer. So, I need to create a PointCloud object from my list of Vector3f.

Would it be possible to have the code for this ?

Thanks.

devbridie commented 3 years ago

It's not possible to construct your own PointCloud and fill it in with your own points. You could adjust PointCloudRenderer.update() to accept your list of Vector3f instead, but a discussion on how this is done is probably better suited as a StackOverflow question.

brianm-sra commented 3 years ago

You can create your own Java class (MyPointCloud, for example) with a method that returns a FloatBuffer in the same format that ARCore's PointCloud.getPoints() uses for its FloatBuffer output, and use that in a modified PointCloudRenderer.update() method

agGitHub commented 3 years ago

Thanks. If anybody has the code to create the FloatBuffer, would be great to mention it here or on Stackoverflow: https://stackoverflow.com/questions/64061348/arcore-how-to-create-a-pointcloud-from-a-list-of-vector3f Thanks !!!

brianm-sra commented 3 years ago

It's pretty easy. The FloatBuffer just needs to contain a sequence of floats representing the points in format: X Y Z Confidence X Y Z Confidence X Y Z Confidence ...

RGregat commented 3 years ago

@agGitHub this might help you https://stackoverflow.com/questions/51966132/collouring-android-sceneform-pointcloud-by-confidence-value