0

I wanna load .obj/.mtl models in C# using the HelixToolkit.ObjReader. The Read(string path) method works fine but the Read(Stream objStream, Stream[] mtlStreams) method sometimes returns a transparent model. But i need to use the stream reading as my final models will come in a stream.

I got a Tree and a Appartment model:

The two models

And the two Read methods of this code..

    ObjReader objReader = new()
    {
        IsSmoothingDefault = true,
        SkipTransparencyValues = true,
        IgnoreErrors = false,
        SwitchYZ = false,
    };

    Model3DGroup modelGroup;

    //Read(path)
    modelGroup = objReader.Read(path);

    // Read(objStream, mtlStreams)
    string mtlPath = Path.ChangeExtension(path, "mtl");
    modelGroup = objReader.Read(
        new FileStream(path, FileMode.Open),
        new Stream[] { new FileStream(mtlPath, FileMode.Open) });

.. produce these two different results:

Read(path): Everything looks fine. Path

Read(objStream, mtlStreams) : The appartmant has no materials and is transparent. ObjAndMtlStreams

I am expecting both methods to behave the same, especially as the second method explicitely obtains the path to the .mtl file. Why is the model transparent?

0 Answers0