What is the significance of the andy.obj
file in the ARCore Sample?
Let's say if we replace the andy.png with a new image, how can we generate .obj
file for the new image?
What is the significance of the andy.obj
file in the ARCore Sample?
Let's say if we replace the andy.png with a new image, how can we generate .obj
file for the new image?
The sample code only can handle the simplest OBJ models that only have 1 texture file.
Fo those complicated OBJ models, they usually come with a MTL file that refers to several different texture files. To be able to handle that ,you need some extra work on the existing code. Please check the code I implement for this case if you are interested @https://github.com/JohnLXiang/arcore-sandbox . Specifially ,you can take a look at ObjectRenderer.createOnGlThread().
For creating a new .obj
model for your AR app you need to use 3D authoring software like Autodesk Maya, Autodesk 3dsMax, Blender, SideFx Houdini, Cinema 4D, etc. These applications can help you create a high quality polygonal model with corresponding .mtl
texture file.
But you should know that Sceneform supports 3D assets not only in
OBJ
format (where animations aren't supported) but also inFBX
(with animations) and inglTF
(animations not supported).
Sceneform's
ASCII
andBinary
Asset Definitions are also welcome:
Supported material files (aka textures for your 3D assets) have the following extensions:
MTL
,BIN
,PNG
,JPG
and native Sceneform'sSFM
.
Hope this helps.
To export a texture as image in Blender do the following:
Select your object and enter in edit mode. Select all vertices/faces (press 'a'). Then start the UV Mapping, press 'u'. And Select one of the options of the UVMapping. You must test the best option for your model. I'm not sure which UV Mapping mapping option the ARCore uses.
Then go to the UV/Image Editor:
Export UV Layout at the menu, and save your image.
The OBJ file describes the geometry, the png file the texture to "stretch" over this 3D object. You have to use a 3D modelling program like Blender to create a new model.
This is how you export OBJ files in Blender: https://blender.stackexchange.com/questions/121/how-do-i-export-a-model-to-obj-format