-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chapter 3 Part 1: Model Loading #90
base: master
Are you sure you want to change the base?
Conversation
Version with same approach than LearnOpenGL for textures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should mark the OBJ file as a binary file or something like that so that git doesn't track 200k lines in this commit. Can you mark a file as binary and still have automatic EOL conversions happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, via .gitattributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some things I want to change with this in the future but I think it's fine to get this merged as it is right now and then I can use my review comments as TODOs in #89.
Common/Model.cs
Outdated
for (int i = 0; i < mat.GetMaterialTextureCount(type); i++) | ||
{ | ||
TextureSlot str; | ||
mat.GetMaterialTexture(type, i, out str); | ||
string filename = directory + "/" + str.FilePath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Path.Combine(directory, str.FilePath)
.
|
||
public static Texture LoadFromFile(string path) | ||
public static Texture LoadFromFile(string filename, string type = "texture_diffuse") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally avoid default arguments in opentk code. Also I don't think this field is a good idea, and if we where going to do it I would rather this be an enum rather than a string.
string number = new string("0"); | ||
string name = textures[i].type; | ||
if (name == "texture_diffuse") | ||
number = new string(""+diffuseNr++); | ||
else if (name == "texture_specular") | ||
number = new string("" + specularNr++); // transfer int to string | ||
else if (name == "texture_normal") | ||
number = new string("" + normalNr++); // transfer int to string | ||
else if (name == "texture_height") | ||
number = new string("" + heightNr++); // transfer int to string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to rework this texture solution in it's entirety.
But I think it's fine for this PR, I'll be able to do the rework as part of #89.
I just realized that there are two model loading PRs. |
Also, after marking |
Ok i have removed the backpack.obj and then added it again. |
bin and obj and all their combinations are in .gitignore, because of bin and obj folders. I am not sure if we should include rather large model files in this repo |
This version is inspired by adamsmith1990 initial work but with the same approach than LearnOpenGL website for textures rendering.
Camera movement is via the left-click on mouse and wireframe/plain texture via the N key.
Tested OK on dotnet6.0 (and revert to dotnet8.0 before commit)