tobj icon indicating copy to clipboard operation
tobj copied to clipboard

Invalid groups when loading object

Open agorgl opened this issue 3 years ago • 1 comments

Using CornellBox-Original.obj from https://casual-effects.com/data/ the following snippet:

        let meshes = models
            .iter()
            .map(|m| {
                let mesh = &m.mesh;
                println!("{}: {}", m.name, mesh.indices.len());
                ...
            })
            .collect();

shows:

floor: 6
ceiling: 6
backWall: 6
rightWall: 6
leftWall: 6
leftWall: 36
shortBox: 36
light: 6

agorgl avatar Aug 26 '21 11:08 agorgl

Hi @agorgl , I think you're seeing this because tobj triangulates obj files by default. So the quads in the OBJ file are turned into 2 triangles. This is why the floor ends up with 6 indices (two triangles) instead of 4 (a quad).

You can now pass the LoadOptions struct to tobj to tell it to not triangulate the mesh. Then I think the indices should match what you expect, since you'll get the quads back.

Twinklebear avatar Mar 05 '22 03:03 Twinklebear