Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to import a 3D model into Android?

Is it possible to create a simple 3D model (for example in 3DS MAX) and then import it to Android?

like image 901
Maciej Gryka Avatar asked Oct 15 '08 11:10

Maciej Gryka


People also ask

Can you import 3D models?

3D models are imported as subsymbols, ready to be used multiple times in a project if need be. Once you have named your model symbol, select OK. An Import 3D modal will then appear allowing you to preview your model and tweak some of the settings to ensure your model is imported correctly.

How do I see 3D models on Android?

Scene Viewer is an immersive viewer that enables 3D and AR experiences from your website or Android app. It lets users of Android mobile devices easily preview, place, view, and interact with web-hosted 3D models in their environment. Most Android browsers support Scene Viewer.

How do you import a 3D object?

To import an OBJ, select File -> Import... from the menu bar. Select the OBJ you wish to import. You can also drag and drop your OBJ into the Resources panel. Once the OBJ is imported into Lens Studio, you should see it listed in your Objects panel as a new object added to the scene.


1 Answers

That's where I got to:

  • I've used Google's APIDemos as a starting point - there are rotating cubes in there, each specified by two arrays: vertices and indices.
  • I've build my model using Blender and exported it as OFF file - it's a text file that lists all the vertices and then faces in terms of these vertices (indexed geometry)
  • Then I've created a simple C++ app that takes that OFF and writes it as two XMLs containing arrays (one for vertices and one for indices)
  • These XML files are then copied to res/values and this way I can assign the data they contain to arrays like this:
    int vertices[] = context.getResources().getIntArray(R.array.vertices);
  • I also need to manually change the number of faces to be drawn in here: gl.glDrawElements(GL10.GL_TRIANGLES, 212*6, GL10.GL_UNSIGNED_SHORT, mIndexBuffer); - you can find that number (212 in this case) on top of the OFF file

Here you can find my project page, which uses this solution: Github project > vsiogap3d

like image 79
Maciej Gryka Avatar answered Sep 20 '22 02:09

Maciej Gryka