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 on Android?

+47
android opengl-es 3d
Oct 15 '08 at 11:17
source share
6 answers

What I got to:

  • I used Googleโ€™s APIDemos as a starting point - there are spinning cubes, each of which is defined by two arrays: vertices and indexes.
  • I built my model using Blender and exported it as an OFF file - this is a text file that lists all the vertices and then the faces in terms of these vertices (indexed geometry)
  • Then I created a simple C ++ application that takes this OFF and writes it as two XML containing arrays (one for vertices and one for indexes)
  • These XML files are then copied to res / values, and so I can assign the data that they contain for the arrays as follows:
    int vertices[] = context.getResources().getIntArray(R.array.vertices);
  • I also need to manually change the number of faces to be drawn here: gl.glDrawElements(GL10.GL_TRIANGLES, 212*6, GL10.GL_UNSIGNED_SHORT, mIndexBuffer); - you can find this number (in this case 212) over the OFF file

Here you can find my project page that uses this solution:

http://code.google.com/p/vsiogap3d/

+33
Apr 12 '09 at 17:35
source share

You can export it to ASE format. from ASE, you can convert it to your code manually or programmatically. You will need a vertex for vertex arrays and faces for indices in Android. do not forget that you must install

 gl.glFrontFace(GL10.GL_CCW); 

because the value of 3ds max is counterclockwise by default.

+11
Apr 12 '09 at 15:19
source share

It should be possible. You can have the file as a data file with your program (and as such it will be placed in the emulator and packaged for installation on the actual device). Then you can write a model loader and viewer in java using the Android and GLES libraries to display the model.

The specific resources on this are probably limited. 3ds is a proprietary format, so third-party bootloaders are in short supply and are mostly reversed. Other formats (such as blender or milkshape) are more open, and you should be able to find the details for writing a bootloader for them in java quite easily.

+5
Oct 15 '08 at 11:24
source share

Have you tried min3d for Android? It supports 3ds max, obj and md2 models.

+4
Apr 26 2018-12-12T00:
source share

Not sure about Android, but generally speaking, you need a script in 3DS Max that manually writes out the formatting you need from the model.

As to whether Android exists or not, I don't know.

+3
Oct. 15 '08 at 11:20
source share

You can do this also with 3D Object Converter

http://web.t-online.hu/karpo/

This tool can convert a 3ds object to text \ xml format or c code.

Open gl 'c' output example:

 glDisable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); glEnable(GL_NORMALIZE); GLfloat Material_1[] = { 0.498039f, 0.498039f, 0.498039f, 1.000000f }; glBegin(GL_TRIANGLES); glMaterialfv(GL_FRONT,GL_DIFFUSE,Material_1 glNormal3d(0.452267,0.000000,0.891883); glVertex3d(5.108326,1.737655,2.650969); glVertex3d(9.124107,-0.002484,0.614596); glVertex3d(9.124107,4.039649,0.614596); glEnd(); 

or 'c' output

 Point3 Object1_vertex[] = { {5.108326,1.737655,2.650969}, {9.124107,-0.002484,0.614596}, {9.124107,4.039649,0.614596}}; long Object1_face[] = { 3,0,1,2, 3,3,4,5 3,6,3,5}; 

Then you can simply replace parts of this code with java code.

Ps This tool is not free, and you can only use it for a 30-day trial period. But the 'c' code and xml converters are available for this period.

+2
Sep 26 '12 at 22:40
source share



All Articles