Java - Download .OBJ files

I want to be able to get information (e.g. subcomponent names) from a .obj file. Is there any loader there? Java3D has an ObjectFile, but the list of methods that I saw makes me think that this is not quite what I want. Would I be better off understanding the file directly?

Thanks -Will be

+4
source share
2 answers

A few months ago, I wrote a java obj format loader that should do what you need. It is on the git at node;

https://github.com/seanrowens/oObjLoader

Please note that README says that this is pre-alpha - this is primarily because almost no one has seen it yet.

It parses most of the .obj format as well as the .mtl format. Now, what does he do with what he analyzes ... well, I tried using a SAX-like approach. There is a Parser that calls methods on the BuilderInterface with each parsed element. There is a simple sample implementation of BuilderInterface, as well as a simple LWJGL viewer application that ties it all together.

Currently, he does nothing useful in more exotic formulations of geometry, that is, nothing but vertices and polygons, in other words, he ignores any geometry except vertices and polygons. It parses and captures .mtl files, but the real viewer does not implement anything but very very simple textures.

I would be glad to hear any feedback and advice. The license is extremely liberal:

This code was written by me, Sean R. Owens, Sean on the guild network, and released into the public domain. Share and enjoy. Since some people claim that it is not possible to release software for the public domain, you can also use this code under any version of the GPL, LPGL, Apache or BSD, or contact me to use a different license.

+7
source

I wrote a Java library to help you parse OBJ and MTL resources.

https://github.com/mokiat/java-data-front

Here are some of the features that it supports:

  • List of all vertices ( v ).
  • List of all normals ( vn ).
  • List of all texture coordinates ( vt ).
  • List all mtllib
  • List of all objects ( o ) and their names.
    • Grouping the faces of objects by material ( usemtl )
    • A list of all persons in the material group.
      • A list of all vertex pointers, normal, texture coordinates that make up the face.
  • List of all materials ( newmtl ) and their names
    • Diffuse color ( Kd )
    • Mirror Color ( Ks )
    • Ambient Color ( Ka )
    • Transparency ( d )
    • Diffuse text reference ( map_Kd )
    • others ...
  • The ability to set limits on the size of the OBJ and MTL resources that are processed.
    Helps prevent OutOfMemory exceptions.

The implementation is supported by a sufficient number of tests. There are no dependencies in the library at runtime, so it's pretty easy to integrate into your project.

It is built through Maven, so it is easy to integrate into Maven projects. (You will need to manually register it in your local repository). If your project is not Maven alone - do not worry, this should not be a problem.

+4
source

Source: https://habr.com/ru/post/1369534/


All Articles