opentk / LearnOpenTK

A port of learnopengl.com's tutorials to OpenTK and C#.
Creative Commons Attribution 4.0 International
465 stars 115 forks source link

Addition of Chapter 3 Part 1: Model Loading #76

Open DarkDoomBringer opened 2 years ago

DarkDoomBringer commented 2 years ago

This is my attempt at beginning a Chapter 3 based on https://learnopengl.com This covers loading a model using AssimpNet and rendering it. This could be continued with another chapter that applies the lighting techniques used in previous chapters.

I had to adjust the texture loading significantly to get it to work properly. For some reason when I tried to load the .obj that the original author supplied (https://learnopengl.com/data/models/backpack.zip), it got stuck in the model loading loop and crashed after using up all of my memory. So instead I just downloaded the original fbx and loaded the texture directly into a Texture object and used a simple shader to apply it.

I adjusted the tutorial from https://learnopengl.com and have attached it to this pull request. I did my best, but I would love for this to be reviewed and standardized to match the rest of the chapters. I hope you like what I have put together!

I did just read through your contributing guidelines, and in the future I will use Early Pull requests.

OpenTK Chapter 3.docx

DarkDoomBringer commented 2 years ago

I just made a second commit with these changes. I would especially appreciate help working with implementing System.Numerics. Thanks for all the feedback and patience. I am learning a lot from this and still getting used to Pull Requests, so let me know if I do anything weird.

NogginBops commented 2 years ago

I've added a new commit to this PR where I refactor a few things. Please take a look and tell me what you think šŸ™‚

Seems like you've got this thing with commits and PRs down šŸ˜Ž, wouldn't know you aren't used to PRs if you didn't tell me.

DarkDoomBringer commented 2 years ago

I did some cleanup and tried to improve the comments throughout. Thanks for catching the inverse transformation matrix needed for the normals. I actually realized this later and was pleasantly surprised to see it had already been fixed. In my latest commit, I specifically mentioned the comment about the Assimp matrix being column-major to make sure I had that right.

Let me know if you see anything else we should change, or go ahead and make the changes. Thanks!

DarkDoomBringer commented 2 years ago

OpenTK Chapter 3_07-09-22.docx

I updated the documentation to match our changes and made a small commit to go with it.

I think we are almost there.

NogginBops commented 2 years ago

Also is the docx file meant for the website? If so I would recommend you make a PR to the website repo where you just add the folder and a markdown file containing the chapter text.

NogginBops commented 2 years ago

@adamsmith1990 What is the status of this? Should I do the last pieces to get this merged or do you have time to do them?

DarkDoomBringer commented 2 years ago

I've just gotten over COVID, so thanks for you patience. I think the commit I just made fits what you were looking for. This way there is a bit more control over how things are drawn and the meshes are now just containers for VAOs and models are just containers for meshes from a loaded model.

DigitalBox98 commented 10 months ago

Nice addition! I've been able to use it with ImGUI to have a quick FBX model viewer.

ModelViewer

Regarding the comment "I had to adjust the texture loading significantly to get it to work properly". I might have a look at his part, as it would be great to use the textures directly from the models.

I have the same C++ program from LearnOpenGL compiled, so I can debug to understand more deeply what remains to be done here.

DigitalBox98 commented 10 months ago

Ok I've got a draft version working which mimicks learnopengl (loading of OBJ model including the various textures). I might propose a dedicated PR soon if it's OK.

obj