Comments (7)
Never mind, I was using ObjUtils.convertToRenderable
incorrectly (after splitting the object instead of before). Sorry!
from obj.
Thanks for this hint. I remember trying out this case, namely whether it makes a difference whether one
- first splits and then converts to renderable
- first converts to renderable and then splits
I think it should work also when first splitting and then converting to renderable. I'll try it out with your model and try to figure out where the difference comes from, and whether it can be fixed sensibly.
(Reopening, so that it doesn't get buried (so easily))
from obj.
Hi,
Not sure if it is related to this issue, but your triangulation code is wrong (ObjUtils.triangulate) . It creates a triangle fan starting from the first vertex, but this doesn't work for concave (non-convex) facets/polygons. It can create triangles that overlap each other.
I haven't found a java-implementation of triangulation for concave polygons/facets yet. I've seen some libraries (in c++, javascript) that delegate to an OpenGL method: gluTesselate , which should do it correctly. But no pure-Java implementation yet.
If it is not related to this issue, could you create an issue from this?
from obj.
@wvc This is probably unrelated to the original issue, but we can quickly talk about this here.
I disagree when you say that the code of triangulate
is "wrong". It is not. It does triangulate the face, exactly as described in the JavaDoc:
* This method will simply subdivide faces with more than 3 vertices so
* that all faces in the output will be triangles.
That's the claim. Nothing more. Nothing less.
Right now, the implementation is trivial, and essentially consists of 3 lines of code - it indeed only creates a simple triangle fan. If this is not a satisfactory output, then everybody is free to either use any tool to preprocess their OBJ, or to use this library (free of charge...) to load an OBJ, and handle the non-triangular faces as they wish: They can think about concave polygons, non-planar polygons, degenerate polygons, self-intersecting polygons, non-connected polygons, winding rules, or even try to compute a conforming delaunay triangulation (if the face is planar).
This library is supposed to do one job, and to do it right. And this job is to load OBJs.
(The claim that it does this job better than most other OBJ loaders may sound bold. But... let's be honest: That's not such a high bar. Everybody who is concerned with graphics has written some ""OBJ loader"" at least once in their life...)
Things like the triangulation (or convertToRenderable
in general, or the OBJ splitting) are convenience functions that are still simple enough to be justified, considering that basically everybody who wants to load an OBJ wants to render it. But more complex triangulations are a rabbit hole that I certainly won't dive into in the context of this library.
from obj.
Alright, just wanted to point it out in case it was related to this issue (since it is still open). I came across your library while searching for a Java triangulation library. In the end, I decided to implement an ear-cutting algorithm myself, which seems to work ok for regular, simple polygons without holes. It still produces very slender triangles though (much like with triangle fans), but a refinement step with flipping triangles according to the Delauney criterion should improve that.
There are some nice references here (not affiliated): http://vterrain.org/Implementation/Libs/triangulate.html Unfortunately, most are c++ implementations which hampered my all-Java approach.
from obj.
(That link is broken in some odd way, but one can copy+paste it).
Indeed, I've recently been looking at triangulation as well. I considered creating a standalone library for that (independent of this OBJ loader). In fact, I created Java bindings for http://www.cs.cmu.edu/~quake/triangle.html quite a while ago, and contacted the author (several times) whether it's OK to publish them, but received no response. A few days ago, I tried to compile the library on Windows 10, and encountered some unexplicable issues, so I'll likely abandon that.
But I still consider to create 1. either a Java library for Delaunay triangulation or 2. create bindings for a more "modern" (C++-based) library, or 3. create a Java port of an existing implementation, like https://doc.cgal.org/latest/Triangulation_2/index.html or https://www.geometrictools.com/Samples/Geometrics.html#Delaunay2D
But again: This would all be independent of the OBJ library (of course), and is nothing that I've scheduled right now - only something of which I thought "yeah, could be nice to have...".
from obj.
This issue was actually resolved, and only kept open because I intended to do further tests. If I'm gonna do that, it will be independent of this issue.
from obj.
Related Issues (19)
- Cannot load an MTL with MTL Reader, application crashes with NullPointerException HOT 5
- my Model stands head HOT 12
- object not loading correctly HOT 43
- Invalid material names when leading white spaces are present HOT 3
- Incorrect object normals HOT 5
- How to get transparency from mtl file using simple Wavefront OBJ file loader library and apply to the 3d object in opengl es android? HOT 4
- Large size obj's not loading its causes java.lang.OutOfMemoryError. HOT 10
- MtlReader wrong parses at least map_Kd tag HOT 2
- Is there any way to get calculated tangent and bitangent for normal mapping? HOT 2
- How do you use this? HOT 1
- Can I use this library for load obj and mtl files in Android for vuforia? HOT 3
- ignore me HOT 1
- Obj#setActiveGroupNames() fails if used on an immutable collection HOT 6
- The filename of mtllib written in the obj file is not used HOT 2
- Is really need the initial value (kd, ks, ka) of DefaultMtl HOT 2
- Propose: support physically-based rendering parameters in de.javagl.obj.Mtl HOT 6
- osm to obj HOT 2
- Java Modules HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obj.