Skip to content

FaceColorOutOfBounds error when loading OBJs with mix of colored vertices/textured vertices #54

@Kmschr

Description

@Kmschr

Import/export of OBJ is built in to Blender 3.3 onwards
https://docs.blender.org/manual/en/latest/files/import_export/obj.html

When exporting a model with a mix of textured meshes and attribute color meshes, the resulting .obj will start with all colored vertices and end with textured vertices. It appears that when tobj encounters any vertex colors at all, it assumes every vertex will have an associated color and goes out of bounds when reaching the textured vertice section.

The .obj which fails to load looks something like this:

# Blender 3.4.1
# www.blender.org
mtllib example.mtl
o Mesh_0
v 1.280000 2.480000 -1.280000 0.4745 0.5686 0.1804
v 0.000000 2.320000 -1.280000 0.4863 0.5804 0.1804
v 1.280000 2.400000 0.000000 0.4863 0.5804 0.1804
vn -0.5517 0.8172 -0.1670
s 0
usemtl untextured
f 1//1 2//1 3//1
o Mesh_1
v 1.280000 4.800000 -5.440000
v 1.280000 4.800000 -5.120000
v 1.280000 2.400000 -5.440000
vn 0.1402 0.9057 0.4000
vt 0.000000 0.000000
vt 0.000000 0.250000
vt 1.000000 1.000000
s 0
usemtl texture_1
f 4/1/2 5/2/2 6/3/2

FYI @soluri

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions