Reputation: 405
I want to display some 3D models (.obj files) in an android app using android studio.
The user enters some data and the models have to be placed relative to each other according to the user input.
So all I need is to display some 3D models placed relative to each other according to the data entered before, and the user will be able to see the models from any direction when swiping the screen.
I don't know how to achieve this. I tried to use OpenGL-ES, but without avail as I can't find enough tutorials and the documentation is hard to be understood.
Any help or suggestion is welcome.
Thanks in advance.
Upvotes: 12
Views: 19516
Reputation: 1
I know this is just about to be a year old, but stumbled on it when trying to possibly share my (viewable) obj that I've been able to 'mesh' together (fun little play on words) to a built-in service/app so the model could be viewed by others who may not have the app I'm building installed... possibly SceneForm?? or something with ARCore atleast...
Either way to assist on your question as I feel I had the same question as was able to resolve it with a webview and the three.js library.
Attempting to use openGL required/requires a lot more effort/time/understanding than I have. Existing libraries don't really support .obj and .mtl with textures they all seem to be focused on the more recent/better alternatives. The source data I was working with only had the .obj/.mtl and I didn't have a way to do runtime conversion.
https://threejs.org/manual/#en/load-obj
Going through this solution available via three.js helped me greatly, minor tweaks were needed for my end goal. So if you run in to further trouble and share some more details I'd be happy to see if I can help. (heads up swapping just the obj source won't help if dimension/camera are way off, you will also need to 're-focus' the camera to your object).
V/R
Fellow Coder
Upvotes: 0
Reputation: 533
You can use for this job SceneForm. In a nutshell SceneForm is used as a middleware between ARCore and Filament to create awesome Augmented Reality Apps, but you can also use SceneForm just to visualize GLTF-Models
Upvotes: 3
Reputation: 381
Found this 3D Viewer on GitHub (supports OBJ, GLTF)
Also, I believe it is possible to find some converters OBJ ~> GLTF (by Khronos). You can write Android App with embedded Web View in which you can show GLTF.
If someone will work on Android app using some HTML / JS framework like Phonegap or VueJS + Quasar, then GLTF could be good way to go (if OBJ ~> GLTF is not a problem).
Upvotes: 7