OBJ File for ARCore Application Development
Asked Answered
D

4

8

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?

Dameron answered 31/8, 2017 at 15:56 Comment(0)
D
6

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

enter image description here

Dowager answered 31/8, 2017 at 17:54 Comment(2)
I have done this, but when I add the new model (.obj) file along with the .mtl file to the arcore project (replacing andy.obj), nothing appears on screen when I tapSplasher
Hi Conti, did you check the console for errors? Please note that in the ARCore sample code, the ObjectRenderer uses a simple 2D texture (the andy.png file), which is different than a texture described in a MTL file.Yvoneyvonne
W
2

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().

Winstead answered 25/9, 2017 at 22:32 Comment(5)
Hey.. have you verified your code on github? Am trying to replicate and it doesn't draw the objects. No crashes or anything and enters the for loop for material groups in draw.Doddering
@ArunReddyKandoor Yes I did. But I also found out for some of OBJs I downloaded online couldn't get drawn for some reason, those ones I included in the assets folder worked fine... Sorry I haven't got chance to look into this issueWinstead
Am not sure what I did (maybe scaling).. am seeing the objects now, but they are in black and white. Any clue how to get the objects in true colors?Doddering
@ArunReddyKandoor Sorry can't help. I also noticed for some texture files, even they are bound properly from my point of view, they still couldn't be rendered for some reason...Winstead
@Winstead which tool have you used to export .OBJ and .MTL(that refers to several texture files) file?Mousebird
C
1

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.

enter image description here

Then go to the UV/Image Editor:

enter image description here

Export UV Layout at the menu, and save your image.

enter image description here

Colcannon answered 4/3, 2018 at 16:4 Comment(0)
B
0

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 in FBX (with animations) and in glTF (animations not supported).

  • .obj
  • .fbx
  • .glTF

Sceneform's ASCII and Binary Asset Definitions are also welcome:

  • .sfa
  • .sfb

Supported material files (aka textures for your 3D assets) have the following extensions: MTL, BIN, PNG, JPG and native Sceneform's SFM.

  • .mtl
  • .bin
  • .png
  • .jpg
  • .sfm

Hope this helps.

Baalbeer answered 7/4, 2019 at 7:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.