I'm currently developing an AR feature for the app I'm working in, and I have to render custom 3d models. I managed to do that using OpenGL ES, and implementing a custom object that extends Renderable.
Rendering the custom 3d model works perfect, but we want to integrate it with the plane detection feature. As it is now, my custom 3d model always renders the same way, it doesn't matter the plane it is supposed to be in (vertical or horizontal).
I thought the model would automatically rotate to match the plane, but it seems it's not doing it.
Is this a bug or there is a way to know the orientation of the plane the object is going to be add to, so i can manually rotate it?
I'm working with a Samsung Galaxy S5 (Android 6.0.1 - API 23).
Thanks in advance.
Good morning Sebastian,
it definitely should be rotated to fit the orientation of the plane. That information is contained in the view matrix you are provided with for a plane. I'm confident to say that this currently works since we are doing the same thing for the plane augmentations rendered in the sample. If there was an issue with this transformation, the planes themselves would not be oriented correctly (would all have the same orientation).
How are you applying the view matrix to your 3D models?
Thanks for your response.
I imagined that would be the case, it make sense the model rotates automatically, but it's not working for me.
Here is how i'm doing it:
- I have my custom model class, that extends Renderable. It works really similar to "StrokedCube" (but instead, i load and render my custom .obj)
- On "PlaneDetectionActivity", when the user taps the screen to add the object, i add it to the wikitude framework by doing "glRenderer.setRenderablesForKey("my_key", myObject, null)"
- When "onTrackingStarted" and "onTracked" are called, i get my object by doing "MyObject aux = glRenderer.getRenderableForKey("my_key")". Finally, y set the view matrix by doing "aux.viewMatrix = target.getViewMatrix()"
Is this the way to go?
that sounds right to me. What happens when you run the sample unaltered such that is renders the default plane augmentations? Do they have different orientations (horizontal/vertical)?
I tested this on the sample I downloaded with the SDK, using that example, but loading my custom 3d model. Rendering plane augmentations works correctly, they have different orientations, but my models still don't.
I'm not sure if this has something to do with the fact that I'm working with an old device, Samsung Galaxy S5 (Android 6.0.1, API 23) with no ARCore support.
I will take a look on "PlanePolygon" class, because I used "StrokedCube" as a guide to my custom 3d model class, and I may have missed something.
Any guide you can provide, i will give it a try.