cnr-isti-vclab / nexus

Nexus is a c++/javascript library for creation and visualization of a batched multiresolution mesh
GNU General Public License v3.0
213 stars 86 forks source link

nxsbuild: Unable to process OBJ files in various face formats #127

Closed asmrcek closed 2 years ago

asmrcek commented 2 years ago

Bug description

The newest nxsbuild (built from source in the master branch) cannot process OBJ models that contain face definitions in formats other than f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 and terminates with "Fatal error: Relative indexes in OBJ are not supported".

Details

There are about 4 face definitions formats which can appear in an OBJ model:

nxsbuild is able to process only the Vertex normal indices format.

How to reproduce

Compile nxsbuild from the most recent commit on the master branch. Pick an OBJ model whose faces aren't defined in the f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 format and try to process it in nxsbuild.

An example with a small bunny model of mine:

# (Windows)

# Create a directory for conversion
cd C:/
mkdir nexus_conversions

# Clone repo with a small bunny model
cd nexus_conversions
git clone https://github.com/asmrcek/test-3d-models.git

# Now we'll launch several Nexus conversions of OBJ files.
# We'll assume that you have compiled nxsbuild.exe available e.g. inside C:/nexus/bin/

# Try to convert OBJ file without normals (faces in "f v1/vt1 v2/vt2 v3/vt3" format)
C:/nexus/bin/nxsbuild.exe C:/nexus_conversions/test-3d-models/models/door_rabbit/reduced/obj/door_rabbit-no-normals.obj -o C:/nexus_conversions/door_rabbit-no-normals.nxs

# (this would be the output of the nxsbuild)
Reading C:/nexus_conversions/test-3d-models/models/door_rabbit/reduced/obj/door_rabbit-no-normals.obj
Vertices read: 4270
Colors read: 1
Texture: door_rabbit.jpg
Fatal error: Relative indexes in OBJ are not supported

# Try to convert OBJ file without texture coordinates (faces in "f v1//vn1 v2//vn2 v3//vn3" format)
C:/nexus/bin/nxsbuild.exe C:/nexus_conversions/test-3d-models/models/door_rabbit/reduced/obj/door_rabbit-no-texture-coords.obj -o C:/nexus_conversions/door_rabbit-no-texture-coords.nxs

# (this would be the output of the nxsbuild)
Reading C:/nexus_conversions/test-3d-models/models/door_rabbit/reduced/obj/door_rabbit-no-texture-coords.obj
Vertices read: 4270
Colors read: 1
Fatal error: Relative indexes in OBJ are not supported

# Try to convert OBJ file without texture coordinates and normals (faces in "f v1 v2 v3" format)
C:/nexus/bin/nxsbuild.exe C:/nexus_conversions/test-3d-models/models/door_rabbit/reduced/obj/door_rabbit-only-vertices.obj -o C:/nexus_conversions/door_rabbit-only-vertices.nxs

# (this would be the output of the nxsbuild)
Reading C:/nexus_conversions/test-3d-models/models/door_rabbit/reduced/obj/door_rabbit-only-vertices.obj
Vertices read: 4270
Colors read: 1
Fatal error: Relative indexes in OBJ are not supported