Skip to content

Error while importing custom .obj model. #1831

Description

@Hanning-Liu

Hi @Perksey and @zoalasaurusrawr,

  1. The usage of the repository:
    I think the repository is a little complex to use. Don't know if I make some stupid operations. I cloned the repository and opened the .sln file. It reports many errors after I click the Build button.
    Finally, I create a .sln file form scratch then import the Silk.NET NuGet packages then I copy and add the example folders manully, then it finally works well.

  2. The error while importing custom .obj model:
    I followed this "Tutorial 4.1 - Model Loading" example file:
    https://github.com/dotnet/Silk.NET/tree/8c14e75e526e21894c74f5ac722d47d70697c292/examples/CSharp/OpenGL%20Tutorials/Tutorial%204.1%20-%20Model%20Loading

I only changed the model imoprting code at the last line:

        private static void OnLoad()
        {
            IInputContext input = window.CreateInput();
            primaryKeyboard = input.Keyboards.FirstOrDefault();
            if (primaryKeyboard != null)
            {
                primaryKeyboard.KeyDown += KeyDown;
            }
            for (int i = 0; i < input.Mice.Count; i++)
            {
                input.Mice[i].Cursor.CursorMode = CursorMode.Raw;
                input.Mice[i].MouseMove += OnMouseMove;
                input.Mice[i].Scroll += OnMouseWheel;
            }

            Gl = GL.GetApi(window);

            Shader = new Shader(Gl, "shader.vert", "shader.frag");
            Texture = new Texture(Gl, "silk.png");
            Model = new Model(Gl, "untitled.model"); // Original code: Model = new Model(Gl, "cube.model");

And it reported this error message:

System.Exception
  HResult=0x80131500
  Message=Unable to open file "untitled.model".
  Source=Tutorial 4.1 - Model Loading
  StackTrace:
   at Tutorial.Model.LoadModel(String path) in C:\Users\77950\Desktop\Silk_NET\Test\ConsoleApp1\Tutorial 4.1 - Model Loading\Model.cs:line 40
   at Tutorial.Model..ctor(GL gl, String path, Boolean gamma) in C:\Users\77950\Desktop\Silk_NET\Test\ConsoleApp1\Tutorial 4.1 - Model Loading\Model.cs:line 21
   at Tutorial.Program.OnLoad() in C:\Users\77950\Desktop\Silk_NET\Test\ConsoleApp1\Tutorial 4.1 - Model Loading\Program.cs:line 69
   at Silk.NET.Windowing.Internals.ViewImplementationBase.Initialize()
   at Silk.NET.Windowing.WindowExtensions.Run(IView view)
   at Tutorial.Program.Main(String[] args) in C:\Users\77950\Desktop\Silk_NET\Test\ConsoleApp1\Tutorial 4.1 - Model Loading\Program.cs:line 45

This is my model file:
untitled.zip

Thank you for your help in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions